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 "remoting/host/register_support_host_request.h" | 5 #include "remoting/host/register_support_host_request.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/test/mock_callback.h" | 15 #include "base/test/mock_callback.h" |
16 #include "remoting/base/constants.h" | 16 #include "remoting/base/constants.h" |
17 #include "remoting/base/rsa_key_pair.h" | 17 #include "remoting/base/rsa_key_pair.h" |
18 #include "remoting/base/test_rsa_key_pair.h" | 18 #include "remoting/base/test_rsa_key_pair.h" |
19 #include "remoting/signaling/iq_sender.h" | 19 #include "remoting/signaling/iq_sender.h" |
20 #include "remoting/signaling/mock_signal_strategy.h" | 20 #include "remoting/signaling/mock_signal_strategy.h" |
| 21 #include "remoting/signaling/signaling_address.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" | 24 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" |
24 #include "third_party/libjingle_xmpp/xmpp/constants.h" | 25 #include "third_party/libjingle_xmpp/xmpp/constants.h" |
25 | 26 |
26 using buzz::QName; | 27 using buzz::QName; |
27 using buzz::XmlElement; | 28 using buzz::XmlElement; |
28 | 29 |
29 using testing::_; | 30 using testing::_; |
30 using testing::Invoke; | 31 using testing::Invoke; |
(...skipping 16 matching lines...) Expand all Loading... |
47 } | 48 } |
48 ACTION_P(RemoveListener, list) { | 49 ACTION_P(RemoveListener, list) { |
49 list->RemoveObserver(arg0); | 50 list->RemoveObserver(arg0); |
50 } | 51 } |
51 | 52 |
52 } // namespace | 53 } // namespace |
53 | 54 |
54 class RegisterSupportHostRequestTest : public testing::Test { | 55 class RegisterSupportHostRequestTest : public testing::Test { |
55 public: | 56 public: |
56 protected: | 57 protected: |
| 58 RegisterSupportHostRequestTest() |
| 59 : signal_strategy_(SignalingAddress(kTestJid)) {} |
| 60 |
57 void SetUp() override { | 61 void SetUp() override { |
58 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); | 62 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); |
59 ASSERT_TRUE(key_pair_.get()); | 63 ASSERT_TRUE(key_pair_.get()); |
60 | 64 |
61 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) | 65 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) |
62 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); | 66 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); |
63 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) | 67 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) |
64 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); | 68 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); |
65 EXPECT_CALL(signal_strategy_, GetLocalJid()) | |
66 .WillRepeatedly(Return(kTestJid)); | |
67 } | 69 } |
68 | 70 |
69 base::MessageLoop message_loop_; | 71 base::MessageLoop message_loop_; |
70 MockSignalStrategy signal_strategy_; | 72 MockSignalStrategy signal_strategy_; |
71 base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_; | 73 base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_; |
72 scoped_refptr<RsaKeyPair> key_pair_; | 74 scoped_refptr<RsaKeyPair> key_pair_; |
73 base::MockCallback<RegisterSupportHostRequest::RegisterCallback> callback_; | 75 base::MockCallback<RegisterSupportHostRequest::RegisterCallback> callback_; |
74 }; | 76 }; |
75 | 77 |
76 TEST_F(RegisterSupportHostRequestTest, Send) { | 78 TEST_F(RegisterSupportHostRequestTest, Send) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 for (auto& listener : signal_strategy_listeners_) { | 150 for (auto& listener : signal_strategy_listeners_) { |
149 if (listener.OnSignalStrategyIncomingStanza(response.get())) | 151 if (listener.OnSignalStrategyIncomingStanza(response.get())) |
150 consumed++; | 152 consumed++; |
151 } | 153 } |
152 EXPECT_EQ(1, consumed); | 154 EXPECT_EQ(1, consumed); |
153 | 155 |
154 base::RunLoop().RunUntilIdle(); | 156 base::RunLoop().RunUntilIdle(); |
155 } | 157 } |
156 | 158 |
157 } // namespace remoting | 159 } // namespace remoting |
OLD | NEW |