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

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

Issue 86523005: Replace all usage of LOG(INFO) in Chromoting host with HOST_LOG to bypass the presubmit check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_status_sender.cc ('k') | remoting/host/input_injector_linux.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_status_sender.h" 5 #include "remoting/host/host_status_sender.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/base/logging.h"
10 #include "remoting/base/rsa_key_pair.h" 11 #include "remoting/base/rsa_key_pair.h"
11 #include "remoting/base/test_rsa_key_pair.h" 12 #include "remoting/base/test_rsa_key_pair.h"
12 #include "remoting/host/host_exit_codes.h" 13 #include "remoting/host/host_exit_codes.h"
13 #include "remoting/jingle_glue/mock_objects.h" 14 #include "remoting/jingle_glue/mock_objects.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 17 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
17 18
18 using buzz::QName; 19 using buzz::QName;
19 using buzz::XmlElement; 20 using buzz::XmlElement;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // So we expect SendStanza to be called only once. 81 // So we expect SendStanza to be called only once.
81 host_status_sender_->SendOnlineStatus(); 82 host_status_sender_->SendOnlineStatus();
82 83
83 host_status_sender_->OnSignalStrategyStateChange( 84 host_status_sender_->OnSignalStrategyStateChange(
84 SignalStrategy::CONNECTED); 85 SignalStrategy::CONNECTED);
85 host_status_sender_->SendOnlineStatus(); 86 host_status_sender_->SendOnlineStatus();
86 87
87 scoped_ptr<XmlElement> stanza(sent_iq); 88 scoped_ptr<XmlElement> stanza(sent_iq);
88 89
89 ASSERT_TRUE(stanza != NULL); 90 ASSERT_TRUE(stanza != NULL);
90 LOG(INFO) << stanza->Str();
91 91
92 ValidateHostStatusStanza(stanza.get(), HostStatusSender::ONLINE); 92 ValidateHostStatusStanza(stanza.get(), HostStatusSender::ONLINE);
93 } 93 }
94 94
95 TEST_F(HostStatusSenderTest, SendOfflineStatus) { 95 TEST_F(HostStatusSenderTest, SendOfflineStatus) {
96 XmlElement* sent_iq = NULL; 96 XmlElement* sent_iq = NULL;
97 EXPECT_CALL(signal_strategy_, GetState()) 97 EXPECT_CALL(signal_strategy_, GetState())
98 .WillOnce(Return(SignalStrategy::DISCONNECTED)) 98 .WillOnce(Return(SignalStrategy::DISCONNECTED))
99 .WillRepeatedly(Return(SignalStrategy::CONNECTED)); 99 .WillRepeatedly(Return(SignalStrategy::CONNECTED));
100 EXPECT_CALL(signal_strategy_, GetLocalJid()) 100 EXPECT_CALL(signal_strategy_, GetLocalJid())
101 .WillRepeatedly(Return(kTestJid)); 101 .WillRepeatedly(Return(kTestJid));
102 EXPECT_CALL(signal_strategy_, GetNextId()) 102 EXPECT_CALL(signal_strategy_, GetNextId())
103 .WillOnce(Return(kStanzaId)); 103 .WillOnce(Return(kStanzaId));
104 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) 104 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull()))
105 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); 105 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true)));
106 106
107 // Call SendOfflineStatus twice. The first call should be a 107 // Call SendOfflineStatus twice. The first call should be a
108 // no-op because |signal_strategy_| is diconnected. 108 // no-op because |signal_strategy_| is diconnected.
109 // So we expect SendStanza to be called only once. 109 // So we expect SendStanza to be called only once.
110 host_status_sender_->SendOfflineStatus(kTestExitCode); 110 host_status_sender_->SendOfflineStatus(kTestExitCode);
111 111
112 host_status_sender_->OnSignalStrategyStateChange( 112 host_status_sender_->OnSignalStrategyStateChange(
113 SignalStrategy::CONNECTED); 113 SignalStrategy::CONNECTED);
114 host_status_sender_->SendOfflineStatus(kTestExitCode); 114 host_status_sender_->SendOfflineStatus(kTestExitCode);
115 115
116 scoped_ptr<XmlElement> stanza(sent_iq); 116 scoped_ptr<XmlElement> stanza(sent_iq);
117 117
118 ASSERT_TRUE(stanza != NULL); 118 ASSERT_TRUE(stanza != NULL);
119 LOG(INFO) << stanza->Str();
120 119
121 ValidateHostStatusStanza(stanza.get(), HostStatusSender::OFFLINE); 120 ValidateHostStatusStanza(stanza.get(), HostStatusSender::OFFLINE);
122 } 121 }
123 122
124 // Validate a host status stanza. 123 // Validate a host status stanza.
125 void HostStatusSenderTest::ValidateHostStatusStanza( 124 void HostStatusSenderTest::ValidateHostStatusStanza(
126 XmlElement* stanza, HostStatusSender::HostStatus status) { 125 XmlElement* stanza, HostStatusSender::HostStatus status) {
127 EXPECT_EQ(stanza->Attr(QName(std::string(), "to")), 126 EXPECT_EQ(stanza->Attr(QName(std::string(), "to")),
128 std::string(kTestBotJid)); 127 std::string(kTestBotJid));
129 EXPECT_EQ(stanza->Attr(QName(std::string(), "type")), "set"); 128 EXPECT_EQ(stanza->Attr(QName(std::string(), "type")), "set");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } else { 184 } else {
186 message += "ONLINE"; 185 message += "ONLINE";
187 } 186 }
188 187
189 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); 188 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair);
190 ASSERT_TRUE(key_pair.get()); 189 ASSERT_TRUE(key_pair.get());
191 190
192 std::string expected_signature = 191 std::string expected_signature =
193 key_pair->SignMessage(message); 192 key_pair->SignMessage(message);
194 EXPECT_EQ(expected_signature, signature->BodyText()); 193 EXPECT_EQ(expected_signature, signature->BodyText());
195
196 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT());
197 LOG(INFO) << "SendHostStatus took " << now - time << " seconds.";
198 } 194 }
199 195
200 } // namespace remoting 196 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_status_sender.cc ('k') | remoting/host/input_injector_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698