| 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/test/test_timeouts.h" | 5 #include "base/test/test_timeouts.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // The timeout values should increase in the order they appear in this block. | 65 // The timeout values should increase in the order they appear in this block. |
| 66 // static | 66 // static |
| 67 int TestTimeouts::tiny_timeout_ms_ = 100; | 67 int TestTimeouts::tiny_timeout_ms_ = 100; |
| 68 int TestTimeouts::action_timeout_ms_ = 10000; | 68 int TestTimeouts::action_timeout_ms_ = 10000; |
| 69 #ifndef NDEBUG | 69 #ifndef NDEBUG |
| 70 int TestTimeouts::action_max_timeout_ms_ = 45000; | 70 int TestTimeouts::action_max_timeout_ms_ = 45000; |
| 71 #else | 71 #else |
| 72 int TestTimeouts::action_max_timeout_ms_ = 30000; | 72 int TestTimeouts::action_max_timeout_ms_ = 30000; |
| 73 #endif // NDEBUG | 73 #endif // NDEBUG |
| 74 | 74 |
| 75 int TestTimeouts::test_launcher_unit_timeout_ms_ = 5000; | |
| 76 int TestTimeouts::test_launcher_timeout_ms_ = 45000; | 75 int TestTimeouts::test_launcher_timeout_ms_ = 45000; |
| 77 | 76 |
| 78 // static | 77 // static |
| 79 void TestTimeouts::Initialize() { | 78 void TestTimeouts::Initialize() { |
| 80 if (initialized_) { | 79 if (initialized_) { |
| 81 NOTREACHED(); | 80 NOTREACHED(); |
| 82 return; | 81 return; |
| 83 } | 82 } |
| 84 initialized_ = true; | 83 initialized_ = true; |
| 85 | 84 |
| 86 if (base::debug::BeingDebugged()) { | 85 if (base::debug::BeingDebugged()) { |
| 87 fprintf(stdout, | 86 fprintf(stdout, |
| 88 "Detected presence of a debugger, running without test timeouts.\n"); | 87 "Detected presence of a debugger, running without test timeouts.\n"); |
| 89 } | 88 } |
| 90 | 89 |
| 91 // Note that these timeouts MUST be initialized in the correct order as | 90 // Note that these timeouts MUST be initialized in the correct order as |
| 92 // per the CHECKS below. | 91 // per the CHECKS below. |
| 93 InitializeTimeout(switches::kTestTinyTimeout, &tiny_timeout_ms_); | 92 InitializeTimeout(switches::kTestTinyTimeout, &tiny_timeout_ms_); |
| 94 InitializeTimeout(switches::kUiTestActionTimeout, | 93 InitializeTimeout(switches::kUiTestActionTimeout, |
| 95 base::debug::BeingDebugged() ? kAlmostInfiniteTimeoutMs | 94 base::debug::BeingDebugged() ? kAlmostInfiniteTimeoutMs |
| 96 : tiny_timeout_ms_, | 95 : tiny_timeout_ms_, |
| 97 &action_timeout_ms_); | 96 &action_timeout_ms_); |
| 98 InitializeTimeout(switches::kUiTestActionMaxTimeout, action_timeout_ms_, | 97 InitializeTimeout(switches::kUiTestActionMaxTimeout, action_timeout_ms_, |
| 99 &action_max_timeout_ms_); | 98 &action_max_timeout_ms_); |
| 100 | 99 |
| 101 // Test launcher timeout is independent from anything above action timeout. | 100 // Test launcher timeout is independent from anything above action timeout. |
| 102 InitializeTimeout(switches::kTestLauncherUnitTimeout, action_timeout_ms_, | 101 InitializeTimeout(switches::kTestLauncherTimeout, action_timeout_ms_, |
| 103 &test_launcher_unit_timeout_ms_); | |
| 104 InitializeTimeout(switches::kTestLauncherTimeout, | |
| 105 test_launcher_unit_timeout_ms_, | |
| 106 &test_launcher_timeout_ms_); | 102 &test_launcher_timeout_ms_); |
| 107 | 103 |
| 108 // The timeout values should be increasing in the right order. | 104 // The timeout values should be increasing in the right order. |
| 109 CHECK(tiny_timeout_ms_ <= action_timeout_ms_); | 105 CHECK(tiny_timeout_ms_ <= action_timeout_ms_); |
| 110 CHECK(action_timeout_ms_ <= action_max_timeout_ms_); | 106 CHECK(action_timeout_ms_ <= action_max_timeout_ms_); |
| 111 | 107 |
| 112 CHECK(action_timeout_ms_ <= test_launcher_unit_timeout_ms_); | 108 CHECK(action_timeout_ms_ <= test_launcher_timeout_ms_); |
| 113 CHECK(test_launcher_unit_timeout_ms_ <= test_launcher_timeout_ms_); | |
| 114 } | 109 } |
| OLD | NEW |