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/shell/renderer/test_runner/TestCommon.h" | 5 #include "content/shell/renderer/test_runner/TestCommon.h" |
6 | 6 |
7 using namespace std; | |
8 | |
9 namespace content { | 7 namespace content { |
10 | 8 |
11 namespace { | 9 namespace { |
12 | 10 |
13 const char layoutTestsPattern[] = "/LayoutTests/"; | 11 const char layoutTestsPattern[] = "/LayoutTests/"; |
14 const string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1; | 12 const std::string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern)
- 1; |
15 const char fileUrlPattern[] = "file:/"; | 13 const char fileUrlPattern[] = "file:/"; |
16 const char fileTestPrefix[] = "(file test):"; | 14 const char fileTestPrefix[] = "(file test):"; |
17 const char dataUrlPattern[] = "data:"; | 15 const char dataUrlPattern[] = "data:"; |
18 const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1; | 16 const std::string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1; |
19 | 17 |
20 } // namespace | 18 } // namespace |
21 | 19 |
22 string normalizeLayoutTestURL(const string& url) | 20 std::string normalizeLayoutTestURL(const std::string& url) |
23 { | 21 { |
24 string result = url; | 22 std::string result = url; |
25 size_t pos; | 23 size_t pos; |
26 if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != st
ring::npos)) { | 24 if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != st
d::string::npos)) { |
27 // adjust file URLs to match upstream results. | 25 // adjust file URLs to match upstream results. |
28 result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix); | 26 result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix); |
29 } else if (!url.find(dataUrlPattern)) { | 27 } else if (!url.find(dataUrlPattern)) { |
30 // URL-escape data URLs to match results upstream. | 28 // URL-escape data URLs to match results upstream. |
31 string path = url.substr(dataUrlPatternSize); | 29 std::string path = url.substr(dataUrlPatternSize); |
32 result.replace(dataUrlPatternSize, url.length(), path); | 30 result.replace(dataUrlPatternSize, url.length(), path); |
33 } | 31 } |
34 return result; | 32 return result; |
35 } | 33 } |
36 | 34 |
37 } // namespace content | 35 } // namespace content |
OLD | NEW |