Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: base/test/test_suite.cc

Issue 9477001: Allow callers of CommandLine::Init to know whether they were the first caller. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comment clarification. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/test_suite.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « base/test/test_suite.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698