summaryrefslogtreecommitdiffstats
path: root/content/test/test_webkit_platform_support.h
blob: 71b03004246fff6d68cda68555bea362494df9e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_
#define CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_

#include "base/compiler_specific.h"
#include "base/files/scoped_temp_dir.h"
#include "content/test/mock_webclipboard_impl.h"
#include "content/test/weburl_loader_mock_factory.h"
#include "third_party/WebKit/public/platform/WebUnitTestSupport.h"
#include "webkit/child/webkitplatformsupport_child_impl.h"
#include "webkit/glue/simple_webmimeregistry_impl.h"
#include "webkit/glue/webfileutilities_impl.h"
#include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"

namespace blink {
class WebLayerTreeView;
}

namespace content {

// An implementation of WebKitPlatformSupport for tests.
class TestWebKitPlatformSupport
    : public blink::WebUnitTestSupport,
      public webkit_glue::WebKitPlatformSupportChildImpl {
 public:
  TestWebKitPlatformSupport();
  virtual ~TestWebKitPlatformSupport();

  virtual blink::WebMimeRegistry* mimeRegistry();
  virtual blink::WebClipboard* clipboard();
  virtual blink::WebFileUtilities* fileUtilities();
  virtual blink::WebIDBFactory* idbFactory();

  virtual blink::WebURLLoader* createURLLoader();
  virtual blink::WebData loadResource(const char* name);
  virtual blink::WebString queryLocalizedString(
      blink::WebLocalizedString::Name name);
  virtual blink::WebString queryLocalizedString(
      blink::WebLocalizedString::Name name,
      const blink::WebString& value);
  virtual blink::WebString queryLocalizedString(
      blink::WebLocalizedString::Name name,
      const blink::WebString& value1,
      const blink::WebString& value2);
  virtual blink::WebString defaultLocale();

#if defined(OS_WIN) || defined(OS_MACOSX)
  void SetThemeEngine(blink::WebThemeEngine* engine);
  virtual blink::WebThemeEngine* themeEngine();
#endif

  virtual blink::WebCompositorSupport* compositorSupport();

  WebURLLoaderMockFactory* url_loader_factory() {
    return url_loader_factory_.get();
  }

  const base::FilePath& file_system_root() const {
    return file_system_root_.path();
  }

  virtual base::string16 GetLocalizedString(int message_id) OVERRIDE;
  virtual base::StringPiece GetDataResource(
      int resource_id,
      ui::ScaleFactor scale_factor) OVERRIDE;
  virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader(
      const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
     OVERRIDE;
  virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
      blink::WebSocketStreamHandle* handle,
      webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE;

  virtual blink::WebGestureCurve* createFlingAnimationCurve(
      int device_source,
      const blink::WebFloatPoint& velocity,
      const blink::WebSize& cumulative_scroll);

  virtual blink::WebUnitTestSupport* unitTestSupport();

  // WebUnitTestSupport implementation
  virtual void registerMockedURL(const blink::WebURL& url,
                                 const blink::WebURLResponse& response,
                                 const blink::WebString& filePath);
  virtual void registerMockedErrorURL(const blink::WebURL& url,
                                      const blink::WebURLResponse& response,
                                      const blink::WebURLError& error);
  virtual void unregisterMockedURL(const blink::WebURL& url);
  virtual void unregisterAllMockedURLs();
  virtual void serveAsynchronousMockedRequests();
  virtual blink::WebString webKitRootDir();
  virtual blink::WebLayerTreeView* createLayerTreeViewForTesting();
  virtual blink::WebLayerTreeView* createLayerTreeViewForTesting(
      TestViewType type);
  virtual blink::WebData readFromFile(const blink::WebString& path);

 private:
  webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
  scoped_ptr<MockWebClipboardImpl> mock_clipboard_;
  webkit_glue::WebFileUtilitiesImpl file_utilities_;
  base::ScopedTempDir file_system_root_;
  scoped_ptr<WebURLLoaderMockFactory> url_loader_factory_;
  webkit::WebCompositorSupportImpl compositor_support_;

#if defined(OS_WIN) || defined(OS_MACOSX)
  blink::WebThemeEngine* active_theme_engine_;
#endif
  DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport);
};

}  // namespace content

#endif  // CONTENT_TEST_TEST_WEBKIT_PLATFORM_SUPPORT_H_