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

Unified Diff: chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc

Issue 1908633002: Introduce ScopedCommandLine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update CrOS Unit Test 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
Index: chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc b/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
index c1509e45f3af0cad8acc8eecce17b68b12e5e6f3..5a4f7d05b460d96b9fb6a77140f8ce355d0e0ea3 100644
--- a/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
+++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc
@@ -17,6 +17,7 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
+#include "base/test/command_line_test_util.h"
#include "base/test/simple_test_clock.h"
#include "base/test/test_timeouts.h"
#include "base/thread_task_runner_handle.h"
@@ -45,21 +46,19 @@ namespace extensions {
class FullStreamUIPolicyTest : public testing::Test {
public:
FullStreamUIPolicyTest()
- : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
- saved_cmdline_(base::CommandLine::NO_PROGRAM) {
+ : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
#if defined OS_CHROMEOS
test_user_manager_.reset(new chromeos::ScopedTestUserManager());
#endif
- base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
- saved_cmdline_ = *base::CommandLine::ForCurrentProcess();
+ base::CommandLine no_program_command_line(base::CommandLine::NO_PROGRAM);
profile_.reset(new TestingProfile());
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExtensionActivityLogging);
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExtensionActivityLogTesting);
+ base::CommandLine* command_line =
+ scoped_command_line_.GetProcessCommandLine();
+ command_line->AppendSwitch(switches::kEnableExtensionActivityLogging);
+ command_line->AppendSwitch(switches::kEnableExtensionActivityLogTesting);
extension_service_ = static_cast<TestExtensionSystem*>(
ExtensionSystem::Get(profile_.get()))->CreateExtensionService
- (&command_line, base::FilePath(), false);
+ (&no_program_command_line, base::FilePath(), false);
}
~FullStreamUIPolicyTest() override {
@@ -69,8 +68,6 @@ class FullStreamUIPolicyTest : public testing::Test {
base::RunLoop().RunUntilIdle();
profile_.reset(NULL);
base::RunLoop().RunUntilIdle();
- // Restore the original command line and undo the affects of SetUp().
- *base::CommandLine::ForCurrentProcess() = saved_cmdline_;
}
// A wrapper function for CheckReadFilteredData, so that we don't need to
@@ -443,11 +440,7 @@ class FullStreamUIPolicyTest : public testing::Test {
ExtensionService* extension_service_;
std::unique_ptr<TestingProfile> profile_;
content::TestBrowserThreadBundle thread_bundle_;
- // Used to preserve a copy of the original command line.
- // The test framework will do this itself as well. However, by then,
- // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in
- // TearDown().
- base::CommandLine saved_cmdline_;
+ base::test::ScopedCommandLine scoped_command_line_;
#if defined OS_CHROMEOS
chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;

Powered by Google App Engine
This is Rietveld 408576698