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

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

Issue 2798393007: Use SignalingAddress in SignalStrategy insterface. (Closed)
Patch Set: header Created 3 years, 8 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
OLDNEW
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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "remoting/base/constants.h" 15 #include "remoting/base/constants.h"
16 #include "remoting/signaling/mock_signal_strategy.h" 16 #include "remoting/signaling/mock_signal_strategy.h"
17 #include "remoting/signaling/signaling_address.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" 20 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
20 #include "third_party/libjingle_xmpp/xmpp/constants.h" 21 #include "third_party/libjingle_xmpp/xmpp/constants.h"
21 22
22 using buzz::QName; 23 using buzz::QName;
23 using buzz::XmlElement; 24 using buzz::XmlElement;
24 25
25 using testing::NotNull; 26 using testing::NotNull;
26 using testing::Return; 27 using testing::Return;
(...skipping 11 matching lines...) Expand all
38 } 39 }
39 40
40 ACTION_P(RemoveListener, list) { 41 ACTION_P(RemoveListener, list) {
41 EXPECT_TRUE(list->find(arg0) != list->end()); 42 EXPECT_TRUE(list->find(arg0) != list->end());
42 list->erase(arg0); 43 list->erase(arg0);
43 } 44 }
44 45
45 46
46 class HostChangeNotificationListenerTest : public testing::Test { 47 class HostChangeNotificationListenerTest : public testing::Test {
47 protected: 48 protected:
49 HostChangeNotificationListenerTest()
50 : signal_strategy_(SignalingAddress(kTestJid)) {}
48 class MockListener : public HostChangeNotificationListener::Listener { 51 class MockListener : public HostChangeNotificationListener::Listener {
49 public: 52 public:
50 MOCK_METHOD0(OnHostDeleted, void()); 53 MOCK_METHOD0(OnHostDeleted, void());
51 }; 54 };
52 55
53 void SetUp() override { 56 void SetUp() override {
54 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) 57 EXPECT_CALL(signal_strategy_, AddListener(NotNull()))
55 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); 58 .WillRepeatedly(AddListener(&signal_strategy_listeners_));
56 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) 59 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull()))
57 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); 60 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_));
58 EXPECT_CALL(signal_strategy_, GetLocalJid())
59 .WillRepeatedly(Return(kTestJid));
60 61
61 host_change_notification_listener_.reset(new HostChangeNotificationListener( 62 host_change_notification_listener_.reset(new HostChangeNotificationListener(
62 &mock_listener_, kHostId, &signal_strategy_, kTestBotJid)); 63 &mock_listener_, kHostId, &signal_strategy_, kTestBotJid));
63 } 64 }
64 65
65 void TearDown() override { 66 void TearDown() override {
66 host_change_notification_listener_.reset(); 67 host_change_notification_listener_.reset();
67 EXPECT_TRUE(signal_strategy_listeners_.empty()); 68 EXPECT_TRUE(signal_strategy_listeners_.empty());
68 } 69 }
69 70
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 std::unique_ptr<XmlElement> stanza = 148 std::unique_ptr<XmlElement> stanza =
148 GetNotificationStanza("update", kHostId, kTestBotJid); 149 GetNotificationStanza("update", kHostId, kTestBotJid);
149 host_change_notification_listener_->OnSignalStrategyIncomingStanza( 150 host_change_notification_listener_->OnSignalStrategyIncomingStanza(
150 stanza.get()); 151 stanza.get());
151 message_loop_.task_runner()->PostTask( 152 message_loop_.task_runner()->PostTask(
152 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 153 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
153 base::RunLoop().Run(); 154 base::RunLoop().Run();
154 } 155 }
155 156
156 } // namespace remoting 157 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_change_notification_listener.cc ('k') | remoting/host/host_status_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698