OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_ | |
7 | |
8 #include "chrome/browser/chromeos/login/owner_manager.h" | |
9 | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/compiler_specific.h" | |
14 #include "base/file_path.h" | |
15 #include "base/file_util.h" | |
16 #include "base/logging.h" | |
17 #include "base/synchronization/waitable_event.h" | |
18 #include "content/public/browser/notification_observer.h" | |
19 #include "content/public/browser/notification_registrar.h" | |
20 #include "content/public/browser/notification_types.h" | |
21 #include "testing/gmock/include/gmock/gmock.h" | |
22 #include "testing/gtest/include/gtest/gtest.h" | |
23 | |
24 | |
25 namespace chromeos { | |
26 class MockKeyLoadObserver : public content::NotificationObserver { | |
27 public: | |
28 explicit MockKeyLoadObserver(base::WaitableEvent* e); | |
29 virtual ~MockKeyLoadObserver(); | |
30 | |
31 // content::NotificationObserver implementation. | |
32 virtual void Observe(int type, | |
33 const content::NotificationSource& source, | |
34 const content::NotificationDetails& details) OVERRIDE; | |
35 | |
36 void ExpectKeyFetchSuccess(bool should_succeed); | |
37 | |
38 private: | |
39 content::NotificationRegistrar registrar_; | |
40 bool success_expected_; | |
41 base::WaitableEvent* event_; | |
42 bool observed_; | |
43 DISALLOW_COPY_AND_ASSIGN(MockKeyLoadObserver); | |
44 }; | |
45 | |
46 class MockKeyUser : public OwnerManager::Delegate { | |
47 public: | |
48 MockKeyUser(const OwnerManager::KeyOpCode expected, base::WaitableEvent* e); | |
49 virtual ~MockKeyUser() {} | |
50 | |
51 virtual void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, | |
52 const std::vector<uint8>& payload) OVERRIDE; | |
53 | |
54 const OwnerManager::KeyOpCode expected_; | |
55 private: | |
56 base::WaitableEvent* event_; | |
57 DISALLOW_COPY_AND_ASSIGN(MockKeyUser); | |
58 }; | |
59 | |
60 class MockKeyUpdateUser : public OwnerManager::KeyUpdateDelegate { | |
61 public: | |
62 explicit MockKeyUpdateUser(base::WaitableEvent* e) : event_(e) {} | |
63 virtual ~MockKeyUpdateUser() {} | |
64 | |
65 virtual void OnKeyUpdated() OVERRIDE; | |
66 | |
67 private: | |
68 base::WaitableEvent* event_; | |
69 DISALLOW_COPY_AND_ASSIGN(MockKeyUpdateUser); | |
70 }; | |
71 | |
72 | |
73 class MockSigner : public OwnerManager::Delegate { | |
74 public: | |
75 MockSigner(const OwnerManager::KeyOpCode expected, | |
76 const std::vector<uint8>& sig, | |
77 base::WaitableEvent* e); | |
78 virtual ~MockSigner(); | |
79 | |
80 virtual void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, | |
81 const std::vector<uint8>& payload) OVERRIDE; | |
82 | |
83 const OwnerManager::KeyOpCode expected_code_; | |
84 const std::vector<uint8> expected_sig_; | |
85 | |
86 private: | |
87 base::WaitableEvent* event_; | |
88 DISALLOW_COPY_AND_ASSIGN(MockSigner); | |
89 }; | |
90 | |
91 } // namespace chromeos | |
92 | |
93 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_ | |
OLD | NEW |