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
;
28 class RendererScheduler
;
29 class WebSchedulerImpl
;
31 // An implementation of blink::WebUnitTestSupport and BlinkPlatformImpl for
33 class TestBlinkWebUnitTestSupport
: public blink::WebUnitTestSupport
,
34 public BlinkPlatformImpl
{
36 TestBlinkWebUnitTestSupport();
37 virtual ~TestBlinkWebUnitTestSupport();
39 virtual blink::WebBlobRegistry
* blobRegistry();
40 virtual blink::WebClipboard
* clipboard();
41 virtual blink::WebFileUtilities
* fileUtilities();
42 virtual blink::WebIDBFactory
* idbFactory();
43 virtual blink::WebMimeRegistry
* mimeRegistry();
45 virtual blink::WebURLLoader
* createURLLoader();
46 virtual blink::WebString
userAgent() override
;
47 virtual blink::WebData
loadResource(const char* name
);
48 virtual blink::WebString
queryLocalizedString(
49 blink::WebLocalizedString::Name name
);
50 virtual blink::WebString
queryLocalizedString(
51 blink::WebLocalizedString::Name name
,
52 const blink::WebString
& value
);
53 virtual blink::WebString
queryLocalizedString(
54 blink::WebLocalizedString::Name name
,
55 const blink::WebString
& value1
,
56 const blink::WebString
& value2
);
57 virtual blink::WebString
defaultLocale();
59 #if defined(OS_WIN) || defined(OS_MACOSX)
60 void SetThemeEngine(blink::WebThemeEngine
* engine
);
61 virtual blink::WebThemeEngine
* themeEngine();
64 virtual blink::WebCompositorSupport
* compositorSupport();
66 virtual blink::WebGestureCurve
* createFlingAnimationCurve(
67 blink::WebGestureDevice device_source
,
68 const blink::WebFloatPoint
& velocity
,
69 const blink::WebSize
& cumulative_scroll
) override
;
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::WebData
readFromFile(const blink::WebString
& path
);
86 virtual bool getBlobItems(const blink::WebString
& uuid
,
87 blink::WebVector
<blink::WebBlobData::Item
*>* items
);
88 virtual blink::WebScheduler
* scheduler();
89 virtual blink::WebThread
* currentThread();
92 MockWebBlobRegistryImpl blob_registry_
;
93 SimpleWebMimeRegistryImpl mime_registry_
;
94 scoped_ptr
<MockWebClipboardImpl
> mock_clipboard_
;
95 WebFileUtilitiesImpl file_utilities_
;
96 base::ScopedTempDir file_system_root_
;
97 scoped_ptr
<WebURLLoaderMockFactory
> url_loader_factory_
;
98 cc_blink::WebCompositorSupportImpl compositor_support_
;
99 scoped_ptr
<RendererScheduler
> renderer_scheduler_
;
100 scoped_ptr
<WebSchedulerImpl
> web_scheduler_
;
101 scoped_ptr
<blink::WebThread
> web_thread_
;
103 #if defined(OS_WIN) || defined(OS_MACOSX)
104 blink::WebThemeEngine
* active_theme_engine_
;
106 DISALLOW_COPY_AND_ASSIGN(TestBlinkWebUnitTestSupport
);
109 } // namespace content
111 #endif // CONTENT_TEST_TEST_BLINK_WEB_UNIT_TEST_SUPPORT_H_