Remove support for specifying version on command line.
[chromium-blink-merge.git] / content / test / webkit_support.cc
blobbb23435350a278aa5bcb8613f729cb195f93e7d9
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
3 // found in the LICENSE file.
5 #include "content/test/webkit_support.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h"
9 #include "content/test/test_webkit_platform_support.h"
10 #include "third_party/WebKit/public/web/WebCache.h"
11 #include "third_party/WebKit/public/web/WebKit.h"
12 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
13 #include "url/url_util.h"
14 #include "webkit/common/user_agent/user_agent.h"
15 #include "webkit/common/user_agent/user_agent_util.h"
17 #if defined(OS_ANDROID)
18 #include "base/android/jni_android.h"
19 #include "net/android/network_library.h"
20 #endif
22 #if defined(OS_MACOSX)
23 #include "base/test/mock_chrome_application_mac.h"
24 #endif
26 namespace content {
28 namespace {
30 class TestEnvironment {
31 public:
32 #if defined(OS_ANDROID)
33 // Android UI message loop goes through Java, so don't use it in tests.
34 typedef base::MessageLoop MessageLoopType;
35 #else
36 typedef base::MessageLoopForUI MessageLoopType;
37 #endif
39 TestEnvironment() {
40 main_message_loop_.reset(new MessageLoopType);
42 // TestWebKitPlatformSupport must be instantiated after MessageLoopType.
43 webkit_platform_support_.reset(new TestWebKitPlatformSupport);
46 TestWebKitPlatformSupport* webkit_platform_support() const {
47 return webkit_platform_support_.get();
50 private:
51 scoped_ptr<MessageLoopType> main_message_loop_;
52 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_;
55 TestEnvironment* test_environment;
57 } // namespace
59 void SetUpTestEnvironmentForUnitTests() {
60 blink::WebRuntimeFeatures::enableStableFeatures(true);
61 blink::WebRuntimeFeatures::enableExperimentalFeatures(true);
62 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true);
64 #if defined(OS_ANDROID)
65 JNIEnv* env = base::android::AttachCurrentThread();
66 net::android::RegisterNetworkLibrary(env);
67 #endif
69 #if defined(OS_MACOSX)
70 mock_cr_app::RegisterMockCrApp();
71 #endif
73 // Explicitly initialize the GURL library before spawning any threads.
74 // Otherwise crash may happend when different threads try to create a GURL
75 // at same time.
76 url_util::Initialize();
77 test_environment = new TestEnvironment;
78 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct(
79 "DumpRenderTree/0.0.0.0"), false);
82 void TearDownTestEnvironment() {
83 // Flush any remaining messages before we kill ourselves.
84 // http://code.google.com/p/chromium/issues/detail?id=9500
85 base::RunLoop().RunUntilIdle();
87 if (RunningOnValgrind())
88 blink::WebCache::clear();
89 delete test_environment;
90 test_environment = NULL;
93 } // namespace content