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.h" | 9 #include "base/message_loop.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const base::TimeDelta& lifetime)); | 52 const base::TimeDelta& lifetime)); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 class RegisterSupportHostRequestTest : public testing::Test { | 57 class RegisterSupportHostRequestTest : public testing::Test { |
58 public: | 58 public: |
59 protected: | 59 protected: |
60 virtual void SetUp() { | 60 virtual void SetUp() { |
61 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); | 61 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); |
62 ASSERT_TRUE(key_pair_); | 62 ASSERT_TRUE(key_pair_.get()); |
63 | 63 |
64 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) | 64 EXPECT_CALL(signal_strategy_, AddListener(NotNull())) |
65 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); | 65 .WillRepeatedly(AddListener(&signal_strategy_listeners_)); |
66 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) | 66 EXPECT_CALL(signal_strategy_, RemoveListener(NotNull())) |
67 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); | 67 .WillRepeatedly(RemoveListener(&signal_strategy_listeners_)); |
68 EXPECT_CALL(signal_strategy_, GetLocalJid()) | 68 EXPECT_CALL(signal_strategy_, GetLocalJid()) |
69 .WillRepeatedly(Return(kTestJid)); | 69 .WillRepeatedly(Return(kTestJid)); |
70 } | 70 } |
71 | 71 |
72 base::MessageLoop message_loop_; | 72 base::MessageLoop message_loop_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 std::string time_str = | 114 std::string time_str = |
115 signature->Attr(QName(kChromotingXmlNamespace, "time")); | 115 signature->Attr(QName(kChromotingXmlNamespace, "time")); |
116 int64 time; | 116 int64 time; |
117 EXPECT_TRUE(base::StringToInt64(time_str, &time)); | 117 EXPECT_TRUE(base::StringToInt64(time_str, &time)); |
118 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); | 118 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); |
119 EXPECT_LE(start_time, time); | 119 EXPECT_LE(start_time, time); |
120 EXPECT_GE(now, time); | 120 EXPECT_GE(now, time); |
121 | 121 |
122 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); | 122 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); |
123 ASSERT_TRUE(key_pair); | 123 ASSERT_TRUE(key_pair.get()); |
124 | 124 |
125 std::string expected_signature = | 125 std::string expected_signature = |
126 key_pair->SignMessage(std::string(kTestJid) + ' ' + time_str); | 126 key_pair->SignMessage(std::string(kTestJid) + ' ' + time_str); |
127 EXPECT_EQ(expected_signature, signature->BodyText()); | 127 EXPECT_EQ(expected_signature, signature->BodyText()); |
128 | 128 |
129 // Generate response and verify that callback is called. | 129 // Generate response and verify that callback is called. |
130 EXPECT_CALL(callback_, OnResponse(true, kSupportId, | 130 EXPECT_CALL(callback_, OnResponse(true, kSupportId, |
131 base::TimeDelta::FromSeconds(300))); | 131 base::TimeDelta::FromSeconds(300))); |
132 | 132 |
133 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); | 133 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); |
(...skipping 22 matching lines...) Expand all Loading... |
156 while ((listener = it.GetNext()) != NULL) { | 156 while ((listener = it.GetNext()) != NULL) { |
157 if (listener->OnSignalStrategyIncomingStanza(response.get())) | 157 if (listener->OnSignalStrategyIncomingStanza(response.get())) |
158 consumed++; | 158 consumed++; |
159 } | 159 } |
160 EXPECT_EQ(1, consumed); | 160 EXPECT_EQ(1, consumed); |
161 | 161 |
162 message_loop_.RunUntilIdle(); | 162 message_loop_.RunUntilIdle(); |
163 } | 163 } |
164 | 164 |
165 } // namespace remoting | 165 } // namespace remoting |
OLD | NEW |