| 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() { |
| 67 // Register mock providers for platform tests. |
| 68 m_mockProviders[mojom::blink::MimeRegistry::Name_] = |
| 69 wrapUnique(new MockMimeRegistryProvider); |
| 70 } |
| 71 |
| 72 virtual ~TestingInterfaceProvider() = default; |
| 73 |
| 74 void getInterface(const char* name, |
| 75 mojo::ScopedMessagePipeHandle request) override { |
| 76 auto it = m_mockProviders.find(std::string(name)); |
| 77 if (it != m_mockProviders.end()) |
| 78 it->second->getInterface(name, std::move(request)); |
| 79 } |
| 80 |
| 81 private: |
| 82 std::map<std::string, std::unique_ptr<InterfaceProvider>> m_mockProviders; |
| 83 }; |
| 84 |
| 61 namespace { | 85 namespace { |
| 62 | 86 |
| 63 double dummyCurrentTime() { | 87 double dummyCurrentTime() { |
| 64 return 0.0; | 88 return 0.0; |
| 65 } | 89 } |
| 66 | 90 |
| 67 class DummyThread final : public blink::WebThread { | 91 class DummyThread final : public blink::WebThread { |
| 68 public: | 92 public: |
| 69 bool isCurrentThread() const override { return true; } | 93 bool isCurrentThread() const override { return true; } |
| 70 blink::WebScheduler* scheduler() const override { return nullptr; } | 94 blink::WebScheduler* scheduler() const override { return nullptr; } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 int thumbThickness, | 132 int thumbThickness, |
| 109 int trackStart, | 133 int trackStart, |
| 110 bool isLeftSideVerticalScrollbar) { | 134 bool isLeftSideVerticalScrollbar) { |
| 111 return nullptr; | 135 return nullptr; |
| 112 } | 136 } |
| 113 | 137 |
| 114 TestingPlatformSupport::TestingPlatformSupport() | 138 TestingPlatformSupport::TestingPlatformSupport() |
| 115 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} | 139 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} |
| 116 | 140 |
| 117 TestingPlatformSupport::TestingPlatformSupport(const Config& config) | 141 TestingPlatformSupport::TestingPlatformSupport(const Config& config) |
| 118 : m_config(config), m_oldPlatform(Platform::current()) { | 142 : m_config(config), |
| 143 m_oldPlatform(Platform::current()), |
| 144 m_interfaceProvider(wrapUnique(new TestingInterfaceProvider)) { |
| 119 ASSERT(m_oldPlatform); | 145 ASSERT(m_oldPlatform); |
| 120 Platform::setCurrentPlatformForTesting(this); | 146 Platform::setCurrentPlatformForTesting(this); |
| 121 } | 147 } |
| 122 | 148 |
| 123 TestingPlatformSupport::~TestingPlatformSupport() { | 149 TestingPlatformSupport::~TestingPlatformSupport() { |
| 124 Platform::setCurrentPlatformForTesting(m_oldPlatform); | 150 Platform::setCurrentPlatformForTesting(m_oldPlatform); |
| 125 } | 151 } |
| 126 | 152 |
| 127 WebString TestingPlatformSupport::defaultLocale() { | 153 WebString TestingPlatformSupport::defaultLocale() { |
| 128 return WebString::fromUTF8("en-US"); | 154 return WebString::fromUTF8("en-US"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 148 } | 174 } |
| 149 | 175 |
| 150 WebFileUtilities* TestingPlatformSupport::fileUtilities() { | 176 WebFileUtilities* TestingPlatformSupport::fileUtilities() { |
| 151 return m_oldPlatform ? m_oldPlatform->fileUtilities() : nullptr; | 177 return m_oldPlatform ? m_oldPlatform->fileUtilities() : nullptr; |
| 152 } | 178 } |
| 153 | 179 |
| 154 WebIDBFactory* TestingPlatformSupport::idbFactory() { | 180 WebIDBFactory* TestingPlatformSupport::idbFactory() { |
| 155 return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr; | 181 return m_oldPlatform ? m_oldPlatform->idbFactory() : nullptr; |
| 156 } | 182 } |
| 157 | 183 |
| 158 WebMimeRegistry* TestingPlatformSupport::mimeRegistry() { | |
| 159 return m_oldPlatform ? m_oldPlatform->mimeRegistry() : nullptr; | |
| 160 } | |
| 161 | |
| 162 WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() { | 184 WebURLLoaderMockFactory* TestingPlatformSupport::getURLLoaderMockFactory() { |
| 163 return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr; | 185 return m_oldPlatform ? m_oldPlatform->getURLLoaderMockFactory() : nullptr; |
| 164 } | 186 } |
| 165 | 187 |
| 166 WebURLLoader* TestingPlatformSupport::createURLLoader() { | 188 WebURLLoader* TestingPlatformSupport::createURLLoader() { |
| 167 return m_oldPlatform ? m_oldPlatform->createURLLoader() : nullptr; | 189 return m_oldPlatform ? m_oldPlatform->createURLLoader() : nullptr; |
| 168 } | 190 } |
| 169 | 191 |
| 170 WebData TestingPlatformSupport::loadResource(const char* name) { | 192 WebData TestingPlatformSupport::loadResource(const char* name) { |
| 171 return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData(); | 193 return m_oldPlatform ? m_oldPlatform->loadResource(name) : WebData(); |
| 172 } | 194 } |
| 173 | 195 |
| 174 WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const { | 196 WebURLError TestingPlatformSupport::cancelledError(const WebURL& url) const { |
| 175 return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError(); | 197 return m_oldPlatform ? m_oldPlatform->cancelledError(url) : WebURLError(); |
| 176 } | 198 } |
| 177 | 199 |
| 200 InterfaceProvider* TestingPlatformSupport::interfaceProvider() { |
| 201 return m_interfaceProvider.get(); |
| 202 } |
| 203 |
| 178 // TestingPlatformSupportWithMockScheduler definition: | 204 // TestingPlatformSupportWithMockScheduler definition: |
| 179 | 205 |
| 180 TestingPlatformSupportWithMockScheduler:: | 206 TestingPlatformSupportWithMockScheduler:: |
| 181 TestingPlatformSupportWithMockScheduler() | 207 TestingPlatformSupportWithMockScheduler() |
| 182 : TestingPlatformSupportWithMockScheduler( | 208 : TestingPlatformSupportWithMockScheduler( |
| 183 TestingPlatformSupport::Config()) {} | 209 TestingPlatformSupport::Config()) {} |
| 184 | 210 |
| 185 TestingPlatformSupportWithMockScheduler:: | 211 TestingPlatformSupportWithMockScheduler:: |
| 186 TestingPlatformSupportWithMockScheduler(const Config& config) | 212 TestingPlatformSupportWithMockScheduler(const Config& config) |
| 187 : TestingPlatformSupport(config), | 213 : TestingPlatformSupport(config), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 ProcessHeap::init(); | 339 ProcessHeap::init(); |
| 314 ThreadState::attachMainThread(); | 340 ThreadState::attachMainThread(); |
| 315 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, | 341 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, |
| 316 nullptr); | 342 nullptr); |
| 317 HTTPNames::init(); | 343 HTTPNames::init(); |
| 318 } | 344 } |
| 319 | 345 |
| 320 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} | 346 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} |
| 321 | 347 |
| 322 } // namespace blink | 348 } // namespace blink |
| OLD | NEW |