Fix flake in WearableDrawerLayoutEspressoTest

tappingActionDrawerPeekIconShouldTriggerFirstAction tries to click the
peek view right away, but sometimes it's not fully on screen yet and the
click fails.

This change deflakes it by waiting until it's completely displayed
before trying to click it.

Test: Ran test many times locally
Bug: 64251663
Change-Id: I356334b7f37150c57759a6e16969aba70114b7e1
diff --git a/wear/tests/src/android/support/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java b/wear/tests/src/android/support/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java
index 07eaa87..dc7a942 100644
--- a/wear/tests/src/android/support/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java
+++ b/wear/tests/src/android/support/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java
@@ -23,7 +23,6 @@
 import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
 import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
 import static android.support.test.espresso.matcher.ViewMatchers.withId;
-import static android.support.test.espresso.matcher.ViewMatchers.withParent;
 import static android.support.test.espresso.matcher.ViewMatchers.withText;
 import static android.support.wear.widget.util.AsyncViewActions.waitForMatchingView;
 
@@ -337,10 +336,12 @@
         OnMenuItemClickListener mockClickListener = mock(OnMenuItemClickListener.class);
         actionDrawer.setOnMenuItemClickListener(mockClickListener);
         // WHEN the action drawer peek view is tapped
-        onView(
-                allOf(
-                        withParent(withId(R.id.action_drawer)),
-                        withId(R.id.ws_drawer_view_peek_container)))
+        onView(withId(R.id.ws_drawer_view_peek_container))
+                .perform(waitForMatchingView(
+                        allOf(
+                                withId(R.id.ws_drawer_view_peek_container),
+                                isCompletelyDisplayed()),
+                        MAX_WAIT_MS))
                 .perform(click());
         // THEN its click listener should be notified
         verify(mockClickListener).onMenuItemClick(any(MenuItem.class));