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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 | 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 "base/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return std::string("dorothy@somewhere.otr"); 80 return std::string("dorothy@somewhere.otr");
81 } 81 }
82 82
83 void CallTask(const base::Closure& task) { 83 void CallTask(const base::Closure& task) {
84 if (!task.is_null()) 84 if (!task.is_null())
85 task.Run(); 85 task.Run();
86 } 86 }
87 87
88 void PostTask(const base::Closure& task) { 88 void PostTask(const base::Closure& task) {
89 if (!task.is_null()) 89 if (!task.is_null())
90 MessageLoop::current()->PostTask(FROM_HERE, task); 90 base::MessageLoop::current()->PostTask(FROM_HERE, task);
91 } 91 }
92 92
93 void MockServiceProcessControl::SetConnectSuccessMockExpectations( 93 void MockServiceProcessControl::SetConnectSuccessMockExpectations(
94 ServiceState service_state, 94 ServiceState service_state,
95 bool post_task) { 95 bool post_task) {
96 EXPECT_CALL(*this, IsConnected()).WillRepeatedly(ReturnPointee(&connected_)); 96 EXPECT_CALL(*this, IsConnected()).WillRepeatedly(ReturnPointee(&connected_));
97 97
98 EXPECT_CALL(*this, Launch(_, _)) 98 EXPECT_CALL(*this, Launch(_, _))
99 .WillRepeatedly( 99 .WillRepeatedly(
100 DoAll(Assign(&connected_, true), 100 DoAll(Assign(&connected_, true),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { 190 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) {
191 int return_code = 0; 191 int return_code = 0;
192 StartupBrowserCreator browser_creator; 192 StartupBrowserCreator browser_creator;
193 return StartupBrowserCreator::ProcessCmdLineImpl( 193 return StartupBrowserCreator::ProcessCmdLineImpl(
194 command_line, base::FilePath(), false, profile, 194 command_line, base::FilePath(), false, profile,
195 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); 195 StartupBrowserCreator::Profiles(), &return_code, &browser_creator);
196 } 196 }
197 197
198 protected: 198 protected:
199 MessageLoopForUI message_loop_; 199 base::MessageLoopForUI message_loop_;
200 content::TestBrowserThread ui_thread_; 200 content::TestBrowserThread ui_thread_;
201 TestingProfile profile_; 201 TestingProfile profile_;
202 }; 202 };
203 203
204 TEST_F(CloudPrintProxyPolicyTest, VerifyExpectations) { 204 TEST_F(CloudPrintProxyPolicyTest, VerifyExpectations) {
205 MockServiceProcessControl mock_control; 205 MockServiceProcessControl mock_control;
206 mock_control.SetConnectSuccessMockExpectations( 206 mock_control.SetConnectSuccessMockExpectations(
207 MockServiceProcessControl::kServiceStateNone, false); 207 MockServiceProcessControl::kServiceStateNone, false);
208 208
209 EXPECT_FALSE(mock_control.IsConnected()); 209 EXPECT_FALSE(mock_control.IsConnected());
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 BrowserContextKeyedService* TestCloudPrintProxyServiceFactory( 425 BrowserContextKeyedService* TestCloudPrintProxyServiceFactory(
426 content::BrowserContext* profile) { 426 content::BrowserContext* profile) {
427 TestCloudPrintProxyService* service = 427 TestCloudPrintProxyService* service =
428 new TestCloudPrintProxyService(static_cast<Profile*>(profile)); 428 new TestCloudPrintProxyService(static_cast<Profile*>(profile));
429 429
430 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 430 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
431 MockServiceProcessControl::kServiceStateEnabled, true); 431 MockServiceProcessControl::kServiceStateEnabled, true);
432 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 432 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
433 433
434 service->Initialize(); 434 service->Initialize();
435 MessageLoop::current()->RunUntilIdle(); 435 base::MessageLoop::current()->RunUntilIdle();
436 return service; 436 return service;
437 } 437 }
438 438
439 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) { 439 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) {
440 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService(); 440 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
441 prefs->SetUserPref(prefs::kCloudPrintEmail, 441 prefs->SetUserPref(prefs::kCloudPrintEmail,
442 Value::CreateStringValue(std::string())); 442 Value::CreateStringValue(std::string()));
443 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 443 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
444 Value::CreateBooleanValue(false)); 444 Value::CreateBooleanValue(false));
445 445
446 CloudPrintProxyServiceFactory::GetInstance()-> 446 CloudPrintProxyServiceFactory::GetInstance()->
447 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory); 447 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory);
448 448
449 CommandLine command_line(CommandLine::NO_PROGRAM); 449 CommandLine command_line(CommandLine::NO_PROGRAM);
450 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); 450 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy);
451 451
452 EXPECT_FALSE(LaunchBrowser(command_line, &profile_)); 452 EXPECT_FALSE(LaunchBrowser(command_line, &profile_));
453 MessageLoop::current()->RunUntilIdle(); 453 base::MessageLoop::current()->RunUntilIdle();
454 } 454 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698