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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
// Copyright (c) 2012 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 WEBKIT_SUPPORT_TEST_WEBKIT_PLATFORM_SUPPORT_H_
#define WEBKIT_SUPPORT_TEST_WEBKIT_PLATFORM_SUPPORT_H_
#include "base/compiler_specific.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
#include "webkit/glue/webfileutilities_impl.h"
#include "webkit/glue/webkitplatformsupport_impl.h"
#include "webkit/support/simple_database_system.h"
#include "webkit/support/weburl_loader_mock_factory.h"
#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
#include "webkit/tools/test_shell/simple_appcache_system.h"
#include "webkit/tools/test_shell/simple_file_system.h"
#include "webkit/tools/test_shell/simple_webcookiejar_impl.h"
#include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h"
class TestShellWebBlobRegistryImpl;
namespace WebKit {
class WebAudioDevice;
}
// An implementation of WebKitPlatformSupport for tests.
class TestWebKitPlatformSupport :
public webkit_glue::WebKitPlatformSupportImpl {
public:
explicit TestWebKitPlatformSupport(bool unit_test_mode);
virtual ~TestWebKitPlatformSupport();
virtual WebKit::WebMimeRegistry* mimeRegistry() OVERRIDE;
virtual WebKit::WebClipboard* clipboard() OVERRIDE;
virtual WebKit::WebFileUtilities* fileUtilities() OVERRIDE;
virtual WebKit::WebSandboxSupport* sandboxSupport() OVERRIDE;
virtual WebKit::WebCookieJar* cookieJar() OVERRIDE;
virtual WebKit::WebBlobRegistry* blobRegistry() OVERRIDE;
virtual WebKit::WebFileSystem* fileSystem() OVERRIDE;
virtual bool sandboxEnabled() OVERRIDE;
virtual WebKit::WebKitPlatformSupport::FileHandle databaseOpenFile(
const WebKit::WebString& vfs_file_name, int desired_flags) OVERRIDE;
virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name,
bool sync_dir) OVERRIDE;
virtual long databaseGetFileAttributes(
const WebKit::WebString& vfs_file_name) OVERRIDE;
virtual long long databaseGetFileSize(
const WebKit::WebString& vfs_file_name) OVERRIDE;
virtual long long databaseGetSpaceAvailableForOrigin(
const WebKit::WebString& origin_identifier) OVERRIDE;
virtual unsigned long long visitedLinkHash(const char* canonicalURL,
size_t length) OVERRIDE;
virtual bool isLinkVisited(unsigned long long linkHash) OVERRIDE;
virtual WebKit::WebMessagePortChannel* createMessagePortChannel() OVERRIDE;
virtual void prefetchHostName(const WebKit::WebString&) OVERRIDE;
virtual WebKit::WebURLLoader* createURLLoader() OVERRIDE;
virtual WebKit::WebData loadResource(const char* name) OVERRIDE;
virtual WebKit::WebString queryLocalizedString(
WebKit::WebLocalizedString::Name name) OVERRIDE;
virtual WebKit::WebString queryLocalizedString(
WebKit::WebLocalizedString::Name name,
const WebKit::WebString& value) OVERRIDE;
virtual WebKit::WebString queryLocalizedString(
WebKit::WebLocalizedString::Name name,
const WebKit::WebString& value1,
const WebKit::WebString& value2) OVERRIDE;
virtual WebKit::WebString defaultLocale() OVERRIDE;
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
const WebKit::WebString& path, unsigned quota) OVERRIDE;
virtual void dispatchStorageEvent(const WebKit::WebString& key,
const WebKit::WebString& old_value, const WebKit::WebString& new_value,
const WebKit::WebString& origin, const WebKit::WebURL& url,
bool is_local_storage) OVERRIDE;
virtual WebKit::WebIDBFactory* idbFactory() OVERRIDE;
virtual void createIDBKeysFromSerializedValuesAndKeyPath(
const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
const WebKit::WebString& keyPath,
WebKit::WebVector<WebKit::WebIDBKey>& keys_out) OVERRIDE;
virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue(
const WebKit::WebIDBKey& key,
const WebKit::WebSerializedScriptValue& value,
const WebKit::WebString& keyPath) OVERRIDE;
#if defined(OS_WIN) || defined(OS_MACOSX)
void SetThemeEngine(WebKit::WebThemeEngine* engine);
virtual WebKit::WebThemeEngine *themeEngine() OVERRIDE;
#endif
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes&);
WebURLLoaderMockFactory* url_loader_factory() {
return &url_loader_factory_;
}
const FilePath& file_system_root() const {
return file_system_root_.path();
}
// Mock out the WebAudioDevice since the real one
// talks with the browser process.
virtual double audioHardwareSampleRate() OVERRIDE;
virtual size_t audioHardwareBufferSize() OVERRIDE;
virtual WebKit::WebAudioDevice* createAudioDevice(size_t bufferSize,
unsigned numberOfChannels, double sampleRate,
WebKit::WebAudioDevice::RenderCallback*) OVERRIDE;
virtual void sampleGamepads(WebKit::WebGamepads& data);
void setGamepadData(const WebKit::WebGamepads& data);
virtual string16 GetLocalizedString(int message_id) OVERRIDE;
virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE;
virtual void GetPlugins(bool refresh,
std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE;
virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader(
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
OVERRIDE;
virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE;
private:
TestShellWebMimeRegistryImpl mime_registry_;
MockWebClipboardImpl mock_clipboard_;
webkit_glue::WebFileUtilitiesImpl file_utilities_;
ScopedTempDir appcache_dir_;
SimpleAppCacheSystem appcache_system_;
SimpleDatabaseSystem database_system_;
SimpleWebCookieJarImpl cookie_jar_;
scoped_refptr<TestShellWebBlobRegistryImpl> blob_registry_;
SimpleFileSystem file_system_;
ScopedTempDir file_system_root_;
WebURLLoaderMockFactory url_loader_factory_;
bool unit_test_mode_;
WebKit::WebGamepads gamepad_data_;
#if defined(OS_WIN) || defined(OS_MACOSX)
WebKit::WebThemeEngine* active_theme_engine_;
#endif
DISALLOW_COPY_AND_ASSIGN(TestWebKitPlatformSupport);
};
#endif // WEBKIT_SUPPORT_TEST_WEBKIT_PLATFORM_SUPPORT_H_
|