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

Unified Diff: base/test/scoped_command_line.h

Issue 1908633002: Introduce ScopedCommandLine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean Up Other Tests Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_command_line.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_command_line.h
diff --git a/base/test/scoped_command_line.h b/base/test/scoped_command_line.h
new file mode 100644
index 0000000000000000000000000000000000000000..dea0c6ac1e660d1ba2553c8a991433b74eb57a64
--- /dev/null
+++ b/base/test/scoped_command_line.h
@@ -0,0 +1,34 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_TEST_SCOPED_COMMAND_LINE_H_
+#define BASE_TEST_SCOPED_COMMAND_LINE_H_
+
+#include "base/command_line.h"
+
+namespace base {
+namespace test {
+
+// Helper class to restore the original command line at the end of the scope.
+// NOTE: In most unit tests, the command line is automatically restored per
+// test, so this class is not necessary if the command line applies to
+// the entire single test.
+class ScopedCommandLine final {
+ public:
+ ScopedCommandLine();
+ ~ScopedCommandLine();
+
+ // Gets the command line for the current process.
+ // NOTE: Do not name this GetCommandLine as this will conflict with Windows's
+ // GetCommandLine and get renamed to GetCommandLineW.
+ CommandLine* GetProcessCommandLine();
+
+ private:
+ const CommandLine original_command_line_;
+};
+
+} // namespace test
+} // namespace base
+
+#endif // BASE_TEST_SCOPED_COMMAND_LINE_H_
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_command_line.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698