OLD | NEW |
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 #ifndef COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ | 5 #ifndef COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ |
6 #define COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ | 6 #define COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | 12 |
14 namespace base { | 13 namespace base { |
15 namespace test { | 14 namespace test { |
16 class ScopedFeatureList; | 15 class ScopedFeatureList; |
17 }; // namespace test | 16 }; // namespace test |
18 | 17 |
19 class FieldTrialList; | 18 class FieldTrialList; |
20 } // namespace base | 19 } // namespace base |
21 | 20 |
| 21 namespace net { |
| 22 namespace test_server { |
| 23 struct HttpRequest; |
| 24 class HttpResponse; |
| 25 } // namespace test_server |
| 26 } // namespace net |
| 27 |
22 namespace network_time { | 28 namespace network_time { |
23 // A test fixture that allows configuring the network time queries field trial. | 29 |
24 class FieldTrialTest : public ::testing::Test { | 30 std::unique_ptr<net::test_server::HttpResponse> GoodTimeResponseHandler( |
| 31 const net::test_server::HttpRequest& request); |
| 32 |
| 33 // Allows tests to configure the network time queries field trial. |
| 34 class FieldTrialTest { |
25 public: | 35 public: |
| 36 enum FetchesOnDemandStatus { |
| 37 ENABLE_FETCHES_ON_DEMAND, |
| 38 DISABLE_FETCHES_ON_DEMAND, |
| 39 }; |
| 40 |
26 FieldTrialTest(); | 41 FieldTrialTest(); |
27 ~FieldTrialTest() override; | 42 virtual ~FieldTrialTest(); |
28 | 43 void SetNetworkQueriesWithVariationsService( |
29 protected: | 44 bool enable, |
30 void SetNetworkQueriesWithVariationsService(bool enable, | 45 float query_probability, |
31 float query_probability); | 46 FetchesOnDemandStatus fetches_on_demand); |
32 | 47 |
33 private: | 48 private: |
34 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 49 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
35 std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; | 50 std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; |
36 | 51 |
37 DISALLOW_COPY_AND_ASSIGN(FieldTrialTest); | 52 DISALLOW_COPY_AND_ASSIGN(FieldTrialTest); |
38 }; | 53 }; |
39 | 54 |
40 } // namespace network_time | 55 } // namespace network_time |
41 | 56 |
42 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ | 57 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ |
OLD | NEW |