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

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

Issue 1550563002: Blink Platform: Remove time functions from Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: third_party/WebKit/Source/core/fetch/CachingCorrectnessTest.cpp
diff --git a/third_party/WebKit/Source/core/fetch/CachingCorrectnessTest.cpp b/third_party/WebKit/Source/core/fetch/CachingCorrectnessTest.cpp
index d90176ed0e61c4d7c064fd74f0ca7c16d1d166f2..11bc8546aaaa1d985d73474d3fe21ba1dc6da3e9 100644
--- a/third_party/WebKit/Source/core/fetch/CachingCorrectnessTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/CachingCorrectnessTest.cpp
@@ -36,8 +36,6 @@
#include "core/fetch/ResourceFetcher.h"
#include "core/fetch/ResourcePtr.h"
#include "platform/network/ResourceRequest.h"
-#include "platform/testing/TestingPlatformSupport.h"
-#include "public/platform/Platform.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/OwnPtr.h"
#include "wtf/RefPtr.h"
@@ -72,9 +70,9 @@ private:
class CachingCorrectnessTest : public ::testing::Test {
protected:
- void advanceClock(double seconds)
+ static void advanceClock(double seconds)
{
- m_proxyPlatform.advanceClock(seconds);
+ s_timeElapsed += seconds;
}
ResourcePtr<Resource> resourceFromResourceResponse(ResourceResponse response, Resource::Type type = Resource::Raw)
@@ -126,25 +124,10 @@ protected:
ResourceFetcher* fetcher() const { return m_fetcher.get(); }
private:
- // A simple platform that mocks out the clock, for cache freshness testing.
- class ProxyPlatform : public TestingPlatformSupport {
- public:
- ProxyPlatform() : m_elapsedSeconds(0.) { }
-
- void advanceClock(double seconds)
- {
- m_elapsedSeconds += seconds;
- }
-
- private:
- // From blink::Platform:
- double currentTimeSeconds() override
- {
- return kOriginalRequestDateAsDouble + m_elapsedSeconds;
- }
-
- double m_elapsedSeconds;
- };
+ static double returnMockTime()
+ {
+ return kOriginalRequestDateAsDouble + s_timeElapsed;
+ }
virtual void SetUp()
{
@@ -152,6 +135,9 @@ private:
m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create());
m_fetcher = ResourceFetcher::create(MockFetchContext::create());
+
+ s_timeElapsed = 0.0;
+ m_originalTimeFunction = setTimeFunctionsForTesting(returnMockTime);
}
virtual void TearDown()
@@ -160,14 +146,18 @@ private:
// Yield the ownership of the global memory cache back.
replaceMemoryCacheForTesting(m_globalMemoryCache.release());
- }
- ProxyPlatform m_proxyPlatform;
+ setTimeFunctionsForTesting(m_originalTimeFunction);
+ }
Persistent<MemoryCache> m_globalMemoryCache;
Persistent<ResourceFetcher> m_fetcher;
+ TimeFunction m_originalTimeFunction;
+ static double s_timeElapsed;
};
+double CachingCorrectnessTest::s_timeElapsed;
+
TEST_F(CachingCorrectnessTest, FreshFromLastModified)
{
ResourceResponse fresh200Response;

Powered by Google App Engine
This is Rietveld 408576698