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

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

Issue 2013203003: content_shell: Update absolute path rewriting logic again. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 Send(new LayoutTestHostMsg_ReadFileToString( 344 Send(new LayoutTestHostMsg_ReadFileToString(
345 routing_id(), local_path, &contents)); 345 routing_id(), local_path, &contents));
346 346
347 std::string contents_base64; 347 std::string contents_base64;
348 base::Base64Encode(contents, &contents_base64); 348 base::Base64Encode(contents, &contents_base64);
349 349
350 const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,"; 350 const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,";
351 return WebURL(GURL(data_url_prefix + contents_base64)); 351 return WebURL(GURL(data_url_prefix + contents_base64));
352 } 352 }
353 353
354 WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url) { 354 WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url,
355 WebURL rewritten_url = RewriteAbsolutePathInWPT(utf8_url); 355 bool is_wpt_mode) {
356 if (!rewritten_url.isEmpty()) 356 if (is_wpt_mode) {
357 return rewritten_url; 357 WebURL rewritten_url = RewriteAbsolutePathInWPT(utf8_url);
358 if (!rewritten_url.isEmpty())
359 return rewritten_url;
360 return WebURL(GURL(utf8_url));
361 }
358 362
359 const char kPrefix[] = "file:///tmp/LayoutTests/"; 363 const char kPrefix[] = "file:///tmp/LayoutTests/";
360 const int kPrefixLen = arraysize(kPrefix) - 1; 364 const int kPrefixLen = arraysize(kPrefix) - 1;
361 365
362 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) 366 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen))
363 return WebURL(GURL(utf8_url)); 367 return WebURL(GURL(utf8_url));
364 368
365 base::FilePath replace_path = 369 base::FilePath replace_path =
366 LayoutTestRenderThreadObserver::GetInstance()->webkit_source_dir() 370 LayoutTestRenderThreadObserver::GetInstance()->webkit_source_dir()
367 .Append(FILE_PATH_LITERAL("LayoutTests/")); 371 .Append(FILE_PATH_LITERAL("LayoutTests/"));
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 546 }
543 #endif 547 #endif
544 548
545 // Some layout tests use file://// which we resolve as a UNC path. Normalize 549 // Some layout tests use file://// which we resolve as a UNC path. Normalize
546 // them to just file:///. 550 // them to just file:///.
547 std::string result = resource; 551 std::string result = resource;
548 while (base::ToLowerASCII(result).find("file:////") == 0) { 552 while (base::ToLowerASCII(result).find("file:////") == 0) {
549 result = result.substr(0, strlen("file:///")) + 553 result = result.substr(0, strlen("file:///")) +
550 result.substr(strlen("file:////")); 554 result.substr(strlen("file:////"));
551 } 555 }
552 return RewriteLayoutTestsURL(result).string().utf8(); 556 return RewriteLayoutTestsURL(result, false).string().utf8();
kinuko 2016/05/27 03:35:57 nit: can we add a comment like /* is_wpt_mode */ a
tkent 2016/05/27 03:43:03 Done.
553 } 557 }
554 558
555 void BlinkTestRunner::SetLocale(const std::string& locale) { 559 void BlinkTestRunner::SetLocale(const std::string& locale) {
556 setlocale(LC_ALL, locale.c_str()); 560 setlocale(LC_ALL, locale.c_str());
557 } 561 }
558 562
559 void BlinkTestRunner::OnLayoutTestRuntimeFlagsChanged( 563 void BlinkTestRunner::OnLayoutTestRuntimeFlagsChanged(
560 const base::DictionaryValue& changed_values) { 564 const base::DictionaryValue& changed_values) {
561 // Ignore changes that happen before we got the initial, accumulated 565 // Ignore changes that happen before we got the initial, accumulated
562 // layout flag changes in ShellViewMsg_ReplicateTestConfiguration. 566 // layout flag changes in ShellViewMsg_ReplicateTestConfiguration.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 get_bluetooth_events_callbacks_.pop_front(); 1005 get_bluetooth_events_callbacks_.pop_front();
1002 callback.Run(events); 1006 callback.Run(events);
1003 } 1007 }
1004 1008
1005 void BlinkTestRunner::ReportLeakDetectionResult( 1009 void BlinkTestRunner::ReportLeakDetectionResult(
1006 const LeakDetectionResult& report) { 1010 const LeakDetectionResult& report) {
1007 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); 1011 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report));
1008 } 1012 }
1009 1013
1010 } // namespace content 1014 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698