Commit e79945b7 authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Add tap on MV tiles integration tests

Bug: 1051226
Change-Id: Ieee0fcb41ff6f3d1282b709cffd23ed381102687
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050754Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742804}
parent 0bfc046c
......@@ -277,6 +277,54 @@ public class StartSurfaceTest {
equalTo(1));
}
@Test
@MediumTest
@Feature({"StartSurface"})
@CommandLineFlags.Add({BASE_PARAMS + "/single"})
public void testTapMVTilesInSingleSurface() {
// TODO(crbug.com/1025296): Set cached flag before starting the activity and mimic clicking
// the 'home' button to show the single start surface home page.
TestThreadUtils.runOnUiThreadBlocking(
()
-> mActivityTestRule.getActivity()
.getStartSurface()
.getController()
.setOverviewState(OverviewModeState.SHOWING_HOMEPAGE));
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().getLayoutManager().showOverview(false));
assertThat(
mActivityTestRule.getActivity().getTabModelSelector().getCurrentModel().getCount(),
equalTo(1));
ViewGroup mvTilesContainer = (ViewGroup) mActivityTestRule.getActivity().findViewById(
org.chromium.chrome.tab_ui.R.id.mv_tiles_layout);
assertTrue(mvTilesContainer.getChildCount() > 0);
OverviewModeBehaviorWatcher hideWatcher =
TabUiTestHelper.createOverviewHideWatcher(mActivityTestRule.getActivity());
try {
// TODO (crbug.com/1025296): Find a way to perform click on a child at index 0 in
// LinearLayout with Espresso. Note that we do not have 'withParentIndex' so far.
TestThreadUtils.runOnUiThreadBlocking(
() -> mvTilesContainer.getChildAt(0).performClick());
} catch (ExecutionException e) {
assertTrue(false);
}
hideWatcher.waitForBehavior();
assertThat(
mActivityTestRule.getActivity().getTabModelSelector().getCurrentModel().getCount(),
equalTo(2));
// Press back button should close the tab opened from the Start surface.
OverviewModeBehaviorWatcher showWatcher =
TabUiTestHelper.createOverviewShowWatcher(mActivityTestRule.getActivity());
pressBack();
showWatcher.waitForBehavior();
assertThat(
mActivityTestRule.getActivity().getTabModelSelector().getCurrentModel().getCount(),
equalTo(1));
}
@Test
@MediumTest
@Feature({"StartSurface"})
......
......@@ -328,7 +328,7 @@ public class TabUiTestHelper {
/**
* Create a {@link OverviewModeBehaviorWatcher} to inspect overview show.
*/
static OverviewModeBehaviorWatcher createOverviewShowWatcher(ChromeTabbedActivity cta) {
public static OverviewModeBehaviorWatcher createOverviewShowWatcher(ChromeTabbedActivity cta) {
return new OverviewModeBehaviorWatcher(cta.getLayoutManager(), true, false);
}
......
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