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

Issue 21121003: Plug the leak in SingleLoginAttemptTest.* (jingle_unittests). (Closed)

Created:
7 years, 4 months ago by earthdok
Modified:
7 years, 4 months ago
CC:
chromium-reviews
Visibility:
Public.

Description

Plug the leak in SingleLoginAttemptTest.* (jingle_unittests). Flushing the message loop after destroying the SingleLoginAttempt makes the test shut down cleanly. Don't know why but it fixes the leak. BUG=259350 R=ajwong@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=214368

Patch Set 1 #

Total comments: 1

Patch Set 2 : Remove explicit NULL. #

Patch Set 3 : Make destructor virtual. #

Patch Set 4 : Make destructor virtual (re-upload). #

Unified diffs Side-by-side diffs Delta from patch set Stats (+13 lines, -8 lines) Patch
M jingle/notifier/communicator/single_login_attempt_unittest.cc View 1 2 6 chunks +13 lines, -8 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
earthdok
please take a look picking a random owner since Fred looks busy
7 years, 4 months ago (2013-07-29 18:50:28 UTC) #1
awong
Can you add a little more info into the description for why this plugs the ...
7 years, 4 months ago (2013-07-29 20:59:59 UTC) #2
earthdok
On 2013/07/29 20:59:59, awong wrote: > Can you add a little more info into the ...
7 years, 4 months ago (2013-07-29 23:59:32 UTC) #3
earthdok
On 2013/07/29 23:59:32, earthdok wrote: > On 2013/07/29 20:59:59, awong wrote: > > Can you ...
7 years, 4 months ago (2013-07-30 00:02:36 UTC) #4
awong
On 2013/07/30 00:02:36, earthdok wrote: > On 2013/07/29 23:59:32, earthdok wrote: > > On 2013/07/29 ...
7 years, 4 months ago (2013-07-30 00:04:44 UTC) #5
earthdok
On 2013/07/30 00:04:44, awong wrote: > On 2013/07/30 00:02:36, earthdok wrote: > > On 2013/07/29 ...
7 years, 4 months ago (2013-07-30 00:08:12 UTC) #6
awong
LGTM
7 years, 4 months ago (2013-07-30 00:10:04 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/earthdok@chromium.org/21121003/9001
7 years, 4 months ago (2013-07-30 08:52:23 UTC) #8
earthdok
Committed patchset #4 manually as r214368 (presubmit successful).
7 years, 4 months ago (2013-07-30 16:51:14 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/earthdok@chromium.org/21121003/9001
7 years, 4 months ago (2013-07-30 19:27:41 UTC) #10
commit-bot: I haz the power
7 years, 4 months ago (2013-07-30 19:27:45 UTC) #11
Message was sent while issue was closed.
Failed to apply patch for
jingle/notifier/communicator/single_login_attempt_unittest.cc:
While running patch -p1 --forward --force --no-backup-if-mismatch;
  patching file jingle/notifier/communicator/single_login_attempt_unittest.cc
  Hunk #1 FAILED at 95.
  Hunk #2 FAILED at 110.
  Hunk #3 FAILED at 118.
  Hunk #4 FAILED at 129.
  Hunk #5 FAILED at 137.
  Hunk #6 FAILED at 245.
  6 out of 6 hunks FAILED -- saving rejects to file
jingle/notifier/communicator/single_login_attempt_unittest.cc.rej

Patch:       jingle/notifier/communicator/single_login_attempt_unittest.cc
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..0e80fd0dfe38723e294230fc5b7c00ea004867fb
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();
+    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());
 }

Powered by Google App Engine
This is Rietveld 408576698