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

Side by Side Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber_unittest.cc

Issue 2804023003: Network traffic annotation added to chrome/browser/ unittests. (Closed)
Patch Set: Another missing header added. 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 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/data_use_measurement/chrome_data_use_ascriber.h" 5 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h"
6 6
7 #include <list> 7 #include <list>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "components/data_use_measurement/core/data_use_recorder.h" 12 #include "components/data_use_measurement/core/data_use_recorder.h"
13 #include "content/public/browser/resource_request_info.h" 13 #include "content/public/browser/resource_request_info.h"
14 #include "content/public/common/browser_side_navigation_policy.h" 14 #include "content/public/common/browser_side_navigation_policy.h"
15 #include "content/public/common/previews_state.h" 15 #include "content/public/common/previews_state.h"
16 #include "content/public/common/process_type.h" 16 #include "content/public/common/process_type.h"
17 #include "content/public/test/mock_resource_context.h" 17 #include "content/public/test/mock_resource_context.h"
18 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
19 #include "net/url_request/url_request_test_util.h" 20 #include "net/url_request/url_request_test_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace { 23 namespace {
23 int kRenderProcessId = 1; 24 int kRenderProcessId = 1;
24 int kRenderFrameId = 2; 25 int kRenderFrameId = 2;
25 int kRequestId = 3; 26 int kRequestId = 3;
26 } 27 }
27 28
28 namespace data_use_measurement { 29 namespace data_use_measurement {
(...skipping 18 matching lines...) Expand all
47 return resource_context_.get(); 48 return resource_context_.get();
48 } 49 }
49 50
50 ChromeDataUseAscriber* ascriber() { return &ascriber_; } 51 ChromeDataUseAscriber* ascriber() { return &ascriber_; }
51 52
52 std::unique_ptr<net::URLRequest> CreateNewRequest(std::string url, 53 std::unique_ptr<net::URLRequest> CreateNewRequest(std::string url,
53 bool is_main_frame, 54 bool is_main_frame,
54 int request_id, 55 int request_id,
55 int render_process_id, 56 int render_process_id,
56 int render_frame_id) { 57 int render_frame_id) {
57 std::unique_ptr<net::URLRequest> request = 58 std::unique_ptr<net::URLRequest> request = context()->CreateRequest(
58 context()->CreateRequest(GURL(url), net::IDLE, nullptr); 59 GURL(url), net::IDLE, nullptr, TRAFFIC_ANNOTATION_FOR_TESTS);
59 // TODO(kundaji): Allow request_id to be specified in AllocateForTesting. 60 // TODO(kundaji): Allow request_id to be specified in AllocateForTesting.
60 content::ResourceRequestInfo::AllocateForTesting( 61 content::ResourceRequestInfo::AllocateForTesting(
61 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, resource_context(), 62 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, resource_context(),
62 render_process_id, 63 render_process_id,
63 /*render_view_id=*/-1, render_frame_id, is_main_frame, 64 /*render_view_id=*/-1, render_frame_id, is_main_frame,
64 /*parent_is_main_frame=*/false, 65 /*parent_is_main_frame=*/false,
65 /*allow_download=*/false, 66 /*allow_download=*/false,
66 /*is_async=*/true, content::PREVIEWS_OFF); 67 /*is_async=*/true, content::PREVIEWS_OFF);
67 return request; 68 return request;
68 } 69 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ascriber()->RenderFrameHostChanged(kRenderProcessId, kRenderFrameId, 165 ascriber()->RenderFrameHostChanged(kRenderProcessId, kRenderFrameId,
165 kRenderProcessId + 1, kRenderFrameId + 1); 166 kRenderProcessId + 1, kRenderFrameId + 1);
166 ascriber()->RenderFrameDeleted(kRenderProcessId, kRenderFrameId, -1, -1); 167 ascriber()->RenderFrameDeleted(kRenderProcessId, kRenderFrameId, -1, -1);
167 168
168 ascriber()->WasShownOrHidden(kRenderProcessId + 1, kRenderFrameId + 1, true); 169 ascriber()->WasShownOrHidden(kRenderProcessId + 1, kRenderFrameId + 1, true);
169 ascriber()->RenderFrameDeleted(kRenderProcessId + 1, kRenderFrameId + 1, -1, 170 ascriber()->RenderFrameDeleted(kRenderProcessId + 1, kRenderFrameId + 1, -1,
170 -1); 171 -1);
171 } 172 }
172 173
173 } // namespace data_use_measurement 174 } // namespace data_use_measurement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698