| 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 "content/test/blink_test_environment.h" | 5 #include "content/test/blink_test_environment.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 30 #include "base/test/mock_chrome_application_mac.h" | 30 #include "base/test/mock_chrome_application_mac.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 void EnableBlinkPlatformLogChannels(const std::string& channels) { | |
| 38 if (channels.empty()) | |
| 39 return; | |
| 40 base::StringTokenizer t(channels, ", "); | |
| 41 while (t.GetNext()) | |
| 42 blink::enableLogChannel(t.token().c_str()); | |
| 43 } | |
| 44 | |
| 45 void ParseBlinkCommandLineArgumentsForUnitTests() { | |
| 46 const base::CommandLine& command_line = | |
| 47 *base::CommandLine::ForCurrentProcess(); | |
| 48 EnableBlinkPlatformLogChannels( | |
| 49 command_line.GetSwitchValueASCII(switches::kBlinkPlatformLogChannels)); | |
| 50 } | |
| 51 | |
| 52 class TestEnvironment { | 37 class TestEnvironment { |
| 53 public: | 38 public: |
| 54 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 55 // Android UI message loop goes through Java, so don't use it in tests. | 40 // Android UI message loop goes through Java, so don't use it in tests. |
| 56 typedef base::MessageLoop MessageLoopType; | 41 typedef base::MessageLoop MessageLoopType; |
| 57 #else | 42 #else |
| 58 typedef base::MessageLoopForUI MessageLoopType; | 43 typedef base::MessageLoopForUI MessageLoopType; |
| 59 #endif | 44 #endif |
| 60 | 45 |
| 61 TestEnvironment() { | 46 TestEnvironment() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 81 std::unique_ptr<TestBlinkWebUnitTestSupport> blink_test_support_; | 66 std::unique_ptr<TestBlinkWebUnitTestSupport> blink_test_support_; |
| 82 std::unique_ptr<TestContentClientInitializer> content_initializer_; | 67 std::unique_ptr<TestContentClientInitializer> content_initializer_; |
| 83 base::TestDiscardableMemoryAllocator discardable_memory_allocator_; | 68 base::TestDiscardableMemoryAllocator discardable_memory_allocator_; |
| 84 }; | 69 }; |
| 85 | 70 |
| 86 TestEnvironment* test_environment; | 71 TestEnvironment* test_environment; |
| 87 | 72 |
| 88 } // namespace | 73 } // namespace |
| 89 | 74 |
| 90 void SetUpBlinkTestEnvironment() { | 75 void SetUpBlinkTestEnvironment() { |
| 91 ParseBlinkCommandLineArgumentsForUnitTests(); | |
| 92 | |
| 93 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); | 76 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); |
| 94 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); | 77 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); |
| 95 | 78 |
| 96 #if defined(OS_MACOSX) | 79 #if defined(OS_MACOSX) |
| 97 mock_cr_app::RegisterMockCrApp(); | 80 mock_cr_app::RegisterMockCrApp(); |
| 98 #endif | 81 #endif |
| 99 | 82 |
| 100 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 101 display::win::SetDefaultDeviceScaleFactor(1.0f); | 84 display::win::SetDefaultDeviceScaleFactor(1.0f); |
| 102 #endif | 85 #endif |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 // http://code.google.com/p/chromium/issues/detail?id=9500 | 96 // http://code.google.com/p/chromium/issues/detail?id=9500 |
| 114 base::RunLoop().RunUntilIdle(); | 97 base::RunLoop().RunUntilIdle(); |
| 115 | 98 |
| 116 if (RunningOnValgrind()) | 99 if (RunningOnValgrind()) |
| 117 blink::WebCache::clear(); | 100 blink::WebCache::clear(); |
| 118 delete test_environment; | 101 delete test_environment; |
| 119 test_environment = NULL; | 102 test_environment = NULL; |
| 120 } | 103 } |
| 121 | 104 |
| 122 } // namespace content | 105 } // namespace content |
| OLD | NEW |