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

Side by Side Diff: chrome/browser/policy/device_management_service_unittest.cc

Issue 6880031: Merge server-side changes of the cloud policy protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "chrome/browser/policy/device_management_backend_impl.h" 9 #include "chrome/browser/policy/device_management_backend_impl.h"
10 #include "chrome/browser/policy/device_management_backend_mock.h" 10 #include "chrome/browser/policy/device_management_backend_mock.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 em::DeviceManagementRequest expected_request_wrapper; 302 em::DeviceManagementRequest expected_request_wrapper;
303 expected_request_wrapper.mutable_register_request()->CopyFrom(request); 303 expected_request_wrapper.mutable_register_request()->CopyFrom(request);
304 std::string expected_request_data; 304 std::string expected_request_data;
305 ASSERT_TRUE(expected_request_wrapper.SerializeToString( 305 ASSERT_TRUE(expected_request_wrapper.SerializeToString(
306 &expected_request_data)); 306 &expected_request_data));
307 EXPECT_EQ(expected_request_data, fetcher->upload_data()); 307 EXPECT_EQ(expected_request_data, fetcher->upload_data());
308 308
309 // Generate the response. 309 // Generate the response.
310 std::string response_data; 310 std::string response_data;
311 em::DeviceManagementResponse response_wrapper; 311 em::DeviceManagementResponse response_wrapper;
312 response_wrapper.set_error(em::DeviceManagementResponse::SUCCESS);
313 response_wrapper.mutable_register_response()->CopyFrom(expected_response); 312 response_wrapper.mutable_register_response()->CopyFrom(expected_response);
314 ASSERT_TRUE(response_wrapper.SerializeToString(&response_data)); 313 ASSERT_TRUE(response_wrapper.SerializeToString(&response_data));
315 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 314 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
316 fetcher->delegate()->OnURLFetchComplete(fetcher, 315 fetcher->delegate()->OnURLFetchComplete(fetcher,
317 GURL(kServiceUrl), 316 GURL(kServiceUrl),
318 status, 317 status,
319 200, 318 200,
320 ResponseCookies(), 319 ResponseCookies(),
321 response_data); 320 response_data);
322 } 321 }
(...skipping 22 matching lines...) Expand all
345 em::DeviceManagementRequest expected_request_wrapper; 344 em::DeviceManagementRequest expected_request_wrapper;
346 expected_request_wrapper.mutable_unregister_request()->CopyFrom(request); 345 expected_request_wrapper.mutable_unregister_request()->CopyFrom(request);
347 std::string expected_request_data; 346 std::string expected_request_data;
348 ASSERT_TRUE(expected_request_wrapper.SerializeToString( 347 ASSERT_TRUE(expected_request_wrapper.SerializeToString(
349 &expected_request_data)); 348 &expected_request_data));
350 EXPECT_EQ(expected_request_data, fetcher->upload_data()); 349 EXPECT_EQ(expected_request_data, fetcher->upload_data());
351 350
352 // Generate the response. 351 // Generate the response.
353 std::string response_data; 352 std::string response_data;
354 em::DeviceManagementResponse response_wrapper; 353 em::DeviceManagementResponse response_wrapper;
355 response_wrapper.set_error(em::DeviceManagementResponse::SUCCESS);
356 response_wrapper.mutable_unregister_response()->CopyFrom(expected_response); 354 response_wrapper.mutable_unregister_response()->CopyFrom(expected_response);
357 ASSERT_TRUE(response_wrapper.SerializeToString(&response_data)); 355 ASSERT_TRUE(response_wrapper.SerializeToString(&response_data));
358 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 356 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
359 fetcher->delegate()->OnURLFetchComplete(fetcher, 357 fetcher->delegate()->OnURLFetchComplete(fetcher,
360 GURL(kServiceUrl), 358 GURL(kServiceUrl),
361 status, 359 status,
362 200, 360 200,
363 ResponseCookies(), 361 ResponseCookies(),
364 response_data); 362 response_data);
365 } 363 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 419
422 // Now initialize the service. That should start the job. 420 // Now initialize the service. That should start the job.
423 service_->Initialize(request_context_.get()); 421 service_->Initialize(request_context_.get());
424 fetcher = factory_.GetFetcherByID(0); 422 fetcher = factory_.GetFetcherByID(0);
425 ASSERT_TRUE(fetcher); 423 ASSERT_TRUE(fetcher);
426 factory_.RemoveFetcherFromMap(0); 424 factory_.RemoveFetcherFromMap(0);
427 425
428 // Check that the request is processed as expected. 426 // Check that the request is processed as expected.
429 std::string response_data; 427 std::string response_data;
430 em::DeviceManagementResponse response_wrapper; 428 em::DeviceManagementResponse response_wrapper;
431 response_wrapper.set_error(em::DeviceManagementResponse::SUCCESS);
432 response_wrapper.mutable_register_response()->CopyFrom(expected_response); 429 response_wrapper.mutable_register_response()->CopyFrom(expected_response);
433 ASSERT_TRUE(response_wrapper.SerializeToString(&response_data)); 430 ASSERT_TRUE(response_wrapper.SerializeToString(&response_data));
434 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 431 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
435 fetcher->delegate()->OnURLFetchComplete(fetcher, 432 fetcher->delegate()->OnURLFetchComplete(fetcher,
436 GURL(kServiceUrl), 433 GURL(kServiceUrl),
437 status, 434 status,
438 200, 435 200,
439 ResponseCookies(), 436 ResponseCookies(),
440 response_data); 437 response_data);
441 } 438 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 status, 474 status,
478 500, 475 500,
479 ResponseCookies(), 476 ResponseCookies(),
480 ""); 477 "");
481 478
482 // Backend should have been reset. 479 // Backend should have been reset.
483 EXPECT_FALSE(backend_.get()); 480 EXPECT_FALSE(backend_.get());
484 } 481 }
485 482
486 } // namespace policy 483 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_backend_impl.cc ('k') | chrome/browser/policy/proto/device_management_backend.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698