OLD | NEW |
---|---|
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.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" |
21 | 21 |
22 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
23 #include "base/android/application_status_listener.h" | 23 #include "base/android/application_status_listener.h" |
24 #endif | 24 #endif |
25 | 25 |
26 namespace data_use_measurement { | 26 namespace data_use_measurement { |
27 | 27 |
28 class DataUseMeasurementTest : public testing::Test { | 28 class DataUseMeasurementTest : public testing::Test { |
29 public: | 29 public: |
30 DataUseMeasurementTest() { | 30 DataUseMeasurementTest() |
31 : data_use_measurement_(metrics::UpdateUsagePrefCallbackType()) { | |
bengr
2016/04/06 20:57:11
Please test that the callback gets called appropri
gayane -on leave until 09-2017
2016/04/07 15:30:39
Done.
| |
31 // During the test it is expected to not have cellular connection. | 32 // During the test it is expected to not have cellular connection. |
32 DCHECK(!net::NetworkChangeNotifier::IsConnectionCellular( | 33 DCHECK(!net::NetworkChangeNotifier::IsConnectionCellular( |
33 net::NetworkChangeNotifier::GetConnectionType())); | 34 net::NetworkChangeNotifier::GetConnectionType())); |
34 } | 35 } |
35 | 36 |
36 // This function makes a user request and confirms that its effect is | 37 // This function makes a user request and confirms that its effect is |
37 // reflected in proper histograms. | 38 // reflected in proper histograms. |
38 void TestForAUserRequest(const std::string& target_dimension) { | 39 void TestForAUserRequest(const std::string& target_dimension) { |
39 net::TestDelegate test_delegate; | 40 net::TestDelegate test_delegate; |
40 InitializeContext(); | 41 InitializeContext(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 // background and OS is Android. | 145 // background and OS is Android. |
145 TEST_F(DataUseMeasurementTest, ApplicationStateTest) { | 146 TEST_F(DataUseMeasurementTest, ApplicationStateTest) { |
146 data_use_measurement()->OnApplicationStateChangeForTesting( | 147 data_use_measurement()->OnApplicationStateChangeForTesting( |
147 base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES); | 148 base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES); |
148 TestForAServiceRequest("Background."); | 149 TestForAServiceRequest("Background."); |
149 TestForAUserRequest("Background."); | 150 TestForAUserRequest("Background."); |
150 } | 151 } |
151 #endif | 152 #endif |
152 | 153 |
153 } // namespace data_use_measurement | 154 } // namespace data_use_measurement |
OLD | NEW |