OLD | NEW |
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 // Create a service process that uses a Mock to respond to the browser in order | 5 // Create a service process that uses a Mock to respond to the browser in order |
6 // to test launching the browser using the cloud print policy check command | 6 // to test launching the browser using the cloud print policy check command |
7 // line switch. | 7 // line switch. |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 TestingBrowserProcess* browser_process = | 465 TestingBrowserProcess* browser_process = |
466 static_cast<TestingBrowserProcess*>(g_browser_process); | 466 static_cast<TestingBrowserProcess*>(g_browser_process); |
467 TestingProfileManager profile_manager(browser_process); | 467 TestingProfileManager profile_manager(browser_process); |
468 ASSERT_TRUE(profile_manager.SetUp()); | 468 ASSERT_TRUE(profile_manager.SetUp()); |
469 | 469 |
470 TestingProfile* profile = | 470 TestingProfile* profile = |
471 profile_manager.CreateTestingProfile("StartBrowserWithoutPolicy"); | 471 profile_manager.CreateTestingProfile("StartBrowserWithoutPolicy"); |
472 CloudPrintProxyServiceFactory::GetInstance()-> | 472 CloudPrintProxyServiceFactory::GetInstance()-> |
473 SetTestingFactory(profile, CloudPrintProxyServiceFactoryForPolicyTest); | 473 SetTestingFactory(profile, CloudPrintProxyServiceFactoryForPolicyTest); |
474 | 474 |
475 TestingPrefService* prefs = profile->GetTestingPrefService(); | 475 TestingPrefServiceSyncable* prefs = profile->GetTestingPrefService(); |
476 prefs->SetUserPref(prefs::kCloudPrintEmail, | 476 prefs->SetUserPref(prefs::kCloudPrintEmail, |
477 Value::CreateStringValue( | 477 Value::CreateStringValue( |
478 MockServiceIPCServer::EnabledUserId())); | 478 MockServiceIPCServer::EnabledUserId())); |
479 | 479 |
480 CommandLine command_line(CommandLine::NO_PROGRAM); | 480 CommandLine command_line(CommandLine::NO_PROGRAM); |
481 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); | 481 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
482 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); | 482 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); |
483 | 483 |
484 WaitForConnect(); | 484 WaitForConnect(); |
485 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 485 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
(...skipping 19 matching lines...) Expand all Loading... |
505 TestingBrowserProcess* browser_process = | 505 TestingBrowserProcess* browser_process = |
506 static_cast<TestingBrowserProcess*>(g_browser_process); | 506 static_cast<TestingBrowserProcess*>(g_browser_process); |
507 TestingProfileManager profile_manager(browser_process); | 507 TestingProfileManager profile_manager(browser_process); |
508 ASSERT_TRUE(profile_manager.SetUp()); | 508 ASSERT_TRUE(profile_manager.SetUp()); |
509 | 509 |
510 TestingProfile* profile = | 510 TestingProfile* profile = |
511 profile_manager.CreateTestingProfile("StartBrowserWithPolicy"); | 511 profile_manager.CreateTestingProfile("StartBrowserWithPolicy"); |
512 CloudPrintProxyServiceFactory::GetInstance()-> | 512 CloudPrintProxyServiceFactory::GetInstance()-> |
513 SetTestingFactory(profile, CloudPrintProxyServiceFactoryForPolicyTest); | 513 SetTestingFactory(profile, CloudPrintProxyServiceFactoryForPolicyTest); |
514 | 514 |
515 TestingPrefService* prefs = profile->GetTestingPrefService(); | 515 TestingPrefServiceSyncable* prefs = profile->GetTestingPrefService(); |
516 prefs->SetUserPref(prefs::kCloudPrintEmail, | 516 prefs->SetUserPref(prefs::kCloudPrintEmail, |
517 Value::CreateStringValue( | 517 Value::CreateStringValue( |
518 MockServiceIPCServer::EnabledUserId())); | 518 MockServiceIPCServer::EnabledUserId())); |
519 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, | 519 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, |
520 Value::CreateBooleanValue(false)); | 520 Value::CreateBooleanValue(false)); |
521 | 521 |
522 CommandLine command_line(CommandLine::NO_PROGRAM); | 522 CommandLine command_line(CommandLine::NO_PROGRAM); |
523 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); | 523 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
524 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); | 524 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); |
525 | 525 |
526 WaitForConnect(); | 526 WaitForConnect(); |
527 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 527 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
528 MessageLoop::QuitClosure(), | 528 MessageLoop::QuitClosure(), |
529 TestTimeouts::action_timeout()); | 529 TestTimeouts::action_timeout()); |
530 | 530 |
531 bool run_loop = LaunchBrowser(command_line, profile); | 531 bool run_loop = LaunchBrowser(command_line, profile); |
532 | 532 |
533 // No expectations on run_loop being true here; that would be a race | 533 // No expectations on run_loop being true here; that would be a race |
534 // condition. | 534 // condition. |
535 if (run_loop) | 535 if (run_loop) |
536 MessageLoop::current()->Run(); | 536 MessageLoop::current()->Run(); |
537 | 537 |
538 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); | 538 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); |
539 | 539 |
540 ShutdownAndWaitForExitWithTimeout(handle); | 540 ShutdownAndWaitForExitWithTimeout(handle); |
541 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); | 541 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); |
542 } | 542 } |
OLD | NEW |