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_BLINK_WEB_UNIT_TEST_SUPPORT_H_
6 #define CONTENT_TEST_TEST_BLINK_WEB_UNIT_TEST_SUPPORT_H_
8 #include "base/compiler_specific.h"
9 #include "base/files/scoped_temp_dir.h"
10 #include "cc/blink/web_compositor_support_impl.h"
11 #include "content/child/blink_platform_impl.h"
12 #include "content/child/simple_webmimeregistry_impl.h"
13 #include "content/child/webfileutilities_impl.h"
14 #include "content/test/mock_webblob_registry_impl.h"
15 #include "content/test/mock_webclipboard_impl.h"
16 #include "content/test/weburl_loader_mock_factory.h"
17 #include "third_party/WebKit/public/platform/WebUnitTestSupport.h"
24 class WebLayerTreeView
;
29 // An implementation of blink::WebUnitTestSupport and BlinkPlatformImpl for
31 class TestBlinkWebUnitTestSupport
: public blink::WebUnitTestSupport
,
32 public BlinkPlatformImpl
{
34 TestBlinkWebUnitTestSupport();
35 virtual ~TestBlinkWebUnitTestSupport();
37 virtual blink::WebBlobRegistry
* blobRegistry();
38 virtual blink::WebClipboard
* clipboard();
39 virtual blink::WebFileUtilities
* fileUtilities();
40 virtual blink::WebIDBFactory
* idbFactory();
41 virtual blink::WebMimeRegistry
* mimeRegistry();
43 virtual blink::WebURLLoader
* createURLLoader();
44 virtual blink::WebString
userAgent() override
;
45 virtual blink::WebData
loadResource(const char* name
);
46 virtual blink::WebString
queryLocalizedString(
47 blink::WebLocalizedString::Name name
);
48 virtual blink::WebString
queryLocalizedString(
49 blink::WebLocalizedString::Name name
,
50 const blink::WebString
& value
);
51 virtual blink::WebString
queryLocalizedString(
52 blink::WebLocalizedString::Name name
,
53 const blink::WebString
& value1
,
54 const blink::WebString
& value2
);
55 virtual blink::WebString
defaultLocale();
57 #if defined(OS_WIN) || defined(OS_MACOSX)
58 void SetThemeEngine(blink::WebThemeEngine
* engine
);
59 virtual blink::WebThemeEngine
* themeEngine();
62 virtual blink::WebCompositorSupport
* compositorSupport();
64 virtual blink::WebGestureCurve
* createFlingAnimationCurve(
65 blink::WebGestureDevice device_source
,
66 const blink::WebFloatPoint
& velocity
,
67 const blink::WebSize
& cumulative_scroll
) override
;
69 virtual blink::WebUnitTestSupport
* unitTestSupport();
71 // WebUnitTestSupport implementation
72 virtual void registerMockedURL(const blink::WebURL
& url
,
73 const blink::WebURLResponse
& response
,
74 const blink::WebString
& filePath
);
75 virtual void registerMockedErrorURL(const blink::WebURL
& url
,
76 const blink::WebURLResponse
& response
,
77 const blink::WebURLError
& error
);
78 virtual void unregisterMockedURL(const blink::WebURL
& url
);
79 virtual void unregisterAllMockedURLs();
80 virtual void serveAsynchronousMockedRequests();
81 virtual blink::WebString
webKitRootDir();
82 virtual blink::WebLayerTreeView
* createLayerTreeViewForTesting();
83 virtual blink::WebData
readFromFile(const blink::WebString
& path
);
84 virtual bool getBlobItems(const blink::WebString
& uuid
,
85 blink::WebVector
<blink::WebBlobData::Item
*>* items
);
88 MockWebBlobRegistryImpl blob_registry_
;
89 SimpleWebMimeRegistryImpl mime_registry_
;
90 scoped_ptr
<MockWebClipboardImpl
> mock_clipboard_
;
91 WebFileUtilitiesImpl file_utilities_
;
92 base::ScopedTempDir file_system_root_
;
93 scoped_ptr
<WebURLLoaderMockFactory
> url_loader_factory_
;
94 cc_blink::WebCompositorSupportImpl compositor_support_
;
95 scoped_ptr
<base::StatsTable
> stats_table_
;
97 #if defined(OS_WIN) || defined(OS_MACOSX)
98 blink::WebThemeEngine
* active_theme_engine_
;
100 DISALLOW_COPY_AND_ASSIGN(TestBlinkWebUnitTestSupport
);
103 } // namespace content
105 #endif // CONTENT_TEST_TEST_BLINK_WEB_UNIT_TEST_SUPPORT_H_