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

Side by Side Diff: components/data_use_measurement/content/data_use_measurement_unittest.cc

Issue 1921973002: Convert //components/[a-e]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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 "components/data_use_measurement/content/data_use_measurement.h" 5 #include "components/data_use_measurement/content/data_use_measurement.h"
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/test/histogram_tester.h" 11 #include "base/test/histogram_tester.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "content/public/browser/resource_request_info.h" 13 #include "content/public/browser/resource_request_info.h"
14 #include "net/base/network_change_notifier.h" 14 #include "net/base/network_change_notifier.h"
15 #include "net/base/request_priority.h" 15 #include "net/base/request_priority.h"
16 #include "net/socket/socket_test_util.h" 16 #include "net/socket/socket_test_util.h"
17 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_test_util.h" 18 #include "net/url_request/url_request_test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
(...skipping 20 matching lines...) Expand all
41 void SendRequest(bool is_user_request) { 41 void SendRequest(bool is_user_request) {
42 net::TestDelegate test_delegate; 42 net::TestDelegate test_delegate;
43 InitializeContext(); 43 InitializeContext();
44 net::MockRead reads[] = {net::MockRead("HTTP/1.1 200 OK\r\n" 44 net::MockRead reads[] = {net::MockRead("HTTP/1.1 200 OK\r\n"
45 "Content-Length: 12\r\n\r\n"), 45 "Content-Length: 12\r\n\r\n"),
46 net::MockRead("Test Content")}; 46 net::MockRead("Test Content")};
47 net::StaticSocketDataProvider socket_data(reads, arraysize(reads), nullptr, 47 net::StaticSocketDataProvider socket_data(reads, arraysize(reads), nullptr,
48 0); 48 0);
49 socket_factory_->AddSocketDataProvider(&socket_data); 49 socket_factory_->AddSocketDataProvider(&socket_data);
50 50
51 scoped_ptr<net::URLRequest> request(context_->CreateRequest( 51 std::unique_ptr<net::URLRequest> request(context_->CreateRequest(
52 GURL("http://foo.com"), net::DEFAULT_PRIORITY, &test_delegate)); 52 GURL("http://foo.com"), net::DEFAULT_PRIORITY, &test_delegate));
53 if (is_user_request) { 53 if (is_user_request) {
54 request->SetUserData( 54 request->SetUserData(
55 data_use_measurement::DataUseUserData::kUserDataKey, 55 data_use_measurement::DataUseUserData::kUserDataKey,
56 new data_use_measurement::DataUseUserData( 56 new data_use_measurement::DataUseUserData(
57 data_use_measurement::DataUseUserData::SUGGESTIONS)); 57 data_use_measurement::DataUseUserData::SUGGESTIONS));
58 } else { 58 } else {
59 content::ResourceRequestInfo::AllocateForTesting( 59 content::ResourceRequestInfo::AllocateForTesting(
60 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, 60 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2,
61 true, false, true, true, false); 61 true, false, true, true, false);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 void FakeDataUseforwarder(const std::string& service_name, 118 void FakeDataUseforwarder(const std::string& service_name,
119 int message_size, 119 int message_size,
120 bool is_celllular) { 120 bool is_celllular) {
121 is_data_use_forwarder_called_ = true; 121 is_data_use_forwarder_called_ = true;
122 } 122 }
123 123
124 base::MessageLoopForIO loop_; 124 base::MessageLoopForIO loop_;
125 DataUseMeasurement data_use_measurement_; 125 DataUseMeasurement data_use_measurement_;
126 scoped_ptr<net::MockClientSocketFactory> socket_factory_; 126 std::unique_ptr<net::MockClientSocketFactory> socket_factory_;
127 scoped_ptr<net::TestURLRequestContext> context_; 127 std::unique_ptr<net::TestURLRequestContext> context_;
128 const std::string kConnectionType = "NotCellular"; 128 const std::string kConnectionType = "NotCellular";
129 bool is_data_use_forwarder_called_ = false; 129 bool is_data_use_forwarder_called_ = false;
130 130
131 DISALLOW_COPY_AND_ASSIGN(DataUseMeasurementTest); 131 DISALLOW_COPY_AND_ASSIGN(DataUseMeasurementTest);
132 }; 132 };
133 133
134 // This test function tests recording of data use information in UMA histogram 134 // This test function tests recording of data use information in UMA histogram
135 // when packet is originated from user or services when the app is in the 135 // when packet is originated from user or services when the app is in the
136 // foreground or the OS is not Android. 136 // foreground or the OS is not Android.
137 // TODO(amohammadkhan): Add tests for Cellular/non-cellular connection types 137 // TODO(amohammadkhan): Add tests for Cellular/non-cellular connection types
(...skipping 19 matching lines...) Expand all
157 } 157 }
158 #endif 158 #endif
159 159
160 TEST_F(DataUseMeasurementTest, DataUseForwarderIsCalled) { 160 TEST_F(DataUseMeasurementTest, DataUseForwarderIsCalled) {
161 EXPECT_FALSE(IsDataUseForwarderCalled()); 161 EXPECT_FALSE(IsDataUseForwarderCalled());
162 SendRequest(true); 162 SendRequest(true);
163 EXPECT_TRUE(IsDataUseForwarderCalled()); 163 EXPECT_TRUE(IsDataUseForwarderCalled());
164 } 164 }
165 165
166 } // namespace data_use_measurement 166 } // namespace data_use_measurement
OLDNEW
« no previous file with comments | « components/data_use_measurement/content/data_use_measurement.h ('k') | components/device_event_log/device_event_log_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698