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

Unified Diff: components/network_time/network_time_test_utils.h

Issue 2449193002: Attempt an on-demand time fetch when encountering a date invalid error (Closed)
Patch Set: meacer nits Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/BUILD.gn ('k') | components/network_time/network_time_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/network_time/network_time_test_utils.h
diff --git a/components/network_time/network_time_test_utils.h b/components/network_time/network_time_test_utils.h
index 97ed8dce53509e93ea1fda438cc1f54103447b83..c7aa18c026f4d2c4574ba7fe59af6d2c1c0f6f93 100644
--- a/components/network_time/network_time_test_utils.h
+++ b/components/network_time/network_time_test_utils.h
@@ -27,25 +27,53 @@ class HttpResponse;
namespace network_time {
+// The body of a valid time response. Can be returned, with
+// |kGoodTimeResponseServerProofHeader|, in responses from test servers
+// to simulate a network time server. This response uses 1 as the key
+// version and 123123123 as the nonce. Use
+// NetworkTimeTracker::OverrideNonceForTesting() to set the nonce so
+// that this response validates.
+extern const char kGoodTimeResponseBody[];
+
+// The x-cup-server-proof header value that should be served along with
+// |kGoodTimeResponseBody| to make a test server response be accepted by
+// NetworkTimeTracker as a valid response.
+extern const char kGoodTimeResponseServerProofHeader[];
+
+// The time that |kGoodTimeResponseBody| uses. Can be converted to a
+// base::Time with base::Time::FromJsTime.
+extern const double kGoodTimeResponseHandlerJsTime;
+
+// Returns a valid network time response using the constants above. See
+// comments in the .cc for how to update the time returned in the response.
std::unique_ptr<net::test_server::HttpResponse> GoodTimeResponseHandler(
const net::test_server::HttpRequest& request);
// Allows tests to configure the network time queries field trial.
class FieldTrialTest {
public:
- enum FetchesOnDemandStatus {
- ENABLE_FETCHES_ON_DEMAND,
- DISABLE_FETCHES_ON_DEMAND,
+ enum FetchBehavior {
+ FETCHES_IN_BACKGROUND_ONLY,
+ FETCHES_ON_DEMAND_ONLY,
+ FETCHES_IN_BACKGROUND_AND_ON_DEMAND,
};
- FieldTrialTest();
virtual ~FieldTrialTest();
- void SetNetworkQueriesWithVariationsService(
- bool enable,
- float query_probability,
- FetchesOnDemandStatus fetches_on_demand);
+
+ // A FieldTrialList exists as a global singleton. Use
+ // CreateForUnitTest() in unit tests to create a FieldTrialTest that
+ // creates its own FieldTrialList; use CreateForBrowserTest() to use
+ // the singleton FieldTrialList that is created during browser setup.
+ static FieldTrialTest* CreateForUnitTest();
+ static FieldTrialTest* CreateForBrowserTest();
+
+ void SetNetworkQueriesWithVariationsService(bool enable,
+ float query_probability,
+ FetchBehavior fetch_behavior);
private:
+ FieldTrialTest();
+ bool create_field_trial_list_ = true;
std::unique_ptr<base::FieldTrialList> field_trial_list_;
std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
« no previous file with comments | « chrome/test/BUILD.gn ('k') | components/network_time/network_time_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698