Commit 92f89de1 authored by Mehran Mahmoudi's avatar Mehran Mahmoudi Committed by Commit Bot

[Paint Preview] Attempt to fix test in StartupPaintPreviewHelperTest

This attepts to fix StartupPaintPreviewHelperTest#testDisplayOnStartup
by waiting for activity to be destroyed first.

Bug: 1145783
Change-Id: Icd949712cb348dc12829a6eddec17b86045d2c35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533030Reviewed-by: default avatarCalder Kitagawa <ckitagawa@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826481}
parent fe411eb1
......@@ -17,8 +17,8 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.params.ParameterizedCommandLineFlags;
import org.chromium.base.test.params.ParameterizedCommandLineFlags.Switches;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.paint_preview.services.PaintPreviewTabServiceFactory;
......@@ -31,9 +31,8 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils;
import java.util.concurrent.ExecutionException;
/**
* Tests for the {@link StartupPaintPreviewHelper} class.
* This test suite cannot be batched because tests rely on the cold start behavior of
* {@link ChromeActivity}.
* Tests for the {@link StartupPaintPreviewHelper} class. This test suite cannot be batched because
* tests rely on the cold start behavior of {@link ChromeActivity}.
*/
@RunWith(StartupPaintPreviewHelperTestRunner.class)
@Features.EnableFeatures({ChromeFeatureList.PAINT_PREVIEW_SHOW_ON_STARTUP})
......@@ -95,17 +94,20 @@ public class StartupPaintPreviewHelperTest {
@Test
@MediumTest
@Restriction(StartupPaintPreviewHelperTestRunner.RESTRICTION_TYPE_KEEP_ACTIVITIES)
@DisabledTest(message = "https://crbug.com/1145783")
public void testDisplayOnStartup() throws ExecutionException {
mActivityTestRule.startMainActivityWithURL(
mActivityTestRule.getTestServer().getURL(TEST_URL));
// Send Chrome to background to trigger capture.
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).pressHome();
assertHasCaptureForTab(mActivityTestRule.getActivity().getActivityTab(), true);
ChromeTabbedActivity firstActivity = mActivityTestRule.getActivity();
assertHasCaptureForTab(firstActivity.getActivityTab(), true);
// Restart Chrome. Paint preview should be shown on startup.
TestThreadUtils.runOnUiThreadBlocking(() -> mActivityTestRule.getActivity().finish());
TestThreadUtils.runOnUiThreadBlocking(firstActivity::finish);
CriteriaHelper.pollInstrumentationThread(
firstActivity::isDestroyed, "Activity is not destroyed.");
mActivityTestRule.startMainActivityFromLauncher();
final Tab tab = mActivityTestRule.getActivity().getActivityTab();
TabbedPaintPreview tabbedPaintPreview =
......
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