| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 using testing::_; | 32 using testing::_; |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| 35 | 35 |
| 36 class SessionManagerOperationTest : public testing::Test { | 36 class SessionManagerOperationTest : public testing::Test { |
| 37 public: | 37 public: |
| 38 SessionManagerOperationTest() | 38 SessionManagerOperationTest() |
| 39 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 39 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 40 file_thread_(content::BrowserThread::FILE, &message_loop_), | 40 file_thread_(content::BrowserThread::FILE, &message_loop_), |
| 41 owner_key_util_(new ownership::MockOwnerKeyUtil()), | 41 owner_key_util_(new ownership::MockOwnerKeyUtil()), |
| 42 validated_(false) {} | 42 validated_(false) { |
| 43 OwnerSettingsServiceFactory::GetInstance()->SetOwnerKeyUtilForTesting( |
| 44 owner_key_util_); |
| 45 } |
| 43 | 46 |
| 44 virtual void SetUp() OVERRIDE { | 47 virtual void SetUp() OVERRIDE { |
| 45 policy_.payload().mutable_pinned_apps()->add_app_id("fake-app"); | 48 policy_.payload().mutable_pinned_apps()->add_app_id("fake-app"); |
| 46 policy_.Build(); | 49 policy_.Build(); |
| 47 | 50 |
| 48 profile_.reset(new TestingProfile()); | 51 profile_.reset(new TestingProfile()); |
| 49 OwnerSettingsService::SetOwnerKeyUtilForTesting(owner_key_util_); | |
| 50 service_ = OwnerSettingsServiceFactory::GetForProfile(profile_.get()); | 52 service_ = OwnerSettingsServiceFactory::GetForProfile(profile_.get()); |
| 51 } | 53 } |
| 52 | 54 |
| 53 void TearDown() { OwnerSettingsService::SetOwnerKeyUtilForTesting(NULL); } | |
| 54 | |
| 55 MOCK_METHOD2(OnOperationCompleted, | 55 MOCK_METHOD2(OnOperationCompleted, |
| 56 void(SessionManagerOperation*, DeviceSettingsService::Status)); | 56 void(SessionManagerOperation*, DeviceSettingsService::Status)); |
| 57 | 57 |
| 58 void CheckSuccessfulValidation( | 58 void CheckSuccessfulValidation( |
| 59 policy::DeviceCloudPolicyValidator* validator) { | 59 policy::DeviceCloudPolicyValidator* validator) { |
| 60 EXPECT_TRUE(validator->success()); | 60 EXPECT_TRUE(validator->success()); |
| 61 EXPECT_TRUE(validator->payload().get()); | 61 EXPECT_TRUE(validator->payload().get()); |
| 62 EXPECT_EQ(validator->payload()->SerializeAsString(), | 62 EXPECT_EQ(validator->payload()->SerializeAsString(), |
| 63 policy_.payload().SerializeAsString()); | 63 policy_.payload().SerializeAsString()); |
| 64 validated_ = true; | 64 validated_ = true; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 message_loop_.RunUntilIdle(); | 266 message_loop_.RunUntilIdle(); |
| 267 EXPECT_TRUE(validated_); | 267 EXPECT_TRUE(validated_); |
| 268 | 268 |
| 269 // Loaded device settings should match what the operation received. | 269 // Loaded device settings should match what the operation received. |
| 270 ASSERT_TRUE(op.device_settings().get()); | 270 ASSERT_TRUE(op.device_settings().get()); |
| 271 EXPECT_EQ(policy_.payload().SerializeAsString(), | 271 EXPECT_EQ(policy_.payload().SerializeAsString(), |
| 272 op.device_settings()->SerializeAsString()); | 272 op.device_settings()->SerializeAsString()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace chromeos | 275 } // namespace chromeos |
| OLD | NEW |