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/glue/webfileutilities_impl.h"
16 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"
19 class WebLayerTreeView
;
24 // An implementation of WebKitPlatformSupport for tests.
25 class TestWebKitPlatformSupport
26 : public WebKit::WebUnitTestSupport
,
27 public webkit_glue::WebKitPlatformSupportChildImpl
{
29 TestWebKitPlatformSupport();
30 virtual ~TestWebKitPlatformSupport();
32 virtual WebKit::WebMimeRegistry
* mimeRegistry();
33 virtual WebKit::WebClipboard
* clipboard();
34 virtual WebKit::WebFileUtilities
* fileUtilities();
35 virtual WebKit::WebIDBFactory
* idbFactory();
37 virtual WebKit::WebURLLoader
* createURLLoader();
38 virtual WebKit::WebData
loadResource(const char* name
);
39 virtual WebKit::WebString
queryLocalizedString(
40 WebKit::WebLocalizedString::Name name
);
41 virtual WebKit::WebString
queryLocalizedString(
42 WebKit::WebLocalizedString::Name name
,
43 const WebKit::WebString
& value
);
44 virtual WebKit::WebString
queryLocalizedString(
45 WebKit::WebLocalizedString::Name name
,
46 const WebKit::WebString
& value1
,
47 const WebKit::WebString
& value2
);
48 virtual WebKit::WebString
defaultLocale();
50 #if defined(OS_WIN) || defined(OS_MACOSX)
51 void SetThemeEngine(WebKit::WebThemeEngine
* engine
);
52 virtual WebKit::WebThemeEngine
* themeEngine();
55 virtual WebKit::WebCompositorSupport
* compositorSupport();
57 WebURLLoaderMockFactory
* url_loader_factory() {
58 return url_loader_factory_
.get();
61 const base::FilePath
& file_system_root() const {
62 return file_system_root_
.path();
65 virtual base::string16
GetLocalizedString(int message_id
) OVERRIDE
;
66 virtual base::StringPiece
GetDataResource(
68 ui::ScaleFactor scale_factor
) OVERRIDE
;
69 virtual webkit_glue::ResourceLoaderBridge
* CreateResourceLoader(
70 const webkit_glue::ResourceLoaderBridge::RequestInfo
& request_info
)
72 virtual webkit_glue::WebSocketStreamHandleBridge
* CreateWebSocketStreamBridge(
73 WebKit::WebSocketStreamHandle
* handle
,
74 webkit_glue::WebSocketStreamHandleDelegate
* delegate
) OVERRIDE
;
76 virtual WebKit::WebGestureCurve
* createFlingAnimationCurve(
78 const WebKit::WebFloatPoint
& velocity
,
79 const WebKit::WebSize
& cumulative_scroll
);
81 virtual WebKit::WebUnitTestSupport
* unitTestSupport();
83 // WebUnitTestSupport implementation
84 virtual void registerMockedURL(const WebKit::WebURL
& url
,
85 const WebKit::WebURLResponse
& response
,
86 const WebKit::WebString
& filePath
);
87 virtual void registerMockedErrorURL(const WebKit::WebURL
& url
,
88 const WebKit::WebURLResponse
& response
,
89 const WebKit::WebURLError
& error
);
90 virtual void unregisterMockedURL(const WebKit::WebURL
& url
);
91 virtual void unregisterAllMockedURLs();
92 virtual void serveAsynchronousMockedRequests();
93 virtual WebKit::WebString
webKitRootDir();
94 virtual WebKit::WebLayerTreeView
* createLayerTreeViewForTesting();
95 virtual WebKit::WebLayerTreeView
* createLayerTreeViewForTesting(
97 virtual WebKit::WebData
readFromFile(const WebKit::WebString
& path
);
100 webkit_glue::SimpleWebMimeRegistryImpl mime_registry_
;
101 scoped_ptr
<MockWebClipboardImpl
> mock_clipboard_
;
102 webkit_glue::WebFileUtilitiesImpl file_utilities_
;
103 base::ScopedTempDir file_system_root_
;
104 scoped_ptr
<WebURLLoaderMockFactory
> url_loader_factory_
;
105 webkit::WebCompositorSupportImpl compositor_support_
;
107 #if defined(OS_WIN) || defined(OS_MACOSX)
108 WebKit::WebThemeEngine
* active_theme_engine_
;
110 DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport
);
113 } // namespace content
115 #endif // CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_