Commit fcd9434e authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Ignore thumbnails in tests about search term chip

Thumbnail-related checking became flaky, and we are not specifically
testing thumbnails in the tests for search term chip. This CL removes
the thumbnail-related checking in the following tests:

- StartSurfaceLayoutTest#testSearchTermChip_noChip
- StartSurfaceLayoutTest#testSearchTermChip_adaptiveIcon
- StartSurfaceLayoutTest#testSearchTermChip_withChip

Bug: 1064367
Change-Id: I73d5e1c29bc9e3c646fdec1bca610b395088f89b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2117646
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarMei Liang <meiliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757936}
parent f3c39687
...@@ -88,6 +88,7 @@ import org.chromium.chrome.browser.flags.ChromeSwitches; ...@@ -88,6 +88,7 @@ import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory; import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModel; import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tasks.pseudotab.TabAttributeCache;
import org.chromium.chrome.browser.tasks.tab_management.TabProperties; import org.chromium.chrome.browser.tasks.tab_management.TabProperties;
import org.chromium.chrome.browser.tasks.tab_management.TabSelectionEditorTestingRobot; import org.chromium.chrome.browser.tasks.tab_management.TabSelectionEditorTestingRobot;
import org.chromium.chrome.browser.tasks.tab_management.TabSuggestionMessageService; import org.chromium.chrome.browser.tasks.tab_management.TabSuggestionMessageService;
...@@ -102,6 +103,7 @@ import org.chromium.chrome.test.util.ChromeRenderTestRule; ...@@ -102,6 +103,7 @@ import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils; import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.MenuUtils; import org.chromium.chrome.test.util.MenuUtils;
import org.chromium.chrome.test.util.OverviewModeBehaviorWatcher; import org.chromium.chrome.test.util.OverviewModeBehaviorWatcher;
import org.chromium.chrome.test.util.ViewUtils;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
...@@ -1433,6 +1435,11 @@ public class StartSurfaceLayoutTest { ...@@ -1433,6 +1435,11 @@ public class StartSurfaceLayoutTest {
} }
} }
private void waitForLastSearchTerm(Tab tab, String expected) {
CriteriaHelper.pollUiThread(
Criteria.equals(expected, () -> TabAttributeCache.getLastSearchTerm(tab.getId())));
}
@Test @Test
@MediumTest @MediumTest
// Disable TAB_TO_GTS_ANIMATION to make it less flaky. // Disable TAB_TO_GTS_ANIMATION to make it less flaky.
...@@ -1441,7 +1448,7 @@ public class StartSurfaceLayoutTest { ...@@ -1441,7 +1448,7 @@ public class StartSurfaceLayoutTest {
public void testSearchTermChip_noChip() throws InterruptedException { public void testSearchTermChip_noChip() throws InterruptedException {
assertTrue(TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue()); assertTrue(TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue());
prepareTabs(1, 0, mUrl); prepareTabs(1, 0, mUrl);
enterGTSWithThumbnailChecking(); enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(withId(R.id.search_button)).check(matches(not(isDisplayed()))); onView(withId(R.id.search_button)).check(matches(not(isDisplayed())));
...@@ -1465,59 +1472,66 @@ public class StartSurfaceLayoutTest { ...@@ -1465,59 +1472,66 @@ public class StartSurfaceLayoutTest {
// Do search, and verify the chip is still not shown. // Do search, and verify the chip is still not shown.
AtomicReference<String> searchUrl = new AtomicReference<>(); AtomicReference<String> searchUrl = new AtomicReference<>();
ChromeTabbedActivity cta = mActivityTestRule.getActivity(); ChromeTabbedActivity cta = mActivityTestRule.getActivity();
Tab currentTab = cta.getTabModelSelector().getCurrentTab();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
TemplateUrlServiceFactory.get().setSearchEngine("google.com"); TemplateUrlServiceFactory.get().setSearchEngine("google.com");
searchUrl.set(TemplateUrlServiceFactory.get().getUrlForSearchQuery( searchUrl.set(TemplateUrlServiceFactory.get().getUrlForSearchQuery(
searchTermWithSpecialCodePoints)); searchTermWithSpecialCodePoints));
cta.getTabModelSelector().getCurrentTab().loadUrl(new LoadUrlParams(searchUrl.get())); currentTab.loadUrl(new LoadUrlParams(searchUrl.get()));
}); });
enterGTSWithThumbnailChecking(); ChromeTabUtils.waitForTabPageLoaded(currentTab, null);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(withId(R.id.search_button)).check(matches(not(isDisplayed()))); onView(withId(R.id.search_button)).check(matches(not(isDisplayed())));
leaveGTSAndVerifyThumbnailsAreReleased(); Espresso.pressBack();
// Navigate, and verify the chip is shown. // Navigate, and verify the chip is shown.
mActivityTestRule.loadUrl(mUrl); mActivityTestRule.loadUrl(mUrl);
enterGTSWithThumbnailChecking(); waitForLastSearchTerm(currentTab, expectedTerm);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(allOf(withParent(withId(R.id.search_button)), withText(expectedTerm))) onView(withId(R.id.search_button))
.check(matches(isDisplayed())); .check(ViewUtils.waitForView(allOf(withText(expectedTerm), isDisplayed())));
leaveGTSAndVerifyThumbnailsAreReleased(); Espresso.pressBack();
// Do another search, and verify the chip is gone. // Do another search, and verify the chip is gone.
AtomicReference<String> searchUrl2 = new AtomicReference<>(); AtomicReference<String> searchUrl2 = new AtomicReference<>();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
TemplateUrlServiceFactory.get().setSearchEngine("google.com"); TemplateUrlServiceFactory.get().setSearchEngine("google.com");
searchUrl2.set(TemplateUrlServiceFactory.get().getUrlForSearchQuery(anotherTerm)); searchUrl2.set(TemplateUrlServiceFactory.get().getUrlForSearchQuery(anotherTerm));
cta.getTabModelSelector().getCurrentTab().loadUrl(new LoadUrlParams(searchUrl2.get())); currentTab.loadUrl(new LoadUrlParams(searchUrl2.get()));
}); });
enterGTSWithThumbnailChecking(); ChromeTabUtils.waitForTabPageLoaded(currentTab, null);
waitForLastSearchTerm(currentTab, null);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(withId(R.id.search_button)).check(matches(not(isDisplayed()))); onView(withId(R.id.search_button)).check(matches(not(isDisplayed())));
leaveGTSAndVerifyThumbnailsAreReleased(); Espresso.pressBack();
// Back to previous page, and verify the chip is back. // Back to previous page, and verify the chip is back.
Espresso.pressBack(); Espresso.pressBack();
enterGTSWithThumbnailChecking(); waitForLastSearchTerm(currentTab, expectedTerm);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(allOf(withParent(withId(R.id.search_button)), withText(expectedTerm))) onView(withId(R.id.search_button))
.check(matches(isDisplayed())); .check(ViewUtils.waitForView(allOf(withText(expectedTerm), isDisplayed())));
// Click the chip and check the tab navigates back to the search result page. // Click the chip and check the tab navigates back to the search result page.
assertEquals(mUrl, cta.getTabModelSelector().getCurrentTab().getUrlString()); assertEquals(mUrl, currentTab.getUrlString());
OverviewModeBehaviorWatcher hideWatcher = TabUiTestHelper.createOverviewHideWatcher(cta); OverviewModeBehaviorWatcher hideWatcher = TabUiTestHelper.createOverviewHideWatcher(cta);
onView(allOf(withParent(withId(R.id.search_button)), withText(expectedTerm))) onView(withId(R.id.search_button))
.perform(click()); .check(ViewUtils.waitForView(allOf(withText(expectedTerm), isDisplayed())));
onView(withId(R.id.search_button)).perform(click());
hideWatcher.waitForBehavior(); hideWatcher.waitForBehavior();
CriteriaHelper.pollUiThread(Criteria.equals( ChromeTabUtils.waitForTabPageLoaded(currentTab, searchUrl.get());
searchUrl.get(), () -> cta.getTabModelSelector().getCurrentTab().getUrlString()));
// Verify the chip is gone. // Verify the chip is gone.
enterGTSWithThumbnailChecking(); waitForLastSearchTerm(currentTab, null);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(withId(R.id.search_button)).check(matches(not(isDisplayed()))); onView(withId(R.id.search_button)).check(matches(not(isDisplayed())));
...@@ -1539,24 +1553,27 @@ public class StartSurfaceLayoutTest { ...@@ -1539,24 +1553,27 @@ public class StartSurfaceLayoutTest {
// Do search, and verify the chip is still not shown. // Do search, and verify the chip is still not shown.
AtomicReference<String> searchUrl = new AtomicReference<>(); AtomicReference<String> searchUrl = new AtomicReference<>();
ChromeTabbedActivity cta = mActivityTestRule.getActivity(); ChromeTabbedActivity cta = mActivityTestRule.getActivity();
Tab currentTab = cta.getTabModelSelector().getCurrentTab();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
TemplateUrlServiceFactory.get().setSearchEngine("google.com"); TemplateUrlServiceFactory.get().setSearchEngine("google.com");
searchUrl.set(TemplateUrlServiceFactory.get().getUrlForSearchQuery(searchTerm)); searchUrl.set(TemplateUrlServiceFactory.get().getUrlForSearchQuery(searchTerm));
cta.getTabModelSelector().getCurrentTab().loadUrl(new LoadUrlParams(searchUrl.get())); currentTab.loadUrl(new LoadUrlParams(searchUrl.get()));
}); });
enterGTSWithThumbnailChecking(); ChromeTabUtils.waitForTabPageLoaded(currentTab, null);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(withId(R.id.search_button)).check(matches(not(isDisplayed()))); onView(withId(R.id.search_button)).check(matches(not(isDisplayed())));
leaveGTSAndVerifyThumbnailsAreReleased(); Espresso.pressBack();
// Navigate, and verify the chip is shown. // Navigate, and verify the chip is shown.
mActivityTestRule.loadUrl(mUrl); mActivityTestRule.loadUrl(mUrl);
enterGTSWithThumbnailChecking(); waitForLastSearchTerm(currentTab, searchTerm);
enterTabSwitcher(mActivityTestRule.getActivity());
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1)); onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(allOf(withParent(withId(R.id.search_button)), withText(searchTerm))) onView(withId(R.id.search_button))
.check(matches(isDisplayed())); .check(ViewUtils.waitForView(allOf(withText(searchTerm), isDisplayed())));
// Switch the default search engine from google.com to yahoo.com, the search chip icon // Switch the default search engine from google.com to yahoo.com, the search chip icon
// should change. // should change.
......
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