OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_change_notification_listener.h" | 5 #include "remoting/host/host_change_notification_listener.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 class HostChangeNotificationListenerTest : public testing::Test { | 44 class HostChangeNotificationListenerTest : public testing::Test { |
45 protected: | 45 protected: |
46 class MockListener : public HostChangeNotificationListener::Listener { | 46 class MockListener : public HostChangeNotificationListener::Listener { |
47 public: | 47 public: |
48 MOCK_METHOD0(OnHostDeleted, void()); | 48 MOCK_METHOD0(OnHostDeleted, void()); |
49 }; | 49 }; |
50 | 50 |
51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() override { |
52 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) | 52 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) |
53 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); | 53 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); |
54 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) | 54 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) |
55 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); | 55 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); |
56 EXPECT_CALL(signal_strategy_, GetLocalJid()) | 56 EXPECT_CALL(signal_strategy_, GetLocalJid()) |
57 .WillRepeatedly(Return(kTestJid)); | 57 .WillRepeatedly(Return(kTestJid)); |
58 | 58 |
59 host_change_notification_listener_.reset(new HostChangeNotificationListener( | 59 host_change_notification_listener_.reset(new HostChangeNotificationListener( |
60 &mock_listener_, kHostId, &signal_strategy_, kTestBotJid)); | 60 &mock_listener_, kHostId, &signal_strategy_, kTestBotJid)); |
61 } | 61 } |
62 | 62 |
63 virtual void TearDown() OVERRIDE { | 63 virtual void TearDown() override { |
64 host_change_notification_listener_.reset(); | 64 host_change_notification_listener_.reset(); |
65 EXPECT_TRUE(signal_strategy_listeners_.empty()); | 65 EXPECT_TRUE(signal_strategy_listeners_.empty()); |
66 } | 66 } |
67 | 67 |
68 scoped_ptr<XmlElement> GetNotificationStanza(std::string operation, | 68 scoped_ptr<XmlElement> GetNotificationStanza(std::string operation, |
69 std::string hostId, | 69 std::string hostId, |
70 std::string botJid) { | 70 std::string botJid) { |
71 scoped_ptr<XmlElement> stanza(new XmlElement(buzz::QN_IQ)); | 71 scoped_ptr<XmlElement> stanza(new XmlElement(buzz::QN_IQ)); |
72 stanza->AddAttr(QName(std::string(), "type"), "set"); | 72 stanza->AddAttr(QName(std::string(), "type"), "set"); |
73 XmlElement* host_changed = | 73 XmlElement* host_changed = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 scoped_ptr<XmlElement> stanza = GetNotificationStanza( | 144 scoped_ptr<XmlElement> stanza = GetNotificationStanza( |
145 "update", kHostId, kTestBotJid); | 145 "update", kHostId, kTestBotJid); |
146 host_change_notification_listener_->OnSignalStrategyIncomingStanza( | 146 host_change_notification_listener_->OnSignalStrategyIncomingStanza( |
147 stanza.get()); | 147 stanza.get()); |
148 message_loop_.PostTask(FROM_HERE, | 148 message_loop_.PostTask(FROM_HERE, |
149 base::Bind(base::MessageLoop::QuitClosure())); | 149 base::Bind(base::MessageLoop::QuitClosure())); |
150 message_loop_.Run(); | 150 message_loop_.Run(); |
151 } | 151 } |
152 | 152 |
153 } // namespace remoting | 153 } // namespace remoting |
OLD | NEW |