Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: content/shell/renderer/layout_test/blink_test_runner.cc

Issue 2648433008: Use explicit WebString conversions in LayoutTest related files (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shell/renderer/layout_test/blink_test_runner.h" 5 #include "content/shell/renderer/layout_test/blink_test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <clocale> 10 #include <clocale>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 WebString BlinkTestRunner::GetAbsoluteWebStringFromUTF8Path( 327 WebString BlinkTestRunner::GetAbsoluteWebStringFromUTF8Path(
328 const std::string& utf8_path) { 328 const std::string& utf8_path) {
329 base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path); 329 base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path);
330 if (!path.IsAbsolute()) { 330 if (!path.IsAbsolute()) {
331 GURL base_url = 331 GURL base_url =
332 net::FilePathToFileURL(test_config_.current_working_directory.Append( 332 net::FilePathToFileURL(test_config_.current_working_directory.Append(
333 FILE_PATH_LITERAL("foo"))); 333 FILE_PATH_LITERAL("foo")));
334 net::FileURLToFilePath(base_url.Resolve(utf8_path), &path); 334 net::FileURLToFilePath(base_url.Resolve(utf8_path), &path);
335 } 335 }
336 return path.AsUTF16Unsafe(); 336 return blink::FilePathToWebString(path);
337 } 337 }
338 338
339 WebURL BlinkTestRunner::LocalFileToDataURL(const WebURL& file_url) { 339 WebURL BlinkTestRunner::LocalFileToDataURL(const WebURL& file_url) {
340 base::FilePath local_path; 340 base::FilePath local_path;
341 if (!net::FileURLToFilePath(file_url, &local_path)) 341 if (!net::FileURLToFilePath(file_url, &local_path))
342 return WebURL(); 342 return WebURL();
343 343
344 std::string contents; 344 std::string contents;
345 Send(new LayoutTestHostMsg_ReadFileToString( 345 Send(new LayoutTestHostMsg_ReadFileToString(
346 routing_id(), local_path, &contents)); 346 routing_id(), local_path, &contents));
(...skipping 16 matching lines...) Expand all
363 363
364 const char kPrefix[] = "file:///tmp/LayoutTests/"; 364 const char kPrefix[] = "file:///tmp/LayoutTests/";
365 const int kPrefixLen = arraysize(kPrefix) - 1; 365 const int kPrefixLen = arraysize(kPrefix) - 1;
366 366
367 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) 367 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen))
368 return WebURL(GURL(utf8_url)); 368 return WebURL(GURL(utf8_url));
369 369
370 base::FilePath replace_path = 370 base::FilePath replace_path =
371 LayoutTestRenderThreadObserver::GetInstance()->webkit_source_dir() 371 LayoutTestRenderThreadObserver::GetInstance()->webkit_source_dir()
372 .Append(FILE_PATH_LITERAL("LayoutTests/")); 372 .Append(FILE_PATH_LITERAL("LayoutTests/"));
373 #if defined(OS_WIN) 373 std::string utf8_path = replace_path.AsUTF8Unsafe();
374 std::string utf8_path = base::WideToUTF8(replace_path.value());
375 #else
376 std::string utf8_path =
377 base::WideToUTF8(base::SysNativeMBToWide(replace_path.value()));
378 #endif
379 std::string new_url = 374 std::string new_url =
380 std::string("file://") + utf8_path + utf8_url.substr(kPrefixLen); 375 std::string("file://") + utf8_path + utf8_url.substr(kPrefixLen);
381 return WebURL(GURL(new_url)); 376 return WebURL(GURL(new_url));
382 } 377 }
383 378
384 test_runner::TestPreferences* BlinkTestRunner::Preferences() { 379 test_runner::TestPreferences* BlinkTestRunner::Preferences() {
385 return &prefs_; 380 return &prefs_;
386 } 381 }
387 382
388 void BlinkTestRunner::ApplyPreferences() { 383 void BlinkTestRunner::ApplyPreferences() {
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 void BlinkTestRunner::ReportLeakDetectionResult( 1026 void BlinkTestRunner::ReportLeakDetectionResult(
1032 const LeakDetectionResult& report) { 1027 const LeakDetectionResult& report) {
1033 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); 1028 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report));
1034 } 1029 }
1035 1030
1036 void BlinkTestRunner::OnDestruct() { 1031 void BlinkTestRunner::OnDestruct() {
1037 delete this; 1032 delete this;
1038 } 1033 }
1039 1034
1040 } // namespace content 1035 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698