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 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/file_util.h" | 12 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
15 #include "base/path_service.h" | 17 #include "base/path_service.h" |
16 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
(...skipping 17 matching lines...) Expand all Loading... |
34 #include "components/policy/core/common/cloud/policy_builder.h" | 36 #include "components/policy/core/common/cloud/policy_builder.h" |
35 #include "components/policy/core/common/external_data_fetcher.h" | 37 #include "components/policy/core/common/external_data_fetcher.h" |
36 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 38 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
37 #include "components/policy/core/common/policy_bundle.h" | 39 #include "components/policy/core/common/policy_bundle.h" |
38 #include "components/policy/core/common/policy_map.h" | 40 #include "components/policy/core/common/policy_map.h" |
39 #include "components/policy/core/common/schema_registry.h" | 41 #include "components/policy/core/common/schema_registry.h" |
40 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
41 #include "net/url_request/url_request_test_util.h" | 43 #include "net/url_request/url_request_test_util.h" |
42 #include "policy/policy_constants.h" | 44 #include "policy/policy_constants.h" |
43 #include "policy/proto/cloud_policy.pb.h" | 45 #include "policy/proto/cloud_policy.pb.h" |
| 46 #include "policy/proto/device_management_backend.pb.h" |
44 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
45 | 48 |
46 using testing::AnyNumber; | 49 using testing::AnyNumber; |
47 using testing::AtLeast; | 50 using testing::AtLeast; |
48 using testing::Mock; | 51 using testing::Mock; |
49 using testing::SaveArg; | 52 using testing::SaveArg; |
50 using testing::_; | 53 using testing::_; |
51 | 54 |
52 namespace em = enterprise_management; | 55 namespace em = enterprise_management; |
53 | 56 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 EXPECT_TRUE(request.has_policy_request()); | 418 EXPECT_TRUE(request.has_policy_request()); |
416 ASSERT_EQ(2, request.policy_request().request_size()); | 419 ASSERT_EQ(2, request.policy_request().request_size()); |
417 | 420 |
418 const em::PolicyFetchRequest* public_account = | 421 const em::PolicyFetchRequest* public_account = |
419 &request.policy_request().request(0); | 422 &request.policy_request().request(0); |
420 const em::PolicyFetchRequest* extensions = | 423 const em::PolicyFetchRequest* extensions = |
421 &request.policy_request().request(1); | 424 &request.policy_request().request(1); |
422 // The order is not guarateed. | 425 // The order is not guarateed. |
423 if (extensions->policy_type() == | 426 if (extensions->policy_type() == |
424 dm_protocol::kChromePublicAccountPolicyType) { | 427 dm_protocol::kChromePublicAccountPolicyType) { |
425 const em::PolicyFetchRequest* tmp = public_account; | 428 std::swap(public_account, extensions); |
426 public_account = extensions; | |
427 extensions = tmp; | |
428 } | 429 } |
429 | 430 |
430 EXPECT_EQ(dm_protocol::kChromePublicAccountPolicyType, | 431 EXPECT_EQ(dm_protocol::kChromePublicAccountPolicyType, |
431 public_account->policy_type()); | 432 public_account->policy_type()); |
432 EXPECT_FALSE(public_account->has_machine_id()); | 433 EXPECT_FALSE(public_account->has_machine_id()); |
433 EXPECT_EQ(kAccount1, public_account->settings_entity_id()); | 434 EXPECT_EQ(kAccount1, public_account->settings_entity_id()); |
434 | 435 |
435 EXPECT_EQ(dm_protocol::kChromeExtensionPolicyType, | 436 EXPECT_EQ(dm_protocol::kChromeExtensionPolicyType, |
436 extensions->policy_type()); | 437 extensions->policy_type()); |
437 EXPECT_FALSE(extensions->has_machine_id()); | 438 EXPECT_FALSE(extensions->has_machine_id()); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 em::DeviceManagementResponse response; | 966 em::DeviceManagementResponse response; |
966 device_local_account_policy_.Build(); | 967 device_local_account_policy_.Build(); |
967 response.mutable_policy_response()->add_response()->CopyFrom( | 968 response.mutable_policy_response()->add_response()->CopyFrom( |
968 device_local_account_policy_.policy()); | 969 device_local_account_policy_.policy()); |
969 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 970 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
970 FlushDeviceSettings(); | 971 FlushDeviceSettings(); |
971 Mock::VerifyAndClearExpectations(&provider_observer_); | 972 Mock::VerifyAndClearExpectations(&provider_observer_); |
972 } | 973 } |
973 | 974 |
974 } // namespace policy | 975 } // namespace policy |
OLD | NEW |