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

Unified Diff: content/browser/service_worker/foreign_fetch_request_handler_unittest.cc

Issue 2555333006: Deflake origin trial token validator tests (Closed)
Patch Set: Switch WrapUnique to MakeUnique Created 3 years, 4 months 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 | « no previous file | content/browser/service_worker/link_header_support.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/foreign_fetch_request_handler_unittest.cc
diff --git a/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc b/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc
index cdf3bc48a5fadb166da6f4c30b85660ee1629112..5f6382b7aeea986d137b3e5f6f534f18002be66b 100644
--- a/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc
+++ b/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc
@@ -6,6 +6,7 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
+#include "base/test/simple_test_clock.h"
#include "base/test/simple_test_tick_clock.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
@@ -50,6 +51,10 @@ int kMockProviderId = 1;
const char* kValidUrl = "https://valid.example.com/foo/bar";
+// This timestamp is set to a time after the expiry timestamp of the expired
+// tokens in this test, but before the expiry timestamp of the valid ones.
+double kNowTimestamp = 1500000000;
+
void EmptyCallback() {}
} // namespace
@@ -79,6 +84,12 @@ class ForeignFetchRequestHandlerTest : public testing::Test {
kVersionId, context()->AsWeakPtr());
version_->set_foreign_fetch_scopes({kScope});
+ // Fix the time for testing to kNowTimestamp
+ std::unique_ptr<base::SimpleTestClock> clock =
+ base::MakeUnique<base::SimpleTestClock>();
+ clock->SetNow(base::Time::FromDoubleT(kNowTimestamp));
+ version_->SetClockForTesting(std::move(clock));
+
context()->storage()->LazyInitialize(base::Bind(&EmptyCallback));
base::RunLoop().RunUntilIdle();
« no previous file with comments | « no previous file | content/browser/service_worker/link_header_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698