Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / test / test_webkit_platform_support.h
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.
4
5 #ifndef CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_
6 #define CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_
7
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/renderer/compositor_bindings/web_compositor_support_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"
18
19 namespace base {
20 class StatsTable;
21 }
22
23 namespace blink {
24 class WebLayerTreeView;
25 }
26
27 namespace content {
28
29 // An implementation of WebKitPlatformSupport for tests.
30 class TestWebKitPlatformSupport
31     : public blink::WebUnitTestSupport,
32       public BlinkPlatformImpl {
33  public:
34   TestWebKitPlatformSupport();
35   virtual ~TestWebKitPlatformSupport();
36
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();
42
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();
56
57 #if defined(OS_WIN) || defined(OS_MACOSX)
58   void SetThemeEngine(blink::WebThemeEngine* engine);
59   virtual blink::WebThemeEngine* themeEngine();
60 #endif
61
62   virtual blink::WebCompositorSupport* compositorSupport();
63
64   WebURLLoaderMockFactory* url_loader_factory() {
65     return url_loader_factory_.get();
66   }
67
68   const base::FilePath& file_system_root() const {
69     return file_system_root_.path();
70   }
71
72   virtual blink::WebGestureCurve* createFlingAnimationCurve(
73       blink::WebGestureDevice device_source,
74       const blink::WebFloatPoint& velocity,
75       const blink::WebSize& cumulative_scroll) OVERRIDE;
76
77   virtual blink::WebUnitTestSupport* unitTestSupport();
78
79   // WebUnitTestSupport implementation
80   virtual void registerMockedURL(const blink::WebURL& url,
81                                  const blink::WebURLResponse& response,
82                                  const blink::WebString& filePath);
83   virtual void registerMockedErrorURL(const blink::WebURL& url,
84                                       const blink::WebURLResponse& response,
85                                       const blink::WebURLError& error);
86   virtual void unregisterMockedURL(const blink::WebURL& url);
87   virtual void unregisterAllMockedURLs();
88   virtual void serveAsynchronousMockedRequests();
89   virtual blink::WebString webKitRootDir();
90   virtual blink::WebLayerTreeView* createLayerTreeViewForTesting();
91   virtual blink::WebData readFromFile(const blink::WebString& path);
92
93  private:
94   MockWebBlobRegistryImpl blob_registry_;
95   SimpleWebMimeRegistryImpl mime_registry_;
96   scoped_ptr<MockWebClipboardImpl> mock_clipboard_;
97   WebFileUtilitiesImpl file_utilities_;
98   base::ScopedTempDir file_system_root_;
99   scoped_ptr<WebURLLoaderMockFactory> url_loader_factory_;
100   WebCompositorSupportImpl compositor_support_;
101   scoped_ptr<base::StatsTable> stats_table_;
102
103 #if defined(OS_WIN) || defined(OS_MACOSX)
104   blink::WebThemeEngine* active_theme_engine_;
105 #endif
106   DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport);
107 };
108
109 }  // namespace content
110
111 #endif  // CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_