summaryrefslogtreecommitdiffstats
path: root/base/test_suite.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/test_suite.h')
-rw-r--r--base/test_suite.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/base/test_suite.h b/base/test_suite.h
index 8a163ec..ae5faf1 100644
--- a/base/test_suite.h
+++ b/base/test_suite.h
@@ -9,13 +9,11 @@
// instantiate this class in your main function and call its Run method to run
// any gtest based tests that are linked into your executable.
-#include "build/build_config.h"
-
+#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/debug_on_start.h"
#include "base/icu_util.h"
#include "base/logging.h"
-#include "base/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
@@ -26,23 +24,18 @@
class TestSuite {
public:
TestSuite(int argc, char** argv) {
+ CommandLine::SetArgcArgv(argc, argv);
testing::InitGoogleTest(&argc, argv);
}
- virtual ~TestSuite() {
- // Flush any remaining messages. This ensures that any accumulated Task
- // objects get destroyed before we exit, which avoids noise in purify
- // leak-test results.
- message_loop_.RunAllPending();
- }
+ virtual ~TestSuite() {}
int Run() {
Initialize();
#if defined(OS_WIN)
// Check to see if we are being run as a client process.
- std::wstring client_func =
- parsed_command_line_.GetSwitchValue(kRunClientProcess);
+ std::wstring client_func = CommandLine().GetSwitchValue(kRunClientProcess);
if (!client_func.empty()) {
// Convert our function name to a usable string for GetProcAddress.
std::string func_name(client_func.begin(), client_func.end());
@@ -57,7 +50,11 @@ class TestSuite {
return -1;
}
#endif
- return RUN_ALL_TESTS();
+
+ int result = RUN_ALL_TESTS();
+
+ Shutdown();
+ return result;
}
protected:
@@ -80,11 +77,14 @@ class TestSuite {
}
#endif
+ // Override these for custom initialization and shutdown handling. Use these
+ // instead of putting complex code in your constructor/destructor.
+
virtual void Initialize() {
#if defined(OS_WIN)
// In some cases, we do not want to see standard error dialogs.
if (!IsDebuggerPresent() &&
- !parsed_command_line_.HasSwitch(L"show-error-dialogs")) {
+ !CommandLine().HasSwitch(L"show-error-dialogs")) {
SuppressErrorDialogs();
logging::SetLogAssertHandler(UnitTestAssertHandler);
}
@@ -93,8 +93,12 @@ class TestSuite {
icu_util::Initialize();
}
- CommandLine parsed_command_line_;
- MessageLoop message_loop_;
+ virtual void Shutdown() {
+ }
+
+ // Make sure that we setup an AtExitManager so Singleton objects will be
+ // destroyed.
+ base::AtExitManager at_exit_manager_;
};
#endif // BASE_TEST_SUITE_H_