Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 #include "platform/testing/TestingPlatformSupport.h" | 31 #include "platform/testing/TestingPlatformSupport.h" |
| 32 | 32 |
| 33 #include "base/command_line.h" | 33 #include "base/command_line.h" |
| 34 #include "base/memory/discardable_memory_allocator.h" | 34 #include "base/memory/discardable_memory_allocator.h" |
| 35 #include "base/memory/ptr_util.h" | 35 #include "base/memory/ptr_util.h" |
| 36 #include "base/metrics/statistics_recorder.h" | 36 #include "base/metrics/statistics_recorder.h" |
| 37 #include "base/test/icu_test_util.h" | 37 #include "base/test/icu_test_util.h" |
| 38 #include "base/test/test_discardable_memory_allocator.h" | 38 #include "base/test/test_discardable_memory_allocator.h" |
| 39 #include "cc/blink/web_compositor_support_impl.h" | 39 #include "cc/blink/web_compositor_support_impl.h" |
| 40 #include "cc/test/ordered_simple_task_runner.h" | 40 #include "cc/test/ordered_simple_task_runner.h" |
| 41 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 41 #include "platform/HTTPNames.h" | 42 #include "platform/HTTPNames.h" |
| 42 #include "platform/heap/Heap.h" | 43 #include "platform/heap/Heap.h" |
| 44 #include "platform/network/mime/MockMimeRegistry.h" | |
| 43 #include "platform/scheduler/base/real_time_domain.h" | 45 #include "platform/scheduler/base/real_time_domain.h" |
| 44 #include "platform/scheduler/base/task_queue_manager.h" | 46 #include "platform/scheduler/base/task_queue_manager.h" |
| 45 #include "platform/scheduler/base/test_time_source.h" | 47 #include "platform/scheduler/base/test_time_source.h" |
| 46 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" | 48 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" |
| 47 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" | 49 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
| 50 #include "public/platform/InterfaceProvider.h" | |
| 48 #include "public/platform/WebContentLayer.h" | 51 #include "public/platform/WebContentLayer.h" |
| 49 #include "public/platform/WebExternalTextureLayer.h" | 52 #include "public/platform/WebExternalTextureLayer.h" |
| 50 #include "public/platform/WebImageLayer.h" | 53 #include "public/platform/WebImageLayer.h" |
| 51 #include "public/platform/WebScrollbarLayer.h" | 54 #include "public/platform/WebScrollbarLayer.h" |
| 52 #include "wtf/CryptographicallyRandomNumber.h" | 55 #include "wtf/CryptographicallyRandomNumber.h" |
| 53 #include "wtf/CurrentTime.h" | 56 #include "wtf/CurrentTime.h" |
| 54 #include "wtf/PtrUtil.h" | 57 #include "wtf/PtrUtil.h" |
| 55 #include "wtf/WTF.h" | 58 #include "wtf/WTF.h" |
| 56 #include "wtf/allocator/Partitions.h" | 59 #include "wtf/allocator/Partitions.h" |
| 57 #include <memory> | 60 #include <memory> |
| 58 | 61 |
| 59 namespace blink { | 62 namespace blink { |
| 60 | 63 |
| 64 class TestingPlatformSupport::TestingInterfaceProvider | |
| 65 : public blink::InterfaceProvider { | |
| 66 public: | |
| 67 TestingInterfaceProvider() = default; | |
| 68 virtual ~TestingInterfaceProvider() = default; | |
| 69 | |
| 70 void getInterface(const char* name, | |
| 71 mojo::ScopedMessagePipeHandle handle) override { | |
| 72 if (std::string(name) == mojom::blink::MimeRegistry::Name_) { | |
| 73 mojo::MakeStrongBinding( | |
| 74 wrapUnique(new MockMimeRegistry()), | |
| 75 mojo::MakeRequest<mojom::blink::MimeRegistry>(std::move(handle))); | |
| 76 return; | |
| 77 } | |
| 78 } | |
| 79 }; | |
| 80 | |
| 61 namespace { | 81 namespace { |
| 62 | 82 |
| 63 double dummyCurrentTime() { | 83 double dummyCurrentTime() { |
| 64 return 0.0; | 84 return 0.0; |
| 65 } | 85 } |
| 66 | 86 |
| 67 class DummyThread final : public blink::WebThread { | 87 class DummyThread final : public blink::WebThread { |
| 68 public: | 88 public: |
| 69 bool isCurrentThread() const override { return true; } | 89 bool isCurrentThread() const override { return true; } |
| 70 blink::WebScheduler* scheduler() const override { return nullptr; } | 90 blink::WebScheduler* scheduler() const override { return nullptr; } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 int thumbThickness, | 128 int thumbThickness, |
| 109 int trackStart, | 129 int trackStart, |
| 110 bool isLeftSideVerticalScrollbar) { | 130 bool isLeftSideVerticalScrollbar) { |
| 111 return nullptr; | 131 return nullptr; |
| 112 } | 132 } |
| 113 | 133 |
| 114 TestingPlatformSupport::TestingPlatformSupport() | 134 TestingPlatformSupport::TestingPlatformSupport() |
| 115 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} | 135 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} |
| 116 | 136 |
| 117 TestingPlatformSupport::TestingPlatformSupport(const Config& config) | 137 TestingPlatformSupport::TestingPlatformSupport(const Config& config) |
| 118 : m_config(config), m_oldPlatform(Platform::current()) { | 138 : m_config(config), |
| 139 m_oldPlatform(Platform::current()), | |
| 140 m_interfaceProvider(wrapUnique(new TestingInterfaceProvider)) { | |
|
dcheng
2016/10/28 23:50:30
Nit: no wrapUnique needed here
kinuko
2016/11/01 14:02:47
Done.
| |
| 119 ASSERT(m_oldPlatform); | 141 ASSERT(m_oldPlatform); |
| 120 Platform::setCurrentPlatformForTesting(this); | 142 Platform::setCurrentPlatformForTesting(this); |
| 121 } | 143 } |
| 122 | 144 |
| 123 TestingPlatformSupport::~TestingPlatformSupport() { | 145 TestingPlatformSupport::~TestingPlatformSupport() { |
| 124 Platform::setCurrentPlatformForTesting(m_oldPlatform); | 146 Platform::setCurrentPlatformForTesting(m_oldPlatform); |
| 125 } | 147 } |
| 126 | 148 |
| 127 WebString TestingPlatformSupport::defaultLocale() { | 149 WebString TestingPlatformSupport::defaultLocale() { |
| 128 return WebString::fromUTF8("en-US"); | 150 return WebString::fromUTF8("en-US"); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 148 } | 170 } |
| 149 | 171 |
| 150 WebFileUtilities* TestingPlatformSupport::fileUtilities() { | 172 WebFileUtilities* TestingPlatformSupport::fileUtilities() { |
| 151 return m_oldPlatform ? m_oldPlatform->fileUtilities() : nullptr; | 173 return m_oldPlatform ? m_oldPlatform->fileUtilities() : nullptr; |
| 152 } | 174 } |
| 153 | 175 |
| 154 WebIDBFactory* TestingPlatformSupport::idbFactory() { | 176 WebIDBFactory* TestingPlatformSupport::idbFactory() { |
| 155 return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr; | 177 return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr; |
| 156 } | 178 } |
| 157 | 179 |
| 158 WebMimeRegistry* TestingPlatformSupport::mimeRegistry() { | |
| 159 return m_oldPlatform ? m_oldPlatform->mimeRegistry() : nullptr; | |
| 160 } | |
| 161 | |
| 162 WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() { | 180 WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() { |
| 163 return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr; | 181 return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr; |
| 164 } | 182 } |
| 165 | 183 |
| 166 WebURLLoader* TestingPlatformSupport::createURLLoader() { | 184 WebURLLoader* TestingPlatformSupport::createURLLoader() { |
| 167 return m_oldPlatform ? m_oldPlatform->createURLLoader() : nullptr; | 185 return m_oldPlatform ? m_oldPlatform->createURLLoader() : nullptr; |
| 168 } | 186 } |
| 169 | 187 |
| 170 WebData TestingPlatformSupport::loadResource(const char* name) { | 188 WebData TestingPlatformSupport::loadResource(const char* name) { |
| 171 return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData(); | 189 return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData(); |
| 172 } | 190 } |
| 173 | 191 |
| 174 WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const { | 192 WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const { |
| 175 return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError(); | 193 return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError(); |
| 176 } | 194 } |
| 177 | 195 |
| 196 InterfaceProvider* TestingPlatformSupport::interfaceProvider() { | |
| 197 return m_interfaceProvider.get(); | |
| 198 } | |
| 199 | |
| 178 // TestingPlatformSupportWithMockScheduler definition: | 200 // TestingPlatformSupportWithMockScheduler definition: |
| 179 | 201 |
| 180 TestingPlatformSupportWithMockScheduler:: | 202 TestingPlatformSupportWithMockScheduler:: |
| 181 TestingPlatformSupportWithMockScheduler() | 203 TestingPlatformSupportWithMockScheduler() |
| 182 : TestingPlatformSupportWithMockScheduler( | 204 : TestingPlatformSupportWithMockScheduler( |
| 183 TestingPlatformSupport::Config()) {} | 205 TestingPlatformSupport::Config()) {} |
| 184 | 206 |
| 185 TestingPlatformSupportWithMockScheduler:: | 207 TestingPlatformSupportWithMockScheduler:: |
| 186 TestingPlatformSupportWithMockScheduler(const Config& config) | 208 TestingPlatformSupportWithMockScheduler(const Config& config) |
| 187 : TestingPlatformSupport(config), | 209 : TestingPlatformSupport(config), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 ProcessHeap::init(); | 335 ProcessHeap::init(); |
| 314 ThreadState::attachMainThread(); | 336 ThreadState::attachMainThread(); |
| 315 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, | 337 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, |
| 316 nullptr); | 338 nullptr); |
| 317 HTTPNames::init(); | 339 HTTPNames::init(); |
| 318 } | 340 } |
| 319 | 341 |
| 320 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} | 342 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} |
| 321 | 343 |
| 322 } // namespace blink | 344 } // namespace blink |
| OLD | NEW |