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

Unified Diff: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp

Issue 1464953003: Revert of More regular Platform implementations in unit tests (reland.) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
Index: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp
index e504997a7fc9aa080b5763e2d2512cbfc5c827db..4187ec2b13329c4a4c097daf0d82170c6288bc21 100644
--- a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurfaceTest.cpp
@@ -9,7 +9,6 @@
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/ImageBufferClient.h"
#include "platform/graphics/UnacceleratedImageBufferSurface.h"
-#include "platform/testing/TestingPlatformSupport.h"
#include "public/platform/Platform.h"
#include "public/platform/WebTaskRunner.h"
#include "public/platform/WebThread.h"
@@ -237,13 +236,24 @@
// for the current thread. The Mock thread is capable of queuing a single non-delayed task
// and registering a single task observer. The run loop exits immediately after running
// the single task.
-
-class CurrentThreadPlatformMock : public TestingPlatformSupport {
+class AutoInstallCurrentThreadPlatformMock {
public:
- CurrentThreadPlatformMock() { }
- WebThread* currentThread() override { return &m_currentThread; }
-
- void enterRunLoop() { m_currentThread.enterRunLoop(); }
+ AutoInstallCurrentThreadPlatformMock()
+ {
+ m_oldPlatform = Platform::current();
+ Platform::initialize(&m_mockPlatform);
+ }
+
+ ~AutoInstallCurrentThreadPlatformMock()
+ {
+ Platform::initialize(m_oldPlatform);
+ }
+
+ void enterRunLoop()
+ {
+ m_mockPlatform.enterRunLoop();
+ }
+
private:
class MockWebTaskRunner : public WebTaskRunner {
public:
@@ -325,7 +335,22 @@
TaskObserver* m_taskObserver;
};
- CurrentThreadMock m_currentThread;
+ class CurrentThreadPlatformMock : public Platform {
+ public:
+ CurrentThreadPlatformMock() { }
+ virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length)
+ {
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ WebThread* currentThread() override { return &m_currentThread; }
+
+ void enterRunLoop() { m_currentThread.enterRunLoop(); }
+ private:
+ CurrentThreadMock m_currentThread;
+ };
+
+ CurrentThreadPlatformMock m_mockPlatform;
+ Platform* m_oldPlatform;
};
} // anonymous namespace
@@ -341,7 +366,7 @@
#define CALL_TEST_TASK_WRAPPER(TEST_METHOD) \
{ \
- CurrentThreadPlatformMock ctpm; \
+ AutoInstallCurrentThreadPlatformMock ctpm; \
Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE, new TestWrapperTask_ ## TEST_METHOD(this)); \
ctpm.enterRunLoop(); \
}

Powered by Google App Engine
This is Rietveld 408576698