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

Side by Side Diff: base/test/test_timeouts.h

Issue 7044048: GTTF: Initialize TestTimeouts in out-of-process test runner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 | « base/process_util_unittest.cc ('k') | chrome/test/out_of_proc_test_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_TEST_TEST_TIMEOUTS_H_ 5 #ifndef BASE_TEST_TEST_TIMEOUTS_H_
6 #define BASE_TEST_TEST_TIMEOUTS_H_ 6 #define BASE_TEST_TEST_TIMEOUTS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h"
9 10
10 // Returns common timeouts to use in tests. Makes it possible to adjust 11 // Returns common timeouts to use in tests. Makes it possible to adjust
11 // the timeouts for different environments (like Valgrind). 12 // the timeouts for different environments (like Valgrind).
12 class TestTimeouts { 13 class TestTimeouts {
13 public: 14 public:
14 // Initializes the timeouts. Non thread-safe. Should be called exactly once 15 // Initializes the timeouts. Non thread-safe. Should be called exactly once
15 // by the test suite. 16 // by the test suite.
16 static void Initialize(); 17 static void Initialize();
17 18
18 // Timeout for actions that are expected to finish "almost instantly". 19 // Timeout for actions that are expected to finish "almost instantly".
19 static int tiny_timeout_ms() { return tiny_timeout_ms_; } 20 static int tiny_timeout_ms() {
21 DCHECK(initialized_);
22 return tiny_timeout_ms_;
23 }
20 24
21 // Timeout to wait for something to happen. If you are not sure 25 // Timeout to wait for something to happen. If you are not sure
22 // which timeout to use, this is the one you want. 26 // which timeout to use, this is the one you want.
23 static int action_timeout_ms() { return action_timeout_ms_; } 27 static int action_timeout_ms() {
28 DCHECK(initialized_);
29 return action_timeout_ms_;
30 }
24 31
25 // Timeout longer than the above, but still suitable to use 32 // Timeout longer than the above, but still suitable to use
26 // multiple times in a single test. Use if the timeout above 33 // multiple times in a single test. Use if the timeout above
27 // is not sufficient. 34 // is not sufficient.
28 static int action_max_timeout_ms() { return action_max_timeout_ms_; } 35 static int action_max_timeout_ms() {
36 DCHECK(initialized_);
37 return action_max_timeout_ms_;
38 }
29 39
30 // Timeout for a large test that may take a few minutes to run. 40 // Timeout for a large test that may take a few minutes to run.
31 static int large_test_timeout_ms() { return large_test_timeout_ms_; } 41 static int large_test_timeout_ms() {
42 DCHECK(initialized_);
43 return large_test_timeout_ms_;
44 }
32 45
33 // Timeout for a huge test (like running a layout test inside the browser). 46 // Timeout for a huge test (like running a layout test inside the browser).
34 // Do not use unless absolutely necessary - try to make the test smaller. 47 // Do not use unless absolutely necessary - try to make the test smaller.
35 // Do not use multiple times in a single test. 48 // Do not use multiple times in a single test.
36 static int huge_test_timeout_ms() { return huge_test_timeout_ms_; } 49 static int huge_test_timeout_ms() {
50 DCHECK(initialized_);
51 return huge_test_timeout_ms_;
52 }
37 53
38 // Timeout to wait for a live operation to complete. Used by tests that access 54 // Timeout to wait for a live operation to complete. Used by tests that access
39 // external services. 55 // external services.
40 static int live_operation_timeout_ms() { 56 static int live_operation_timeout_ms() {
57 DCHECK(initialized_);
41 return live_operation_timeout_ms_; 58 return live_operation_timeout_ms_;
42 } 59 }
43 60
44 private: 61 private:
45 static bool initialized_; 62 static bool initialized_;
46 63
47 static int tiny_timeout_ms_; 64 static int tiny_timeout_ms_;
48 static int action_timeout_ms_; 65 static int action_timeout_ms_;
49 static int action_max_timeout_ms_; 66 static int action_max_timeout_ms_;
50 static int large_test_timeout_ms_; 67 static int large_test_timeout_ms_;
51 static int huge_test_timeout_ms_; 68 static int huge_test_timeout_ms_;
52 static int live_operation_timeout_ms_; 69 static int live_operation_timeout_ms_;
53 70
54 DISALLOW_IMPLICIT_CONSTRUCTORS(TestTimeouts); 71 DISALLOW_IMPLICIT_CONSTRUCTORS(TestTimeouts);
55 }; 72 };
56 73
57 #endif // BASE_TEST_TEST_TIMEOUTS_H_ 74 #endif // BASE_TEST_TEST_TIMEOUTS_H_
OLDNEW
« no previous file with comments | « base/process_util_unittest.cc ('k') | chrome/test/out_of_proc_test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698