summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-11 14:44:30 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-11 14:44:30 +0000
commit82c28a0791b71fc8514f23c70f1f2185e73452fe (patch)
tree3750d8784f3d2056e3294528ba92e654a80fcfdb
parent0fd736799a66a7f8ccfd2f40753638a34921b1ec (diff)
downloadchromium_src-82c28a0791b71fc8514f23c70f1f2185e73452fe.zip
chromium_src-82c28a0791b71fc8514f23c70f1f2185e73452fe.tar.gz
chromium_src-82c28a0791b71fc8514f23c70f1f2185e73452fe.tar.bz2
Explicitly create the TestAttemptState if it's needed.
The ownership if this state is transferred to the parallel authenticator, but only in some tests. It's therefore not deleted in the TearDown method, so it also shouldn't be created in the SetUp method. BUG=none TEST=leak #FFFFFFFFA994B305# goes away TBR=cmasone@chromium.org Review URL: http://codereview.chromium.org/3673003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62143 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/parallel_authenticator_unittest.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
index 18e0e35..a3de926 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
@@ -73,7 +73,6 @@ class ParallelAuthenticatorTest : public ::testing::Test {
io_thread_.Start();
auth_ = new ParallelAuthenticator(&consumer_);
- state_ = new TestAttemptState(username_, "", hash_ascii_, "", "");
}
// Tears down the test fixture.
@@ -85,6 +84,10 @@ class ParallelAuthenticatorTest : public ::testing::Test {
test_api->SetCryptohomeLibrary(NULL, false);
}
+ void CreateAttemptState() {
+ state_ = new TestAttemptState(username_, "", hash_ascii_, "", "");
+ }
+
FilePath PopulateTempFile(const char* data, int data_len) {
FilePath out;
FILE* tmp_file = CreateAndOpenTemporaryFile(&out);
@@ -248,6 +251,7 @@ TEST_F(ParallelAuthenticatorTest, OnLoginSuccess) {
.Times(1)
.RetiresOnSaturation();
+ CreateAttemptState();
SetAttemptState(auth_, state_);
auth_->OnLoginSuccess(result_, false);
}
@@ -256,11 +260,13 @@ TEST_F(ParallelAuthenticatorTest, OnPasswordChangeDetected) {
EXPECT_CALL(consumer_, OnPasswordChangeDetected(result_))
.Times(1)
.RetiresOnSaturation();
+ CreateAttemptState();
SetAttemptState(auth_, state_);
auth_->OnPasswordChangeDetected(result_);
}
TEST_F(ParallelAuthenticatorTest, ResolveNothingDone) {
+ CreateAttemptState();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableFunction(&ParallelAuthenticatorTest::CheckResolve,
@@ -272,6 +278,7 @@ TEST_F(ParallelAuthenticatorTest, ResolveNothingDone) {
TEST_F(ParallelAuthenticatorTest, ResolvePossiblePwChange) {
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(false,
chromeos::kCryptohomeMountErrorKeyFailure);
BrowserThread::PostTask(
@@ -288,6 +295,7 @@ TEST_F(ParallelAuthenticatorTest, DriveFailedMount) {
// Set up state as though a cryptohome mount attempt has occurred
// and failed.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(false, 0);
SetAttemptState(auth_, state_);
@@ -339,6 +347,7 @@ TEST_F(ParallelAuthenticatorTest, DriveDataResync) {
.Times(1)
.RetiresOnSaturation();
+ CreateAttemptState();
state_->PresetOnlineLoginStatus(result_, LoginFailure::None());
SetAttemptState(auth_, state_);
@@ -356,6 +365,7 @@ TEST_F(ParallelAuthenticatorTest, DriveResyncFail) {
.Times(1)
.RetiresOnSaturation();
+ CreateAttemptState();
SetAttemptState(auth_, state_);
auth_->ResyncEncryptedData(result_);
@@ -366,6 +376,7 @@ TEST_F(ParallelAuthenticatorTest, DriveRequestOldPassword) {
FailOnLoginSuccess();
ExpectPasswordChange();
+ CreateAttemptState();
state_->PresetCryptohomeStatus(false,
chromeos::kCryptohomeMountErrorKeyFailure);
state_->PresetOnlineLoginStatus(result_, LoginFailure::None());
@@ -390,6 +401,7 @@ TEST_F(ParallelAuthenticatorTest, DriveDataRecover) {
.WillOnce(Return(CryptohomeBlob(2, 0)))
.RetiresOnSaturation();
+ CreateAttemptState();
state_->PresetOnlineLoginStatus(result_, LoginFailure::None());
SetAttemptState(auth_, state_);
@@ -411,6 +423,7 @@ TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) {
.WillOnce(Return(CryptohomeBlob(2, 0)))
.RetiresOnSaturation();
+ CreateAttemptState();
SetAttemptState(auth_, state_);
auth_->RecoverEncryptedData(std::string(), result_);
@@ -420,6 +433,7 @@ TEST_F(ParallelAuthenticatorTest, DriveDataRecoverButFail) {
TEST_F(ParallelAuthenticatorTest, ResolveNoMount) {
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected because the user doesn't exist.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(
false,
chromeos::kCryptohomeMountErrorUserDoesNotExist);
@@ -436,6 +450,7 @@ TEST_F(ParallelAuthenticatorTest, ResolveCreateNew) {
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected because the user doesn't exist; additionally,
// an online auth attempt has completed successfully.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(
false,
chromeos::kCryptohomeMountErrorUserDoesNotExist);
@@ -464,6 +479,7 @@ TEST_F(ParallelAuthenticatorTest, DriveCreateForNewUser) {
// Set up state as though a cryptohome mount attempt has occurred
// and been rejected because the user doesn't exist; additionally,
// an online auth attempt has completed successfully.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(
false,
chromeos::kCryptohomeMountErrorUserDoesNotExist);
@@ -480,6 +496,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLogin) {
// Set up state as though a cryptohome mount attempt has occurred and
// succeeded.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(true, 0);
GoogleServiceAuthError error =
GoogleServiceAuthError::FromConnectionError(net::ERR_CONNECTION_RESET);
@@ -496,6 +513,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginDelayedOnline) {
// Set up state as though a cryptohome mount attempt has occurred and
// succeeded.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(true, 0);
SetAttemptState(auth_, state_);
RunResolve(auth_.get(), &message_loop_);
@@ -525,6 +543,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOfflineLoginGetNewPassword) {
// Set up state as though a cryptohome mount attempt has occurred and
// succeeded; also, an online request that never made it.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(true, 0);
SetAttemptState(auth_, state_);
RunResolve(auth_.get(), &message_loop_);
@@ -560,6 +579,7 @@ TEST_F(ParallelAuthenticatorTest, DriveOnlineLogin) {
// Set up state as though a cryptohome mount attempt has occurred and
// succeeded.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(true, 0);
state_->PresetOnlineLoginStatus(success, LoginFailure::None());
SetAttemptState(auth_, state_);
@@ -578,6 +598,7 @@ TEST_F(ParallelAuthenticatorTest, DriveNeedNewPassword) {
// Set up state as though a cryptohome mount attempt has occurred and
// succeeded.
+ CreateAttemptState();
state_->PresetCryptohomeStatus(true, 0);
state_->PresetOnlineLoginStatus(result_, failure);
SetAttemptState(auth_, state_);
@@ -602,6 +623,7 @@ TEST_F(ParallelAuthenticatorTest, DriveLocalLogin) {
GoogleServiceAuthError::FromConnectionError(net::ERR_CONNECTION_RESET);
LoginFailure failure =
LoginFailure::FromNetworkAuthFailure(error);
+ CreateAttemptState();
state_->PresetOnlineLoginStatus(result_, failure);
state_->PresetCryptohomeStatus(
false,