OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/host/host_status_monitor_fake.h" |
| 8 #include "remoting/host/log_to_server.h" |
7 #include "remoting/jingle_glue/mock_objects.h" | 9 #include "remoting/jingle_glue/mock_objects.h" |
8 #include "remoting/host/log_to_server.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gmock_mutant.h" | 11 #include "testing/gmock_mutant.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 13 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
13 | 14 |
14 using buzz::XmlElement; | 15 using buzz::XmlElement; |
15 using buzz::QName; | 16 using buzz::QName; |
16 using testing::_; | 17 using testing::_; |
17 using testing::DeleteArg; | 18 using testing::DeleteArg; |
18 using testing::InSequence; | 19 using testing::InSequence; |
19 using testing::Return; | 20 using testing::Return; |
20 | 21 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 120 |
120 } // namespace | 121 } // namespace |
121 | 122 |
122 class LogToServerTest : public testing::Test { | 123 class LogToServerTest : public testing::Test { |
123 public: | 124 public: |
124 LogToServerTest() {} | 125 LogToServerTest() {} |
125 virtual void SetUp() OVERRIDE { | 126 virtual void SetUp() OVERRIDE { |
126 message_loop_proxy_ = base::MessageLoopProxy::current(); | 127 message_loop_proxy_ = base::MessageLoopProxy::current(); |
127 EXPECT_CALL(signal_strategy_, AddListener(_)); | 128 EXPECT_CALL(signal_strategy_, AddListener(_)); |
128 log_to_server_.reset( | 129 log_to_server_.reset( |
129 new LogToServer(NULL, ServerLogEntry::ME2ME, &signal_strategy_, | 130 new LogToServer(host_status_monitor_.AsWeakPtr(), |
| 131 ServerLogEntry::ME2ME, |
| 132 &signal_strategy_, |
130 kTestBotJid)); | 133 kTestBotJid)); |
131 EXPECT_CALL(signal_strategy_, RemoveListener(_)); | 134 EXPECT_CALL(signal_strategy_, RemoveListener(_)); |
132 } | 135 } |
133 | 136 |
134 protected: | 137 protected: |
135 MessageLoop message_loop_; | 138 MessageLoop message_loop_; |
136 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 139 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
137 MockSignalStrategy signal_strategy_; | 140 MockSignalStrategy signal_strategy_; |
138 scoped_ptr<LogToServer> log_to_server_; | 141 scoped_ptr<LogToServer> log_to_server_; |
| 142 HostStatusMonitorFake host_status_monitor_; |
139 }; | 143 }; |
140 | 144 |
141 TEST_F(LogToServerTest, SendNow) { | 145 TEST_F(LogToServerTest, SendNow) { |
142 { | 146 { |
143 InSequence s; | 147 InSequence s; |
144 EXPECT_CALL(signal_strategy_, GetLocalJid()) | 148 EXPECT_CALL(signal_strategy_, GetLocalJid()) |
145 .WillRepeatedly(Return(kHostJid)); | 149 .WillRepeatedly(Return(kHostJid)); |
146 EXPECT_CALL(signal_strategy_, AddListener(_)); | 150 EXPECT_CALL(signal_strategy_, AddListener(_)); |
147 EXPECT_CALL(signal_strategy_, GetNextId()); | 151 EXPECT_CALL(signal_strategy_, GetNextId()); |
148 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) | 152 EXPECT_CALL(signal_strategy_, SendStanzaPtr(IsClientConnected("direct"))) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 route2.type = protocol::TransportRoute::STUN; | 246 route2.type = protocol::TransportRoute::STUN; |
243 log_to_server_->OnClientRouteChange(kClientJid2, "video", route2); | 247 log_to_server_->OnClientRouteChange(kClientJid2, "video", route2); |
244 log_to_server_->OnClientDisconnected(kClientJid1); | 248 log_to_server_->OnClientDisconnected(kClientJid1); |
245 log_to_server_->OnClientAuthenticated(kClientJid2); | 249 log_to_server_->OnClientAuthenticated(kClientJid2); |
246 log_to_server_->OnClientConnected(kClientJid2); | 250 log_to_server_->OnClientConnected(kClientJid2); |
247 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); | 251 log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED); |
248 message_loop_.Run(); | 252 message_loop_.Run(); |
249 } | 253 } |
250 | 254 |
251 } // namespace remoting | 255 } // namespace remoting |
OLD | NEW |