| 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/settings/session_manager_operation.h" | 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 #include <vector> |
| 9 |
| 7 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 11 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 13 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 14 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" | 17 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" |
| 15 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" | 18 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" |
| 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 19 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 20 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 19 #include "components/ownership/mock_owner_key_util.h" | 22 #include "components/ownership/mock_owner_key_util.h" |
| 20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 23 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 21 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 24 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 22 #include "components/policy/core/common/cloud/policy_builder.h" | 25 #include "components/policy/core/common/cloud/policy_builder.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 27 #include "content/public/test/test_utils.h" |
| 24 #include "crypto/rsa_private_key.h" | 28 #include "crypto/rsa_private_key.h" |
| 25 #include "policy/proto/device_management_backend.pb.h" | 29 #include "policy/proto/device_management_backend.pb.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 32 |
| 29 namespace em = enterprise_management; | 33 namespace em = enterprise_management; |
| 30 | 34 |
| 31 using testing::Mock; | 35 using testing::Mock; |
| 32 using testing::_; | 36 using testing::_; |
| 33 | 37 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 152 |
| 149 TEST_F(SessionManagerOperationTest, RestartLoad) { | 153 TEST_F(SessionManagerOperationTest, RestartLoad) { |
| 150 owner_key_util_->SetPrivateKey(policy_.GetSigningKey()); | 154 owner_key_util_->SetPrivateKey(policy_.GetSigningKey()); |
| 151 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); | 155 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); |
| 152 LoadSettingsOperation op( | 156 LoadSettingsOperation op( |
| 153 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, | 157 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, |
| 154 base::Unretained(this))); | 158 base::Unretained(this))); |
| 155 | 159 |
| 156 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0); | 160 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0); |
| 157 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); | 161 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); |
| 158 device_settings_test_helper_.FlushLoops(); | 162 content::RunAllBlockingPoolTasksUntilIdle(); |
| 159 device_settings_test_helper_.FlushRetrieve(); | 163 device_settings_test_helper_.FlushRetrieve(); |
| 160 EXPECT_TRUE(op.public_key().get()); | 164 EXPECT_TRUE(op.public_key().get()); |
| 161 EXPECT_TRUE(op.public_key()->is_loaded()); | 165 EXPECT_TRUE(op.public_key()->is_loaded()); |
| 162 Mock::VerifyAndClearExpectations(this); | 166 Mock::VerifyAndClearExpectations(this); |
| 163 | 167 |
| 164 // Now install a different key and policy and restart the operation. | 168 // Now install a different key and policy and restart the operation. |
| 165 policy_.SetSigningKey(*policy::PolicyBuilder::CreateTestOtherSigningKey()); | 169 policy_.SetSigningKey(*policy::PolicyBuilder::CreateTestOtherSigningKey()); |
| 166 policy_.payload().mutable_metrics_enabled()->set_metrics_enabled(true); | 170 policy_.payload().mutable_metrics_enabled()->set_metrics_enabled(true); |
| 167 policy_.Build(); | 171 policy_.Build(); |
| 168 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); | 172 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 message_loop_.RunUntilIdle(); | 270 message_loop_.RunUntilIdle(); |
| 267 EXPECT_TRUE(validated_); | 271 EXPECT_TRUE(validated_); |
| 268 | 272 |
| 269 // Loaded device settings should match what the operation received. | 273 // Loaded device settings should match what the operation received. |
| 270 ASSERT_TRUE(op.device_settings().get()); | 274 ASSERT_TRUE(op.device_settings().get()); |
| 271 EXPECT_EQ(policy_.payload().SerializeAsString(), | 275 EXPECT_EQ(policy_.payload().SerializeAsString(), |
| 272 op.device_settings()->SerializeAsString()); | 276 op.device_settings()->SerializeAsString()); |
| 273 } | 277 } |
| 274 | 278 |
| 275 } // namespace chromeos | 279 } // namespace chromeos |
| OLD | NEW |