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 22 matching lines...) Expand all Loading... | |
| 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 "platform/HTTPNames.h" | 41 #include "platform/HTTPNames.h" |
| 42 #include "platform/heap/Heap.h" | 42 #include "platform/heap/Heap.h" |
| 43 #include "platform/network/mime/MockMimeRegistry.h" | |
| 43 #include "platform/scheduler/base/real_time_domain.h" | 44 #include "platform/scheduler/base/real_time_domain.h" |
| 44 #include "platform/scheduler/base/task_queue_manager.h" | 45 #include "platform/scheduler/base/task_queue_manager.h" |
| 45 #include "platform/scheduler/base/test_time_source.h" | 46 #include "platform/scheduler/base/test_time_source.h" |
| 46 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" | 47 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" |
| 47 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" | 48 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
| 49 #include "public/platform/InterfaceProvider.h" | |
| 48 #include "public/platform/WebContentLayer.h" | 50 #include "public/platform/WebContentLayer.h" |
| 49 #include "public/platform/WebExternalTextureLayer.h" | 51 #include "public/platform/WebExternalTextureLayer.h" |
| 50 #include "public/platform/WebImageLayer.h" | 52 #include "public/platform/WebImageLayer.h" |
| 51 #include "public/platform/WebScrollbarLayer.h" | 53 #include "public/platform/WebScrollbarLayer.h" |
| 52 #include "wtf/CryptographicallyRandomNumber.h" | 54 #include "wtf/CryptographicallyRandomNumber.h" |
| 53 #include "wtf/CurrentTime.h" | 55 #include "wtf/CurrentTime.h" |
| 54 #include "wtf/PtrUtil.h" | 56 #include "wtf/PtrUtil.h" |
| 55 #include "wtf/WTF.h" | 57 #include "wtf/WTF.h" |
| 56 #include "wtf/allocator/Partitions.h" | 58 #include "wtf/allocator/Partitions.h" |
| 57 #include <memory> | 59 #include <memory> |
| 58 | 60 |
| 59 namespace blink { | 61 namespace blink { |
| 60 | 62 |
| 63 class TestingPlatformSupport::TestingInterfaceProvider | |
| 64 : public blink::InterfaceProvider { | |
| 65 public: | |
| 66 TestingInterfaceProvider() = default; | |
| 67 virtual ~TestingInterfaceProvider() = default; | |
| 68 | |
| 69 void getInterface(const char* name, | |
| 70 mojo::ScopedMessagePipeHandle handle) override { | |
| 71 if (std::string(name) == mojom::blink::MimeRegistry::Name_) { | |
| 72 m_mockMimeRegistry = wrapUnique(new MockMimeRegistry( | |
| 73 mojo::MakeRequest<mojom::blink::MimeRegistry>(std::move(handle)))); | |
|
Reilly Grant (use Gerrit)
2016/10/28 01:12:41
Instead of saving the MockMimeRegistry here, which
kinuko
2016/10/28 01:18:46
Cool, done.
| |
| 74 return; | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 private: | |
| 79 std::unique_ptr<MockMimeRegistry> m_mockMimeRegistry; | |
| 80 }; | |
| 81 | |
| 61 namespace { | 82 namespace { |
| 62 | 83 |
| 63 double dummyCurrentTime() { | 84 double dummyCurrentTime() { |
| 64 return 0.0; | 85 return 0.0; |
| 65 } | 86 } |
| 66 | 87 |
| 67 class DummyThread final : public blink::WebThread { | 88 class DummyThread final : public blink::WebThread { |
| 68 public: | 89 public: |
| 69 bool isCurrentThread() const override { return true; } | 90 bool isCurrentThread() const override { return true; } |
| 70 blink::WebScheduler* scheduler() const override { return nullptr; } | 91 blink::WebScheduler* scheduler() const override { return nullptr; } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 int thumbThickness, | 129 int thumbThickness, |
| 109 int trackStart, | 130 int trackStart, |
| 110 bool isLeftSideVerticalScrollbar) { | 131 bool isLeftSideVerticalScrollbar) { |
| 111 return nullptr; | 132 return nullptr; |
| 112 } | 133 } |
| 113 | 134 |
| 114 TestingPlatformSupport::TestingPlatformSupport() | 135 TestingPlatformSupport::TestingPlatformSupport() |
| 115 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} | 136 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} |
| 116 | 137 |
| 117 TestingPlatformSupport::TestingPlatformSupport(const Config& config) | 138 TestingPlatformSupport::TestingPlatformSupport(const Config& config) |
| 118 : m_config(config), m_oldPlatform(Platform::current()) { | 139 : m_config(config), |
| 140 m_oldPlatform(Platform::current()), | |
| 141 m_interfaceProvider(wrapUnique(new TestingInterfaceProvider)) { | |
| 119 ASSERT(m_oldPlatform); | 142 ASSERT(m_oldPlatform); |
| 120 Platform::setCurrentPlatformForTesting(this); | 143 Platform::setCurrentPlatformForTesting(this); |
| 121 } | 144 } |
| 122 | 145 |
| 123 TestingPlatformSupport::~TestingPlatformSupport() { | 146 TestingPlatformSupport::~TestingPlatformSupport() { |
| 124 Platform::setCurrentPlatformForTesting(m_oldPlatform); | 147 Platform::setCurrentPlatformForTesting(m_oldPlatform); |
| 125 } | 148 } |
| 126 | 149 |
| 127 WebString TestingPlatformSupport::defaultLocale() { | 150 WebString TestingPlatformSupport::defaultLocale() { |
| 128 return WebString::fromUTF8("en-US"); | 151 return WebString::fromUTF8("en-US"); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 148 } | 171 } |
| 149 | 172 |
| 150 WebFileUtilities* TestingPlatformSupport::fileUtilities() { | 173 WebFileUtilities* TestingPlatformSupport::fileUtilities() { |
| 151 return m_oldPlatform ? m_oldPlatform->fileUtilities() : nullptr; | 174 return m_oldPlatform ? m_oldPlatform->fileUtilities() : nullptr; |
| 152 } | 175 } |
| 153 | 176 |
| 154 WebIDBFactory* TestingPlatformSupport::idbFactory() { | 177 WebIDBFactory* TestingPlatformSupport::idbFactory() { |
| 155 return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr; | 178 return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr; |
| 156 } | 179 } |
| 157 | 180 |
| 158 WebMimeRegistry* TestingPlatformSupport::mimeRegistry() { | |
| 159 return m_oldPlatform ? m_oldPlatform->mimeRegistry() : nullptr; | |
| 160 } | |
| 161 | |
| 162 WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() { | 181 WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() { |
| 163 return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr; | 182 return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr; |
| 164 } | 183 } |
| 165 | 184 |
| 166 WebURLLoader* TestingPlatformSupport::createURLLoader() { | 185 WebURLLoader* TestingPlatformSupport::createURLLoader() { |
| 167 return m_oldPlatform ? m_oldPlatform->createURLLoader() : nullptr; | 186 return m_oldPlatform ? m_oldPlatform->createURLLoader() : nullptr; |
| 168 } | 187 } |
| 169 | 188 |
| 170 WebData TestingPlatformSupport::loadResource(const char* name) { | 189 WebData TestingPlatformSupport::loadResource(const char* name) { |
| 171 return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData(); | 190 return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData(); |
| 172 } | 191 } |
| 173 | 192 |
| 174 WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const { | 193 WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const { |
| 175 return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError(); | 194 return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError(); |
| 176 } | 195 } |
| 177 | 196 |
| 197 InterfaceProvider* TestingPlatformSupport::interfaceProvider() { | |
| 198 return m_interfaceProvider.get(); | |
| 199 } | |
| 200 | |
| 178 // TestingPlatformSupportWithMockScheduler definition: | 201 // TestingPlatformSupportWithMockScheduler definition: |
| 179 | 202 |
| 180 TestingPlatformSupportWithMockScheduler:: | 203 TestingPlatformSupportWithMockScheduler:: |
| 181 TestingPlatformSupportWithMockScheduler() | 204 TestingPlatformSupportWithMockScheduler() |
| 182 : TestingPlatformSupportWithMockScheduler( | 205 : TestingPlatformSupportWithMockScheduler( |
| 183 TestingPlatformSupport::Config()) {} | 206 TestingPlatformSupport::Config()) {} |
| 184 | 207 |
| 185 TestingPlatformSupportWithMockScheduler:: | 208 TestingPlatformSupportWithMockScheduler:: |
| 186 TestingPlatformSupportWithMockScheduler(const Config& config) | 209 TestingPlatformSupportWithMockScheduler(const Config& config) |
| 187 : TestingPlatformSupport(config), | 210 : TestingPlatformSupport(config), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 ProcessHeap::init(); | 336 ProcessHeap::init(); |
| 314 ThreadState::attachMainThread(); | 337 ThreadState::attachMainThread(); |
| 315 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, | 338 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, |
| 316 nullptr); | 339 nullptr); |
| 317 HTTPNames::init(); | 340 HTTPNames::init(); |
| 318 } | 341 } |
| 319 | 342 |
| 320 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} | 343 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} |
| 321 | 344 |
| 322 } // namespace blink | 345 } // namespace blink |
| OLD | NEW |