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

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

Issue 2444873002: Move WebMIMERegistry impl from //content to blink:platform/network/mime (Closed)
Patch Set: test code support Created 4 years, 2 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 0497600ee4c8e2c347f4b2f58c961af59027c670..c25b8a94aff2e8cd263a5e2436fdeadb63c50359 100644
--- a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
+++ b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
@@ -40,11 +40,13 @@
#include "cc/test/ordered_simple_task_runner.h"
#include "platform/HTTPNames.h"
#include "platform/heap/Heap.h"
+#include "platform/network/mime/MockMimeRegistry.h"
#include "platform/scheduler/base/real_time_domain.h"
#include "platform/scheduler/base/task_queue_manager.h"
#include "platform/scheduler/base/test_time_source.h"
#include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h"
#include "platform/scheduler/renderer/renderer_scheduler_impl.h"
+#include "public/platform/InterfaceProvider.h"
#include "public/platform/WebContentLayer.h"
#include "public/platform/WebExternalTextureLayer.h"
#include "public/platform/WebImageLayer.h"
@@ -58,6 +60,28 @@
namespace blink {
+class TestingPlatformSupport::TestingInterfaceProvider
+ : public blink::InterfaceProvider {
+ public:
+ TestingInterfaceProvider() {
+ // Register mock providers for platform tests.
+ m_mockProviders[mojom::blink::MimeRegistry::Name_] =
+ wrapUnique(new MockMimeRegistryProvider);
+ }
+
+ virtual ~TestingInterfaceProvider() = default;
+
+ void getInterface(const char* name,
+ mojo::ScopedMessagePipeHandle request) override {
+ auto it = m_mockProviders.find(std::string(name));
+ if (it != m_mockProviders.end())
+ it->second->getInterface(name, std::move(request));
+ }
+
+ private:
+ std::map<std::string, std::unique_ptr<InterfaceProvider>> m_mockProviders;
+};
+
namespace {
double dummyCurrentTime() {
@@ -115,7 +139,9 @@ TestingPlatformSupport::TestingPlatformSupport()
: TestingPlatformSupport(TestingPlatformSupport::Config()) {}
TestingPlatformSupport::TestingPlatformSupport(const Config& config)
- : m_config(config), m_oldPlatform(Platform::current()) {
+ : m_config(config),
+ m_oldPlatform(Platform::current()),
+ m_interfaceProvider(wrapUnique(new TestingInterfaceProvider)) {
ASSERT(m_oldPlatform);
Platform::setCurrentPlatformForTesting(this);
}
@@ -155,10 +181,6 @@ WebIDBFactory* TestingPlatformSupport::idbFactory() {
return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr;
}
-WebMimeRegistry* TestingPlatformSupport::mimeRegistry() {
- return m_oldPlatform ? m_oldPlatform->mimeRegistry() : nullptr;
-}
-
WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() {
return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr;
}
@@ -175,6 +197,10 @@ WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const {
return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError();
}
+InterfaceProvider* TestingPlatformSupport::interfaceProvider() {
+ return m_interfaceProvider.get();
+}
+
// TestingPlatformSupportWithMockScheduler definition:
TestingPlatformSupportWithMockScheduler::

Powered by Google App Engine
This is Rietveld 408576698