Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: chrome/browser/chromeos/login/owner_manager_unittest.h

Issue 7034003: cros: Slightly more mock out-of-lining. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_
7 7
8 #include "chrome/browser/chromeos/login/owner_manager.h" 8 #include "chrome/browser/chromeos/login/owner_manager.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 21 matching lines...) Expand all
32 this, 32 this,
33 NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED, 33 NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED,
34 NotificationService::AllSources()); 34 NotificationService::AllSources());
35 registrar_.Add( 35 registrar_.Add(
36 this, 36 this,
37 NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 37 NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
38 NotificationService::AllSources()); 38 NotificationService::AllSources());
39 } 39 }
40 40
41 virtual ~MockKeyLoadObserver() { 41 virtual ~MockKeyLoadObserver() {
42 EXPECT_TRUE(observed_); 42 DCHECK(observed_);
43 } 43 }
44 44
45 // NotificationObserver implementation. 45 // NotificationObserver implementation.
46 virtual void Observe(NotificationType type, 46 virtual void Observe(NotificationType type,
47 const NotificationSource& source, 47 const NotificationSource& source,
48 const NotificationDetails& details) { 48 const NotificationDetails& details);
49 LOG(INFO) << "Observed key fetch event";
50 if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) {
51 EXPECT_TRUE(success_expected_);
52 observed_ = true;
53 if (quit_on_observe_)
54 MessageLoop::current()->Quit();
55 } else if (type == NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED) {
56 EXPECT_FALSE(success_expected_);
57 observed_ = true;
58 if (quit_on_observe_)
59 MessageLoop::current()->Quit();
60 }
61 }
62 49
63 void ExpectKeyFetchSuccess(bool should_succeed) { 50 void ExpectKeyFetchSuccess(bool should_succeed) {
64 success_expected_ = should_succeed; 51 success_expected_ = should_succeed;
65 } 52 }
66 53
67 void SetQuitOnKeyFetch(bool should_quit) { quit_on_observe_ = should_quit; } 54 void SetQuitOnKeyFetch(bool should_quit) { quit_on_observe_ = should_quit; }
68 55
69 private: 56 private:
70 NotificationRegistrar registrar_; 57 NotificationRegistrar registrar_;
71 bool success_expected_; 58 bool success_expected_;
72 bool quit_on_observe_; 59 bool quit_on_observe_;
73 bool observed_; 60 bool observed_;
74 DISALLOW_COPY_AND_ASSIGN(MockKeyLoadObserver); 61 DISALLOW_COPY_AND_ASSIGN(MockKeyLoadObserver);
75 }; 62 };
76 63
77 class MockKeyUser : public OwnerManager::Delegate { 64 class MockKeyUser : public OwnerManager::Delegate {
78 public: 65 public:
79 explicit MockKeyUser(const OwnerManager::KeyOpCode expected) 66 explicit MockKeyUser(const OwnerManager::KeyOpCode expected)
80 : expected_(expected), 67 : expected_(expected),
81 quit_on_callback_(true) { 68 quit_on_callback_(true) {
82 } 69 }
83 MockKeyUser(const OwnerManager::KeyOpCode expected, bool quit_on_callback) 70 MockKeyUser(const OwnerManager::KeyOpCode expected, bool quit_on_callback)
84 : expected_(expected), 71 : expected_(expected),
85 quit_on_callback_(quit_on_callback) { 72 quit_on_callback_(quit_on_callback) {
86 } 73 }
87 74
88 virtual ~MockKeyUser() {} 75 virtual ~MockKeyUser() {}
89 76
90 void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, 77 virtual void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
91 const std::vector<uint8>& payload) { 78 const std::vector<uint8>& payload);
92 EXPECT_EQ(expected_, return_code);
93 if (quit_on_callback_)
94 MessageLoop::current()->Quit();
95 }
96 79
97 const OwnerManager::KeyOpCode expected_; 80 const OwnerManager::KeyOpCode expected_;
98 const bool quit_on_callback_; 81 const bool quit_on_callback_;
99 private: 82 private:
100 DISALLOW_COPY_AND_ASSIGN(MockKeyUser); 83 DISALLOW_COPY_AND_ASSIGN(MockKeyUser);
101 }; 84 };
102 85
103 class MockKeyUpdateUser : public OwnerManager::KeyUpdateDelegate { 86 class MockKeyUpdateUser : public OwnerManager::KeyUpdateDelegate {
104 public: 87 public:
105 MockKeyUpdateUser() {} 88 MockKeyUpdateUser() {}
(...skipping 29 matching lines...) Expand all
135 const OwnerManager::KeyOpCode expected_code_; 118 const OwnerManager::KeyOpCode expected_code_;
136 const std::vector<uint8> expected_sig_; 119 const std::vector<uint8> expected_sig_;
137 120
138 private: 121 private:
139 DISALLOW_COPY_AND_ASSIGN(MockSigner); 122 DISALLOW_COPY_AND_ASSIGN(MockSigner);
140 }; 123 };
141 124
142 } // namespace chromeos 125 } // namespace chromeos
143 126
144 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_ 127 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_UNITTEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/mock_owner_key_utils.cc ('k') | chrome/browser/chromeos/login/owner_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698