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

Unified Diff: chrome/browser/chromeos/cros/mock_cryptohome_library.h

Issue 3407008: [Chrome OS] Infrastucture for doing offline/online login simultaneously (Closed)
Patch Set: re-upload (again) due to 500s Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/auth_attempt_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/mock_cryptohome_library.h
diff --git a/chrome/browser/chromeos/cros/mock_cryptohome_library.h b/chrome/browser/chromeos/cros/mock_cryptohome_library.h
index 1b510a6cbea8b47e0db154630347f11c6888bdd2..808db1bac23dd2e087c93a222b2ce968e4ccc0f5 100644
--- a/chrome/browser/chromeos/cros/mock_cryptohome_library.h
+++ b/chrome/browser/chromeos/cros/mock_cryptohome_library.h
@@ -11,11 +11,25 @@
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
#include "testing/gmock/include/gmock/gmock.h"
+using ::testing::Invoke;
+using ::testing::_;
+
namespace chromeos {
class MockCryptohomeLibrary : public CryptohomeLibrary {
public:
- MockCryptohomeLibrary() {}
+ MockCryptohomeLibrary() {
+ ON_CALL(*this, AsyncCheckKey(_, _, _))
+ .WillByDefault(Invoke(this, &MockCryptohomeLibrary::TwoString));
+ ON_CALL(*this, AsyncMigrateKey(_, _, _, _))
+ .WillByDefault(Invoke(this, &MockCryptohomeLibrary::ThreeString));
+ ON_CALL(*this, AsyncMount(_, _, _))
+ .WillByDefault(Invoke(this, &MockCryptohomeLibrary::TwoString));
+ ON_CALL(*this, AsyncMountForBwsi(_))
+ .WillByDefault(Invoke(this, &MockCryptohomeLibrary::ZeroString));
+ ON_CALL(*this, AsyncRemove(_, _))
+ .WillByDefault(Invoke(this, &MockCryptohomeLibrary::OneString));
+ }
virtual ~MockCryptohomeLibrary() {}
MOCK_METHOD2(CheckKey, bool(const std::string& user_email,
const std::string& passhash));
@@ -41,6 +55,41 @@ class MockCryptohomeLibrary : public CryptohomeLibrary {
MOCK_METHOD2(AsyncRemove, bool(const std::string& user_email, Delegate* d));
MOCK_METHOD0(IsMounted, bool(void));
MOCK_METHOD0(GetSystemSalt, CryptohomeBlob(void));
+
+ void SetAsyncBehavior(bool outcome, int code) {
+ outcome_ = outcome;
+ code_ = code;
+ }
+
+ bool ThreeString(const std::string& user_email,
+ const std::string& old_hash,
+ const std::string& new_hash,
+ Delegate* d) {
+ d->OnComplete(outcome_, code_);
+ return true;
+ }
+
+ bool TwoString(const std::string& user_email,
+ const std::string& passhash,
+ Delegate* d) {
+ d->OnComplete(outcome_, code_);
+ return true;
+ }
+
+ bool OneString(const std::string& user_email, Delegate* d) {
+ d->OnComplete(outcome_, code_);
+ return true;
+ }
+
+ bool ZeroString(Delegate* d) {
+ d->OnComplete(outcome_, code_);
+ return true;
+ }
+
+ private:
+ bool outcome_;
+ int code_;
+ DISALLOW_COPY_AND_ASSIGN(MockCryptohomeLibrary);
};
} // namespace chromeos
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/auth_attempt_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698