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

Unified Diff: jingle/notifier/communicator/single_login_attempt_unittest.cc

Issue 21121003: Plug the leak in SingleLoginAttemptTest.* (jingle_unittests). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/notifier/communicator/single_login_attempt_unittest.cc
diff --git a/jingle/notifier/communicator/single_login_attempt_unittest.cc b/jingle/notifier/communicator/single_login_attempt_unittest.cc
index c00df3d3a4e96b048f32eac0ec3d018d0791426c..c37cfc178f0504721696c27acd28061eec4b8a09 100644
--- a/jingle/notifier/communicator/single_login_attempt_unittest.cc
+++ b/jingle/notifier/communicator/single_login_attempt_unittest.cc
@@ -95,14 +95,19 @@ class SingleLoginAttemptTest : public ::testing::Test {
net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)),
false /* try_ssltcp_first */,
"auth_mechanism"),
- attempt_(login_settings_, &fake_delegate_) {}
+ attempt_(new SingleLoginAttempt(login_settings_, &fake_delegate_)) {}
virtual void TearDown() OVERRIDE {
message_loop_.RunUntilIdle();
}
void FireRedirect(buzz::XmlElement* redirect_error) {
- attempt_.OnError(buzz::XmppEngine::ERROR_STREAM, 0, redirect_error);
+ attempt_->OnError(buzz::XmppEngine::ERROR_STREAM, 0, redirect_error);
+ }
+
+ ~SingleLoginAttemptTest() {
+ attempt_.reset(NULL);
awong 2013/07/29 20:59:59 Don't need the explicit NULL.
+ message_loop_.RunUntilIdle();
}
private:
@@ -110,7 +115,7 @@ class SingleLoginAttemptTest : public ::testing::Test {
const LoginSettings login_settings_;
protected:
- SingleLoginAttempt attempt_;
+ scoped_ptr<SingleLoginAttempt> attempt_;
FakeDelegate fake_delegate_;
FakeBaseTask fake_base_task_;
};
@@ -118,7 +123,7 @@ class SingleLoginAttemptTest : public ::testing::Test {
// Fire OnConnect and make sure the base task gets passed to the
// delegate properly.
TEST_F(SingleLoginAttemptTest, Basic) {
- attempt_.OnConnect(fake_base_task_.AsWeakPtr());
+ attempt_->OnConnect(fake_base_task_.AsWeakPtr());
EXPECT_EQ(CONNECTED, fake_delegate_.state());
EXPECT_EQ(fake_base_task_.AsWeakPtr().get(),
fake_delegate_.base_task().get());
@@ -129,7 +134,7 @@ TEST_F(SingleLoginAttemptTest, Basic) {
TEST_F(SingleLoginAttemptTest, Error) {
for (int i = 0; i < 2; ++i) {
EXPECT_EQ(IDLE, fake_delegate_.state());
- attempt_.OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL);
+ attempt_->OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL);
}
EXPECT_EQ(SETTINGS_EXHAUSTED, fake_delegate_.state());
}
@@ -137,8 +142,8 @@ TEST_F(SingleLoginAttemptTest, Error) {
// Fire OnErrors but replace the last one with OnConnect, and make
// sure the delegate still gets the OnConnect message.
TEST_F(SingleLoginAttemptTest, ErrorThenSuccess) {
- attempt_.OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL);
- attempt_.OnConnect(fake_base_task_.AsWeakPtr());
+ attempt_->OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL);
+ attempt_->OnConnect(fake_base_task_.AsWeakPtr());
EXPECT_EQ(CONNECTED, fake_delegate_.state());
EXPECT_EQ(fake_base_task_.AsWeakPtr().get(),
fake_delegate_.base_task().get());
@@ -245,7 +250,7 @@ TEST_F(SingleLoginAttemptTest, RedirectMissingSeeOtherHost) {
// Fire 'Unauthorized' errors and make sure the delegate gets the
// OnCredentialsRejected() event.
TEST_F(SingleLoginAttemptTest, CredentialsRejected) {
- attempt_.OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL);
+ attempt_->OnError(buzz::XmppEngine::ERROR_UNAUTHORIZED, 0, NULL);
EXPECT_EQ(CREDENTIALS_REJECTED, fake_delegate_.state());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698