Skip to content

Commit

Permalink
[Start] Enable two StartSurfaceBackButtonTest#testSwipeBack* tests
Browse files Browse the repository at this point in the history
After adding the statement "AsyncInitializationActivity.interceptMoveTaskToBackForTesting();". We have run the tests StartSurfaceBackButtonTest#testSwipeBackOnStartSurfaceHomePage__* and StartSurfaceBackButtonTest#testSwipeBackOnStartSurfaceHomePage_BackGestureRefactor__* with android-12-x64-rel, and android-nougat-x86-rel. Since we didn't find out any error with these tests, we enabled it.

Bug: 1246457, 1371614, 1371613, 1371612, 1434978
Change-Id: I6c09f454fc64e6fbd0cb106c071be7382cb88288
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4461529
Commit-Queue: Xinyi Ji <xinyiji@chromium.org>
Reviewed-by: Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1134849}
  • Loading branch information
Xinyi Ji authored and Chromium LUCI CQ committed Apr 24, 2023
1 parent 51a2f58 commit 1dbd803
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.chromium.ui.test.util.ViewUtils.waitForView;

import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.view.View;

import androidx.test.InstrumentationRegistry;
Expand All @@ -39,6 +40,7 @@
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.CriteriaHelper;
import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.DoNotBatch;
import org.chromium.base.test.util.Feature;
Expand All @@ -57,7 +59,6 @@
import org.chromium.chrome.test.ChromeJUnit4RunnerDelegate;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.R;
import org.chromium.chrome.test.util.ChromeApplicationTestUtils;
import org.chromium.chrome.test.util.MenuUtils;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
Expand Down Expand Up @@ -351,8 +352,8 @@ public void testUserActionLoggedWhenBackToStartSurfaceHomePage() throws Executio
@Feature({"StartSurface"})
// clang-format off
@CommandLineFlags.Add({START_SURFACE_TEST_SINGLE_ENABLED_PARAMS})
@DisabledTest(message = "https://crbug.com/1246457")
@DisableFeatures({ChromeFeatureList.BACK_GESTURE_REFACTOR})
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.S_V2, message = "crbug/1436048")
public void testSwipeBackOnStartSurfaceHomePage() throws ExecutionException {
// clang-format on
verifySwipeBackOnStartSurfaceHomePage();
Expand All @@ -362,8 +363,8 @@ public void testSwipeBackOnStartSurfaceHomePage() throws ExecutionException {
@MediumTest
@Feature({"StartSurface"})
@CommandLineFlags.Add({START_SURFACE_TEST_SINGLE_ENABLED_PARAMS})
@DisabledTest(message = "https://crbug.com/1246457")
@EnableFeatures({ChromeFeatureList.BACK_GESTURE_REFACTOR})
@DisableIf.Build(sdk_is_greater_than = VERSION_CODES.S_V2, message = "crbug/1436048")
public void testSwipeBackOnStartSurfaceHomePage_BackGestureRefactor()
throws ExecutionException {
verifySwipeBackOnStartSurfaceHomePage();
Expand Down Expand Up @@ -451,10 +452,7 @@ private void verifySwipeBackOnStartSurfaceHomePage() {
StartSurfaceTestUtils.waitForStartSurfaceVisible(mLayoutChangedCallbackHelper,
mCurrentlyActiveLayout, mActivityTestRule.getActivity());

StartSurfaceTestUtils.gestureNavigateBack(mActivityTestRule);

// Back gesture on the start surface puts Chrome background.
ChromeApplicationTestUtils.waitUntilChromeInBackground();
StartSurfaceTestUtils.gestureNavigateBackToBringChromeBackground(mActivityTestRule);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,21 @@ public static void gestureNavigateBack(ChromeTabbedActivityTestRule activityTest
navUtils.swipeFromLeftEdge();
}

/**
* Perform gesture navigate back action on the start surface to put Chrome background.
* @param activityTestRule The ChromeTabbedActivityTestRule under test.
*/
public static void gestureNavigateBackToBringChromeBackground(
ChromeTabbedActivityTestRule activityTestRule) {
AsyncInitializationActivity.interceptMoveTaskToBackForTesting();
GestureNavigationUtils navUtils = new GestureNavigationUtils(activityTestRule);
navUtils.swipeFromLeftEdge();

// Back gesture on the start surface puts Chrome background.
CriteriaHelper.pollUiThread(
() -> AsyncInitializationActivity.wasMoveTaskToBackInterceptedForTesting());
}

/**
* Click the first MV tile (Explore tile) in mv_tiles_layout.
* @param cta The ChromeTabbedActivity under test.
Expand Down

0 comments on commit 1dbd803

Please sign in to comment.