Merge "[Chooser/ResolverActivity] Fix flakiness in work profile tests" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
da209b100a
@@ -16,11 +16,14 @@
|
|||||||
|
|
||||||
package com.android.internal.app;
|
package com.android.internal.app;
|
||||||
|
|
||||||
|
import static android.util.PollingCheck.waitFor;
|
||||||
|
|
||||||
import static androidx.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static androidx.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static androidx.test.espresso.action.ViewActions.swipeUp;
|
import static androidx.test.espresso.action.ViewActions.swipeUp;
|
||||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.isSelected;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
@@ -49,6 +52,8 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.app.ResolverActivity.ResolvedComponentInfo;
|
import com.android.internal.app.ResolverActivity.ResolvedComponentInfo;
|
||||||
import com.android.internal.app.ChooserActivityWorkProfileTest.TestCase.Tab;
|
import com.android.internal.app.ChooserActivityWorkProfileTest.TestCase.Tab;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -331,9 +336,18 @@ public class ChooserActivityWorkProfileTest {
|
|||||||
final int stringId = tab == Tab.WORK ? R.string.resolver_work_tab
|
final int stringId = tab == Tab.WORK ? R.string.resolver_work_tab
|
||||||
: R.string.resolver_personal_tab;
|
: R.string.resolver_personal_tab;
|
||||||
|
|
||||||
|
waitFor(() -> {
|
||||||
onView(withText(stringId)).perform(click());
|
onView(withText(stringId)).perform(click());
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
|
|
||||||
|
try {
|
||||||
|
onView(withText(stringId)).check(matches(isSelected()));
|
||||||
|
return true;
|
||||||
|
} catch (AssertionFailedError e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onView(withId(R.id.contentPanel))
|
onView(withId(R.id.contentPanel))
|
||||||
.perform(swipeUp());
|
.perform(swipeUp());
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
|
|||||||
@@ -16,11 +16,14 @@
|
|||||||
|
|
||||||
package com.android.internal.app;
|
package com.android.internal.app;
|
||||||
|
|
||||||
|
import static android.util.PollingCheck.waitFor;
|
||||||
|
|
||||||
import static androidx.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static androidx.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static androidx.test.espresso.action.ViewActions.swipeUp;
|
import static androidx.test.espresso.action.ViewActions.swipeUp;
|
||||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.isSelected;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
@@ -48,6 +51,8 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.app.ResolverActivity.ResolvedComponentInfo;
|
import com.android.internal.app.ResolverActivity.ResolvedComponentInfo;
|
||||||
import com.android.internal.app.ResolverActivityWorkProfileTest.TestCase.Tab;
|
import com.android.internal.app.ResolverActivityWorkProfileTest.TestCase.Tab;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -309,9 +314,18 @@ public class ResolverActivityWorkProfileTest {
|
|||||||
final int stringId = tab == Tab.WORK ? R.string.resolver_work_tab
|
final int stringId = tab == Tab.WORK ? R.string.resolver_work_tab
|
||||||
: R.string.resolver_personal_tab;
|
: R.string.resolver_personal_tab;
|
||||||
|
|
||||||
|
waitFor(() -> {
|
||||||
onView(withText(stringId)).perform(click());
|
onView(withText(stringId)).perform(click());
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
|
|
||||||
|
try {
|
||||||
|
onView(withText(stringId)).check(matches(isSelected()));
|
||||||
|
return true;
|
||||||
|
} catch (AssertionFailedError e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onView(withId(R.id.contentPanel))
|
onView(withId(R.id.contentPanel))
|
||||||
.perform(swipeUp());
|
.perform(swipeUp());
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
|
|||||||
Reference in New Issue
Block a user