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

Unified Diff: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp

Issue 2199493002: libFuzzer for blink::MHTMLParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback from esprehn@. Created 4 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
Index: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
diff --git a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
index 528f9e3e4f33eaace6bf030d62239db4ede5bb3d..e9204e8b212c6aa1cb43f556551a398a7cf6d432 100644
--- a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
+++ b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
@@ -30,11 +30,39 @@
#include "platform/testing/TestingPlatformSupport.h"
+#include "base/command_line.h"
+#include "base/memory/discardable_memory_allocator.h"
+#include "base/metrics/statistics_recorder.h"
+#include "base/test/icu_test_util.h"
+#include "base/test/test_discardable_memory_allocator.h"
+#include "cc/blink/web_compositor_support_impl.h"
+#include "platform/EventTracer.h"
+#include "platform/HTTPNames.h"
+#include "platform/heap/Heap.h"
+#include "wtf/CryptographicallyRandomNumber.h"
+#include "wtf/CurrentTime.h"
#include "wtf/PtrUtil.h"
+#include "wtf/WTF.h"
+#include "wtf/allocator/Partitions.h"
#include <memory>
namespace blink {
+namespace {
+
+double dummyCurrentTime()
+{
+ return 0.0;
+}
+
+class DummyThread final : public blink::WebThread {
+public:
+ bool isCurrentThread() const override { return true; }
+ blink::WebScheduler* scheduler() const override { return nullptr; }
+};
+
+} // namespace
+
TestingPlatformSupport::TestingPlatformSupport()
: TestingPlatformSupport(TestingPlatformSupport::Config())
{
@@ -193,4 +221,58 @@ TestingPlatformMockScheduler* TestingPlatformSupportWithMockScheduler::mockWebSc
return m_mockWebThread->mockWebScheduler();
}
+class ScopedUnittestsEnvironmentSetup::DummyPlatform final : public blink::Platform {
+public:
+ DummyPlatform() { }
+
+ blink::WebThread* currentThread() override
+ {
+ static DummyThread dummyThread;
+ return &dummyThread;
+ };
+};
+
+ScopedUnittestsEnvironmentSetup::ScopedUnittestsEnvironmentSetup(int argc, char** argv)
+{
+ base::CommandLine::Init(argc, argv);
+
+ base::test::InitializeICUForTesting();
+
+ m_discardableMemoryAllocator = wrapUnique(new base::TestDiscardableMemoryAllocator);
+ base::DiscardableMemoryAllocator::SetInstance(m_discardableMemoryAllocator.get());
+ base::StatisticsRecorder::Initialize();
+
+ m_platform = wrapUnique(new DummyPlatform);
+ Platform::setCurrentPlatformForTesting(m_platform.get());
+
+ WTF::Partitions::initialize(nullptr);
+ WTF::setTimeFunctionsForTesting(dummyCurrentTime);
+ WTF::initialize(nullptr);
+
+ m_compositorSupport = wrapUnique(new cc_blink::WebCompositorSupportImpl);
+ m_testingPlatformConfig.compositorSupport = m_compositorSupport.get();
+ m_testingPlatformSupport = wrapUnique(new TestingPlatformSupport(m_testingPlatformConfig));
+
+ ProcessHeap::init();
+ ThreadState::attachMainThread();
+ ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr);
+ EventTracer::initialize();
+ HTTPNames::init();
+}
+
+ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup()
+{
+ blink::ThreadState::detachMainThread();
+ blink::ProcessHeap::shutdown();
+
+ // Destroy test platform objects before shutting down WTF layer.
+ m_testingPlatformSupport.reset();
+ m_compositorSupport.reset();
+
+ WTF::shutdown();
+ WTF::Partitions::shutdown();
+
+ // Now - implicitly destroy m_platform and m_discardableMemoryAllocator.
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h ('k') | third_party/WebKit/Source/web/tests/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698