OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/test_blink_web_unit_test_support.h" | 5 #include "content/test/test_blink_web_unit_test_support.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop/message_loop.h" | |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "components/scheduler/renderer/renderer_scheduler.h" | 13 #include "components/scheduler/renderer/renderer_scheduler.h" |
13 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" | 14 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" |
14 #include "content/test/mock_webclipboard_impl.h" | 15 #include "content/test/mock_webclipboard_impl.h" |
15 #include "content/test/web_gesture_curve_mock.h" | 16 #include "content/test/web_gesture_curve_mock.h" |
16 #include "content/test/web_layer_tree_view_impl_for_testing.h" | 17 #include "content/test/web_layer_tree_view_impl_for_testing.h" |
17 #include "content/test/weburl_loader_mock_factory.h" | 18 #include "content/test/weburl_loader_mock_factory.h" |
18 #include "media/base/media.h" | 19 #include "media/base/media.h" |
19 #include "net/cookies/cookie_monster.h" | 20 #include "net/cookies/cookie_monster.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
37 #include "base/mac/scoped_nsautorelease_pool.h" | 38 #include "base/mac/scoped_nsautorelease_pool.h" |
38 #endif | 39 #endif |
39 | 40 |
40 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 41 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
41 #include "gin/v8_initializer.h" | 42 #include "gin/v8_initializer.h" |
42 #endif | 43 #endif |
43 | 44 |
44 namespace content { | 45 namespace content { |
45 | 46 |
46 TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() { | 47 TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() { |
48 base::MessageLoop message_loop; | |
Primiano Tucci (use gerrit)
2015/04/29 17:45:11
Hmm this will destroy the messageloop after the ct
Sami
2015/04/29 17:48:23
Ah, sorry for not picking up on this. In my head w
| |
47 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
48 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 50 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
49 #endif | 51 #endif |
50 | 52 |
51 url_loader_factory_.reset(new WebURLLoaderMockFactory()); | 53 url_loader_factory_.reset(new WebURLLoaderMockFactory()); |
52 mock_clipboard_.reset(new MockWebClipboardImpl()); | 54 mock_clipboard_.reset(new MockWebClipboardImpl()); |
53 | 55 |
54 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 56 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
55 gin::V8Initializer::LoadV8Snapshot(); | 57 gin::V8Initializer::LoadV8Snapshot(); |
56 #endif | 58 #endif |
57 | 59 |
58 if (base::MessageLoopProxy::current()) { | 60 renderer_scheduler_ = scheduler::RendererScheduler::Create(); |
59 renderer_scheduler_ = scheduler::RendererScheduler::Create(); | 61 web_thread_.reset(new scheduler::WebThreadImplForRendererScheduler( |
60 web_thread_.reset(new scheduler::WebThreadImplForRendererScheduler( | 62 renderer_scheduler_.get())); |
61 renderer_scheduler_.get())); | |
62 } | |
63 | 63 |
64 blink::initialize(this); | 64 blink::initialize(this); |
65 blink::setLayoutTestMode(true); | 65 blink::setLayoutTestMode(true); |
66 blink::WebSecurityPolicy::registerURLSchemeAsLocal( | 66 blink::WebSecurityPolicy::registerURLSchemeAsLocal( |
67 blink::WebString::fromUTF8("test-shell-resource")); | 67 blink::WebString::fromUTF8("test-shell-resource")); |
68 blink::WebSecurityPolicy::registerURLSchemeAsNoAccess( | 68 blink::WebSecurityPolicy::registerURLSchemeAsNoAccess( |
69 blink::WebString::fromUTF8("test-shell-resource")); | 69 blink::WebString::fromUTF8("test-shell-resource")); |
70 blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( | 70 blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( |
71 blink::WebString::fromUTF8("test-shell-resource")); | 71 blink::WebString::fromUTF8("test-shell-resource")); |
72 blink::WebSecurityPolicy::registerURLSchemeAsEmptyDocument( | 72 blink::WebSecurityPolicy::registerURLSchemeAsEmptyDocument( |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 return blob_registry_.GetBlobItems(uuid, items); | 313 return blob_registry_.GetBlobItems(uuid, items); |
314 } | 314 } |
315 | 315 |
316 blink::WebThread* TestBlinkWebUnitTestSupport::currentThread() { | 316 blink::WebThread* TestBlinkWebUnitTestSupport::currentThread() { |
317 if (web_thread_ && web_thread_->isCurrentThread()) | 317 if (web_thread_ && web_thread_->isCurrentThread()) |
318 return web_thread_.get(); | 318 return web_thread_.get(); |
319 return BlinkPlatformImpl::currentThread(); | 319 return BlinkPlatformImpl::currentThread(); |
320 } | 320 } |
321 | 321 |
322 } // namespace content | 322 } // namespace content |
OLD | NEW |