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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "chrome/browser/chromeos/login/mock_owner_key_utils.h" | 14 #include "chrome/browser/chromeos/login/mock_owner_key_utils.h" |
| 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
16 #include "crypto/nss_util.h" | 17 #include "crypto/nss_util.h" |
17 #include "crypto/rsa_private_key.h" | 18 #include "crypto/rsa_private_key.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 using ::crypto::RSAPrivateKey; | 22 using ::crypto::RSAPrivateKey; |
22 using ::testing::DoAll; | 23 using ::testing::DoAll; |
23 using ::testing::Eq; | 24 using ::testing::Eq; |
24 using ::testing::Invoke; | 25 using ::testing::Invoke; |
25 using ::testing::Return; | 26 using ::testing::Return; |
26 using ::testing::SetArgumentPointee; | 27 using ::testing::SetArgumentPointee; |
27 using ::testing::_; | 28 using ::testing::_; |
28 | 29 |
29 namespace chromeos { | 30 namespace chromeos { |
30 | 31 |
31 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
32 // MockKeyLoadObserver | 33 // MockKeyLoadObserver |
33 MockKeyLoadObserver::MockKeyLoadObserver(base::WaitableEvent* e) | 34 MockKeyLoadObserver::MockKeyLoadObserver(base::WaitableEvent* e) |
34 : success_expected_(false), | 35 : success_expected_(false), |
35 event_(e), | 36 event_(e), |
36 observed_(false) { | 37 observed_(false) { |
37 registrar_.Add( | 38 registrar_.Add( |
38 this, | 39 this, |
39 NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED, | 40 chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_FAILED, |
40 NotificationService::AllSources()); | 41 NotificationService::AllSources()); |
41 registrar_.Add( | 42 registrar_.Add( |
42 this, | 43 this, |
43 NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, | 44 chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, |
44 NotificationService::AllSources()); | 45 NotificationService::AllSources()); |
45 } | 46 } |
46 | 47 |
47 MockKeyLoadObserver::~MockKeyLoadObserver() { | 48 MockKeyLoadObserver::~MockKeyLoadObserver() { |
48 DCHECK(observed_); | 49 DCHECK(observed_); |
49 } | 50 } |
50 | 51 |
51 void MockKeyLoadObserver::Observe(NotificationType type, | 52 void MockKeyLoadObserver::Observe(int type, |
52 const NotificationSource& source, | 53 const NotificationSource& source, |
53 const NotificationDetails& details) { | 54 const NotificationDetails& details) { |
54 LOG(INFO) << "Observed key fetch event"; | 55 LOG(INFO) << "Observed key fetch event"; |
55 if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { | 56 if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { |
56 DCHECK(success_expected_); | 57 DCHECK(success_expected_); |
57 observed_ = true; | 58 observed_ = true; |
58 if (event_) | 59 if (event_) |
59 event_->Signal(); | 60 event_->Signal(); |
60 } else if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED) { | 61 } else if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_FAILED) { |
61 DCHECK(!success_expected_); | 62 DCHECK(!success_expected_); |
62 observed_ = true; | 63 observed_ = true; |
63 if (event_) | 64 if (event_) |
64 event_->Signal(); | 65 event_->Signal(); |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
68 void MockKeyLoadObserver::ExpectKeyFetchSuccess(bool should_succeed) { | 69 void MockKeyLoadObserver::ExpectKeyFetchSuccess(bool should_succeed) { |
69 success_expected_ = should_succeed; | 70 success_expected_ = should_succeed; |
70 } | 71 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 NewRunnableMethod(manager.get(), | 355 NewRunnableMethod(manager.get(), |
355 &OwnerManager::Sign, | 356 &OwnerManager::Sign, |
356 BrowserThread::UI, | 357 BrowserThread::UI, |
357 data, | 358 data, |
358 &delegate)); | 359 &delegate)); |
359 while (!event.IsSignaled()) | 360 while (!event.IsSignaled()) |
360 message_loop_.RunAllPending(); | 361 message_loop_.RunAllPending(); |
361 } | 362 } |
362 | 363 |
363 } // namespace chromeos | 364 } // namespace chromeos |
OLD | NEW |