| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/host/host_status_logger.h" | 5 #include "remoting/host/host_status_logger.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | |
| 9 #include "remoting/host/fake_host_status_monitor.h" | 8 #include "remoting/host/fake_host_status_monitor.h" |
| 10 #include "remoting/signaling/mock_signal_strategy.h" | 9 #include "remoting/signaling/mock_signal_strategy.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gmock_mutant.h" | 11 #include "testing/gmock_mutant.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 13 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 15 | 14 |
| 16 using buzz::XmlElement; | 15 using buzz::XmlElement; |
| 17 using buzz::QName; | 16 using buzz::QName; |
| 18 using testing::_; | 17 using testing::_; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 118 } |
| 120 return true; | 119 return true; |
| 121 } | 120 } |
| 122 | 121 |
| 123 } // namespace | 122 } // namespace |
| 124 | 123 |
| 125 class HostStatusLoggerTest : public testing::Test { | 124 class HostStatusLoggerTest : public testing::Test { |
| 126 public: | 125 public: |
| 127 HostStatusLoggerTest() {} | 126 HostStatusLoggerTest() {} |
| 128 void SetUp() override { | 127 void SetUp() override { |
| 129 message_loop_proxy_ = base::MessageLoopProxy::current(); | |
| 130 EXPECT_CALL(signal_strategy_, AddListener(_)); | 128 EXPECT_CALL(signal_strategy_, AddListener(_)); |
| 131 host_status_logger_.reset( | 129 host_status_logger_.reset( |
| 132 new HostStatusLogger(host_status_monitor_.AsWeakPtr(), | 130 new HostStatusLogger(host_status_monitor_.AsWeakPtr(), |
| 133 ServerLogEntry::ME2ME, | 131 ServerLogEntry::ME2ME, |
| 134 &signal_strategy_, | 132 &signal_strategy_, |
| 135 kTestBotJid)); | 133 kTestBotJid)); |
| 136 EXPECT_CALL(signal_strategy_, RemoveListener(_)); | 134 EXPECT_CALL(signal_strategy_, RemoveListener(_)); |
| 137 } | 135 } |
| 138 | 136 |
| 139 protected: | 137 protected: |
| 140 base::MessageLoop message_loop_; | 138 base::MessageLoop message_loop_; |
| 141 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | |
| 142 MockSignalStrategy signal_strategy_; | 139 MockSignalStrategy signal_strategy_; |
| 143 scoped_ptr<HostStatusLogger> host_status_logger_; | 140 scoped_ptr<HostStatusLogger> host_status_logger_; |
| 144 FakeHostStatusMonitor host_status_monitor_; | 141 FakeHostStatusMonitor host_status_monitor_; |
| 145 }; | 142 }; |
| 146 | 143 |
| 147 TEST_F(HostStatusLoggerTest, SendNow) { | 144 TEST_F(HostStatusLoggerTest, SendNow) { |
| 148 { | 145 { |
| 149 InSequence s; | 146 InSequence s; |
| 150 EXPECT_CALL(signal_strategy_, GetLocalJid()) | 147 EXPECT_CALL(signal_strategy_, GetLocalJid()) |
| 151 .WillRepeatedly(Return(kHostJid)); | 148 .WillRepeatedly(Return(kHostJid)); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 route2.type = protocol::TransportRoute::STUN; | 246 route2.type = protocol::TransportRoute::STUN; |
| 250 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2); | 247 host_status_logger_->OnClientRouteChange(kClientJid2, "video", route2); |
| 251 host_status_logger_->OnClientDisconnected(kClientJid1); | 248 host_status_logger_->OnClientDisconnected(kClientJid1); |
| 252 host_status_logger_->OnClientAuthenticated(kClientJid2); | 249 host_status_logger_->OnClientAuthenticated(kClientJid2); |
| 253 host_status_logger_->OnClientConnected(kClientJid2); | 250 host_status_logger_->OnClientConnected(kClientJid2); |
| 254 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); | 251 host_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); |
| 255 message_loop_.Run(); | 252 message_loop_.Run(); |
| 256 } | 253 } |
| 257 | 254 |
| 258 } // namespace remoting | 255 } // namespace remoting |
| OLD | NEW |