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 "components/network_time/network_time_tracker.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 namespace test { | 15 namespace test { |
15 class ScopedFeatureList; | 16 class ScopedFeatureList; |
16 }; // namespace test | 17 }; // namespace test |
17 | 18 |
18 class FieldTrialList; | 19 class FieldTrialList; |
19 } // namespace base | 20 } // namespace base |
20 | 21 |
21 namespace net { | 22 namespace net { |
(...skipping 23 matching lines...) Expand all Loading... |
45 extern const double kGoodTimeResponseHandlerJsTime; | 46 extern const double kGoodTimeResponseHandlerJsTime; |
46 | 47 |
47 // Returns a valid network time response using the constants above. See | 48 // Returns a valid network time response using the constants above. See |
48 // comments in the .cc for how to update the time returned in the response. | 49 // comments in the .cc for how to update the time returned in the response. |
49 std::unique_ptr<net::test_server::HttpResponse> GoodTimeResponseHandler( | 50 std::unique_ptr<net::test_server::HttpResponse> GoodTimeResponseHandler( |
50 const net::test_server::HttpRequest& request); | 51 const net::test_server::HttpRequest& request); |
51 | 52 |
52 // Allows tests to configure the network time queries field trial. | 53 // Allows tests to configure the network time queries field trial. |
53 class FieldTrialTest { | 54 class FieldTrialTest { |
54 public: | 55 public: |
55 enum FetchBehavior { | |
56 FETCHES_IN_BACKGROUND_ONLY, | |
57 FETCHES_ON_DEMAND_ONLY, | |
58 FETCHES_IN_BACKGROUND_AND_ON_DEMAND, | |
59 }; | |
60 | |
61 virtual ~FieldTrialTest(); | 56 virtual ~FieldTrialTest(); |
62 | 57 |
63 // A FieldTrialList exists as a global singleton. Use | 58 // A FieldTrialList exists as a global singleton. Use |
64 // CreateForUnitTest() in unit tests to create a FieldTrialTest that | 59 // CreateForUnitTest() in unit tests to create a FieldTrialTest that |
65 // creates its own FieldTrialList; use CreateForBrowserTest() to use | 60 // creates its own FieldTrialList; use CreateForBrowserTest() to use |
66 // the singleton FieldTrialList that is created during browser setup. | 61 // the singleton FieldTrialList that is created during browser setup. |
67 static FieldTrialTest* CreateForUnitTest(); | 62 static FieldTrialTest* CreateForUnitTest(); |
68 static FieldTrialTest* CreateForBrowserTest(); | 63 static FieldTrialTest* CreateForBrowserTest(); |
69 | 64 |
70 void SetNetworkQueriesWithVariationsService(bool enable, | 65 void SetNetworkQueriesWithVariationsService( |
71 float query_probability, | 66 bool enable, |
72 FetchBehavior fetch_behavior); | 67 float query_probability, |
| 68 NetworkTimeTracker::FetchBehavior fetch_behavior); |
73 | 69 |
74 private: | 70 private: |
75 FieldTrialTest(); | 71 FieldTrialTest(); |
76 bool create_field_trial_list_ = true; | 72 bool create_field_trial_list_ = true; |
77 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 73 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
78 std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; | 74 std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; |
79 | 75 |
80 DISALLOW_COPY_AND_ASSIGN(FieldTrialTest); | 76 DISALLOW_COPY_AND_ASSIGN(FieldTrialTest); |
81 }; | 77 }; |
82 | 78 |
83 } // namespace network_time | 79 } // namespace network_time |
84 | 80 |
85 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ | 81 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ |
OLD | NEW |