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

Unified Diff: third_party/WebKit/Source/core/fetch/MemoryCacheCorrectnessTest.cpp

Issue 2631383003: Use TestingPlatformSupportWithMockScheduler to use mocked Time (Closed)
Patch Set: rebase Created 3 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/MemoryCacheCorrectnessTest.cpp
diff --git a/third_party/WebKit/Source/core/fetch/MemoryCacheCorrectnessTest.cpp b/third_party/WebKit/Source/core/fetch/MemoryCacheCorrectnessTest.cpp
index 46b3f6c7d43bf73d1f19d913599b819e45dc5f3e..baefbba4fcacdc8a30ea4bbb61de0a3f4acff98a 100644
--- a/third_party/WebKit/Source/core/fetch/MemoryCacheCorrectnessTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/MemoryCacheCorrectnessTest.cpp
@@ -38,6 +38,7 @@
#include "core/fetch/Resource.h"
#include "core/fetch/ResourceFetcher.h"
#include "platform/network/ResourceRequest.h"
+#include "platform/testing/TestingPlatformSupport.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
@@ -49,21 +50,9 @@ constexpr char kResourceURL[] = "http://resource.com/";
// The origin time of our first request.
constexpr char kOriginalRequestDateAsString[] = "Thu, 25 May 1977 18:30:00 GMT";
-constexpr double kOriginalRequestDateAsDouble = 233433000.;
-
constexpr char kOneDayBeforeOriginalRequest[] = "Wed, 24 May 1977 18:30:00 GMT";
constexpr char kOneDayAfterOriginalRequest[] = "Fri, 26 May 1977 18:30:00 GMT";
-double timeElapsed = 0.0;
-
-void advanceClock(double seconds) {
- timeElapsed += seconds;
-}
-
-double returnMockTime() {
- return kOriginalRequestDateAsDouble + timeElapsed;
-}
-
} // namespace
class MemoryCacheCorrectnessTest : public ::testing::Test {
@@ -105,6 +94,9 @@ class MemoryCacheCorrectnessTest : public ::testing::Test {
return MockResource::fetch(fetchRequest, fetcher());
}
ResourceFetcher* fetcher() const { return m_fetcher.get(); }
+ void advanceClock(double seconds) {
+ m_platform->advanceClockSeconds(seconds);
+ }
private:
// Overrides ::testing::Test.
@@ -114,22 +106,18 @@ class MemoryCacheCorrectnessTest : public ::testing::Test {
m_fetcher = ResourceFetcher::create(
MockFetchContext::create(MockFetchContext::kShouldNotLoadNewResource));
-
- timeElapsed = 0.0;
- m_originalTimeFunction = setTimeFunctionsForTesting(returnMockTime);
}
void TearDown() override {
memoryCache()->evictResources();
// Yield the ownership of the global memory cache back.
replaceMemoryCacheForTesting(m_globalMemoryCache.release());
-
- setTimeFunctionsForTesting(m_originalTimeFunction);
}
Persistent<MemoryCache> m_globalMemoryCache;
Persistent<ResourceFetcher> m_fetcher;
- TimeFunction m_originalTimeFunction;
+ ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
+ m_platform;
};
TEST_F(MemoryCacheCorrectnessTest, FreshFromLastModified) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698