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/child/blink_platform_impl.h"
11 #include "content/child/simple_webmimeregistry_impl.h"
12 #include "content/child/webfileutilities_impl.h"
13 #include "content/test/mock_webclipboard_impl.h"
14 #include "content/test/weburl_loader_mock_factory.h"
15 #include "third_party/WebKit/public/platform/WebUnitTestSupport.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 blink::WebUnitTestSupport
,
27 public BlinkPlatformImpl
{
29 TestWebKitPlatformSupport();
30 virtual ~TestWebKitPlatformSupport();
32 virtual blink::WebMimeRegistry
* mimeRegistry();
33 virtual blink::WebClipboard
* clipboard();
34 virtual blink::WebFileUtilities
* fileUtilities();
35 virtual blink::WebIDBFactory
* idbFactory();
37 virtual blink::WebURLLoader
* createURLLoader();
38 virtual blink::WebString
userAgent() OVERRIDE
;
39 virtual blink::WebData
loadResource(const char* name
);
40 virtual blink::WebString
queryLocalizedString(
41 blink::WebLocalizedString::Name name
);
42 virtual blink::WebString
queryLocalizedString(
43 blink::WebLocalizedString::Name name
,
44 const blink::WebString
& value
);
45 virtual blink::WebString
queryLocalizedString(
46 blink::WebLocalizedString::Name name
,
47 const blink::WebString
& value1
,
48 const blink::WebString
& value2
);
49 virtual blink::WebString
defaultLocale();
51 #if defined(OS_WIN) || defined(OS_MACOSX)
52 void SetThemeEngine(blink::WebThemeEngine
* engine
);
53 virtual blink::WebThemeEngine
* themeEngine();
56 virtual blink::WebCompositorSupport
* compositorSupport();
58 WebURLLoaderMockFactory
* url_loader_factory() {
59 return url_loader_factory_
.get();
62 const base::FilePath
& file_system_root() const {
63 return file_system_root_
.path();
66 virtual blink::WebGestureCurve
* createFlingAnimationCurve(
68 const blink::WebFloatPoint
& velocity
,
69 const blink::WebSize
& cumulative_scroll
);
71 virtual blink::WebUnitTestSupport
* unitTestSupport();
73 // WebUnitTestSupport implementation
74 virtual void registerMockedURL(const blink::WebURL
& url
,
75 const blink::WebURLResponse
& response
,
76 const blink::WebString
& filePath
);
77 virtual void registerMockedErrorURL(const blink::WebURL
& url
,
78 const blink::WebURLResponse
& response
,
79 const blink::WebURLError
& error
);
80 virtual void unregisterMockedURL(const blink::WebURL
& url
);
81 virtual void unregisterAllMockedURLs();
82 virtual void serveAsynchronousMockedRequests();
83 virtual blink::WebString
webKitRootDir();
84 virtual blink::WebLayerTreeView
* createLayerTreeViewForTesting();
85 virtual blink::WebLayerTreeView
* createLayerTreeViewForTesting(
87 virtual blink::WebData
readFromFile(const blink::WebString
& path
);
90 SimpleWebMimeRegistryImpl mime_registry_
;
91 scoped_ptr
<MockWebClipboardImpl
> mock_clipboard_
;
92 WebFileUtilitiesImpl file_utilities_
;
93 base::ScopedTempDir file_system_root_
;
94 scoped_ptr
<WebURLLoaderMockFactory
> url_loader_factory_
;
95 webkit::WebCompositorSupportImpl compositor_support_
;
97 #if defined(OS_WIN) || defined(OS_MACOSX)
98 blink::WebThemeEngine
* active_theme_engine_
;
100 DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport
);
103 } // namespace content
105 #endif // CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_