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

Unified Diff: third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp

Issue 1466603003: Revert of More regular Platform implementations in unit tests. (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/core/dom/ScriptRunnerTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp b/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp
index 09e5579b06e2a871feb4d81eb80934ac4f0dfe56..b9668ec507af2e7981912ea7d232d2d4f7562221 100644
--- a/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp
@@ -10,7 +10,6 @@
#include "core/dom/ScriptLoader.h"
#include "platform/heap/Handle.h"
#include "platform/scheduler/CancellableTaskFactory.h"
-#include "platform/testing/TestingPlatformSupport.h"
#include "public/platform/Platform.h"
#include "public/platform/WebViewScheduler.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -96,12 +95,23 @@
Deque<OwnPtr<WebTaskRunner::Task>>* m_tasks; // NOT OWNED
};
-class MockPlatform : public TestingPlatformSupport, public WebScheduler {
+class MockPlatform : public Platform, public WebScheduler {
public:
MockPlatform()
: m_mockWebThread(this)
, m_mockWebTaskRunner(&m_tasks)
{
+ }
+
+ void cryptographicallyRandomValues(unsigned char* buffer, size_t length) override
+ {
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+
+ const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) override
+ {
+ static const unsigned char tracingIsDisabled = 0;
+ return &tracingIsDisabled;
}
WebThread* currentThread() override { return &m_mockWebThread; }
@@ -153,14 +163,16 @@
class ScriptRunnerTest : public testing::Test {
public:
- ScriptRunnerTest()
- : m_document(Document::create())
- , m_element(m_document->createElement("foo", ASSERT_NO_EXCEPTION))
- {
- }
-
void SetUp() override
{
+ m_document = Document::create();
+ m_element = m_document->createElement("foo", ASSERT_NO_EXCEPTION);
+
+ m_oldPlatform = Platform::current();
+
+ // Force Platform::initialize to create a new one pointing at MockPlatform.
+ Platform::initialize(&m_platform);
+
// We have to create ScriptRunner after initializing platform, because we need
// Platform::current()->currentThread()->scheduler()->loadingTaskRunner()
// to be initialized before creating ScriptRunner to save it in constructor.
@@ -170,13 +182,15 @@
void TearDown() override
{
m_scriptRunner.release();
+ Platform::initialize(m_oldPlatform);
}
RefPtrWillBePersistent<Document> m_document;
RefPtrWillBePersistent<Element> m_element;
- MockPlatform m_platform;
OwnPtrWillBePersistent<ScriptRunner> m_scriptRunner;
WTF::Vector<int> m_order;
+ MockPlatform m_platform;
+ Platform* m_oldPlatform; // NOT OWNED
};
TEST_F(ScriptRunnerTest, QueueSingleScript_Async)

Powered by Google App Engine
This is Rietveld 408576698