OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/environment.h" | 6 #include "base/environment.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/test/test_launcher_utils.h" | 13 #include "chrome/test/test_launcher_utils.h" |
14 #include "ui/gfx/gl/gl_switches.h" | 14 #include "ui/gfx/gl/gl_switches.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // TODO(phajdan.jr): remove this flag and fix its users. | |
19 // We should use base/test/test_timeouts and not custom flags. | |
20 static const char kTestTerminateTimeoutFlag[] = "test-terminate-timeout"; | |
21 | |
22 // A multiplier for slow tests. We generally avoid multiplying | 18 // A multiplier for slow tests. We generally avoid multiplying |
23 // test timeouts by any constants. Here it is used as last resort | 19 // test timeouts by any constants. Here it is used as last resort |
24 // to implement the SLOW_ test prefix. | 20 // to implement the SLOW_ test prefix. |
25 static const int kSlowTestTimeoutMultiplier = 5; | 21 static const int kSlowTestTimeoutMultiplier = 5; |
26 | 22 |
27 } // namespace | 23 } // namespace |
28 | 24 |
29 namespace test_launcher_utils { | 25 namespace test_launcher_utils { |
30 | 26 |
31 void PrepareBrowserCommandLineForTests(CommandLine* command_line) { | 27 void PrepareBrowserCommandLineForTests(CommandLine* command_line) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return false; | 83 return false; |
88 | 84 |
89 command_line->AppendSwitchASCII(switches::kUseGL, implementation_name); | 85 command_line->AppendSwitchASCII(switches::kUseGL, implementation_name); |
90 | 86 |
91 return true; | 87 return true; |
92 } | 88 } |
93 | 89 |
94 int GetTestTerminationTimeout(const std::string& test_name, | 90 int GetTestTerminationTimeout(const std::string& test_name, |
95 int default_timeout_ms) { | 91 int default_timeout_ms) { |
96 int timeout_ms = default_timeout_ms; | 92 int timeout_ms = default_timeout_ms; |
97 if (CommandLine::ForCurrentProcess()->HasSwitch(kTestTerminateTimeoutFlag)) { | |
98 std::string timeout_str = | |
99 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
100 kTestTerminateTimeoutFlag); | |
101 int timeout; | |
102 if (base::StringToInt(timeout_str, &timeout)) { | |
103 timeout_ms = std::max(timeout_ms, timeout); | |
104 } else { | |
105 LOG(ERROR) << "Invalid timeout (" << kTestTerminateTimeoutFlag << "): " | |
106 << timeout_str; | |
107 } | |
108 } | |
109 | 93 |
110 // Make it possible for selected tests to request a longer timeout. | 94 // Make it possible for selected tests to request a longer timeout. |
111 // Generally tests should really avoid doing too much, and splitting | 95 // Generally tests should really avoid doing too much, and splitting |
112 // a test instead of using SLOW prefix is strongly preferred. | 96 // a test instead of using SLOW prefix is strongly preferred. |
113 if (test_name.find("SLOW_") != std::string::npos) | 97 if (test_name.find("SLOW_") != std::string::npos) |
114 timeout_ms *= kSlowTestTimeoutMultiplier; | 98 timeout_ms *= kSlowTestTimeoutMultiplier; |
115 | 99 |
116 return timeout_ms; | 100 return timeout_ms; |
117 } | 101 } |
118 | 102 |
119 } // namespace test_launcher_utils | 103 } // namespace test_launcher_utils |
OLD | NEW |