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

Unified Diff: chrome/browser/extensions/activity_log/counting_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/counting_policy_unittest.cc
diff --git a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
index 8b08a4abf519791ef0503dcaef8133ffc4b31d36..b0aa2dee085dd039d470bf3b6311a5a455cae49e 100644
--- a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
+++ b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
@@ -19,6 +19,7 @@
#include "base/strings/string_split.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"
@@ -48,16 +49,14 @@ namespace extensions {
class CountingPolicyTest : public testing::Test {
public:
CountingPolicyTest()
- : 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();
profile_.reset(new TestingProfile());
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExtensionActivityLogging);
+ scoped_command_line_.GetProcessCommandLine()->
+ AppendSwitch(switches::kEnableExtensionActivityLogging);
+ base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
extension_service_ = static_cast<TestExtensionSystem*>(
ExtensionSystem::Get(profile_.get()))->CreateExtensionService
(&command_line, base::FilePath(), false);
@@ -70,8 +69,6 @@ class CountingPolicyTest : 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_;
}
// Wait for the task queue for the specified thread to empty.
@@ -526,11 +523,7 @@ class CountingPolicyTest : 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.
Devlin 2016/04/22 17:22:33 I don't understand this comment (there's no TearDo
robliao 2016/04/22 19:28:30 Looks like CountingPolicyTest never had a TearDown
Devlin 2016/04/22 20:35:21 Personally, I'm in favor of just having the test i
danakj 2016/04/22 20:37:52 Which infrastructure? TestSuite could do it but th
robliao 2016/04/22 20:41:19 The current infrastructure is TestClientInitialize
- // 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