| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/owner_manager.h" | 5 #include "chrome/browser/chromeos/login/owner_manager.h" |
| 6 #include "chrome/browser/chromeos/login/owner_manager_unittest.h" | 6 #include "chrome/browser/chromeos/login/owner_manager_unittest.h" |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 using ::crypto::RSAPrivateKey; | 21 using ::crypto::RSAPrivateKey; |
| 22 using ::testing::DoAll; | 22 using ::testing::DoAll; |
| 23 using ::testing::Eq; | 23 using ::testing::Eq; |
| 24 using ::testing::Invoke; | 24 using ::testing::Invoke; |
| 25 using ::testing::Return; | 25 using ::testing::Return; |
| 26 using ::testing::SetArgumentPointee; | 26 using ::testing::SetArgumentPointee; |
| 27 using ::testing::_; | 27 using ::testing::_; |
| 28 | 28 |
| 29 namespace chromeos { | 29 namespace chromeos { |
| 30 | 30 |
| 31 |
| 32 void MockKeyLoadObserver::Observe(NotificationType type, |
| 33 const NotificationSource& source, |
| 34 const NotificationDetails& details) { |
| 35 LOG(INFO) << "Observed key fetch event"; |
| 36 if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { |
| 37 EXPECT_TRUE(success_expected_); |
| 38 observed_ = true; |
| 39 if (quit_on_observe_) |
| 40 MessageLoop::current()->Quit(); |
| 41 } else if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED) { |
| 42 EXPECT_FALSE(success_expected_); |
| 43 observed_ = true; |
| 44 if (quit_on_observe_) |
| 45 MessageLoop::current()->Quit(); |
| 46 } |
| 47 } |
| 48 |
| 49 void MockKeyUser::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, |
| 50 const std::vector<uint8>& payload) { |
| 51 EXPECT_EQ(expected_, return_code); |
| 52 if (quit_on_callback_) |
| 53 MessageLoop::current()->Quit(); |
| 54 } |
| 55 |
| 56 |
| 31 class OwnerManagerTest : public ::testing::Test { | 57 class OwnerManagerTest : public ::testing::Test { |
| 32 public: | 58 public: |
| 33 OwnerManagerTest() | 59 OwnerManagerTest() |
| 34 : message_loop_(MessageLoop::TYPE_UI), | 60 : message_loop_(MessageLoop::TYPE_UI), |
| 35 ui_thread_(BrowserThread::UI, &message_loop_), | 61 ui_thread_(BrowserThread::UI, &message_loop_), |
| 36 file_thread_(BrowserThread::FILE), | 62 file_thread_(BrowserThread::FILE), |
| 37 mock_(new MockKeyUtils), | 63 mock_(new MockKeyUtils), |
| 38 injector_(mock_) /* injector_ takes ownership of mock_ */ { | 64 injector_(mock_) /* injector_ takes ownership of mock_ */ { |
| 39 } | 65 } |
| 40 virtual ~OwnerManagerTest() {} | 66 virtual ~OwnerManagerTest() {} |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 BrowserThread::FILE, FROM_HERE, | 279 BrowserThread::FILE, FROM_HERE, |
| 254 NewRunnableMethod(manager.get(), | 280 NewRunnableMethod(manager.get(), |
| 255 &OwnerManager::Sign, | 281 &OwnerManager::Sign, |
| 256 BrowserThread::UI, | 282 BrowserThread::UI, |
| 257 data, | 283 data, |
| 258 &delegate)); | 284 &delegate)); |
| 259 message_loop_.Run(); | 285 message_loop_.Run(); |
| 260 } | 286 } |
| 261 | 287 |
| 262 } // namespace chromeos | 288 } // namespace chromeos |
| OLD | NEW |