Adding DelayedCheck() in testHasWindowFocus.

After executing findViewById(), there are some cases where test case is failed since flags that are set asynchronously are checked only once immediately after that event.

To avoid this, I changed the code to monitor the change of flag.

Change-Id: Iaf30f18144a5ef1887334bc65cbef59ea5de70ac
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 3370e2b..6706c37 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -2276,8 +2276,14 @@
         assertFalse(view.hasWindowFocus());
 
         // mAttachInfo is not null
-        view = mActivity.findViewById(R.id.fit_windows);
-        assertTrue(view.hasWindowFocus());
+        final View view2 = mActivity.findViewById(R.id.fit_windows);
+        // Wait until the window has been focused.
+        new DelayedCheck(TIMEOUT_DELTA) {
+            @Override
+            protected boolean check() {
+                return view2.hasWindowFocus();
+            }
+        }.run();
     }
 
     @TestTargetNew(