| 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 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 // The time that |kGoodTimeResponseBody| uses. Can be converted to a | 44 // The time that |kGoodTimeResponseBody| uses. Can be converted to a |
| 45 // base::Time with base::Time::FromJsTime. | 45 // base::Time with base::Time::FromJsTime. |
| 46 extern const double kGoodTimeResponseHandlerJsTime; | 46 extern const double kGoodTimeResponseHandlerJsTime; |
| 47 | 47 |
| 48 // Returns a valid network time response using the constants above. See | 48 // Returns a valid network time response using the constants above. See |
| 49 // 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. |
| 50 std::unique_ptr<net::test_server::HttpResponse> GoodTimeResponseHandler( | 50 std::unique_ptr<net::test_server::HttpResponse> GoodTimeResponseHandler( |
| 51 const net::test_server::HttpRequest& request); | 51 const net::test_server::HttpRequest& request); |
| 52 | 52 |
| 53 // Allows tests to configure the network time queries field trial. | 53 // Allows unit tests to configure the network time queries field trial. |
| 54 class FieldTrialTest { | 54 class FieldTrialTest { |
| 55 public: | 55 public: |
| 56 FieldTrialTest(); |
| 56 virtual ~FieldTrialTest(); | 57 virtual ~FieldTrialTest(); |
| 57 | 58 |
| 58 // A FieldTrialList exists as a global singleton. Use | |
| 59 // CreateForUnitTest() in unit tests to create a FieldTrialTest that | |
| 60 // creates its own FieldTrialList; use CreateForBrowserTest() to use | |
| 61 // the singleton FieldTrialList that is created during browser setup. | |
| 62 static FieldTrialTest* CreateForUnitTest(); | |
| 63 static FieldTrialTest* CreateForBrowserTest(); | |
| 64 | |
| 65 void SetNetworkQueriesWithVariationsService( | 59 void SetNetworkQueriesWithVariationsService( |
| 66 bool enable, | 60 bool enable, |
| 67 float query_probability, | 61 float query_probability, |
| 68 NetworkTimeTracker::FetchBehavior fetch_behavior); | 62 NetworkTimeTracker::FetchBehavior fetch_behavior); |
| 69 | 63 |
| 70 private: | 64 private: |
| 71 FieldTrialTest(); | |
| 72 bool create_field_trial_list_ = true; | |
| 73 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 65 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
| 74 std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; | 66 std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; |
| 75 | 67 |
| 76 DISALLOW_COPY_AND_ASSIGN(FieldTrialTest); | 68 DISALLOW_COPY_AND_ASSIGN(FieldTrialTest); |
| 77 }; | 69 }; |
| 78 | 70 |
| 79 } // namespace network_time | 71 } // namespace network_time |
| 80 | 72 |
| 81 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ | 73 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TEST_UTILS_H_ |
| OLD | NEW |