Commit 7973b6e9 authored by Michael Thiessen's avatar Michael Thiessen Committed by Chromium LUCI CQ

Speculative de-flake of TabsOpenedFromExternalAppTest

It looks like when we send CTA to the background, then call finish()
on it, it doesn't actually get Finished. Likely Android just doesn't
bother actually finishing background Activities right away (maybe
something to do with the launcher)?

I haven't been able to reproduce the issue, but this appears to be the
commonality between the failing tests, and this should fix it if so.

If this works, I'll follow up with some infra changes to detect/advise
in this case.

Bug: 1153712
Change-Id: Ic46c30c99df390e0cf8c7d732c3a10535dddc2a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565619
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832044}
parent 6edf3578
......@@ -386,7 +386,7 @@ public class TabsOpenedFromExternalAppTest {
@Test
@LargeTest
@Feature({"Navigation"})
public void testNoNewTabForSameApp() {
public void testNoNewTabForSameApp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage();
String url1 = mTestServer.getURL("/chrome/test/data/android/google.html");
......@@ -418,6 +418,7 @@ public class TabsOpenedFromExternalAppTest {
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().onBackPressed());
CriteriaHelper.pollUiThread(() -> !mActivityTestRule.getActivity().hasWindowFocus());
mActivityTestRule.resumeMainActivityFromLauncher();
}
/**
......@@ -427,7 +428,7 @@ public class TabsOpenedFromExternalAppTest {
@Test
@LargeTest
@Feature({"Navigation"})
public void testNewTabForUnknownApp() {
public void testNewTabForUnknownApp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage();
String url1 = mTestServer.getURL("/chrome/test/data/android/google.html");
......@@ -465,6 +466,7 @@ public class TabsOpenedFromExternalAppTest {
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().onBackPressed());
CriteriaHelper.pollUiThread(() -> !mActivityTestRule.getActivity().hasWindowFocus());
mActivityTestRule.resumeMainActivityFromLauncher();
}
/**
......@@ -474,7 +476,7 @@ public class TabsOpenedFromExternalAppTest {
@Test
@LargeTest
@Feature({"Navigation"})
public void testNewTabWithNewTabExtra() {
public void testNewTabWithNewTabExtra() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage();
String url1 = mTestServer.getURL("/chrome/test/data/android/google.html");
......@@ -506,6 +508,7 @@ public class TabsOpenedFromExternalAppTest {
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().onBackPressed());
CriteriaHelper.pollUiThread(() -> !mActivityTestRule.getActivity().hasWindowFocus());
mActivityTestRule.resumeMainActivityFromLauncher();
}
/**
......@@ -515,7 +518,7 @@ public class TabsOpenedFromExternalAppTest {
@Test
@LargeTest
@Feature({"Navigation", "Main"})
public void testNoNewTabForSameAppOnStart() {
public void testNoNewTabForSameAppOnStart() throws Exception {
String url1 = mTestServer.getURL("/chrome/test/data/android/google.html");
String url2 = mTestServer.getURL("/chrome/test/data/android/about.html");
......@@ -540,6 +543,7 @@ public class TabsOpenedFromExternalAppTest {
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().onBackPressed());
CriteriaHelper.pollUiThread(() -> !mActivityTestRule.getActivity().hasWindowFocus());
mActivityTestRule.resumeMainActivityFromLauncher();
}
/**
......
......@@ -53,8 +53,9 @@ public class ChromeTabbedActivityTestRule extends ChromeActivityTestRule<ChromeT
public void resumeMainActivityFromLauncher() throws Exception {
Assert.assertNotNull(getActivity());
Assert.assertEquals(
ApplicationStatus.getStateForActivity(getActivity()), ActivityState.STOPPED);
@ActivityState
int state = ApplicationStatus.getStateForActivity(getActivity());
Assert.assertTrue(state == ActivityState.STOPPED || state == ActivityState.PAUSED);
Intent launchIntent = getActivity().getPackageManager().getLaunchIntentForPackage(
getActivity().getPackageName());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment