diff options
author | kraush <kraush@amazon.com> | 2016-03-25 15:28:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 22:30:02 +0000 |
commit | 4c94be22307df94b2da87ce920880ada92c28efe (patch) | |
tree | 402913f2a49b1ab4294725a1cf6309f6f433d35c | |
parent | 66cb92537d00d4ffdafd72a4c2a39d01fc1b5598 (diff) | |
download | chromium_src-4c94be22307df94b2da87ce920880ada92c28efe.zip chromium_src-4c94be22307df94b2da87ce920880ada92c28efe.tar.gz chromium_src-4c94be22307df94b2da87ce920880ada92c28efe.tar.bz2 |
Eliminate race condition in CustomTabActivityTest
Eliminates a race condition in CustomTabActivityTest#testPrecreatedRenderer
by waiting for the new custom tab to open before asserting
BUG=597741
Review URL: https://codereview.chromium.org/1834783002
Cr-Commit-Position: refs/heads/master@{#383385}
-rw-r--r-- | chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java index 50e1226..e54c13a 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java @@ -788,8 +788,7 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { * only one in the navigation history. */ @SmallTest - @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) - public void testPrecreatedRenderer() { + public void testPrecreatedRenderer() throws InterruptedException { CustomTabsConnection connection = warmUpAndWait(); ICustomTabsCallback cb = new CustomTabsTestUtils.DummyCallback(); assertTrue(connection.newSession(cb)); @@ -797,15 +796,21 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { extras.putBoolean(CustomTabsConnection.NO_PRERENDERING_KEY, true); assertTrue(connection.mayLaunchUrl(cb, Uri.parse(mTestPage), extras, null)); Context context = getInstrumentation().getTargetContext().getApplicationContext(); + final Tab previousTab = getActivity().getActivityTab(); try { startCustomTabActivityWithIntent(CustomTabsTestUtils.createMinimalCustomTabIntent( context, mTestPage, cb.asBinder())); } catch (InterruptedException e) { fail(); } - Tab tab = getActivity().getActivityTab(); - assertEquals(mTestPage, tab.getUrl()); - assertFalse(tab.canGoBack()); + CriteriaHelper.pollInstrumentationThread(new Criteria() { + @Override + public boolean isSatisfied() { + final Tab currentTab = getActivity().getActivityTab(); + return currentTab != previousTab && mTestPage.equals(currentTab.getUrl()); + } + }); + assertFalse(getActivity().getActivityTab().canGoBack()); } /** Tests that calling mayLaunchUrl() without warmup() succeeds. */ |