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

Unified Diff: mock_nss_util.h

Issue 6820024: [login_manager] Fix race condition that caused ownership to never work (Closed) Base URL: http://git.chromium.org/git/login_manager.git@master
Patch Set: comment update Created 9 years, 8 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 | nss_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mock_nss_util.h
diff --git a/mock_nss_util.h b/mock_nss_util.h
index c958ec2b702bdd29163cf5132b68b5a9ed30064e..b3de13f1a4f8f80469fc78b493be1d539ac6e571 100644
--- a/mock_nss_util.h
+++ b/mock_nss_util.h
@@ -26,6 +26,7 @@ class MockNssUtil : public NssUtil {
MockNssUtil() {}
virtual ~MockNssUtil() {}
+ MOCK_METHOD0(MightHaveKeys, bool());
MOCK_METHOD0(OpenUserDB, bool());
MOCK_METHOD1(GetPrivateKey, base::RSAPrivateKey*(const std::vector<uint8>&));
MOCK_METHOD0(GenerateKeyPair, base::RSAPrivateKey*());
@@ -39,8 +40,7 @@ class MockNssUtil : public NssUtil {
base::RSAPrivateKey* key));
protected:
void ExpectGetOwnerKeyFilePath() {
- EXPECT_CALL(*this, GetOwnerKeyFilePath())
- .WillOnce(Return(FilePath("")));
+ EXPECT_CALL(*this, GetOwnerKeyFilePath()).WillOnce(Return(FilePath("")));
}
};
@@ -60,8 +60,8 @@ class KeyCheckUtil : public MockNssUtil {
public:
KeyCheckUtil() {
ExpectGetOwnerKeyFilePath();
- EXPECT_CALL(*this, OpenUserDB())
- .WillOnce(Return(true));
+ EXPECT_CALL(*this, MightHaveKeys()).WillOnce(Return(true));
+ EXPECT_CALL(*this, OpenUserDB()).WillOnce(Return(true));
EXPECT_CALL(*this, GetPrivateKey(_))
.WillOnce(Return(reinterpret_cast<base::RSAPrivateKey*>(7)));
}
@@ -72,8 +72,8 @@ class KeyFailUtil : public MockNssUtil {
public:
KeyFailUtil() {
ExpectGetOwnerKeyFilePath();
- EXPECT_CALL(*this, OpenUserDB())
- .WillOnce(Return(true));
+ EXPECT_CALL(*this, MightHaveKeys()).WillOnce(Return(true));
+ EXPECT_CALL(*this, OpenUserDB()).WillOnce(Return(true));
EXPECT_CALL(*this, GetPrivateKey(_))
.WillOnce(Return(reinterpret_cast<base::RSAPrivateKey*>(NULL)));
}
@@ -84,19 +84,27 @@ class SadNssUtil : public MockNssUtil {
public:
SadNssUtil() {
ExpectGetOwnerKeyFilePath();
- EXPECT_CALL(*this, OpenUserDB())
- .WillOnce(Return(false));
+ EXPECT_CALL(*this, MightHaveKeys()).WillOnce(Return(true));
+ EXPECT_CALL(*this, OpenUserDB()).WillOnce(Return(false));
}
virtual ~SadNssUtil() {}
};
+class EmptyNssUtil : public MockNssUtil {
+ public:
+ EmptyNssUtil() {
+ ExpectGetOwnerKeyFilePath();
+ EXPECT_CALL(*this, MightHaveKeys()).WillOnce(Return(false));
+ }
+ virtual ~EmptyNssUtil() {}
+};
+
class ShortKeyGenerator : public MockNssUtil {
public:
ShortKeyGenerator() {
base::EnsureNSSInit();
base::OpenPersistentNSSDB();
- ON_CALL(*this, GenerateKeyPair())
- .WillByDefault(Invoke(CreateFake));
+ ON_CALL(*this, GenerateKeyPair()).WillByDefault(Invoke(CreateFake));
}
virtual ~ShortKeyGenerator() {}
@@ -111,10 +119,9 @@ class ShortKeyUtil : public ShortKeyGenerator {
public:
ShortKeyUtil() {
ExpectGetOwnerKeyFilePath();
- EXPECT_CALL(*this, OpenUserDB())
- .WillOnce(Return(true));
- EXPECT_CALL(*this, GenerateKeyPair())
- .Times(1);
+ EXPECT_CALL(*this, MightHaveKeys()).WillOnce(Return(true));
+ EXPECT_CALL(*this, OpenUserDB()).WillOnce(Return(true));
+ EXPECT_CALL(*this, GenerateKeyPair()).Times(1);
}
virtual ~ShortKeyUtil() {}
};
« no previous file with comments | « no previous file | nss_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698