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

Unified Diff: chrome/browser/extensions/activity_log/activity_log_enabled_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/activity_log_enabled_unittest.cc
diff --git a/chrome/browser/extensions/activity_log/activity_log_enabled_unittest.cc b/chrome/browser/extensions/activity_log/activity_log_enabled_unittest.cc
index 7d42b96f6b46737a1efb4d6a3dfcadca004f9d89..0f03756e6ccbde16fa49619f07c8ff82d0753ec3 100644
--- a/chrome/browser/extensions/activity_log/activity_log_enabled_unittest.cc
+++ b/chrome/browser/extensions/activity_log/activity_log_enabled_unittest.cc
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/run_loop.h"
+#include "base/test/command_line_test_util.h"
#include "chrome/browser/extensions/activity_log/activity_log.h"
#include "chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -69,12 +70,13 @@ TEST_F(ActivityLogEnabledTest, CommandLineSwitch) {
std::unique_ptr<TestingProfile> profile2(
static_cast<TestingProfile*>(CreateBrowserContext()));
- base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
- base::CommandLine saved_cmdline_ = *base::CommandLine::ForCurrentProcess();
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ ActivityLog* activity_log1;
+ {
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch(
switches::kEnableExtensionActivityLogging);
- ActivityLog* activity_log1 = ActivityLog::GetInstance(profile1.get());
- *base::CommandLine::ForCurrentProcess() = saved_cmdline_;
+ activity_log1 = ActivityLog::GetInstance(profile1.get());
+ }
ActivityLog* activity_log2 = ActivityLog::GetInstance(profile2.get());
EXPECT_EQ(0,
@@ -229,15 +231,14 @@ TEST_F(ActivityLogEnabledTest, WatchdogSwitch) {
}
TEST_F(ActivityLogEnabledTest, AppAndCommandLine) {
- // Set the command line switch.
- base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
- base::CommandLine saved_cmdline_ = *base::CommandLine::ForCurrentProcess();
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch(
switches::kEnableExtensionActivityLogging);
std::unique_ptr<TestingProfile> profile(
static_cast<TestingProfile*>(CreateBrowserContext()));
// Extension service is destroyed by the profile.
+ base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
ExtensionService* extension_service =
static_cast<TestExtensionSystem*>(
ExtensionSystem::Get(profile.get()))->CreateExtensionService(
@@ -281,9 +282,6 @@ TEST_F(ActivityLogEnabledTest, AppAndCommandLine) {
EXPECT_EQ(0,
profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive));
EXPECT_FALSE(activity_log->IsWatchdogAppActive());
-
- // Cleanup.
- *base::CommandLine::ForCurrentProcess() = saved_cmdline_;
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698