| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "third_party/WebKit/public/platform/Platform.h" | |
| 13 #include "third_party/WebKit/public/web/WebKit.h" | |
| 14 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 12 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 13 #include "url/gurl.h" |
| 15 | 14 |
| 16 namespace test_runner { | 15 namespace test_runner { |
| 17 | 16 |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 const char layout_tests_pattern[] = "/LayoutTests/"; | 19 const char layout_tests_pattern[] = "/LayoutTests/"; |
| 21 const std::string::size_type layout_tests_pattern_size = | 20 const std::string::size_type layout_tests_pattern_size = |
| 22 sizeof(layout_tests_pattern) - 1; | 21 sizeof(layout_tests_pattern) - 1; |
| 23 const char file_url_pattern[] = "file:/"; | 22 const char file_url_pattern[] = "file:/"; |
| 24 const char file_test_prefix[] = "(file test):"; | 23 const char file_test_prefix[] = "(file test):"; |
| 25 const char data_url_pattern[] = "data:"; | 24 const char data_url_pattern[] = "data:"; |
| 26 const std::string::size_type data_url_pattern_size = | 25 const std::string::size_type data_url_pattern_size = |
| 27 sizeof(data_url_pattern) - 1; | 26 sizeof(data_url_pattern) - 1; |
| 28 | |
| 29 // This mock is used to initialize blink. | |
| 30 class MockBlinkPlatform : NON_EXPORTED_BASE(public blink::Platform) { | |
| 31 public: | |
| 32 MockBlinkPlatform() { | |
| 33 blink::Platform::initialize(this); | |
| 34 } | |
| 35 ~MockBlinkPlatform() override {} | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(MockBlinkPlatform); | |
| 39 }; | |
| 40 | |
| 41 base::LazyInstance<MockBlinkPlatform>::Leaky g_mock_blink_platform = | |
| 42 LAZY_INSTANCE_INITIALIZER; | |
| 43 | |
| 44 const char* kIllegalString = "illegal value"; | 27 const char* kIllegalString = "illegal value"; |
| 45 const char* kPolicyIgnore = "Ignore"; | 28 const char* kPolicyIgnore = "Ignore"; |
| 46 const char* kPolicyDownload = "download"; | 29 const char* kPolicyDownload = "download"; |
| 47 const char* kPolicyCurrentTab = "current tab"; | 30 const char* kPolicyCurrentTab = "current tab"; |
| 48 const char* kPolicyNewBackgroundTab = "new background tab"; | 31 const char* kPolicyNewBackgroundTab = "new background tab"; |
| 49 const char* kPolicyNewForegroundTab = "new foreground tab"; | 32 const char* kPolicyNewForegroundTab = "new foreground tab"; |
| 50 const char* kPolicyNewWindow = "new window"; | 33 const char* kPolicyNewWindow = "new window"; |
| 51 const char* kPolicyNewPopup = "new popup"; | 34 const char* kPolicyNewPopup = "new popup"; |
| 52 | 35 |
| 53 } // namespace | 36 } // namespace |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 78 } |
| 96 } | 79 } |
| 97 | 80 |
| 98 blink::WebString V8StringToWebString(v8::Local<v8::String> v8_str) { | 81 blink::WebString V8StringToWebString(v8::Local<v8::String> v8_str) { |
| 99 int length = v8_str->Utf8Length() + 1; | 82 int length = v8_str->Utf8Length() + 1; |
| 100 std::unique_ptr<char[]> chars(new char[length]); | 83 std::unique_ptr<char[]> chars(new char[length]); |
| 101 v8_str->WriteUtf8(chars.get(), length); | 84 v8_str->WriteUtf8(chars.get(), length); |
| 102 return blink::WebString::fromUTF8(chars.get()); | 85 return blink::WebString::fromUTF8(chars.get()); |
| 103 } | 86 } |
| 104 | 87 |
| 105 void EnsureBlinkInitialized() { | |
| 106 g_mock_blink_platform.Get(); | |
| 107 } | |
| 108 | |
| 109 } // namespace test_runner | 88 } // namespace test_runner |
| OLD | NEW |