| 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/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/location.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/single_thread_task_runner.h" |
| 18 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "chromeos/dbus/mock_cryptohome_client.h" | 22 #include "chromeos/dbus/mock_cryptohome_client.h" |
| 20 #include "chromeos/dbus/mock_session_manager_client.h" | 23 #include "chromeos/dbus/mock_session_manager_client.h" |
| 21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 24 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 22 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 25 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
| 23 #include "components/policy/core/common/cloud/policy_builder.h" | 26 #include "components/policy/core/common/cloud/policy_builder.h" |
| 24 #include "components/policy/core/common/policy_types.h" | 27 #include "components/policy/core/common/policy_types.h" |
| 25 #include "policy/policy_constants.h" | 28 #include "policy/policy_constants.h" |
| 26 #include "policy/proto/cloud_policy.pb.h" | 29 #include "policy/proto/cloud_policy.pb.h" |
| 27 #include "policy/proto/device_management_local.pb.h" | 30 #include "policy/proto/device_management_local.pb.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 | 46 |
| 44 namespace { | 47 namespace { |
| 45 | 48 |
| 46 const char kLegacyDeviceId[] = "legacy-device-id"; | 49 const char kLegacyDeviceId[] = "legacy-device-id"; |
| 47 const char kLegacyToken[] = "legacy-token"; | 50 const char kLegacyToken[] = "legacy-token"; |
| 48 const char kSanitizedUsername[] = | 51 const char kSanitizedUsername[] = |
| 49 "0123456789ABCDEF0123456789ABCDEF012345678@example.com"; | 52 "0123456789ABCDEF0123456789ABCDEF012345678@example.com"; |
| 50 const char kDefaultHomepage[] = "http://chromium.org"; | 53 const char kDefaultHomepage[] = "http://chromium.org"; |
| 51 | 54 |
| 52 ACTION_P2(SendSanitizedUsername, call_status, sanitized_username) { | 55 ACTION_P2(SendSanitizedUsername, call_status, sanitized_username) { |
| 53 base::MessageLoop::current()->PostTask( | 56 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 54 FROM_HERE, base::Bind(arg1, call_status, sanitized_username)); | 57 FROM_HERE, base::Bind(arg1, call_status, sanitized_username)); |
| 55 } | 58 } |
| 56 | 59 |
| 57 class UserCloudPolicyStoreChromeOSTest : public testing::Test { | 60 class UserCloudPolicyStoreChromeOSTest : public testing::Test { |
| 58 protected: | 61 protected: |
| 59 UserCloudPolicyStoreChromeOSTest() {} | 62 UserCloudPolicyStoreChromeOSTest() {} |
| 60 | 63 |
| 61 void SetUp() override { | 64 void SetUp() override { |
| 62 EXPECT_CALL(cryptohome_client_, GetSanitizedUsername(cryptohome_id_, _)) | 65 EXPECT_CALL(cryptohome_client_, GetSanitizedUsername(cryptohome_id_, _)) |
| 63 .Times(AnyNumber()) | 66 .Times(AnyNumber()) |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 Mock::VerifyAndClearExpectations(&cryptohome_client_); | 666 Mock::VerifyAndClearExpectations(&cryptohome_client_); |
| 664 | 667 |
| 665 EXPECT_FALSE(store_->policy()); | 668 EXPECT_FALSE(store_->policy()); |
| 666 EXPECT_TRUE(store_->policy_map().empty()); | 669 EXPECT_TRUE(store_->policy_map().empty()); |
| 667 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); | 670 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); |
| 668 } | 671 } |
| 669 | 672 |
| 670 } // namespace | 673 } // namespace |
| 671 | 674 |
| 672 } // namespace policy | 675 } // namespace policy |
| OLD | NEW |