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

Side by Side Diff: components/test_runner/test_common.cc

Issue 1419293005: Add assertions that the empty Platform::cryptographicallyRandomValues() overrides are not being use… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to RELEASE_ASSERT and use base::RandBytes() in Chromium. Created 5 years, 1 month 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 | « no previous file | media/blink/run_all_unittests.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/test_runner/test_common.h" 5 #include "components/test_runner/test_common.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/rand_util.h"
9 #include "third_party/WebKit/public/platform/Platform.h" 10 #include "third_party/WebKit/public/platform/Platform.h"
10 #include "third_party/WebKit/public/web/WebKit.h" 11 #include "third_party/WebKit/public/web/WebKit.h"
11 12
12 namespace test_runner { 13 namespace test_runner {
13 14
14 namespace { 15 namespace {
15 16
16 const char layout_tests_pattern[] = "/LayoutTests/"; 17 const char layout_tests_pattern[] = "/LayoutTests/";
17 const std::string::size_type layout_tests_pattern_size = 18 const std::string::size_type layout_tests_pattern_size =
18 sizeof(layout_tests_pattern) - 1; 19 sizeof(layout_tests_pattern) - 1;
19 const char file_url_pattern[] = "file:/"; 20 const char file_url_pattern[] = "file:/";
20 const char file_test_prefix[] = "(file test):"; 21 const char file_test_prefix[] = "(file test):";
21 const char data_url_pattern[] = "data:"; 22 const char data_url_pattern[] = "data:";
22 const std::string::size_type data_url_pattern_size = 23 const std::string::size_type data_url_pattern_size =
23 sizeof(data_url_pattern) - 1; 24 sizeof(data_url_pattern) - 1;
24 25
25 // This mock is used to initialize blink. 26 // This mock is used to initialize blink.
26 class MockBlinkPlatform : NON_EXPORTED_BASE(public blink::Platform) { 27 class MockBlinkPlatform : NON_EXPORTED_BASE(public blink::Platform) {
27 public: 28 public:
28 MockBlinkPlatform() { 29 MockBlinkPlatform() {
29 blink::initializeWithoutV8(this); 30 blink::initializeWithoutV8(this);
30 } 31 }
31 ~MockBlinkPlatform() override {} 32 ~MockBlinkPlatform() override {}
32 void cryptographicallyRandomValues(unsigned char* buffer, 33 void cryptographicallyRandomValues(unsigned char* buffer,
33 size_t length) override {} 34 size_t length) override {
35 base::RandBytes(buffer, length);
36 }
37
34 private: 38 private:
35 DISALLOW_COPY_AND_ASSIGN(MockBlinkPlatform); 39 DISALLOW_COPY_AND_ASSIGN(MockBlinkPlatform);
36 }; 40 };
37 41
38 base::LazyInstance<MockBlinkPlatform>::Leaky g_mock_blink_platform = 42 base::LazyInstance<MockBlinkPlatform>::Leaky g_mock_blink_platform =
39 LAZY_INSTANCE_INITIALIZER; 43 LAZY_INSTANCE_INITIALIZER;
40 44
41 } // namespace 45 } // namespace
42 46
43 std::string NormalizeLayoutTestURL(const std::string& url) { 47 std::string NormalizeLayoutTestURL(const std::string& url) {
44 std::string result = url; 48 std::string result = url;
45 size_t pos; 49 size_t pos;
46 if (!url.find(file_url_pattern) && 50 if (!url.find(file_url_pattern) &&
47 ((pos = url.find(layout_tests_pattern)) != std::string::npos)) { 51 ((pos = url.find(layout_tests_pattern)) != std::string::npos)) {
48 // adjust file URLs to match upstream results. 52 // adjust file URLs to match upstream results.
49 result.replace(0, pos + layout_tests_pattern_size, file_test_prefix); 53 result.replace(0, pos + layout_tests_pattern_size, file_test_prefix);
50 } else if (!url.find(data_url_pattern)) { 54 } else if (!url.find(data_url_pattern)) {
51 // URL-escape data URLs to match results upstream. 55 // URL-escape data URLs to match results upstream.
52 std::string path = url.substr(data_url_pattern_size); 56 std::string path = url.substr(data_url_pattern_size);
53 result.replace(data_url_pattern_size, url.length(), path); 57 result.replace(data_url_pattern_size, url.length(), path);
54 } 58 }
55 return result; 59 return result;
56 } 60 }
57 61
58 void EnsureBlinkInitialized() { 62 void EnsureBlinkInitialized() {
59 g_mock_blink_platform.Get(); 63 g_mock_blink_platform.Get();
60 } 64 }
61 65
62 } // namespace test_runner 66 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | media/blink/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698