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

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

Issue 9004050: Move signaling connection creation out of ChromotingHost. (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
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 13 matching lines...) Expand all
24 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 24 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 class LogToServerTest : public testing::Test { 29 class LogToServerTest : public testing::Test {
30 public: 30 public:
31 LogToServerTest() {} 31 LogToServerTest() {}
32 virtual void SetUp() OVERRIDE { 32 virtual void SetUp() OVERRIDE {
33 message_loop_proxy_ = base::MessageLoopProxy::current(); 33 message_loop_proxy_ = base::MessageLoopProxy::current();
34 log_to_server_.reset(new LogToServer(message_loop_proxy_)); 34 EXPECT_CALL(signal_strategy_, AddListener(_));
35 log_to_server_.reset(new LogToServer(&signal_strategy_));
36 EXPECT_CALL(signal_strategy_, RemoveListener(_));
35 } 37 }
36 38
37 protected: 39 protected:
40 MessageLoop message_loop_;
38 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 41 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
42 MockSignalStrategy signal_strategy_;
39 scoped_ptr<LogToServer> log_to_server_; 43 scoped_ptr<LogToServer> log_to_server_;
40 MessageLoop message_loop_;
41 MockSignalStrategy signal_strategy_;
42 }; 44 };
43 45
44 TEST_F(LogToServerTest, SendNow) { 46 TEST_F(LogToServerTest, SendNow) {
45 { 47 {
46 InSequence s; 48 InSequence s;
47 EXPECT_CALL(signal_strategy_, GetLocalJid()) 49 EXPECT_CALL(signal_strategy_, GetLocalJid())
48 .WillRepeatedly(Return("host@domain.com/1234")); 50 .WillRepeatedly(Return("host@domain.com/1234"));
49 EXPECT_CALL(signal_strategy_, AddListener(_)); 51 EXPECT_CALL(signal_strategy_, AddListener(_));
50 EXPECT_CALL(signal_strategy_, GetNextId()); 52 EXPECT_CALL(signal_strategy_, GetNextId());
51 EXPECT_CALL(signal_strategy_, SendStanza(_)) 53 EXPECT_CALL(signal_strategy_, SendStanza(_))
52 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 54 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
53 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 55 EXPECT_CALL(signal_strategy_, RemoveListener(_))
54 .WillOnce(QuitMainMessageLoop(&message_loop_)) 56 .WillOnce(QuitMainMessageLoop(&message_loop_))
55 .RetiresOnSaturation(); 57 .RetiresOnSaturation();
56 } 58 }
57 log_to_server_->OnSignallingConnected(&signal_strategy_); 59 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
58 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 60 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
59 log_to_server_->OnSignallingDisconnected(); 61 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED);
60 message_loop_.Run(); 62 message_loop_.Run();
61 } 63 }
62 64
63 TEST_F(LogToServerTest, SendLater) { 65 TEST_F(LogToServerTest, SendLater) {
64 { 66 {
65 InSequence s; 67 InSequence s;
66 EXPECT_CALL(signal_strategy_, GetLocalJid()) 68 EXPECT_CALL(signal_strategy_, GetLocalJid())
67 .WillRepeatedly(Return("host@domain.com/1234")); 69 .WillRepeatedly(Return("host@domain.com/1234"));
68 EXPECT_CALL(signal_strategy_, AddListener(_)); 70 EXPECT_CALL(signal_strategy_, AddListener(_));
69 EXPECT_CALL(signal_strategy_, GetNextId()); 71 EXPECT_CALL(signal_strategy_, GetNextId());
70 EXPECT_CALL(signal_strategy_, SendStanza(_)) 72 EXPECT_CALL(signal_strategy_, SendStanza(_))
71 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 73 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
72 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 74 EXPECT_CALL(signal_strategy_, RemoveListener(_))
73 .WillOnce(QuitMainMessageLoop(&message_loop_)) 75 .WillOnce(QuitMainMessageLoop(&message_loop_))
74 .RetiresOnSaturation(); 76 .RetiresOnSaturation();
75 } 77 }
76 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 78 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
77 log_to_server_->OnSignallingConnected(&signal_strategy_); 79 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
Wez 2012/01/03 16:25:04 nit: This test should really verify that the stanz
Sergey Ulanov 2012/01/03 21:51:02 Done.
78 log_to_server_->OnSignallingDisconnected(); 80 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED);
79 message_loop_.Run(); 81 message_loop_.Run();
80 } 82 }
81 83
82 TEST_F(LogToServerTest, SendTwoEntriesLater) { 84 TEST_F(LogToServerTest, SendTwoEntriesLater) {
83 { 85 {
84 InSequence s; 86 InSequence s;
85 EXPECT_CALL(signal_strategy_, GetLocalJid()) 87 EXPECT_CALL(signal_strategy_, GetLocalJid())
86 .WillRepeatedly(Return("host@domain.com/1234")); 88 .WillRepeatedly(Return("host@domain.com/1234"));
87 EXPECT_CALL(signal_strategy_, AddListener(_)); 89 EXPECT_CALL(signal_strategy_, AddListener(_));
88 EXPECT_CALL(signal_strategy_, GetNextId()); 90 EXPECT_CALL(signal_strategy_, GetNextId());
89 EXPECT_CALL(signal_strategy_, SendStanza(_)) 91 EXPECT_CALL(signal_strategy_, SendStanza(_))
90 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 92 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
91 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 93 EXPECT_CALL(signal_strategy_, RemoveListener(_))
92 .WillOnce(QuitMainMessageLoop(&message_loop_)) 94 .WillOnce(QuitMainMessageLoop(&message_loop_))
93 .RetiresOnSaturation(); 95 .RetiresOnSaturation();
94 } 96 }
95 log_to_server_->OnClientAuthenticated("client@domain.com/5678"); 97 log_to_server_->OnClientAuthenticated("client@domain.com/5678");
96 log_to_server_->OnClientAuthenticated("client2@domain.com/6789"); 98 log_to_server_->OnClientAuthenticated("client2@domain.com/6789");
97 log_to_server_->OnSignallingConnected(&signal_strategy_); 99 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
98 log_to_server_->OnSignallingDisconnected(); 100 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED);
99 message_loop_.Run(); 101 message_loop_.Run();
100 } 102 }
101 103
102 } // namespace remoting 104 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698