OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/test_webkit_platform_support.h" | 5 #include "content/test/test_webkit_platform_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 #include "third_party/WebKit/public/platform/win/WebThemeEngine.h" | 41 #include "third_party/WebKit/public/platform/win/WebThemeEngine.h" |
42 #elif defined(OS_MACOSX) | 42 #elif defined(OS_MACOSX) |
43 #include "base/mac/mac_util.h" | 43 #include "base/mac/mac_util.h" |
44 #endif | 44 #endif |
45 | 45 |
46 using WebKit::WebScriptController; | 46 using WebKit::WebScriptController; |
47 using webkit::WebLayerTreeViewImplForTesting; | 47 using webkit::WebLayerTreeViewImplForTesting; |
48 | 48 |
| 49 namespace content { |
| 50 |
49 TestWebKitPlatformSupport::TestWebKitPlatformSupport() { | 51 TestWebKitPlatformSupport::TestWebKitPlatformSupport() { |
50 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); | 52 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); |
51 | 53 |
52 WebKit::initialize(this); | 54 WebKit::initialize(this); |
53 WebKit::setLayoutTestMode(true); | 55 WebKit::setLayoutTestMode(true); |
54 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( | 56 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( |
55 WebKit::WebString::fromUTF8("test-shell-resource")); | 57 WebKit::WebString::fromUTF8("test-shell-resource")); |
56 WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( | 58 WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( |
57 WebKit::WebString::fromUTF8("test-shell-resource")); | 59 WebKit::WebString::fromUTF8("test-shell-resource")); |
58 WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( | 60 WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 case WebKit::WebLocalizedString::ThisWeekButtonLabel: | 173 case WebKit::WebLocalizedString::ThisWeekButtonLabel: |
172 return ASCIIToUTF16("<<ThisWeekLabel>>"); | 174 return ASCIIToUTF16("<<ThisWeekLabel>>"); |
173 case WebKit::WebLocalizedString::WeekFormatTemplate: | 175 case WebKit::WebLocalizedString::WeekFormatTemplate: |
174 return ASCIIToUTF16("Week $2, $1"); | 176 return ASCIIToUTF16("Week $2, $1"); |
175 default: | 177 default: |
176 return WebKitPlatformSupportImpl::queryLocalizedString(name); | 178 return WebKitPlatformSupportImpl::queryLocalizedString(name); |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 WebKit::WebString TestWebKitPlatformSupport::queryLocalizedString( | 182 WebKit::WebString TestWebKitPlatformSupport::queryLocalizedString( |
181 WebKit::WebLocalizedString::Name name, const WebKit::WebString& value) { | 183 WebKit::WebLocalizedString::Name name, |
| 184 const WebKit::WebString& value) { |
182 if (name == WebKit::WebLocalizedString::ValidationRangeUnderflow) | 185 if (name == WebKit::WebLocalizedString::ValidationRangeUnderflow) |
183 return ASCIIToUTF16("range underflow"); | 186 return ASCIIToUTF16("range underflow"); |
184 if (name == WebKit::WebLocalizedString::ValidationRangeOverflow) | 187 if (name == WebKit::WebLocalizedString::ValidationRangeOverflow) |
185 return ASCIIToUTF16("range overflow"); | 188 return ASCIIToUTF16("range overflow"); |
186 return WebKitPlatformSupportImpl::queryLocalizedString(name, value); | 189 return WebKitPlatformSupportImpl::queryLocalizedString(name, value); |
187 } | 190 } |
188 | 191 |
189 WebKit::WebString TestWebKitPlatformSupport::queryLocalizedString( | 192 WebKit::WebString TestWebKitPlatformSupport::queryLocalizedString( |
190 WebKit::WebLocalizedString::Name name, | 193 WebKit::WebLocalizedString::Name name, |
191 const WebKit::WebString& value1, | 194 const WebKit::WebString& value1, |
(...skipping 13 matching lines...) Expand all Loading... |
205 void TestWebKitPlatformSupport::SetThemeEngine(WebKit::WebThemeEngine* engine) { | 208 void TestWebKitPlatformSupport::SetThemeEngine(WebKit::WebThemeEngine* engine) { |
206 active_theme_engine_ = engine ? | 209 active_theme_engine_ = engine ? |
207 engine : WebKitPlatformSupportChildImpl::themeEngine(); | 210 engine : WebKitPlatformSupportChildImpl::themeEngine(); |
208 } | 211 } |
209 | 212 |
210 WebKit::WebThemeEngine* TestWebKitPlatformSupport::themeEngine() { | 213 WebKit::WebThemeEngine* TestWebKitPlatformSupport::themeEngine() { |
211 return active_theme_engine_; | 214 return active_theme_engine_; |
212 } | 215 } |
213 #endif | 216 #endif |
214 | 217 |
215 WebKit::WebCompositorSupport* | 218 WebKit::WebCompositorSupport* TestWebKitPlatformSupport::compositorSupport() { |
216 TestWebKitPlatformSupport::compositorSupport() { | |
217 return &compositor_support_; | 219 return &compositor_support_; |
218 } | 220 } |
219 | 221 |
220 base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | 222 base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
221 return base::string16(); | 223 return base::string16(); |
222 } | 224 } |
223 | 225 |
224 base::StringPiece TestWebKitPlatformSupport::GetDataResource( | 226 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
225 int resource_id, | 227 int resource_id, |
226 ui::ScaleFactor scale_factor) { | 228 ui::ScaleFactor scale_factor) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 base::FilePath path; | 286 base::FilePath path; |
285 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 287 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
286 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); | 288 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); |
287 path = base::MakeAbsoluteFilePath(path); | 289 path = base::MakeAbsoluteFilePath(path); |
288 CHECK(!path.empty()); | 290 CHECK(!path.empty()); |
289 std::string path_ascii = path.MaybeAsASCII(); | 291 std::string path_ascii = path.MaybeAsASCII(); |
290 CHECK(!path_ascii.empty()); | 292 CHECK(!path_ascii.empty()); |
291 return WebKit::WebString::fromUTF8(path_ascii.c_str()); | 293 return WebKit::WebString::fromUTF8(path_ascii.c_str()); |
292 } | 294 } |
293 | 295 |
294 | |
295 WebKit::WebLayerTreeView* | 296 WebKit::WebLayerTreeView* |
296 TestWebKitPlatformSupport::createLayerTreeViewForTesting() { | 297 TestWebKitPlatformSupport::createLayerTreeViewForTesting() { |
297 scoped_ptr<WebLayerTreeViewImplForTesting> view( | 298 scoped_ptr<WebLayerTreeViewImplForTesting> view( |
298 new WebLayerTreeViewImplForTesting()); | 299 new WebLayerTreeViewImplForTesting()); |
299 | 300 |
300 if (!view->Initialize()) | 301 if (!view->Initialize()) |
301 return NULL; | 302 return NULL; |
302 return view.release(); | 303 return view.release(); |
303 } | 304 } |
304 | 305 |
305 WebKit::WebLayerTreeView* | 306 WebKit::WebLayerTreeView* |
306 TestWebKitPlatformSupport::createLayerTreeViewForTesting( | 307 TestWebKitPlatformSupport::createLayerTreeViewForTesting(TestViewType type) { |
307 TestViewType type) { | |
308 DCHECK_EQ(TestViewTypeUnitTest, type); | 308 DCHECK_EQ(TestViewTypeUnitTest, type); |
309 return createLayerTreeViewForTesting(); | 309 return createLayerTreeViewForTesting(); |
310 } | 310 } |
311 | 311 |
312 WebKit::WebData TestWebKitPlatformSupport::readFromFile( | 312 WebKit::WebData TestWebKitPlatformSupport::readFromFile( |
313 const WebKit::WebString& path) { | 313 const WebKit::WebString& path) { |
314 base::FilePath file_path = base::FilePath::FromUTF16Unsafe(path); | 314 base::FilePath file_path = base::FilePath::FromUTF16Unsafe(path); |
315 | 315 |
316 std::string buffer; | 316 std::string buffer; |
317 base::ReadFileToString(file_path, &buffer); | 317 base::ReadFileToString(file_path, &buffer); |
318 | 318 |
319 return WebKit::WebData(buffer.data(), buffer.size()); | 319 return WebKit::WebData(buffer.data(), buffer.size()); |
320 } | 320 } |
| 321 |
| 322 } // namespace content |
OLD | NEW |