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

Side by Side Diff: content/test/webkit_support.cc

Issue 139783014: Parse blink platform log channel command line args in webkit unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/public/common/content_switches.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/webkit_support.h" 5 #include "content/test/webkit_support.h"
6 6
7 #include <string>
8
9 #include "base/command_line.h"
7 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
8 #include "base/path_service.h" 11 #include "base/path_service.h"
9 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string_tokenizer.h"
14 #include "content/public/common/content_switches.h"
10 #include "content/test/test_webkit_platform_support.h" 15 #include "content/test/test_webkit_platform_support.h"
11 #include "third_party/WebKit/public/web/WebCache.h" 16 #include "third_party/WebKit/public/web/WebCache.h"
12 #include "third_party/WebKit/public/web/WebKit.h" 17 #include "third_party/WebKit/public/web/WebKit.h"
13 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 18 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
14 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
15 #include "url/url_util.h" 20 #include "url/url_util.h"
16 #include "webkit/common/user_agent/user_agent.h" 21 #include "webkit/common/user_agent/user_agent.h"
17 #include "webkit/common/user_agent/user_agent_util.h" 22 #include "webkit/common/user_agent/user_agent_util.h"
18 23
19 #if defined(OS_ANDROID) 24 #if defined(OS_ANDROID)
20 #include "base/android/jni_android.h" 25 #include "base/android/jni_android.h"
21 #include "net/android/network_library.h" 26 #include "net/android/network_library.h"
22 #endif 27 #endif
23 28
24 #if defined(OS_MACOSX) 29 #if defined(OS_MACOSX)
25 #include "base/test/mock_chrome_application_mac.h" 30 #include "base/test/mock_chrome_application_mac.h"
26 #endif 31 #endif
27 32
28 namespace content { 33 namespace content {
29 34
30 namespace { 35 namespace {
31 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 CommandLine& command_line = *CommandLine::ForCurrentProcess();
47 EnableBlinkPlatformLogChannels(
48 command_line.GetSwitchValueASCII(switches::kBlinkPlatformLogChannels));
49 }
50
32 class TestEnvironment { 51 class TestEnvironment {
33 public: 52 public:
34 #if defined(OS_ANDROID) 53 #if defined(OS_ANDROID)
35 // Android UI message loop goes through Java, so don't use it in tests. 54 // Android UI message loop goes through Java, so don't use it in tests.
36 typedef base::MessageLoop MessageLoopType; 55 typedef base::MessageLoop MessageLoopType;
37 #else 56 #else
38 typedef base::MessageLoopForUI MessageLoopType; 57 typedef base::MessageLoopForUI MessageLoopType;
39 #endif 58 #endif
40 59
41 TestEnvironment() { 60 TestEnvironment() {
(...skipping 23 matching lines...) Expand all
65 private: 84 private:
66 scoped_ptr<MessageLoopType> main_message_loop_; 85 scoped_ptr<MessageLoopType> main_message_loop_;
67 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; 86 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_;
68 }; 87 };
69 88
70 TestEnvironment* test_environment; 89 TestEnvironment* test_environment;
71 90
72 } // namespace 91 } // namespace
73 92
74 void SetUpTestEnvironmentForUnitTests() { 93 void SetUpTestEnvironmentForUnitTests() {
94 ParseBlinkCommandLineArgumentsForUnitTests();
95
75 blink::WebRuntimeFeatures::enableStableFeatures(true); 96 blink::WebRuntimeFeatures::enableStableFeatures(true);
76 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); 97 blink::WebRuntimeFeatures::enableExperimentalFeatures(true);
77 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); 98 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true);
78 99
79 #if defined(OS_ANDROID) 100 #if defined(OS_ANDROID)
80 JNIEnv* env = base::android::AttachCurrentThread(); 101 JNIEnv* env = base::android::AttachCurrentThread();
81 net::android::RegisterNetworkLibrary(env); 102 net::android::RegisterNetworkLibrary(env);
82 #endif 103 #endif
83 104
84 #if defined(OS_MACOSX) 105 #if defined(OS_MACOSX)
(...skipping 14 matching lines...) Expand all
99 // http://code.google.com/p/chromium/issues/detail?id=9500 120 // http://code.google.com/p/chromium/issues/detail?id=9500
100 base::RunLoop().RunUntilIdle(); 121 base::RunLoop().RunUntilIdle();
101 122
102 if (RunningOnValgrind()) 123 if (RunningOnValgrind())
103 blink::WebCache::clear(); 124 blink::WebCache::clear();
104 delete test_environment; 125 delete test_environment;
105 test_environment = NULL; 126 test_environment = NULL;
106 } 127 }
107 128
108 } // namespace content 129 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698