OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Run all of our test shell tests. This is just an entry point | 5 // TODO(jam): remove this target when all the bots are updated. |
6 // to kick off gTest's RUN_ALL_TESTS(). | |
7 | |
8 #include "base/basictypes.h" | |
9 | |
10 #if defined(OS_WIN) | |
11 #include <windows.h> | |
12 #include <commctrl.h> | |
13 #endif | |
14 | |
15 #include "base/command_line.h" | |
16 #include "base/message_loop.h" | |
17 #include "base/process_util.h" | |
18 #include "base/test/test_suite.h" | |
19 #include "webkit/glue/webkit_glue.h" | |
20 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | |
21 #include "webkit/tools/test_shell/test_shell.h" | |
22 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" | |
23 #include "webkit/tools/test_shell/test_shell_switches.h" | |
24 #include "webkit/tools/test_shell/test_shell_test.h" | |
25 #include "webkit/tools/test_shell/test_shell_webkit_init.h" | |
26 #include "testing/gtest/include/gtest/gtest.h" | |
27 | |
28 #if defined(OS_MACOSX) | |
29 #include "base/mac/bundle_locations.h" | |
30 #include "base/mac/mac_util.h" | |
31 #include "base/mac/scoped_nsautorelease_pool.h" | |
32 #include "base/path_service.h" | |
33 #endif | |
34 | |
35 class TestShellTestSuite : public base::TestSuite { | |
36 public: | |
37 TestShellTestSuite(int argc, char** argv) | |
38 : base::TestSuite(argc, argv), | |
39 platform_delegate_(*CommandLine::ForCurrentProcess()), | |
40 test_shell_webkit_init_(true) { | |
41 } | |
42 | |
43 virtual void Initialize() OVERRIDE { | |
44 // Override DIR_EXE early in case anything in base::TestSuite uses it. | |
45 #if defined(OS_MACOSX) | |
46 base::FilePath path; | |
47 PathService::Get(base::DIR_EXE, &path); | |
48 path = path.AppendASCII("TestShell.app"); | |
49 base::mac::SetOverrideFrameworkBundlePath(path); | |
50 #endif | |
51 | |
52 base::TestSuite::Initialize(); | |
53 | |
54 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | |
55 | |
56 // Allow tests to analyze GC information from V8 log, and expose GC | |
57 // triggering function. | |
58 std::string js_flags = | |
59 parsed_command_line.GetSwitchValueASCII(test_shell::kJavaScriptFlags); | |
60 js_flags += " --expose_gc"; | |
61 webkit_glue::SetJavaScriptFlags(js_flags); | |
62 | |
63 // Suppress error dialogs and do not show GP fault error box on Windows. | |
64 TestShell::InitLogging(true, false, false); | |
65 | |
66 // Some of the individual tests wind up calling TestShell::WaitTestFinished | |
67 // which has a timeout in it. For these tests, we don't care about | |
68 // a timeout so just set it to be really large. This is necessary because | |
69 // we hit those timeouts under Valgrind. | |
70 TestShell::SetFileTestTimeout(10 * 60 * 60 * 1000); // Ten hours. | |
71 | |
72 // Initialize test shell in layout test mode, which will let us load one | |
73 // request than automatically quit. | |
74 TestShell::InitializeTestShell(true, false); | |
75 | |
76 platform_delegate_.InitializeGUI(); | |
77 platform_delegate_.SelectUnifiedTheme(); | |
78 } | |
79 | |
80 virtual void Shutdown() OVERRIDE { | |
81 TestShell::ShutdownTestShell(); | |
82 TestShell::CleanupLogging(); | |
83 | |
84 base::TestSuite::Shutdown(); | |
85 } | |
86 | |
87 private: | |
88 TestShellPlatformDelegate platform_delegate_; | |
89 | |
90 // Allocate a message loop for this thread. Although it is not used | |
91 // directly, its constructor sets up some necessary state. | |
92 MessageLoopForUI main_message_loop_; | |
93 | |
94 // Initialize WebKit for this scope. | |
95 TestShellWebKitInit test_shell_webkit_init_; | |
96 | |
97 DISALLOW_COPY_AND_ASSIGN(TestShellTestSuite); | |
98 }; | |
99 | 6 |
100 int main(int argc, char** argv) { | 7 int main(int argc, char** argv) { |
101 #if defined(OS_MACOSX) | 8 return 0; |
102 base::mac::ScopedNSAutoreleasePool scoped_pool; | |
103 #endif | |
104 | |
105 TestShellPlatformDelegate::PreflightArgs(&argc, &argv); | |
106 return TestShellTestSuite(argc, argv).Run(); | |
107 } | 9 } |
OLD | NEW |