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

Side by Side Diff: remoting/client/client_status_logger_unittest.cc

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: h264_vt_encoder_unittest.cc Created 4 years, 5 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
« no previous file with comments | « ppapi/proxy/ppb_message_loop_proxy.cc ('k') | remoting/host/host_status_logger_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/client/client_status_logger.h" 5 #include "remoting/client/client_status_logger.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "remoting/protocol/performance_tracker.h" 9 #include "remoting/protocol/performance_tracker.h"
10 #include "remoting/signaling/mock_signal_strategy.h" 10 #include "remoting/signaling/mock_signal_strategy.h"
11 #include "remoting/signaling/server_log_entry_unittest.h" 11 #include "remoting/signaling/server_log_entry_unittest.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
15 15
16 using buzz::XmlElement; 16 using buzz::XmlElement;
17 using buzz::QName; 17 using buzz::QName;
18 using remoting::protocol::ConnectionToHost; 18 using remoting::protocol::ConnectionToHost;
19 using testing::_; 19 using testing::_;
20 using testing::DeleteArg; 20 using testing::DeleteArg;
21 using testing::InSequence; 21 using testing::InSequence;
22 using testing::Return; 22 using testing::Return;
23 23
24 namespace remoting { 24 namespace remoting {
25 25
26 namespace { 26 namespace {
27 27
28 ACTION_P(QuitMainMessageLoop, message_loop) { 28 ACTION_P(QuitRunLoop, run_loop) {
29 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 29 run_loop->QuitWhenIdle();
30 } 30 }
31 31
32 const char kTestBotJid[] = "remotingunittest@bot.talk.google.com"; 32 const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
33 const char kClientJid[] = "host@domain.com/1234"; 33 const char kClientJid[] = "host@domain.com/1234";
34 34
35 MATCHER_P2(IsStateChange, new_state, error, "") { 35 MATCHER_P2(IsStateChange, new_state, error, "") {
36 XmlElement* entry = GetSingleLogEntryFromStanza(arg); 36 XmlElement* entry = GetSingleLogEntryFromStanza(arg);
37 if (!entry) { 37 if (!entry) {
38 return false; 38 return false;
39 } 39 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 kTestBotJid)); 74 kTestBotJid));
75 } 75 }
76 76
77 protected: 77 protected:
78 base::MessageLoop message_loop_; 78 base::MessageLoop message_loop_;
79 MockSignalStrategy signal_strategy_; 79 MockSignalStrategy signal_strategy_;
80 std::unique_ptr<ClientStatusLogger> client_status_logger_; 80 std::unique_ptr<ClientStatusLogger> client_status_logger_;
81 }; 81 };
82 82
83 TEST_F(ClientStatusLoggerTest, LogStateChange) { 83 TEST_F(ClientStatusLoggerTest, LogStateChange) {
84 base::RunLoop run_loop;
84 { 85 {
85 InSequence s; 86 InSequence s;
86 EXPECT_CALL(signal_strategy_, GetLocalJid()) 87 EXPECT_CALL(signal_strategy_, GetLocalJid())
87 .WillRepeatedly(Return(kClientJid)); 88 .WillRepeatedly(Return(kClientJid));
88 EXPECT_CALL(signal_strategy_, AddListener(_)); 89 EXPECT_CALL(signal_strategy_, AddListener(_));
89 EXPECT_CALL(signal_strategy_, GetNextId()); 90 EXPECT_CALL(signal_strategy_, GetNextId());
90 EXPECT_CALL(signal_strategy_, SendStanzaPtr( 91 EXPECT_CALL(signal_strategy_, SendStanzaPtr(
91 IsStateChange("connected", std::string()))) 92 IsStateChange("connected", std::string())))
92 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 93 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
93 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 94 EXPECT_CALL(signal_strategy_, RemoveListener(_))
94 .WillOnce(QuitMainMessageLoop(&message_loop_)) 95 .WillOnce(QuitRunLoop(&run_loop))
95 .RetiresOnSaturation(); 96 .RetiresOnSaturation();
96 } 97 }
97 client_status_logger_->LogSessionStateChange(ConnectionToHost::CONNECTED, 98 client_status_logger_->LogSessionStateChange(ConnectionToHost::CONNECTED,
98 protocol::OK); 99 protocol::OK);
99 100
100 // Setting the state to CONNECTED causes the log to be sent. Setting the 101 // Setting the state to CONNECTED causes the log to be sent. Setting the
101 // state to DISCONNECTED causes |signal_strategy_| to be cleaned up, 102 // state to DISCONNECTED causes |signal_strategy_| to be cleaned up,
102 // which removes the listener and terminates the test. 103 // which removes the listener and terminates the test.
103 client_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 104 client_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
104 client_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 105 client_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
105 base::RunLoop().Run(); 106 run_loop.Run();
106 } 107 }
107 108
108 TEST_F(ClientStatusLoggerTest, LogStateChangeError) { 109 TEST_F(ClientStatusLoggerTest, LogStateChangeError) {
110 base::RunLoop run_loop;
109 { 111 {
110 InSequence s; 112 InSequence s;
111 EXPECT_CALL(signal_strategy_, GetLocalJid()) 113 EXPECT_CALL(signal_strategy_, GetLocalJid())
112 .WillRepeatedly(Return(kClientJid)); 114 .WillRepeatedly(Return(kClientJid));
113 EXPECT_CALL(signal_strategy_, AddListener(_)); 115 EXPECT_CALL(signal_strategy_, AddListener(_));
114 EXPECT_CALL(signal_strategy_, GetNextId()); 116 EXPECT_CALL(signal_strategy_, GetNextId());
115 EXPECT_CALL(signal_strategy_, SendStanzaPtr( 117 EXPECT_CALL(signal_strategy_, SendStanzaPtr(
116 IsStateChange("connection-failed", "host-is-offline"))) 118 IsStateChange("connection-failed", "host-is-offline")))
117 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 119 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
118 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 120 EXPECT_CALL(signal_strategy_, RemoveListener(_))
119 .WillOnce(QuitMainMessageLoop(&message_loop_)) 121 .WillOnce(QuitRunLoop(&run_loop))
120 .RetiresOnSaturation(); 122 .RetiresOnSaturation();
121 } 123 }
122 client_status_logger_->LogSessionStateChange(ConnectionToHost::FAILED, 124 client_status_logger_->LogSessionStateChange(ConnectionToHost::FAILED,
123 protocol::PEER_IS_OFFLINE); 125 protocol::PEER_IS_OFFLINE);
124 126
125 client_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 127 client_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
126 client_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 128 client_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
127 base::RunLoop().Run(); 129 run_loop.Run();
128 } 130 }
129 131
130 TEST_F(ClientStatusLoggerTest, LogStatistics) { 132 TEST_F(ClientStatusLoggerTest, LogStatistics) {
133 base::RunLoop run_loop;
131 { 134 {
132 InSequence s; 135 InSequence s;
133 EXPECT_CALL(signal_strategy_, GetLocalJid()) 136 EXPECT_CALL(signal_strategy_, GetLocalJid())
134 .WillRepeatedly(Return(kClientJid)); 137 .WillRepeatedly(Return(kClientJid));
135 EXPECT_CALL(signal_strategy_, AddListener(_)); 138 EXPECT_CALL(signal_strategy_, AddListener(_));
136 EXPECT_CALL(signal_strategy_, GetNextId()); 139 EXPECT_CALL(signal_strategy_, GetNextId());
137 EXPECT_CALL(signal_strategy_, SendStanzaPtr( 140 EXPECT_CALL(signal_strategy_, SendStanzaPtr(
138 IsStatisticsLog())) 141 IsStatisticsLog()))
139 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); 142 .WillOnce(DoAll(DeleteArg<0>(), Return(true)));
140 EXPECT_CALL(signal_strategy_, RemoveListener(_)) 143 EXPECT_CALL(signal_strategy_, RemoveListener(_))
141 .WillOnce(QuitMainMessageLoop(&message_loop_)) 144 .WillOnce(QuitRunLoop(&run_loop))
142 .RetiresOnSaturation(); 145 .RetiresOnSaturation();
143 } 146 }
144 147
145 protocol::PerformanceTracker perf_tracker; 148 protocol::PerformanceTracker perf_tracker;
146 client_status_logger_->LogStatistics(&perf_tracker); 149 client_status_logger_->LogStatistics(&perf_tracker);
147 150
148 client_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED); 151 client_status_logger_->SetSignalingStateForTest(SignalStrategy::CONNECTED);
149 client_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED); 152 client_status_logger_->SetSignalingStateForTest(SignalStrategy::DISCONNECTED);
150 base::RunLoop().Run(); 153 run_loop.Run();
151 } 154 }
152 155
153 } // namespace remoting 156 } // namespace remoting
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_message_loop_proxy.cc ('k') | remoting/host/host_status_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698