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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc

Issue 2807723002: Use SameDocument term instead of SamePage in chrome tests. (Closed)
Patch Set: Self review Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/public/test/test_renderer_host.h" 23 #include "content/public/test/test_renderer_host.h"
24 #include "content/public/test/web_contents_tester.h" 24 #include "content/public/test/web_contents_tester.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 namespace page_load_metrics { 28 namespace page_load_metrics {
29 29
30 namespace { 30 namespace {
31 31
32 const char kDefaultTestUrl[] = "https://google.com/"; 32 const char kDefaultTestUrl[] = "https://google.com/";
33 const char kDefaultTestUrlAnchor[] = "https://google.com/#samepage"; 33 const char kDefaultTestUrlAnchor[] = "https://google.com/#samedocument";
34 const char kDefaultTestUrl2[] = "https://whatever.com/"; 34 const char kDefaultTestUrl2[] = "https://whatever.com/";
35 const char kFilteredStartUrl[] = "https://whatever.com/ignore-on-start"; 35 const char kFilteredStartUrl[] = "https://whatever.com/ignore-on-start";
36 const char kFilteredCommitUrl[] = "https://whatever.com/ignore-on-commit"; 36 const char kFilteredCommitUrl[] = "https://whatever.com/ignore-on-commit";
37 37
38 // Simple PageLoadMetricsObserver that copies observed PageLoadTimings into the 38 // Simple PageLoadMetricsObserver that copies observed PageLoadTimings into the
39 // provided std::vector, so they can be analyzed by unit tests. 39 // provided std::vector, so they can be analyzed by unit tests.
40 class TestPageLoadMetricsObserver : public PageLoadMetricsObserver { 40 class TestPageLoadMetricsObserver : public PageLoadMetricsObserver {
41 public: 41 public:
42 TestPageLoadMetricsObserver(std::vector<PageLoadTiming>* updated_timings, 42 TestPageLoadMetricsObserver(std::vector<PageLoadTiming>* updated_timings,
43 std::vector<PageLoadTiming>* complete_timings, 43 std::vector<PageLoadTiming>* complete_timings,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); 277 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2));
278 278
279 ASSERT_EQ(0, CountUpdatedTimingReported()); 279 ASSERT_EQ(0, CountUpdatedTimingReported());
280 ASSERT_EQ(1, CountCompleteTimingReported()); 280 ASSERT_EQ(1, CountCompleteTimingReported());
281 ASSERT_EQ(1, CountEmptyCompleteTimingReported()); 281 ASSERT_EQ(1, CountEmptyCompleteTimingReported());
282 CheckErrorEvent(ERR_TIMING_IPC_FROM_SUBFRAME, 1); 282 CheckErrorEvent(ERR_TIMING_IPC_FROM_SUBFRAME, 1);
283 CheckErrorEvent(ERR_NO_IPCS_RECEIVED, 1); 283 CheckErrorEvent(ERR_NO_IPCS_RECEIVED, 1);
284 CheckTotalErrorEvents(); 284 CheckTotalErrorEvents();
285 } 285 }
286 286
287 TEST_F(MetricsWebContentsObserverTest, SamePageNoTrigger) { 287 TEST_F(MetricsWebContentsObserverTest, SameDocumentNoTrigger) {
288 PageLoadTiming timing; 288 PageLoadTiming timing;
289 timing.navigation_start = base::Time::FromDoubleT(1); 289 timing.navigation_start = base::Time::FromDoubleT(1);
290 290
291 content::WebContentsTester* web_contents_tester = 291 content::WebContentsTester* web_contents_tester =
292 content::WebContentsTester::For(web_contents()); 292 content::WebContentsTester::For(web_contents());
293 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); 293 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
294 ASSERT_EQ(0, CountUpdatedTimingReported()); 294 ASSERT_EQ(0, CountUpdatedTimingReported());
295 SimulateTimingUpdate(timing); 295 SimulateTimingUpdate(timing);
296 ASSERT_EQ(1, CountUpdatedTimingReported()); 296 ASSERT_EQ(1, CountUpdatedTimingReported());
297 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrlAnchor)); 297 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrlAnchor));
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2)); 585 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2));
586 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), 586 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}),
587 completed_filtered_urls()); 587 completed_filtered_urls());
588 588
589 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); 589 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
590 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}), 590 ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}),
591 completed_filtered_urls()); 591 completed_filtered_urls());
592 } 592 }
593 593
594 } // namespace page_load_metrics 594 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698