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

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

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/log_to_server.cc ('k') | remoting/host/plugin/host_script_object.h » ('j') | 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"
(...skipping 26 matching lines...) Expand all
37 protected: 37 protected:
38 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 38 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
39 scoped_ptr<LogToServer> log_to_server_; 39 scoped_ptr<LogToServer> log_to_server_;
40 MessageLoop message_loop_; 40 MessageLoop message_loop_;
41 MockSignalStrategy signal_strategy_; 41 MockSignalStrategy signal_strategy_;
42 }; 42 };
43 43
44 TEST_F(LogToServerTest, SendNow) { 44 TEST_F(LogToServerTest, SendNow) {
45 { 45 {
46 InSequence s; 46 InSequence s;
47 EXPECT_CALL(signal_strategy_, GetLocalJid())
48 .WillRepeatedly(Return("host@domain.com/1234"));
47 EXPECT_CALL(signal_strategy_, AddListener(_)); 49 EXPECT_CALL(signal_strategy_, AddListener(_));
48 EXPECT_CALL(signal_strategy_, GetNextId()); 50 EXPECT_CALL(signal_strategy_, GetNextId());
49 EXPECT_CALL(signal_strategy_, SendStanza(_)) 51 EXPECT_CALL(signal_strategy_, SendStanza(_))
50 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 52 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
51 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 53 EXPECT_CALL(signal_strategy_, RemoveListener(_))
52 .WillOnce(QuitMainMessageLoop(&message_loop_)) 54 .WillOnce(QuitMainMessageLoop(&message_loop_))
53 .RetiresOnSaturation(); 55 .RetiresOnSaturation();
54 } 56 }
55 log_to_server_->OnSignallingConnected(&signal_strategy_, 57 log_to_server_->OnSignallingConnected(&signal_strategy_);
56 "host@domain.com/1234");
57 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 58 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
58 log_to_server_->OnSignallingDisconnected(); 59 log_to_server_->OnSignallingDisconnected();
59 message_loop_.Run(); 60 message_loop_.Run();
60 } 61 }
61 62
62 TEST_F(LogToServerTest, SendLater) { 63 TEST_F(LogToServerTest, SendLater) {
63 { 64 {
64 InSequence s; 65 InSequence s;
66 EXPECT_CALL(signal_strategy_, GetLocalJid())
67 .WillRepeatedly(Return("host@domain.com/1234"));
65 EXPECT_CALL(signal_strategy_, AddListener(_)); 68 EXPECT_CALL(signal_strategy_, AddListener(_));
66 EXPECT_CALL(signal_strategy_, GetNextId()); 69 EXPECT_CALL(signal_strategy_, GetNextId());
67 EXPECT_CALL(signal_strategy_, SendStanza(_)) 70 EXPECT_CALL(signal_strategy_, SendStanza(_))
68 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 71 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
69 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 72 EXPECT_CALL(signal_strategy_, RemoveListener(_))
70 .WillOnce(QuitMainMessageLoop(&message_loop_)) 73 .WillOnce(QuitMainMessageLoop(&message_loop_))
71 .RetiresOnSaturation(); 74 .RetiresOnSaturation();
72 } 75 }
73 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 76 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
74 log_to_server_->OnSignallingConnected(&signal_strategy_, 77 log_to_server_->OnSignallingConnected(&signal_strategy_);
75 "host@domain.com/1234");
76 log_to_server_->OnSignallingDisconnected(); 78 log_to_server_->OnSignallingDisconnected();
77 message_loop_.Run(); 79 message_loop_.Run();
78 } 80 }
79 81
80 TEST_F(LogToServerTest, SendTwoEntriesLater) { 82 TEST_F(LogToServerTest, SendTwoEntriesLater) {
81 { 83 {
82 InSequence s; 84 InSequence s;
85 EXPECT_CALL(signal_strategy_, GetLocalJid())
86 .WillRepeatedly(Return("host@domain.com/1234"));
83 EXPECT_CALL(signal_strategy_, AddListener(_)); 87 EXPECT_CALL(signal_strategy_, AddListener(_));
84 EXPECT_CALL(signal_strategy_, GetNextId()); 88 EXPECT_CALL(signal_strategy_, GetNextId());
85 EXPECT_CALL(signal_strategy_, SendStanza(_)) 89 EXPECT_CALL(signal_strategy_, SendStanza(_))
86 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 90 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
87 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 91 EXPECT_CALL(signal_strategy_, RemoveListener(_))
88 .WillOnce(QuitMainMessageLoop(&message_loop_)) 92 .WillOnce(QuitMainMessageLoop(&message_loop_))
89 .RetiresOnSaturation(); 93 .RetiresOnSaturation();
90 } 94 }
91 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 95 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
92 log_to_server_->OnClientAuthenticated("client2@domain.com/6789"); 96 log_to_server_->OnClientAuthenticated("client2@domain.com/6789");
93 log_to_server_->OnSignallingConnected(&signal_strategy_, 97 log_to_server_->OnSignallingConnected(&signal_strategy_);
94 "host@domain.com/1234");
95 log_to_server_->OnSignallingDisconnected(); 98 log_to_server_->OnSignallingDisconnected();
96 message_loop_.Run(); 99 message_loop_.Run();
97 } 100 }
98 101
99 } // namespace remoting 102 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/log_to_server.cc ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698