Skip to content

Commit

Permalink
Add browsertest for PreviewsLitePagePredictor
Browse files Browse the repository at this point in the history
Bug: 971918
Change-Id: Ibee761de7be924f01024a5e155ef539d62041ae4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1667742
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671337}
  • Loading branch information
Robert Ogden authored and Commit Bot committed Jun 21, 2019
1 parent 223585b commit cbf0e61
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions chrome/browser/previews/previews_lite_page_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ IN_PROC_BROWSER_TEST_P(

VerifyPreviewNotLoaded();
ClearDeciderState();
histogram_tester.ExpectTotalCount(
"Previews.ServerLitePage.PreresolvedToPreviewServer", 0);

// Reset ECT for future tests.
g_browser_process->network_quality_tracker()
Expand Down Expand Up @@ -1147,6 +1149,25 @@ IN_PROC_BROWSER_TEST_P(
VerifyPreviewNotLoaded();
}

IN_PROC_BROWSER_TEST_P(
PreviewsLitePageServerBrowserTest,
DISABLE_ON_WIN_MAC_CHROMESOS(PreresolverShownAndHidden)) {
base::HistogramTester histogram_tester;
GetWebContents()->WasHidden();
ui_test_utils::NavigateToURL(browser(), HttpsLitePageURL(kSuccess));
VerifyPreviewLoaded();
histogram_tester.ExpectTotalCount(
"Previews.ServerLitePage.PreresolvedToPreviewServer", 0);

GetWebContents()->WasShown();
ui_test_utils::NavigateToURL(browser(), HttpsLitePageURL(kSuccess));
VerifyPreviewLoaded();
// We expect a value of 2 because the timer will be triggered twice, once when
// the web contents is shown, and once when a new page is committed.
histogram_tester.ExpectUniqueSample(
"Previews.ServerLitePage.PreresolvedToPreviewServer", false, 2);
}

IN_PROC_BROWSER_TEST_P(
PreviewsLitePageServerBrowserTest,
DISABLE_ON_WIN_MAC_CHROMESOS(LitePagePreviewsLoadOriginal)) {
Expand Down Expand Up @@ -1809,12 +1830,12 @@ IN_PROC_BROWSER_TEST_P(
PreviewsLitePageNavigationThrottle::IneligibleReason::kInfoBarNotSeen, 1);
}

class PreviewsLitePageNotificationDSDisabledBrowserTest
class PreviewsLitePageDSDisabledBrowserTest
: public PreviewsLitePageServerBrowserTest {
public:
PreviewsLitePageNotificationDSDisabledBrowserTest() = default;
PreviewsLitePageDSDisabledBrowserTest() = default;

~PreviewsLitePageNotificationDSDisabledBrowserTest() override = default;
~PreviewsLitePageDSDisabledBrowserTest() override = default;

void SetUp() override {
SetUpLitePageTest(false /* use_timeout */, false /* is_control */);
Expand Down Expand Up @@ -1845,16 +1866,19 @@ class PreviewsLitePageNotificationDSDisabledBrowserTest

// True if testing using the URLLoader Interceptor implementation.
INSTANTIATE_TEST_SUITE_P(URLLoaderImplementation,
PreviewsLitePageNotificationDSDisabledBrowserTest,
PreviewsLitePageDSDisabledBrowserTest,
testing::Bool());

IN_PROC_BROWSER_TEST_P(
PreviewsLitePageNotificationDSDisabledBrowserTest,
PreviewsLitePageDSDisabledBrowserTest,
DISABLE_ON_WIN_MAC_CHROMESOS(LitePagePreviewsInfoBarNonDataSaverUser)) {
base::HistogramTester histogram_tester;
ui_test_utils::NavigateToURL(browser(), HttpsLitePageURL(kSuccess));
VerifyPreviewNotLoaded();
ClearDeciderState();
EXPECT_EQ(0U, GetInfoBarService()->infobar_count());
histogram_tester.ExpectTotalCount(
"Previews.ServerLitePage.PreresolvedToPreviewServer", 0);
}

class PreviewsLitePageControlBrowserTest
Expand Down

0 comments on commit cbf0e61

Please sign in to comment.