Home | History | Annotate | Download | only in test
      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
      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).
     12 class 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 for actions that are expected to finish "almost instantly".
     19   static int tiny_timeout_ms() { return tiny_timeout_ms_; }
     20 
     21   // Timeout to wait for something to happen. If you are not sure
     22   // which timeout to use, this is the one you want.
     23   static int action_timeout_ms() { return action_timeout_ms_; }
     24 
     25   // Timeout longer than the above, but still suitable to use
     26   // multiple times in a single test. Use if the timeout above
     27   // is not sufficient.
     28   static int action_max_timeout_ms() { return action_max_timeout_ms_; }
     29 
     30   // 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_; }
     32 
     33   // 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.
     35   // Do not use multiple times in a single test.
     36   static int huge_test_timeout_ms() { return huge_test_timeout_ms_; }
     37 
     38   // Timeout to wait for a process to terminate.
     39   static int wait_for_terminate_timeout_ms() {
     40     return wait_for_terminate_timeout_ms_;
     41   }
     42 
     43   // Timeout to wait for a live operation to complete. Used by tests that access
     44   // external services.
     45   static int live_operation_timeout_ms() {
     46     return live_operation_timeout_ms_;
     47   }
     48 
     49  private:
     50   static bool initialized_;
     51 
     52   static int tiny_timeout_ms_;
     53   static int action_timeout_ms_;
     54   static int action_max_timeout_ms_;
     55   static int large_test_timeout_ms_;
     56   static int huge_test_timeout_ms_;
     57   static int wait_for_terminate_timeout_ms_;
     58   static int live_operation_timeout_ms_;
     59 
     60   DISALLOW_IMPLICIT_CONSTRUCTORS(TestTimeouts);
     61 };
     62 
     63 #endif  // BASE_TEST_TEST_TIMEOUTS_H_
     64