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

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

Issue 2737563007: Add support for tracking loading behavior of child frames. (Closed)
Patch Set: test fixes Created 3 years, 9 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 subframe_tester->SimulateNavigationCommit(GURL(kDefaultTestUrl2)); 272 subframe_tester->SimulateNavigationCommit(GURL(kDefaultTestUrl2));
273 SimulateTimingUpdate(timing, subframe); 273 SimulateTimingUpdate(timing, subframe);
274 subframe_tester->SimulateNavigationStop(); 274 subframe_tester->SimulateNavigationStop();
275 275
276 // Navigate again to see if the timing updated for a subframe message. 276 // Navigate again to see if the timing updated for a subframe message.
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_IPC_FROM_WRONG_FRAME, 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, SamePageNoTrigger) {
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());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 361
362 content::RenderFrameHostTester* rfh_tester = 362 content::RenderFrameHostTester* rfh_tester =
363 content::RenderFrameHostTester::For(main_rfh()); 363 content::RenderFrameHostTester::For(main_rfh());
364 content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); 364 content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe");
365 365
366 content::RenderFrameHostTester* subframe_tester = 366 content::RenderFrameHostTester* subframe_tester =
367 content::RenderFrameHostTester::For(subframe); 367 content::RenderFrameHostTester::For(subframe);
368 subframe_tester->SimulateNavigationStart(GURL(kDefaultTestUrl2)); 368 subframe_tester->SimulateNavigationStart(GURL(kDefaultTestUrl2));
369 subframe_tester->SimulateNavigationCommit(GURL(kDefaultTestUrl2)); 369 subframe_tester->SimulateNavigationCommit(GURL(kDefaultTestUrl2));
370 SimulateTimingUpdate(timing, subframe); 370 SimulateTimingUpdate(timing, subframe);
371 CheckErrorEvent(ERR_IPC_FROM_WRONG_FRAME, 1); 371 CheckErrorEvent(ERR_TIMING_IPC_FROM_SUBFRAME, 1);
372 CheckTotalErrorEvents(); 372 CheckTotalErrorEvents();
373 ASSERT_EQ(0, CountUpdatedTimingReported()); 373 ASSERT_EQ(0, CountUpdatedTimingReported());
374 ASSERT_EQ(0, CountCompleteTimingReported()); 374 ASSERT_EQ(0, CountCompleteTimingReported());
375 } 375 }
376 376
377 TEST_F(MetricsWebContentsObserverTest, BadIPC) { 377 TEST_F(MetricsWebContentsObserverTest, BadIPC) {
378 PageLoadTiming timing; 378 PageLoadTiming timing;
379 timing.navigation_start = base::Time::FromDoubleT(10); 379 timing.navigation_start = base::Time::FromDoubleT(10);
380 PageLoadTiming timing2; 380 PageLoadTiming timing2;
381 timing2.navigation_start = base::Time::FromDoubleT(100); 381 timing2.navigation_start = base::Time::FromDoubleT(100);
(...skipping 203 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