Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/page_load_metrics/observers/https_engagement_metrics/https_engagement_page_load_metrics_observer_browsertest.cc

Issue 2139143002: Standardize which page loads are tracked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/page_load_metrics/observers/https_engagement_metrics/ht tps_engagement_page_load_metrics_observer.h" 5 #include "chrome/browser/page_load_metrics/observers/https_engagement_metrics/ht tps_engagement_page_load_metrics_observer.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); 338 histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1);
339 } 339 }
340 340
341 IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, 341 IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
342 Navigate_Both_NonHtmlMainResource) { 342 Navigate_Both_NonHtmlMainResource) {
343 StartHttpServer(); 343 StartHttpServer();
344 StartHttpsServer(false); 344 StartHttpsServer(false);
345 NavigateTwiceInTabAndClose(http_test_server_->GetURL("/circle.svg"), 345 NavigateTwiceInTabAndClose(http_test_server_->GetURL("/circle.svg"),
346 https_test_server_->GetURL("/circle.svg")); 346 https_test_server_->GetURL("/circle.svg"));
347 347
348 // TODO(bmcquade): for the time being, the page load metrics infrastructure
349 // also tracks non-HTML resources. We should update these to expect 0
350 // histogram events once that gets fixed. See crbug.com/627536.
351
352 // Test the page load metrics. 348 // Test the page load metrics.
353 histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 1); 349 histogram_tester_.ExpectTotalCount(internal::kHttpEngagementHistogram, 0);
354 histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 1); 350 histogram_tester_.ExpectTotalCount(internal::kHttpsEngagementHistogram, 0);
355 351
356 // Test the ratio metric. 352 // Test the ratio metric.
357 FakeUserMetricsUpload(); 353 FakeUserMetricsUpload();
358 histogram_tester_.ExpectTotalCount( 354 histogram_tester_.ExpectTotalCount(
359 internal::kHttpsEngagementSessionPercentage, 1); 355 internal::kHttpsEngagementSessionPercentage, 0);
360 int32_t ratio_bucket =
361 histogram_tester_
362 .GetAllSamples(internal::kHttpsEngagementSessionPercentage)[0]
363 .min;
364 EXPECT_GT(100, ratio_bucket);
365 EXPECT_LT(0, ratio_bucket);
366 } 356 }
367 357
368 IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, 358 IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
369 ClosedWhileHidden_Https) { 359 ClosedWhileHidden_Https) {
370 StartHttpsServer(false); 360 StartHttpsServer(false);
371 base::TimeDelta upper_bound = 361 base::TimeDelta upper_bound =
372 NavigateInForegroundAndCloseInBackgroundWithTiming( 362 NavigateInForegroundAndCloseInBackgroundWithTiming(
373 https_test_server_->GetURL("/simple.html")); 363 https_test_server_->GetURL("/simple.html"));
374 364
375 // Test the page load metrics. 365 // Test the page load metrics.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // Test the ratio metric. 477 // Test the ratio metric.
488 FakeUserMetricsUpload(); 478 FakeUserMetricsUpload();
489 histogram_tester_.ExpectTotalCount( 479 histogram_tester_.ExpectTotalCount(
490 internal::kHttpsEngagementSessionPercentage, 0); 480 internal::kHttpsEngagementSessionPercentage, 0);
491 } 481 }
492 482
493 IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest, 483 IN_PROC_BROWSER_TEST_F(HttpsEngagementPageLoadMetricsBrowserTest,
494 MultipleUploads) { 484 MultipleUploads) {
495 StartHttpsServer(false); 485 StartHttpsServer(false);
496 486
497 NavigateInForegroundAndCloseWithTiming(https_test_server_->GetURL("/")); 487 NavigateInForegroundAndCloseWithTiming(
488 https_test_server_->GetURL("/simple.html"));
498 histogram_tester_.ExpectTotalCount( 489 histogram_tester_.ExpectTotalCount(
499 internal::kHttpsEngagementSessionPercentage, 0); 490 internal::kHttpsEngagementSessionPercentage, 0);
500 FakeUserMetricsUpload(); 491 FakeUserMetricsUpload();
501 FakeUserMetricsUpload(); 492 FakeUserMetricsUpload();
502 FakeUserMetricsUpload(); 493 FakeUserMetricsUpload();
503 histogram_tester_.ExpectTotalCount( 494 histogram_tester_.ExpectTotalCount(
504 internal::kHttpsEngagementSessionPercentage, 1); 495 internal::kHttpsEngagementSessionPercentage, 1);
505 } 496 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698