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

Side by Side Diff: chrome/test/base/scoped_command_line_override.h

Issue 8561031: Replace ScopedCommandLineOverride with TestSuite listener. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
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 #ifndef CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_ 5 #ifndef CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_
6 #define CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_ 6 #define CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 12
13 // ScopedCommandLineOverride takes the CommandLine for the current 13 // ScopedCommandLineOverride takes the CommandLine for the current
14 // process, saves it, then alters it. When the instance of this class 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 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 16 // intended usage is to test something that requires a flag that's off
17 // by default: 17 // by default:
18 // 18 //
19 // ASSERT_TRUE(!Something::NotFullyBaked()); 19 // ASSERT_TRUE(!Something::NotFullyBaked());
20 // { 20 // {
21 // ScopedCommandLineOverride override(switches:kEnableSomethingHalfBaked); 21 // ScopedCommandLineOverride override(switches:kEnableSomethingHalfBaked);
22 // ASSERT_TRUE(Something::NotFullyBaked()); 22 // ASSERT_TRUE(Something::NotFullyBaked());
23 // } 23 // }
24 class ScopedCommandLineOverride { 24 class ScopedCommandLineOverride {
25 public: 25 public:
26 explicit ScopedCommandLineOverride(const std::string& new_switch); 26 explicit ScopedCommandLineOverride(const std::string& new_switch);
27 explicit ScopedCommandLineOverride(CommandLine& old_command_line);
asargent_no_longer_on_chrome 2011/11/21 17:14:23 nit: const CommandLine&
28
29 // These constructors feel dopey, but they're better than the trouble of
30 // constructing a vector, and va_list won't work with references.
asargent_no_longer_on_chrome 2011/11/21 17:14:23 It might be better to group the 3 constructors tha
31 //
32 // TODO(you): if you're a C wizard, make this prettier.
33 ScopedCommandLineOverride(const std::string& switch1,
34 const std::string& switch2);
35 ScopedCommandLineOverride(const std::string& switch1,
36 const std::string& switch2,
37 const std::string& switch3);
27 virtual ~ScopedCommandLineOverride(); 38 virtual ~ScopedCommandLineOverride();
28 private: 39 private:
29 CommandLine old_command_line_; 40 CommandLine old_command_line_;
30 }; 41 };
31 42
32 #endif // CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_ 43 #endif // CHROME_TEST_BASE_SCOPED_COMMAND_LINE_OVERRIDE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_bookmark_unittest.cc ('k') | chrome/test/base/scoped_command_line_override.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698