| 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_suite.h" | 5 #include "base/test/test_suite.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 private: | 64 private: |
| 65 CommandLine old_command_line_; | 65 CommandLine old_command_line_; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); | 67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; | 72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; |
| 73 | 73 |
| 74 TestSuite::TestSuite(int argc, char** argv) { | 74 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { |
| 75 PreInitialize(argc, argv, true); | 75 PreInitialize(argc, argv, true); |
| 76 } | 76 } |
| 77 | 77 |
| 78 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) { | 78 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) |
| 79 : initialized_command_line_(false) { |
| 79 PreInitialize(argc, argv, create_at_exit_manager); | 80 PreInitialize(argc, argv, create_at_exit_manager); |
| 80 } | 81 } |
| 81 | 82 |
| 82 TestSuite::~TestSuite() { | 83 TestSuite::~TestSuite() { |
| 83 CommandLine::Reset(); | 84 if (initialized_command_line_) |
| 85 CommandLine::Reset(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void TestSuite::PreInitialize(int argc, char** argv, | 88 void TestSuite::PreInitialize(int argc, char** argv, |
| 87 bool create_at_exit_manager) { | 89 bool create_at_exit_manager) { |
| 88 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
| 89 testing::GTEST_FLAG(catch_exceptions) = false; | 91 testing::GTEST_FLAG(catch_exceptions) = false; |
| 90 #endif | 92 #endif |
| 91 base::EnableTerminationOnHeapCorruption(); | 93 base::EnableTerminationOnHeapCorruption(); |
| 92 CommandLine::Init(argc, argv); | 94 initialized_command_line_ = CommandLine::Init(argc, argv); |
| 93 testing::InitGoogleTest(&argc, argv); | 95 testing::InitGoogleTest(&argc, argv); |
| 94 #if defined(OS_LINUX) && defined(USE_AURA) | 96 #if defined(OS_LINUX) && defined(USE_AURA) |
| 95 // When calling native char conversion functions (e.g wrctomb) we need to | 97 // When calling native char conversion functions (e.g wrctomb) we need to |
| 96 // have the locale set. In the absence of such a call the "C" locale is the | 98 // have the locale set. In the absence of such a call the "C" locale is the |
| 97 // default. In the gtk code (below) gtk_init() implicitly sets a locale. | 99 // default. In the gtk code (below) gtk_init() implicitly sets a locale. |
| 98 setlocale(LC_ALL, ""); | 100 setlocale(LC_ALL, ""); |
| 99 #elif defined(TOOLKIT_USES_GTK) | 101 #elif defined(TOOLKIT_USES_GTK) |
| 100 gtk_init_check(&argc, &argv); | 102 gtk_init_check(&argc, &argv); |
| 101 #endif // defined(TOOLKIT_USES_GTK) | 103 #endif // defined(TOOLKIT_USES_GTK) |
| 102 if (create_at_exit_manager) | 104 if (create_at_exit_manager) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 #endif | 275 #endif |
| 274 | 276 |
| 275 CatchMaybeTests(); | 277 CatchMaybeTests(); |
| 276 ResetCommandLine(); | 278 ResetCommandLine(); |
| 277 | 279 |
| 278 TestTimeouts::Initialize(); | 280 TestTimeouts::Initialize(); |
| 279 } | 281 } |
| 280 | 282 |
| 281 void TestSuite::Shutdown() { | 283 void TestSuite::Shutdown() { |
| 282 } | 284 } |
| OLD | NEW |