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

Side by Side Diff: chrome/browser/policy/cloud/device_management_service_browsertest.cc

Issue 2083363002: Remove calls to deprecated MessageLoop methods in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/policy/cloud/test_request_interceptor.h" 15 #include "chrome/browser/policy/cloud/test_request_interceptor.h"
15 #include "chrome/browser/policy/test/local_policy_test_server.h" 16 #include "chrome/browser/policy/test/local_policy_test_server.h"
16 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
17 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 18 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
18 #include "components/policy/core/common/cloud/device_management_service.h" 19 #include "components/policy/core/common/cloud/device_management_service.h"
19 #include "components/policy/core/common/cloud/mock_device_management_service.h" 20 #include "components/policy/core/common/cloud/mock_device_management_service.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "net/base/upload_bytes_element_reader.h" 22 #include "net/base/upload_bytes_element_reader.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 &base::MessageLoop::QuitWhenIdle))); 135 &base::MessageLoop::QuitWhenIdle)));
135 std::unique_ptr<DeviceManagementRequestJob> job( 136 std::unique_ptr<DeviceManagementRequestJob> job(
136 service_->CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION, 137 service_->CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION,
137 g_browser_process->system_request_context())); 138 g_browser_process->system_request_context()));
138 job->SetGaiaToken("gaia_auth_token"); 139 job->SetGaiaToken("gaia_auth_token");
139 job->SetOAuthToken("oauth_token"); 140 job->SetOAuthToken("oauth_token");
140 job->SetClientID("testid"); 141 job->SetClientID("testid");
141 job->GetRequest()->mutable_register_request(); 142 job->GetRequest()->mutable_register_request();
142 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone, 143 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone,
143 base::Unretained(this))); 144 base::Unretained(this)));
144 base::MessageLoop::current()->Run(); 145 base::RunLoop().Run();
145 } 146 }
146 147
147 void SetUpOnMainThread() override { 148 void SetUpOnMainThread() override {
148 std::string service_url((this->*(GetParam()))()); 149 std::string service_url((this->*(GetParam()))());
149 service_.reset(new DeviceManagementService( 150 service_.reset(new DeviceManagementService(
150 std::unique_ptr<DeviceManagementService::Configuration>( 151 std::unique_ptr<DeviceManagementService::Configuration>(
151 new MockDeviceManagementServiceConfiguration(service_url)))); 152 new MockDeviceManagementServiceConfiguration(service_url))));
152 service_->ScheduleInitialization(0); 153 service_->ScheduleInitialization(0);
153 } 154 }
154 155
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 service_->CreateJob(DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH, 197 service_->CreateJob(DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH,
197 g_browser_process->system_request_context())); 198 g_browser_process->system_request_context()));
198 job->SetDMToken(token_); 199 job->SetDMToken(token_);
199 job->SetClientID("testid"); 200 job->SetClientID("testid");
200 em::DeviceServiceApiAccessRequest* request = 201 em::DeviceServiceApiAccessRequest* request =
201 job->GetRequest()->mutable_service_api_access_request(); 202 job->GetRequest()->mutable_service_api_access_request();
202 request->add_auth_scope("authScope4Test"); 203 request->add_auth_scope("authScope4Test");
203 request->set_oauth2_client_id("oauth2ClientId4Test"); 204 request->set_oauth2_client_id("oauth2ClientId4Test");
204 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone, 205 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone,
205 base::Unretained(this))); 206 base::Unretained(this)));
206 base::MessageLoop::current()->Run(); 207 base::RunLoop().Run();
207 ASSERT_EQ("fake_auth_code", robot_auth_code_); 208 ASSERT_EQ("fake_auth_code", robot_auth_code_);
208 } 209 }
209 210
210 IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, PolicyFetch) { 211 IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, PolicyFetch) {
211 PerformRegistration(); 212 PerformRegistration();
212 213
213 ExpectRequest(); 214 ExpectRequest();
214 EXPECT_CALL(*this, OnJobDone(DM_STATUS_SUCCESS, _, _)) 215 EXPECT_CALL(*this, OnJobDone(DM_STATUS_SUCCESS, _, _))
215 .WillOnce(InvokeWithoutArgs(base::MessageLoop::current(), 216 .WillOnce(InvokeWithoutArgs(base::MessageLoop::current(),
216 &base::MessageLoop::QuitWhenIdle)); 217 &base::MessageLoop::QuitWhenIdle));
217 std::unique_ptr<DeviceManagementRequestJob> job( 218 std::unique_ptr<DeviceManagementRequestJob> job(
218 service_->CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH, 219 service_->CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH,
219 g_browser_process->system_request_context())); 220 g_browser_process->system_request_context()));
220 job->SetDMToken(token_); 221 job->SetDMToken(token_);
221 job->SetClientID("testid"); 222 job->SetClientID("testid");
222 em::DevicePolicyRequest* request = 223 em::DevicePolicyRequest* request =
223 job->GetRequest()->mutable_policy_request(); 224 job->GetRequest()->mutable_policy_request();
224 request->add_request()->set_policy_type(dm_protocol::kChromeUserPolicyType); 225 request->add_request()->set_policy_type(dm_protocol::kChromeUserPolicyType);
225 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone, 226 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone,
226 base::Unretained(this))); 227 base::Unretained(this)));
227 base::MessageLoop::current()->Run(); 228 base::RunLoop().Run();
228 } 229 }
229 230
230 IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, Unregistration) { 231 IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, Unregistration) {
231 PerformRegistration(); 232 PerformRegistration();
232 233
233 ExpectRequest(); 234 ExpectRequest();
234 EXPECT_CALL(*this, OnJobDone(DM_STATUS_SUCCESS, _, _)) 235 EXPECT_CALL(*this, OnJobDone(DM_STATUS_SUCCESS, _, _))
235 .WillOnce(InvokeWithoutArgs(base::MessageLoop::current(), 236 .WillOnce(InvokeWithoutArgs(base::MessageLoop::current(),
236 &base::MessageLoop::QuitWhenIdle)); 237 &base::MessageLoop::QuitWhenIdle));
237 std::unique_ptr<DeviceManagementRequestJob> job( 238 std::unique_ptr<DeviceManagementRequestJob> job(
238 service_->CreateJob(DeviceManagementRequestJob::TYPE_UNREGISTRATION, 239 service_->CreateJob(DeviceManagementRequestJob::TYPE_UNREGISTRATION,
239 g_browser_process->system_request_context())); 240 g_browser_process->system_request_context()));
240 job->SetDMToken(token_); 241 job->SetDMToken(token_);
241 job->SetClientID("testid"); 242 job->SetClientID("testid");
242 job->GetRequest()->mutable_unregister_request(); 243 job->GetRequest()->mutable_unregister_request();
243 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone, 244 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone,
244 base::Unretained(this))); 245 base::Unretained(this)));
245 base::MessageLoop::current()->Run(); 246 base::RunLoop().Run();
246 } 247 }
247 248
248 IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, AutoEnrollment) { 249 IN_PROC_BROWSER_TEST_P(DeviceManagementServiceIntegrationTest, AutoEnrollment) {
249 ExpectRequest(); 250 ExpectRequest();
250 EXPECT_CALL(*this, OnJobDone(DM_STATUS_SUCCESS, _, _)) 251 EXPECT_CALL(*this, OnJobDone(DM_STATUS_SUCCESS, _, _))
251 .WillOnce(InvokeWithoutArgs(base::MessageLoop::current(), 252 .WillOnce(InvokeWithoutArgs(base::MessageLoop::current(),
252 &base::MessageLoop::QuitWhenIdle)); 253 &base::MessageLoop::QuitWhenIdle));
253 std::unique_ptr<DeviceManagementRequestJob> job( 254 std::unique_ptr<DeviceManagementRequestJob> job(
254 service_->CreateJob(DeviceManagementRequestJob::TYPE_AUTO_ENROLLMENT, 255 service_->CreateJob(DeviceManagementRequestJob::TYPE_AUTO_ENROLLMENT,
255 g_browser_process->system_request_context())); 256 g_browser_process->system_request_context()));
256 job->SetClientID("testid"); 257 job->SetClientID("testid");
257 job->GetRequest()->mutable_auto_enrollment_request()->set_remainder(0); 258 job->GetRequest()->mutable_auto_enrollment_request()->set_remainder(0);
258 job->GetRequest()->mutable_auto_enrollment_request()->set_modulus(1); 259 job->GetRequest()->mutable_auto_enrollment_request()->set_modulus(1);
259 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone, 260 job->Start(base::Bind(&DeviceManagementServiceIntegrationTest::OnJobDone,
260 base::Unretained(this))); 261 base::Unretained(this)));
261 base::MessageLoop::current()->Run(); 262 base::RunLoop().Run();
262 } 263 }
263 264
264 INSTANTIATE_TEST_CASE_P( 265 INSTANTIATE_TEST_CASE_P(
265 DeviceManagementServiceIntegrationTestInstance, 266 DeviceManagementServiceIntegrationTestInstance,
266 DeviceManagementServiceIntegrationTest, 267 DeviceManagementServiceIntegrationTest,
267 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse, 268 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse,
268 &DeviceManagementServiceIntegrationTest::InitTestServer)); 269 &DeviceManagementServiceIntegrationTest::InitTestServer));
269 270
270 } // namespace policy 271 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698