OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/test_runner/web_test_interfaces.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/memory/ptr_util.h" | |
10 #include "components/test_runner/mock_web_audio_device.h" | |
11 #include "components/test_runner/mock_web_media_stream_center.h" | |
12 #include "components/test_runner/mock_web_midi_accessor.h" | |
13 #include "components/test_runner/mock_webrtc_peer_connection_handler.h" | |
14 #include "components/test_runner/test_interfaces.h" | |
15 #include "components/test_runner/test_runner.h" | |
16 #include "components/test_runner/web_frame_test_client.h" | |
17 #include "components/test_runner/web_view_test_client.h" | |
18 #include "components/test_runner/web_view_test_proxy.h" | |
19 #include "components/test_runner/web_widget_test_client.h" | |
20 #include "components/test_runner/web_widget_test_proxy.h" | |
21 | |
22 using namespace blink; | |
23 | |
24 namespace test_runner { | |
25 | |
26 WebTestInterfaces::WebTestInterfaces() : interfaces_(new TestInterfaces()) { | |
27 } | |
28 | |
29 WebTestInterfaces::~WebTestInterfaces() { | |
30 } | |
31 | |
32 void WebTestInterfaces::SetMainView(WebView* web_view) { | |
33 interfaces_->SetMainView(web_view); | |
34 } | |
35 | |
36 void WebTestInterfaces::SetDelegate(WebTestDelegate* delegate) { | |
37 interfaces_->SetDelegate(delegate); | |
38 } | |
39 | |
40 void WebTestInterfaces::ResetAll() { | |
41 interfaces_->ResetAll(); | |
42 } | |
43 | |
44 void WebTestInterfaces::SetTestIsRunning(bool running) { | |
45 interfaces_->SetTestIsRunning(running); | |
46 } | |
47 | |
48 void WebTestInterfaces::ConfigureForTestWithURL(const WebURL& test_url, | |
49 bool generate_pixels) { | |
50 interfaces_->ConfigureForTestWithURL(test_url, generate_pixels); | |
51 } | |
52 | |
53 WebTestRunner* WebTestInterfaces::TestRunner() { | |
54 return interfaces_->GetTestRunner(); | |
55 } | |
56 | |
57 WebThemeEngine* WebTestInterfaces::ThemeEngine() { | |
58 return interfaces_->GetThemeEngine(); | |
59 } | |
60 | |
61 TestInterfaces* WebTestInterfaces::GetTestInterfaces() { | |
62 return interfaces_.get(); | |
63 } | |
64 | |
65 WebMediaStreamCenter* WebTestInterfaces::CreateMediaStreamCenter( | |
66 WebMediaStreamCenterClient* client) { | |
67 return new MockWebMediaStreamCenter(); | |
68 } | |
69 | |
70 WebRTCPeerConnectionHandler* | |
71 WebTestInterfaces::CreateWebRTCPeerConnectionHandler( | |
72 WebRTCPeerConnectionHandlerClient* client) { | |
73 return new MockWebRTCPeerConnectionHandler(client, interfaces_.get()); | |
74 } | |
75 | |
76 WebMIDIAccessor* WebTestInterfaces::CreateMIDIAccessor( | |
77 WebMIDIAccessorClient* client) { | |
78 return new MockWebMIDIAccessor(client, interfaces_.get()); | |
79 } | |
80 | |
81 WebAudioDevice* WebTestInterfaces::CreateAudioDevice(double sample_rate, | |
82 int frames_per_buffer) { | |
83 return new MockWebAudioDevice(sample_rate, frames_per_buffer); | |
84 } | |
85 | |
86 std::unique_ptr<WebFrameTestClient> WebTestInterfaces::CreateWebFrameTestClient( | |
87 WebViewTestProxyBase* web_view_test_proxy_base, | |
88 WebFrameTestProxyBase* web_frame_test_proxy_base) { | |
89 // TODO(lukasza): Do not pass the WebTestDelegate below - it's lifetime can | |
90 // differ from the lifetime of WebFrameTestClient - https://crbug.com/606594. | |
91 return base::MakeUnique<WebFrameTestClient>(interfaces_->GetDelegate(), | |
92 web_view_test_proxy_base, | |
93 web_frame_test_proxy_base); | |
94 } | |
95 | |
96 std::unique_ptr<WebViewTestClient> WebTestInterfaces::CreateWebViewTestClient( | |
97 WebViewTestProxyBase* web_view_test_proxy_base) { | |
98 return base::MakeUnique<WebViewTestClient>(web_view_test_proxy_base); | |
99 } | |
100 | |
101 std::unique_ptr<WebWidgetTestClient> | |
102 WebTestInterfaces::CreateWebWidgetTestClient( | |
103 WebWidgetTestProxyBase* web_widget_test_proxy_base) { | |
104 return base::MakeUnique<WebWidgetTestClient>(web_widget_test_proxy_base); | |
105 } | |
106 | |
107 std::vector<blink::WebView*> WebTestInterfaces::GetWindowList() { | |
108 std::vector<blink::WebView*> result; | |
109 for (WebViewTestProxyBase* proxy : interfaces_->GetWindowList()) | |
110 result.push_back(proxy->web_view()); | |
111 return result; | |
112 } | |
113 | |
114 } // namespace test_runner | |
OLD | NEW |