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

Side by Side Diff: remoting/host/log_to_server_unittest.cc

Issue 8669007: Fix leaks from a unit test added in r111239. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/message_loop_proxy.h" 6 #include "base/message_loop_proxy.h"
7 #include "remoting/jingle_glue/mock_objects.h" 7 #include "remoting/jingle_glue/mock_objects.h"
8 #include "remoting/host/log_to_server.h" 8 #include "remoting/host/log_to_server.h"
9 #include "testing/gmock_mutant.h" 9 #include "testing/gmock_mutant.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
12 13
13 using testing::_; 14 using testing::_;
15 using testing::DeleteArg;
14 using testing::InSequence; 16 using testing::InSequence;
17 using testing::Return;
15 18
16 namespace remoting { 19 namespace remoting {
17 20
18 namespace { 21 namespace {
19 22
20 ACTION_P(QuitMainMessageLoop, message_loop) { 23 ACTION_P(QuitMainMessageLoop, message_loop) {
21 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 24 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
22 } 25 }
23 26
24 } // namespace 27 } // namespace
(...skipping 11 matching lines...) Expand all
36 scoped_ptr<LogToServer> log_to_server_; 39 scoped_ptr<LogToServer> log_to_server_;
37 MessageLoop message_loop_; 40 MessageLoop message_loop_;
38 MockSignalStrategy signal_strategy_; 41 MockSignalStrategy signal_strategy_;
39 }; 42 };
40 43
41 TEST_F(LogToServerTest, SendNow) { 44 TEST_F(LogToServerTest, SendNow) {
42 { 45 {
43 InSequence s; 46 InSequence s;
44 EXPECT_CALL(signal_strategy_, AddListener(_)); 47 EXPECT_CALL(signal_strategy_, AddListener(_));
45 EXPECT_CALL(signal_strategy_, GetNextId()); 48 EXPECT_CALL(signal_strategy_, GetNextId());
46 EXPECT_CALL(signal_strategy_, SendStanza(_)); 49 EXPECT_CALL(signal_strategy_, SendStanza(_))
50 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
47 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 51 EXPECT_CALL(signal_strategy_, RemoveListener(_))
48 .WillOnce(QuitMainMessageLoop(&message_loop_)) 52 .WillOnce(QuitMainMessageLoop(&message_loop_))
49 .RetiresOnSaturation(); 53 .RetiresOnSaturation();
50 } 54 }
51 log_to_server_->OnSignallingConnected(&signal_strategy_, 55 log_to_server_->OnSignallingConnected(&signal_strategy_,
52 "host@domain.com/1234"); 56 "host@domain.com/1234");
53 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 57 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
54 log_to_server_->OnSignallingDisconnected(); 58 log_to_server_->OnSignallingDisconnected();
55 message_loop_.Run(); 59 message_loop_.Run();
56 } 60 }
57 61
58 TEST_F(LogToServerTest, SendLater) { 62 TEST_F(LogToServerTest, SendLater) {
59 { 63 {
60 InSequence s; 64 InSequence s;
61 EXPECT_CALL(signal_strategy_, AddListener(_)); 65 EXPECT_CALL(signal_strategy_, AddListener(_));
62 EXPECT_CALL(signal_strategy_, GetNextId()); 66 EXPECT_CALL(signal_strategy_, GetNextId());
63 EXPECT_CALL(signal_strategy_, SendStanza(_)); 67 EXPECT_CALL(signal_strategy_, SendStanza(_))
68 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
64 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 69 EXPECT_CALL(signal_strategy_, RemoveListener(_))
65 .WillOnce(QuitMainMessageLoop(&message_loop_)) 70 .WillOnce(QuitMainMessageLoop(&message_loop_))
66 .RetiresOnSaturation(); 71 .RetiresOnSaturation();
67 } 72 }
68 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 73 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
69 log_to_server_->OnSignallingConnected(&signal_strategy_, 74 log_to_server_->OnSignallingConnected(&signal_strategy_,
70 "host@domain.com/1234"); 75 "host@domain.com/1234");
71 log_to_server_->OnSignallingDisconnected(); 76 log_to_server_->OnSignallingDisconnected();
72 message_loop_.Run(); 77 message_loop_.Run();
73 } 78 }
74 79
75 TEST_F(LogToServerTest, SendTwoEntriesLater) { 80 TEST_F(LogToServerTest, SendTwoEntriesLater) {
76 { 81 {
77 InSequence s; 82 InSequence s;
78 EXPECT_CALL(signal_strategy_, AddListener(_)); 83 EXPECT_CALL(signal_strategy_, AddListener(_));
79 EXPECT_CALL(signal_strategy_, GetNextId()); 84 EXPECT_CALL(signal_strategy_, GetNextId());
80 EXPECT_CALL(signal_strategy_, SendStanza(_)); 85 EXPECT_CALL(signal_strategy_, SendStanza(_))
86 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
81 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 87 EXPECT_CALL(signal_strategy_, RemoveListener(_))
82 .WillOnce(QuitMainMessageLoop(&message_loop_)) 88 .WillOnce(QuitMainMessageLoop(&message_loop_))
83 .RetiresOnSaturation(); 89 .RetiresOnSaturation();
84 } 90 }
85 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 91 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
86 log_to_server_->OnClientAuthenticated("client2@domain.com/6789"); 92 log_to_server_->OnClientAuthenticated("client2@domain.com/6789");
87 log_to_server_->OnSignallingConnected(&signal_strategy_, 93 log_to_server_->OnSignallingConnected(&signal_strategy_,
88 "host@domain.com/1234"); 94 "host@domain.com/1234");
89 log_to_server_->OnSignallingDisconnected(); 95 log_to_server_->OnSignallingDisconnected();
90 message_loop_.Run(); 96 message_loop_.Run();
91 } 97 }
92 98
93 } // namespace remoting 99 } // namespace remoting
OLDNEW
« 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