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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 TEST_F(RegisterSupportHostRequestTest, Send) { | 78 TEST_F(RegisterSupportHostRequestTest, Send) { |
79 // |iq_request| is freed by RegisterSupportHostRequest. | 79 // |iq_request| is freed by RegisterSupportHostRequest. |
80 int64 start_time = static_cast<int64>(base::Time::Now().ToDoubleT()); | 80 int64 start_time = static_cast<int64>(base::Time::Now().ToDoubleT()); |
81 | 81 |
82 scoped_ptr<RegisterSupportHostRequest> request( | 82 scoped_ptr<RegisterSupportHostRequest> request( |
83 new RegisterSupportHostRequest(&signal_strategy_, key_pair_, | 83 new RegisterSupportHostRequest(&signal_strategy_, key_pair_, |
84 kTestBotJid, | 84 kTestBotJid, |
85 base::Bind(&MockCallback::OnResponse, | 85 base::Bind(&MockCallback::OnResponse, |
86 base::Unretained(&callback_)))); | 86 base::Unretained(&callback_)))); |
87 | 87 |
88 XmlElement* sent_iq = NULL; | 88 XmlElement* sent_iq = nullptr; |
89 EXPECT_CALL(signal_strategy_, GetNextId()) | 89 EXPECT_CALL(signal_strategy_, GetNextId()) |
90 .WillOnce(Return(kStanzaId)); | 90 .WillOnce(Return(kStanzaId)); |
91 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) | 91 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) |
92 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); | 92 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); |
93 | 93 |
94 request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); | 94 request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); |
95 base::RunLoop().RunUntilIdle(); | 95 base::RunLoop().RunUntilIdle(); |
96 | 96 |
97 // Verify format of the query. | 97 // Verify format of the query. |
98 scoped_ptr<XmlElement> stanza(sent_iq); | 98 scoped_ptr<XmlElement> stanza(sent_iq); |
99 ASSERT_TRUE(stanza != NULL); | 99 ASSERT_TRUE(stanza != nullptr); |
100 | 100 |
101 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "to")), | 101 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "to")), |
102 std::string(kTestBotJid)); | 102 std::string(kTestBotJid)); |
103 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "type")), "set"); | 103 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "type")), "set"); |
104 | 104 |
105 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"), | 105 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"), |
106 stanza->FirstElement()->Name()); | 106 stanza->FirstElement()->Name()); |
107 | 107 |
108 QName signature_tag(kChromotingXmlNamespace, "signature"); | 108 QName signature_tag(kChromotingXmlNamespace, "signature"); |
109 XmlElement* signature = stanza->FirstElement()->FirstNamed(signature_tag); | 109 XmlElement* signature = stanza->FirstElement()->FirstNamed(signature_tag); |
110 ASSERT_TRUE(signature != NULL); | 110 ASSERT_TRUE(signature != nullptr); |
111 EXPECT_TRUE(stanza->NextNamed(signature_tag) == NULL); | 111 EXPECT_TRUE(stanza->NextNamed(signature_tag) == nullptr); |
112 | 112 |
113 std::string time_str = | 113 std::string time_str = |
114 signature->Attr(QName(kChromotingXmlNamespace, "time")); | 114 signature->Attr(QName(kChromotingXmlNamespace, "time")); |
115 int64 time; | 115 int64 time; |
116 EXPECT_TRUE(base::StringToInt64(time_str, &time)); | 116 EXPECT_TRUE(base::StringToInt64(time_str, &time)); |
117 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); | 117 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); |
118 EXPECT_LE(start_time, time); | 118 EXPECT_LE(start_time, time); |
119 EXPECT_GE(now, time); | 119 EXPECT_GE(now, time); |
120 | 120 |
121 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); | 121 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); |
(...skipping 23 matching lines...) Expand all Loading... |
145 | 145 |
146 XmlElement* support_id_lifetime = new XmlElement( | 146 XmlElement* support_id_lifetime = new XmlElement( |
147 QName(kChromotingXmlNamespace, "support-id-lifetime")); | 147 QName(kChromotingXmlNamespace, "support-id-lifetime")); |
148 support_id_lifetime->AddText(kSupportIdLifetime); | 148 support_id_lifetime->AddText(kSupportIdLifetime); |
149 result->AddElement(support_id_lifetime); | 149 result->AddElement(support_id_lifetime); |
150 | 150 |
151 int consumed = 0; | 151 int consumed = 0; |
152 ObserverListBase<SignalStrategy::Listener>::Iterator it( | 152 ObserverListBase<SignalStrategy::Listener>::Iterator it( |
153 signal_strategy_listeners_); | 153 signal_strategy_listeners_); |
154 SignalStrategy::Listener* listener; | 154 SignalStrategy::Listener* listener; |
155 while ((listener = it.GetNext()) != NULL) { | 155 while ((listener = it.GetNext()) != nullptr) { |
156 if (listener->OnSignalStrategyIncomingStanza(response.get())) | 156 if (listener->OnSignalStrategyIncomingStanza(response.get())) |
157 consumed++; | 157 consumed++; |
158 } | 158 } |
159 EXPECT_EQ(1, consumed); | 159 EXPECT_EQ(1, consumed); |
160 | 160 |
161 base::RunLoop().RunUntilIdle(); | 161 base::RunLoop().RunUntilIdle(); |
162 } | 162 } |
163 | 163 |
164 } // namespace remoting | 164 } // namespace remoting |
OLD | NEW |