test_webkit_platform_support.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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_webclipboard_impl.h"
15#include "content/test/weburl_loader_mock_factory.h"
16#include "third_party/WebKit/public/platform/WebUnitTestSupport.h"
17
18namespace blink {
19class WebLayerTreeView;
20}
21
22namespace content {
23
24// An implementation of WebKitPlatformSupport for tests.
25class TestWebKitPlatformSupport
26    : public blink::WebUnitTestSupport,
27      public BlinkPlatformImpl {
28 public:
29  TestWebKitPlatformSupport();
30  virtual ~TestWebKitPlatformSupport();
31
32  virtual blink::WebMimeRegistry* mimeRegistry();
33  virtual blink::WebClipboard* clipboard();
34  virtual blink::WebFileUtilities* fileUtilities();
35  virtual blink::WebIDBFactory* idbFactory();
36
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();
50
51#if defined(OS_WIN) || defined(OS_MACOSX)
52  void SetThemeEngine(blink::WebThemeEngine* engine);
53  virtual blink::WebThemeEngine* themeEngine();
54#endif
55
56  virtual blink::WebCompositorSupport* compositorSupport();
57
58  WebURLLoaderMockFactory* url_loader_factory() {
59    return url_loader_factory_.get();
60  }
61
62  const base::FilePath& file_system_root() const {
63    return file_system_root_.path();
64  }
65
66  virtual blink::WebGestureCurve* createFlingAnimationCurve(
67      blink::WebGestureDevice device_source,
68      const blink::WebFloatPoint& velocity,
69      const blink::WebSize& cumulative_scroll) OVERRIDE;
70
71  virtual blink::WebUnitTestSupport* unitTestSupport();
72
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
87 private:
88  SimpleWebMimeRegistryImpl mime_registry_;
89  scoped_ptr<MockWebClipboardImpl> mock_clipboard_;
90  WebFileUtilitiesImpl file_utilities_;
91  base::ScopedTempDir file_system_root_;
92  scoped_ptr<WebURLLoaderMockFactory> url_loader_factory_;
93  WebCompositorSupportImpl compositor_support_;
94
95#if defined(OS_WIN) || defined(OS_MACOSX)
96  blink::WebThemeEngine* active_theme_engine_;
97#endif
98  DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport);
99};
100
101}  // namespace content
102
103#endif  // CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_
104