| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login/signed_settings.h" | 5 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/nss_util.h" | 9 #include "base/nss_util.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 using ::testing::_; | 26 using ::testing::_; |
| 27 | 27 |
| 28 namespace chromeos { | 28 namespace chromeos { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 template <class T> | 31 template <class T> |
| 32 class DummyDelegate : public SignedSettings::Delegate<T> { | 32 class DummyDelegate : public SignedSettings::Delegate<T> { |
| 33 public: | 33 public: |
| 34 explicit DummyDelegate(T to_expect) | 34 explicit DummyDelegate(T to_expect) |
| 35 : expect_success_(false), | 35 : expect_success_(false), |
| 36 expected_failure_(SignedSettings::NOT_FOUND), | 36 expected_failure_(SignedSettings::SUCCESS), |
| 37 expected_(to_expect), | 37 expected_(to_expect), |
| 38 run_(false) {} | 38 run_(false) {} |
| 39 virtual ~DummyDelegate() { EXPECT_TRUE(run_); } | 39 virtual ~DummyDelegate() { EXPECT_TRUE(run_); } |
| 40 virtual void OnSettingsOpSucceeded(T value) { | 40 virtual void OnSettingsOpCompleted(SignedSettings::ReturnCode code, |
| 41 T value) { |
| 41 run_ = true; | 42 run_ = true; |
| 42 EXPECT_TRUE(expect_success_); | 43 if (expect_success_) |
| 43 EXPECT_EQ(expected_, value); | 44 EXPECT_EQ(expected_, value); |
| 44 } | |
| 45 virtual void OnSettingsOpFailed(SignedSettings::FailureCode code) { | |
| 46 run_ = true; | |
| 47 EXPECT_FALSE(expect_success_); | |
| 48 EXPECT_EQ(expected_failure_, code); | 45 EXPECT_EQ(expected_failure_, code); |
| 49 } | 46 } |
| 50 virtual void expect_success() { expect_success_ = true; } | 47 virtual void expect_success() { |
| 51 virtual void expect_failure(SignedSettings::FailureCode code) { | 48 expect_success_ = true; |
| 49 expected_failure_ = SignedSettings::SUCCESS; |
| 50 } |
| 51 virtual void expect_failure(SignedSettings::ReturnCode code) { |
| 52 expect_success_ = false; |
| 52 expected_failure_ = code; | 53 expected_failure_ = code; |
| 53 } | 54 } |
| 54 bool expect_success_; | 55 bool expect_success_; |
| 55 SignedSettings::FailureCode expected_failure_; | 56 SignedSettings::ReturnCode expected_failure_; |
| 56 T expected_; | 57 T expected_; |
| 57 bool run_; | 58 bool run_; |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 } // anonymous namespace | 61 } // anonymous namespace |
| 61 | 62 |
| 62 class SignedSettingsTest : public ::testing::Test { | 63 class SignedSettingsTest : public ::testing::Test { |
| 63 public: | 64 public: |
| 64 SignedSettingsTest() | 65 SignedSettingsTest() |
| 65 : fake_email_("fakey"), | 66 : fake_email_("fakey"), |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 334 |
| 334 TEST_F(SignedSettingsTest, RetrievePropertyNoKey) { | 335 TEST_F(SignedSettingsTest, RetrievePropertyNoKey) { |
| 335 FailingRetrievePropertyOp(OwnerManager::KEY_UNAVAILABLE); | 336 FailingRetrievePropertyOp(OwnerManager::KEY_UNAVAILABLE); |
| 336 } | 337 } |
| 337 | 338 |
| 338 TEST_F(SignedSettingsTest, RetrievePropertyFailed) { | 339 TEST_F(SignedSettingsTest, RetrievePropertyFailed) { |
| 339 FailingRetrievePropertyOp(OwnerManager::OPERATION_FAILED); | 340 FailingRetrievePropertyOp(OwnerManager::OPERATION_FAILED); |
| 340 } | 341 } |
| 341 | 342 |
| 342 } // namespace chromeos | 343 } // namespace chromeos |
| OLD | NEW |