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

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log_enabled_unittest.cc

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/extensions/activity_log/activity_log.h" 8 #include "chrome/browser/extensions/activity_log/activity_log.h"
9 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h" 9 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 EXPECT_FALSE(activity_log->IsDatabaseEnabled()); 62 EXPECT_FALSE(activity_log->IsDatabaseEnabled());
63 EXPECT_FALSE(activity_log->IsWatchdogAppActive()); 63 EXPECT_FALSE(activity_log->IsWatchdogAppActive());
64 } 64 }
65 65
66 TEST_F(ActivityLogEnabledTest, CommandLineSwitch) { 66 TEST_F(ActivityLogEnabledTest, CommandLineSwitch) {
67 scoped_ptr<TestingProfile> profile1( 67 scoped_ptr<TestingProfile> profile1(
68 static_cast<TestingProfile*>(CreateBrowserContext())); 68 static_cast<TestingProfile*>(CreateBrowserContext()));
69 scoped_ptr<TestingProfile> profile2( 69 scoped_ptr<TestingProfile> profile2(
70 static_cast<TestingProfile*>(CreateBrowserContext())); 70 static_cast<TestingProfile*>(CreateBrowserContext()));
71 71
72 CommandLine command_line(CommandLine::NO_PROGRAM); 72 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
73 CommandLine saved_cmdline_ = *CommandLine::ForCurrentProcess(); 73 base::CommandLine saved_cmdline_ = *base::CommandLine::ForCurrentProcess();
74 CommandLine::ForCurrentProcess()->AppendSwitch( 74 base::CommandLine::ForCurrentProcess()->AppendSwitch(
75 switches::kEnableExtensionActivityLogging); 75 switches::kEnableExtensionActivityLogging);
76 ActivityLog* activity_log1 = ActivityLog::GetInstance(profile1.get()); 76 ActivityLog* activity_log1 = ActivityLog::GetInstance(profile1.get());
77 *CommandLine::ForCurrentProcess() = saved_cmdline_; 77 *base::CommandLine::ForCurrentProcess() = saved_cmdline_;
78 ActivityLog* activity_log2 = ActivityLog::GetInstance(profile2.get()); 78 ActivityLog* activity_log2 = ActivityLog::GetInstance(profile2.get());
79 79
80 EXPECT_EQ(0, 80 EXPECT_EQ(0,
81 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); 81 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive));
82 EXPECT_EQ(0, 82 EXPECT_EQ(0,
83 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); 83 profile2->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive));
84 EXPECT_TRUE(activity_log1->IsDatabaseEnabled()); 84 EXPECT_TRUE(activity_log1->IsDatabaseEnabled());
85 EXPECT_FALSE(activity_log2->IsDatabaseEnabled()); 85 EXPECT_FALSE(activity_log2->IsDatabaseEnabled());
86 EXPECT_FALSE(activity_log1->IsWatchdogAppActive()); 86 EXPECT_FALSE(activity_log1->IsWatchdogAppActive());
87 EXPECT_FALSE(activity_log2->IsWatchdogAppActive()); 87 EXPECT_FALSE(activity_log2->IsWatchdogAppActive());
(...skipping 28 matching lines...) Expand all
116 profile3->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); 116 profile3->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive));
117 EXPECT_TRUE(activity_log1->IsWatchdogAppActive()); 117 EXPECT_TRUE(activity_log1->IsWatchdogAppActive());
118 EXPECT_FALSE(activity_log2->IsWatchdogAppActive()); 118 EXPECT_FALSE(activity_log2->IsWatchdogAppActive());
119 EXPECT_TRUE(activity_log3->IsWatchdogAppActive()); 119 EXPECT_TRUE(activity_log3->IsWatchdogAppActive());
120 EXPECT_TRUE(activity_log1->IsDatabaseEnabled()); 120 EXPECT_TRUE(activity_log1->IsDatabaseEnabled());
121 EXPECT_FALSE(activity_log2->IsDatabaseEnabled()); 121 EXPECT_FALSE(activity_log2->IsDatabaseEnabled());
122 EXPECT_TRUE(activity_log3->IsDatabaseEnabled()); 122 EXPECT_TRUE(activity_log3->IsDatabaseEnabled());
123 } 123 }
124 124
125 TEST_F(ActivityLogEnabledTest, WatchdogSwitch) { 125 TEST_F(ActivityLogEnabledTest, WatchdogSwitch) {
126 CommandLine command_line(CommandLine::NO_PROGRAM); 126 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
127 scoped_ptr<TestingProfile> profile1( 127 scoped_ptr<TestingProfile> profile1(
128 static_cast<TestingProfile*>(CreateBrowserContext())); 128 static_cast<TestingProfile*>(CreateBrowserContext()));
129 scoped_ptr<TestingProfile> profile2( 129 scoped_ptr<TestingProfile> profile2(
130 static_cast<TestingProfile*>(CreateBrowserContext())); 130 static_cast<TestingProfile*>(CreateBrowserContext()));
131 // Extension service is destroyed by the profile. 131 // Extension service is destroyed by the profile.
132 ExtensionService* extension_service1 = 132 ExtensionService* extension_service1 =
133 static_cast<TestExtensionSystem*>( 133 static_cast<TestExtensionSystem*>(
134 ExtensionSystem::Get(profile1.get()))->CreateExtensionService( 134 ExtensionSystem::Get(profile1.get()))->CreateExtensionService(
135 &command_line, base::FilePath(), false); 135 &command_line, base::FilePath(), false);
136 static_cast<TestExtensionSystem*>( 136 static_cast<TestExtensionSystem*>(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 Extension::DISABLE_USER_ACTION); 221 Extension::DISABLE_USER_ACTION);
222 extension_service1->DisableExtension("fpofdchlamddhnajleknffcbmnjfahpg", 222 extension_service1->DisableExtension("fpofdchlamddhnajleknffcbmnjfahpg",
223 Extension::DISABLE_USER_ACTION); 223 Extension::DISABLE_USER_ACTION);
224 EXPECT_EQ(0, 224 EXPECT_EQ(0,
225 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); 225 profile1->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive));
226 EXPECT_FALSE(activity_log1->IsDatabaseEnabled()); 226 EXPECT_FALSE(activity_log1->IsDatabaseEnabled());
227 } 227 }
228 228
229 TEST_F(ActivityLogEnabledTest, AppAndCommandLine) { 229 TEST_F(ActivityLogEnabledTest, AppAndCommandLine) {
230 // Set the command line switch. 230 // Set the command line switch.
231 CommandLine command_line(CommandLine::NO_PROGRAM); 231 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
232 CommandLine saved_cmdline_ = *CommandLine::ForCurrentProcess(); 232 base::CommandLine saved_cmdline_ = *base::CommandLine::ForCurrentProcess();
233 CommandLine::ForCurrentProcess()->AppendSwitch( 233 base::CommandLine::ForCurrentProcess()->AppendSwitch(
234 switches::kEnableExtensionActivityLogging); 234 switches::kEnableExtensionActivityLogging);
235 235
236 scoped_ptr<TestingProfile> profile( 236 scoped_ptr<TestingProfile> profile(
237 static_cast<TestingProfile*>(CreateBrowserContext())); 237 static_cast<TestingProfile*>(CreateBrowserContext()));
238 // Extension service is destroyed by the profile. 238 // Extension service is destroyed by the profile.
239 ExtensionService* extension_service = 239 ExtensionService* extension_service =
240 static_cast<TestExtensionSystem*>( 240 static_cast<TestExtensionSystem*>(
241 ExtensionSystem::Get(profile.get()))->CreateExtensionService( 241 ExtensionSystem::Get(profile.get()))->CreateExtensionService(
242 &command_line, base::FilePath(), false); 242 &command_line, base::FilePath(), false);
243 static_cast<TestExtensionSystem*>( 243 static_cast<TestExtensionSystem*>(
(...skipping 29 matching lines...) Expand all
273 extensions::UNINSTALL_REASON_FOR_TESTING, 273 extensions::UNINSTALL_REASON_FOR_TESTING,
274 base::Bind(&base::DoNothing), 274 base::Bind(&base::DoNothing),
275 NULL); 275 NULL);
276 276
277 EXPECT_TRUE(activity_log->IsDatabaseEnabled()); 277 EXPECT_TRUE(activity_log->IsDatabaseEnabled());
278 EXPECT_EQ(0, 278 EXPECT_EQ(0,
279 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); 279 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive));
280 EXPECT_FALSE(activity_log->IsWatchdogAppActive()); 280 EXPECT_FALSE(activity_log->IsWatchdogAppActive());
281 281
282 // Cleanup. 282 // Cleanup.
283 *CommandLine::ForCurrentProcess() = saved_cmdline_; 283 *base::CommandLine::ForCurrentProcess() = saved_cmdline_;
284 } 284 }
285 285
286 } // namespace extensions 286 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698