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

Side by Side Diff: chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 mock_control.Disconnect(); 213 mock_control.Disconnect();
214 EXPECT_FALSE(mock_control.IsConnected()); 214 EXPECT_FALSE(mock_control.IsConnected());
215 } 215 }
216 216
217 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabled) { 217 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabled) {
218 TestCloudPrintProxyService service(&profile_); 218 TestCloudPrintProxyService service(&profile_);
219 219
220 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 220 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
221 MockServiceProcessControl::kServiceStateDisabled, false); 221 MockServiceProcessControl::kServiceStateDisabled, false);
222 222
223 TestingPrefService* prefs = profile_.GetTestingPrefService(); 223 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
224 prefs->SetUserPref(prefs::kCloudPrintEmail, 224 prefs->SetUserPref(prefs::kCloudPrintEmail,
225 Value::CreateStringValue( 225 Value::CreateStringValue(
226 MockServiceProcessControl::EnabledUserId())); 226 MockServiceProcessControl::EnabledUserId()));
227 227
228 service.Initialize(); 228 service.Initialize();
229 229
230 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 230 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
231 } 231 }
232 232
233 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyEnabled) { 233 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyEnabled) {
234 TestCloudPrintProxyService service(&profile_); 234 TestCloudPrintProxyService service(&profile_);
235 235
236 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 236 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
237 MockServiceProcessControl::kServiceStateEnabled, false); 237 MockServiceProcessControl::kServiceStateEnabled, false);
238 238
239 TestingPrefService* prefs = profile_.GetTestingPrefService(); 239 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
240 prefs->SetUserPref(prefs::kCloudPrintEmail, 240 prefs->SetUserPref(prefs::kCloudPrintEmail,
241 Value::CreateStringValue(std::string())); 241 Value::CreateStringValue(std::string()));
242 242
243 service.Initialize(); 243 service.Initialize();
244 service.RefreshStatusFromService(); 244 service.RefreshStatusFromService();
245 245
246 EXPECT_EQ(MockServiceProcessControl::EnabledUserId(), 246 EXPECT_EQ(MockServiceProcessControl::EnabledUserId(),
247 prefs->GetString(prefs::kCloudPrintEmail)); 247 prefs->GetString(prefs::kCloudPrintEmail));
248 } 248 }
249 249
250 TEST_F(CloudPrintProxyPolicyTest, StartWithPolicySetProxyDisabled) { 250 TEST_F(CloudPrintProxyPolicyTest, StartWithPolicySetProxyDisabled) {
251 TestCloudPrintProxyService service(&profile_); 251 TestCloudPrintProxyService service(&profile_);
252 252
253 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 253 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
254 MockServiceProcessControl::kServiceStateDisabled, false); 254 MockServiceProcessControl::kServiceStateDisabled, false);
255 255
256 TestingPrefService* prefs = profile_.GetTestingPrefService(); 256 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
257 prefs->SetUserPref(prefs::kCloudPrintEmail, 257 prefs->SetUserPref(prefs::kCloudPrintEmail,
258 Value::CreateStringValue(std::string())); 258 Value::CreateStringValue(std::string()));
259 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 259 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
260 Value::CreateBooleanValue(false)); 260 Value::CreateBooleanValue(false));
261 261
262 service.Initialize(); 262 service.Initialize();
263 263
264 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 264 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
265 } 265 }
266 266
267 TEST_F(CloudPrintProxyPolicyTest, StartWithPolicySetProxyEnabled) { 267 TEST_F(CloudPrintProxyPolicyTest, StartWithPolicySetProxyEnabled) {
268 TestCloudPrintProxyService service(&profile_); 268 TestCloudPrintProxyService service(&profile_);
269 269
270 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 270 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
271 MockServiceProcessControl::kServiceStateEnabled, false); 271 MockServiceProcessControl::kServiceStateEnabled, false);
272 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 272 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
273 273
274 TestingPrefService* prefs = profile_.GetTestingPrefService(); 274 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
275 prefs->SetUserPref(prefs::kCloudPrintEmail, 275 prefs->SetUserPref(prefs::kCloudPrintEmail,
276 Value::CreateStringValue(std::string())); 276 Value::CreateStringValue(std::string()));
277 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 277 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
278 Value::CreateBooleanValue(false)); 278 Value::CreateBooleanValue(false));
279 279
280 service.Initialize(); 280 service.Initialize();
281 281
282 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 282 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
283 } 283 }
284 284
285 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabledThenSetPolicy) { 285 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabledThenSetPolicy) {
286 TestCloudPrintProxyService service(&profile_); 286 TestCloudPrintProxyService service(&profile_);
287 287
288 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 288 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
289 MockServiceProcessControl::kServiceStateDisabled, false); 289 MockServiceProcessControl::kServiceStateDisabled, false);
290 290
291 TestingPrefService* prefs = profile_.GetTestingPrefService(); 291 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
292 prefs->SetUserPref(prefs::kCloudPrintEmail, 292 prefs->SetUserPref(prefs::kCloudPrintEmail,
293 Value::CreateStringValue( 293 Value::CreateStringValue(
294 MockServiceProcessControl::EnabledUserId())); 294 MockServiceProcessControl::EnabledUserId()));
295 295
296 service.Initialize(); 296 service.Initialize();
297 297
298 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 298 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
299 299
300 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 300 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
301 Value::CreateBooleanValue(false)); 301 Value::CreateBooleanValue(false));
302 302
303 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 303 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
304 } 304 }
305 305
306 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyEnabledThenSetPolicy) { 306 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyEnabledThenSetPolicy) {
307 TestCloudPrintProxyService service(&profile_); 307 TestCloudPrintProxyService service(&profile_);
308 308
309 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 309 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
310 MockServiceProcessControl::kServiceStateEnabled, false); 310 MockServiceProcessControl::kServiceStateEnabled, false);
311 311
312 TestingPrefService* prefs = profile_.GetTestingPrefService(); 312 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
313 prefs->SetUserPref(prefs::kCloudPrintEmail, 313 prefs->SetUserPref(prefs::kCloudPrintEmail,
314 Value::CreateStringValue(std::string())); 314 Value::CreateStringValue(std::string()));
315 315
316 service.Initialize(); 316 service.Initialize();
317 service.RefreshStatusFromService(); 317 service.RefreshStatusFromService();
318 318
319 EXPECT_EQ(MockServiceProcessControl::EnabledUserId(), 319 EXPECT_EQ(MockServiceProcessControl::EnabledUserId(),
320 prefs->GetString(prefs::kCloudPrintEmail)); 320 prefs->GetString(prefs::kCloudPrintEmail));
321 321
322 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 322 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
323 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 323 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
324 Value::CreateBooleanValue(false)); 324 Value::CreateBooleanValue(false));
325 325
326 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 326 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
327 } 327 }
328 328
329 TEST_F(CloudPrintProxyPolicyTest, 329 TEST_F(CloudPrintProxyPolicyTest,
330 StartWithPolicySetProxyDisabledThenClearPolicy) { 330 StartWithPolicySetProxyDisabledThenClearPolicy) {
331 TestCloudPrintProxyService service(&profile_); 331 TestCloudPrintProxyService service(&profile_);
332 332
333 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 333 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
334 MockServiceProcessControl::kServiceStateDisabled, false); 334 MockServiceProcessControl::kServiceStateDisabled, false);
335 335
336 TestingPrefService* prefs = profile_.GetTestingPrefService(); 336 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
337 prefs->SetUserPref(prefs::kCloudPrintEmail, 337 prefs->SetUserPref(prefs::kCloudPrintEmail,
338 Value::CreateStringValue(std::string())); 338 Value::CreateStringValue(std::string()));
339 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 339 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
340 Value::CreateBooleanValue(false)); 340 Value::CreateBooleanValue(false));
341 341
342 service.Initialize(); 342 service.Initialize();
343 343
344 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 344 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
345 prefs->RemoveManagedPref(prefs::kCloudPrintProxyEnabled); 345 prefs->RemoveManagedPref(prefs::kCloudPrintProxyEnabled);
346 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 346 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
347 } 347 }
348 348
349 TEST_F(CloudPrintProxyPolicyTest, 349 TEST_F(CloudPrintProxyPolicyTest,
350 StartWithPolicySetProxyEnabledThenClearPolicy) { 350 StartWithPolicySetProxyEnabledThenClearPolicy) {
351 TestCloudPrintProxyService service(&profile_); 351 TestCloudPrintProxyService service(&profile_);
352 352
353 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 353 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
354 MockServiceProcessControl::kServiceStateEnabled, false); 354 MockServiceProcessControl::kServiceStateEnabled, false);
355 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 355 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
356 356
357 TestingPrefService* prefs = profile_.GetTestingPrefService(); 357 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
358 prefs->SetUserPref(prefs::kCloudPrintEmail, 358 prefs->SetUserPref(prefs::kCloudPrintEmail,
359 Value::CreateStringValue(std::string())); 359 Value::CreateStringValue(std::string()));
360 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 360 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
361 Value::CreateBooleanValue(false)); 361 Value::CreateBooleanValue(false));
362 362
363 service.Initialize(); 363 service.Initialize();
364 364
365 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 365 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
366 prefs->RemoveManagedPref(prefs::kCloudPrintProxyEnabled); 366 prefs->RemoveManagedPref(prefs::kCloudPrintProxyEnabled);
367 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 367 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
368 } 368 }
369 369
370 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabledThenEnable) { 370 TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabledThenEnable) {
371 TestCloudPrintProxyService service(&profile_); 371 TestCloudPrintProxyService service(&profile_);
372 372
373 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 373 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
374 MockServiceProcessControl::kServiceStateDisabled, false); 374 MockServiceProcessControl::kServiceStateDisabled, false);
375 375
376 TestingPrefService* prefs = profile_.GetTestingPrefService(); 376 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
377 prefs->SetUserPref(prefs::kCloudPrintEmail, 377 prefs->SetUserPref(prefs::kCloudPrintEmail,
378 Value::CreateStringValue( 378 Value::CreateStringValue(
379 MockServiceProcessControl::EnabledUserId())); 379 MockServiceProcessControl::EnabledUserId()));
380 380
381 service.Initialize(); 381 service.Initialize();
382 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 382 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
383 383
384 service.GetMockServiceProcessControl()->SetWillBeEnabledExpectations(); 384 service.GetMockServiceProcessControl()->SetWillBeEnabledExpectations();
385 service.EnableForUser(std::string(), 385 service.EnableForUser(std::string(),
386 MockServiceProcessControl::EnabledUserId()); 386 MockServiceProcessControl::EnabledUserId());
387 387
388 EXPECT_EQ(MockServiceProcessControl::EnabledUserId(), 388 EXPECT_EQ(MockServiceProcessControl::EnabledUserId(),
389 prefs->GetString(prefs::kCloudPrintEmail)); 389 prefs->GetString(prefs::kCloudPrintEmail));
390 } 390 }
391 391
392 TEST_F(CloudPrintProxyPolicyTest, 392 TEST_F(CloudPrintProxyPolicyTest,
393 StartWithPolicySetProxyEnabledThenClearPolicyAndEnable) { 393 StartWithPolicySetProxyEnabledThenClearPolicyAndEnable) {
394 TestCloudPrintProxyService service(&profile_); 394 TestCloudPrintProxyService service(&profile_);
395 395
396 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 396 service.GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
397 MockServiceProcessControl::kServiceStateEnabled, false); 397 MockServiceProcessControl::kServiceStateEnabled, false);
398 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 398 service.GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
399 399
400 TestingPrefService* prefs = profile_.GetTestingPrefService(); 400 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
401 prefs->SetUserPref(prefs::kCloudPrintEmail, 401 prefs->SetUserPref(prefs::kCloudPrintEmail,
402 Value::CreateStringValue(std::string())); 402 Value::CreateStringValue(std::string()));
403 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 403 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
404 Value::CreateBooleanValue(false)); 404 Value::CreateBooleanValue(false));
405 405
406 service.Initialize(); 406 service.Initialize();
407 407
408 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail)); 408 EXPECT_EQ(std::string(), prefs->GetString(prefs::kCloudPrintEmail));
409 service.EnableForUser(std::string(), 409 service.EnableForUser(std::string(),
410 MockServiceProcessControl::EnabledUserId()); 410 MockServiceProcessControl::EnabledUserId());
(...skipping 16 matching lines...) Expand all
427 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 427 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
428 MockServiceProcessControl::kServiceStateEnabled, true); 428 MockServiceProcessControl::kServiceStateEnabled, true);
429 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 429 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
430 430
431 service->Initialize(); 431 service->Initialize();
432 MessageLoop::current()->RunUntilIdle(); 432 MessageLoop::current()->RunUntilIdle();
433 return service; 433 return service;
434 } 434 }
435 435
436 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) { 436 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) {
437 TestingPrefService* prefs = profile_.GetTestingPrefService(); 437 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
438 prefs->SetUserPref(prefs::kCloudPrintEmail, 438 prefs->SetUserPref(prefs::kCloudPrintEmail,
439 Value::CreateStringValue(std::string())); 439 Value::CreateStringValue(std::string()));
440 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 440 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
441 Value::CreateBooleanValue(false)); 441 Value::CreateBooleanValue(false));
442 442
443 CloudPrintProxyServiceFactory::GetInstance()-> 443 CloudPrintProxyServiceFactory::GetInstance()->
444 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory); 444 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory);
445 445
446 CommandLine command_line(CommandLine::NO_PROGRAM); 446 CommandLine command_line(CommandLine::NO_PROGRAM);
447 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); 447 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy);
448 448
449 EXPECT_FALSE(LaunchBrowser(command_line, &profile_)); 449 EXPECT_FALSE(LaunchBrowser(command_line, &profile_));
450 MessageLoop::current()->RunUntilIdle(); 450 MessageLoop::current()->RunUntilIdle();
451 } 451 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/session_startup_pref_unittest.cc ('k') | chrome/browser/printing/cloud_print/cloud_print_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698