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

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: Created 7 years, 8 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 423 }
424 424
425 ProfileKeyedService* TestCloudPrintProxyServiceFactory(Profile* profile) { 425 ProfileKeyedService* TestCloudPrintProxyServiceFactory(Profile* profile) {
426 TestCloudPrintProxyService* service = new TestCloudPrintProxyService(profile); 426 TestCloudPrintProxyService* service = new TestCloudPrintProxyService(profile);
427 427
428 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( 428 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations(
429 MockServiceProcessControl::kServiceStateEnabled, true); 429 MockServiceProcessControl::kServiceStateEnabled, true);
430 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); 430 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations();
431 431
432 service->Initialize(); 432 service->Initialize();
433 MessageLoop::current()->RunUntilIdle(); 433 base::MessageLoop::current()->RunUntilIdle();
434 return service; 434 return service;
435 } 435 }
436 436
437 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) { 437 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) {
438 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService(); 438 TestingPrefServiceSyncable* prefs = profile_.GetTestingPrefService();
439 prefs->SetUserPref(prefs::kCloudPrintEmail, 439 prefs->SetUserPref(prefs::kCloudPrintEmail,
440 Value::CreateStringValue(std::string())); 440 Value::CreateStringValue(std::string()));
441 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, 441 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled,
442 Value::CreateBooleanValue(false)); 442 Value::CreateBooleanValue(false));
443 443
444 CloudPrintProxyServiceFactory::GetInstance()-> 444 CloudPrintProxyServiceFactory::GetInstance()->
445 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory); 445 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory);
446 446
447 CommandLine command_line(CommandLine::NO_PROGRAM); 447 CommandLine command_line(CommandLine::NO_PROGRAM);
448 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); 448 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy);
449 449
450 EXPECT_FALSE(LaunchBrowser(command_line, &profile_)); 450 EXPECT_FALSE(LaunchBrowser(command_line, &profile_));
451 MessageLoop::current()->RunUntilIdle(); 451 base::MessageLoop::current()->RunUntilIdle();
452 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698