OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/resource_tracking_page_load
_metrics_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/resource_tracking_page_load
_metrics_observer.h" |
6 | 6 |
7 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.h" | 7 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_
test_harness.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 const char kFakeUrl[] = "http://www.google.com/nothingotseehere.html"; | 10 const char kFakeUrl[] = "http://www.google.com/nothingotseehere.html"; |
(...skipping 27 matching lines...) Expand all Loading... |
38 }; | 38 }; |
39 | 39 |
40 TEST_F(ResourceTrackingPageLoadMetricsObserverTest, StartAndFinish) { | 40 TEST_F(ResourceTrackingPageLoadMetricsObserverTest, StartAndFinish) { |
41 page_load_metrics::ExtraRequestStartInfo start_info_1{ | 41 page_load_metrics::ExtraRequestStartInfo start_info_1{ |
42 content::ResourceType::RESOURCE_TYPE_IMAGE}; | 42 content::ResourceType::RESOURCE_TYPE_IMAGE}; |
43 | 43 |
44 page_load_metrics::ExtraRequestStartInfo start_info_2{ | 44 page_load_metrics::ExtraRequestStartInfo start_info_2{ |
45 content::ResourceType::RESOURCE_TYPE_IMAGE}; | 45 content::ResourceType::RESOURCE_TYPE_IMAGE}; |
46 | 46 |
47 page_load_metrics::ExtraRequestCompleteInfo done_info{ | 47 page_load_metrics::ExtraRequestCompleteInfo done_info{ |
48 false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 48 GURL(), |
| 49 -1 /*frame_tree_node_id*/, |
| 50 false /*was_cached*/, |
| 51 1024 * 40 /* raw_body_bytes */, |
49 1024 * 40 /* original_network_content_length */, | 52 1024 * 40 /* original_network_content_length */, |
50 nullptr /* data reduction_proxy */, | 53 nullptr /* data reduction_proxy */, |
51 content::ResourceType::RESOURCE_TYPE_IMAGE}; | 54 content::ResourceType::RESOURCE_TYPE_IMAGE, |
| 55 }; |
52 | 56 |
53 // Start the navigation. This will create the page load tracker and register | 57 // Start the navigation. This will create the page load tracker and register |
54 // the observers. | 58 // the observers. |
55 NavigateAndCommit(GURL(kFakeUrl)); | 59 NavigateAndCommit(GURL(kFakeUrl)); |
56 | 60 |
57 // Simulate starting two images, and completing one. | 61 // Simulate starting two images, and completing one. |
58 SimulateStartedResource(start_info_1); | 62 SimulateStartedResource(start_info_1); |
59 SimulateStartedResource(start_info_2); | 63 SimulateStartedResource(start_info_2); |
60 SimulateLoadedResource(done_info); | 64 SimulateLoadedResource(done_info); |
61 | 65 |
62 int64_t started = -1; | 66 int64_t started = -1; |
63 int64_t completed = -1; | 67 int64_t completed = -1; |
64 EXPECT_NE(nullptr, observer()); | 68 EXPECT_NE(nullptr, observer()); |
65 observer()->GetCountsForTypeForTesting( | 69 observer()->GetCountsForTypeForTesting( |
66 content::ResourceType::RESOURCE_TYPE_IMAGE, &started, &completed); | 70 content::ResourceType::RESOURCE_TYPE_IMAGE, &started, &completed); |
67 EXPECT_EQ(2, started); | 71 EXPECT_EQ(2, started); |
68 EXPECT_EQ(1, completed); | 72 EXPECT_EQ(1, completed); |
69 } | 73 } |
70 | 74 |
71 } // namespace page_load_metrics | 75 } // namespace page_load_metrics |
OLD | NEW |