test_timeouts.h revision 731df977c0511bca2206b5f333555b1205ff1f43
1// Copyright (c) 2010 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. 4 5#ifndef BASE_TEST_TEST_TIMEOUTS_H_ 6#define BASE_TEST_TEST_TIMEOUTS_H_ 7 8#include "base/basictypes.h" 9 10// Returns common timeouts to use in tests. Makes it possible to adjust 11// the timeouts for different environments (like Valgrind). 12class TestTimeouts { 13 public: 14 // Initializes the timeouts. Non thread-safe. Should be called exactly once 15 // by the test suite. 16 static void Initialize(); 17 18 // Timeout to wait for something to happen. If you are not sure 19 // which timeout to use, this is the one you want. 20 static int action_timeout_ms() { return action_timeout_ms_; } 21 22 // Timeout longer than the above, but still suitable to use 23 // multiple times in a single test. Use if the timeout above 24 // is not sufficient. 25 static int action_max_timeout_ms() { return action_max_timeout_ms_; } 26 27 // Timeout for a large test that may take a few minutes to run. 28 static int large_test_timeout_ms() { return large_test_timeout_ms_; } 29 30 // Timeout for a huge test (like running a layout test inside the browser). 31 // Do not use unless absolutely necessary - try to make the test smaller. 32 // Do not use multiple times in a single test. 33 static int huge_test_timeout_ms() { return huge_test_timeout_ms_; } 34 35 // Timeout to use for AutomationProxy. Do not use in other places. 36 // TODO(phajdan.jr): Remove command_execution_timeout_ms. 37 static int command_execution_timeout_ms() { 38 return command_execution_timeout_ms_; 39 } 40 41 // Timeout to wait for a process to terminate. 42 static int wait_for_terminate_timeout_ms() { 43 return wait_for_terminate_timeout_ms_; 44 } 45 46 // Timeout to wait for a live operation to complete. Used by tests that access 47 // external services. 48 static int live_operation_timeout_ms() { 49 return live_operation_timeout_ms_; 50 } 51 52 private: 53 static bool initialized_; 54 55 static int action_timeout_ms_; 56 static int action_max_timeout_ms_; 57 static int large_test_timeout_ms_; 58 static int huge_test_timeout_ms_; 59 static int command_execution_timeout_ms_; 60 static int wait_for_terminate_timeout_ms_; 61 static int live_operation_timeout_ms_; 62 63 DISALLOW_IMPLICIT_CONSTRUCTORS(TestTimeouts); 64}; 65 66#endif // BASE_TEST_TEST_TIMEOUTS_H_ 67