scoped_command_line.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2016 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. #ifndef BASE_TEST_SCOPED_COMMAND_LINE_H_
  5. #define BASE_TEST_SCOPED_COMMAND_LINE_H_
  6. #include "base/command_line.h"
  7. namespace base {
  8. namespace test {
  9. // Helper class to restore the original command line at the end of the scope.
  10. // NOTE: In most unit tests, the command line is automatically restored per
  11. // test, so this class is not necessary if the command line applies to
  12. // the entire single test.
  13. class ScopedCommandLine final {
  14. public:
  15. ScopedCommandLine();
  16. ~ScopedCommandLine();
  17. // Gets the command line for the current process.
  18. // NOTE: Do not name this GetCommandLine as this will conflict with Windows's
  19. // GetCommandLine and get renamed to GetCommandLineW.
  20. CommandLine* GetProcessCommandLine();
  21. private:
  22. const CommandLine original_command_line_;
  23. };
  24. } // namespace test
  25. } // namespace base
  26. #endif // BASE_TEST_SCOPED_COMMAND_LINE_H_