OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_ |
| 6 #define CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/command_line.h" |
| 12 |
| 13 // ScopedCommandLineOverride takes the CommandLine for the current |
| 14 // process, saves it, then alters it. When the instance of this class |
| 15 // goes out of scope, it restores CommandLine to its prior state. The |
| 16 // intended usage is to test something that requires a flag that's off |
| 17 // by default: |
| 18 // |
| 19 // ASSERT_TRUE(!Something::NotFullyBaked()); |
| 20 // { |
| 21 // ScopedCommandLineOverride override(switches:kEnableSomethingHalfBaked); |
| 22 // ASSERT_TRUE(Something::NotFullyBaked()); |
| 23 // } |
| 24 class ScopedCommandLineOverride { |
| 25 public: |
| 26 explicit ScopedCommandLineOverride(const std::string& new_switch); |
| 27 virtual ~ScopedCommandLineOverride(); |
| 28 private: |
| 29 CommandLine old_command_line_; |
| 30 }; |
| 31 |
| 32 #endif // CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_ |
OLD | NEW |