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.
5 #ifndef CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_
6 #define CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_
8 #include "base/compiler_specific.h"
9 #include "base/files/scoped_temp_dir.h"
10 #include "content/test/mock_webclipboard_impl.h"
11 #include "content/test/weburl_loader_mock_factory.h"
12 #include "third_party/WebKit/public/platform/WebUnitTestSupport.h"
13 #include "webkit/child/webkitplatformsupport_child_impl.h"
14 #include "webkit/glue/simple_webmimeregistry_impl.h"
15 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"
18 class WebLayerTreeView
;
23 // An implementation of WebKitPlatformSupport for tests.
24 class TestWebKitPlatformSupport
25 : public WebKit::WebUnitTestSupport
,
26 public webkit_glue::WebKitPlatformSupportChildImpl
{
28 TestWebKitPlatformSupport();
29 virtual ~TestWebKitPlatformSupport();
31 virtual WebKit::WebMimeRegistry
* mimeRegistry();
32 virtual WebKit::WebClipboard
* clipboard();
34 virtual WebKit::WebURLLoader
* createURLLoader();
35 virtual WebKit::WebString
defaultLocale();
37 virtual WebKit::WebString
queryLocalizedString(
38 WebKit::WebLocalizedString::Name name
);
39 virtual WebKit::WebString
queryLocalizedString(
40 WebKit::WebLocalizedString::Name name
,
41 const WebKit::WebString
& value
);
42 virtual WebKit::WebString
queryLocalizedString(
43 WebKit::WebLocalizedString::Name name
,
44 const WebKit::WebString
& value1
,
45 const WebKit::WebString
& value2
);
47 #if defined(OS_WIN) || defined(OS_MACOSX)
48 void SetThemeEngine(WebKit::WebThemeEngine
* engine
);
49 virtual WebKit::WebThemeEngine
* themeEngine();
52 virtual WebKit::WebCompositorSupport
* compositorSupport();
54 WebURLLoaderMockFactory
* url_loader_factory() {
55 return url_loader_factory_
.get();
58 virtual base::string16
GetLocalizedString(int message_id
) OVERRIDE
;
59 virtual base::StringPiece
GetDataResource(
61 ui::ScaleFactor scale_factor
) OVERRIDE
;
62 virtual webkit_glue::ResourceLoaderBridge
* CreateResourceLoader(
63 const webkit_glue::ResourceLoaderBridge::RequestInfo
& request_info
)
65 virtual webkit_glue::WebSocketStreamHandleBridge
* CreateWebSocketStreamBridge(
66 WebKit::WebSocketStreamHandle
* handle
,
67 webkit_glue::WebSocketStreamHandleDelegate
* delegate
) OVERRIDE
;
69 virtual WebKit::WebGestureCurve
* createFlingAnimationCurve(
71 const WebKit::WebFloatPoint
& velocity
,
72 const WebKit::WebSize
& cumulative_scroll
);
74 virtual WebKit::WebUnitTestSupport
* unitTestSupport();
76 // WebUnitTestSupport implementation
77 virtual void registerMockedURL(const WebKit::WebURL
& url
,
78 const WebKit::WebURLResponse
& response
,
79 const WebKit::WebString
& filePath
);
80 virtual void registerMockedErrorURL(const WebKit::WebURL
& url
,
81 const WebKit::WebURLResponse
& response
,
82 const WebKit::WebURLError
& error
);
83 virtual void unregisterMockedURL(const WebKit::WebURL
& url
);
84 virtual void unregisterAllMockedURLs();
85 virtual void serveAsynchronousMockedRequests();
86 virtual WebKit::WebString
webKitRootDir();
87 virtual WebKit::WebLayerTreeView
* createLayerTreeViewForTesting();
88 virtual WebKit::WebLayerTreeView
* createLayerTreeViewForTesting(
90 virtual WebKit::WebData
readFromFile(const WebKit::WebString
& path
);
93 webkit_glue::SimpleWebMimeRegistryImpl mime_registry_
;
94 scoped_ptr
<MockWebClipboardImpl
> mock_clipboard_
;
95 scoped_ptr
<WebURLLoaderMockFactory
> url_loader_factory_
;
96 webkit::WebCompositorSupportImpl compositor_support_
;
98 #if defined(OS_WIN) || defined(OS_MACOSX)
99 WebKit::WebThemeEngine
* active_theme_engine_
;
101 DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport
);
104 } // namespace content
106 #endif // CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_