| 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 TestingProfile* profile = | 597 TestingProfile* profile = |
| 598 profile_manager.CreateTestingProfile("StartBrowserWithPolicy"); | 598 profile_manager.CreateTestingProfile("StartBrowserWithPolicy"); |
| 599 CloudPrintProxyServiceFactory::GetInstance()-> | 599 CloudPrintProxyServiceFactory::GetInstance()-> |
| 600 SetTestingFactory(profile, CloudPrintProxyServiceFactoryForPolicyTest); | 600 SetTestingFactory(profile, CloudPrintProxyServiceFactoryForPolicyTest); |
| 601 | 601 |
| 602 TestingPrefServiceSyncable* prefs = profile->GetTestingPrefService(); | 602 TestingPrefServiceSyncable* prefs = profile->GetTestingPrefService(); |
| 603 prefs->SetUserPref(prefs::kCloudPrintEmail, | 603 prefs->SetUserPref(prefs::kCloudPrintEmail, |
| 604 base::Value::CreateStringValue( | 604 base::Value::CreateStringValue( |
| 605 MockServiceIPCServer::EnabledUserId())); | 605 MockServiceIPCServer::EnabledUserId())); |
| 606 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, | 606 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, |
| 607 base::Value::CreateBooleanValue(false)); | 607 new base::FundamentalValue(false)); |
| 608 | 608 |
| 609 CommandLine command_line(CommandLine::NO_PROGRAM); | 609 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 610 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); | 610 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
| 611 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); | 611 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); |
| 612 | 612 |
| 613 WaitForConnect(); | 613 WaitForConnect(); |
| 614 base::RunLoop run_loop; | 614 base::RunLoop run_loop; |
| 615 base::MessageLoop::current()->PostDelayedTask( | 615 base::MessageLoop::current()->PostDelayedTask( |
| 616 FROM_HERE, | 616 FROM_HERE, |
| 617 run_loop.QuitClosure(), | 617 run_loop.QuitClosure(), |
| 618 TestTimeouts::action_timeout()); | 618 TestTimeouts::action_timeout()); |
| 619 | 619 |
| 620 bool should_run_loop = LaunchBrowser(command_line, profile); | 620 bool should_run_loop = LaunchBrowser(command_line, profile); |
| 621 | 621 |
| 622 // No expectations on run_loop being true here; that would be a race | 622 // No expectations on run_loop being true here; that would be a race |
| 623 // condition. | 623 // condition. |
| 624 if (should_run_loop) | 624 if (should_run_loop) |
| 625 run_loop.Run(); | 625 run_loop.Run(); |
| 626 | 626 |
| 627 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); | 627 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); |
| 628 | 628 |
| 629 ShutdownAndWaitForExitWithTimeout(handle); | 629 ShutdownAndWaitForExitWithTimeout(handle); |
| 630 content::RunAllPendingInMessageLoop(); | 630 content::RunAllPendingInMessageLoop(); |
| 631 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); | 631 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); |
| 632 } | 632 } |
| OLD | NEW |