| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 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 "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "remoting/signaling/iq_sender.h" | 10 #include "remoting/signaling/iq_sender.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 TEST_F(IqSenderTest, Timeout) { | 120 TEST_F(IqSenderTest, Timeout) { |
| 121 ASSERT_NO_FATAL_FAILURE({ | 121 ASSERT_NO_FATAL_FAILURE({ |
| 122 SendTestMessage(); | 122 SendTestMessage(); |
| 123 }); | 123 }); |
| 124 | 124 |
| 125 request_->SetTimeout(base::TimeDelta::FromMilliseconds(2)); | 125 request_->SetTimeout(base::TimeDelta::FromMilliseconds(2)); |
| 126 | 126 |
| 127 EXPECT_CALL(callback_, OnReply(request_.get(), nullptr)) | 127 EXPECT_CALL(callback_, OnReply(request_.get(), nullptr)) |
| 128 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::Quit)); | 128 .WillOnce( |
| 129 InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitWhenIdle)); |
| 129 message_loop_.Run(); | 130 message_loop_.Run(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 TEST_F(IqSenderTest, NotNormalizedJid) { | 133 TEST_F(IqSenderTest, NotNormalizedJid) { |
| 133 ASSERT_NO_FATAL_FAILURE({ | 134 ASSERT_NO_FATAL_FAILURE({ |
| 134 SendTestMessage(); | 135 SendTestMessage(); |
| 135 }); | 136 }); |
| 136 | 137 |
| 137 // Set upper-case from value, which is equivalent to kTo in the original | 138 // Set upper-case from value, which is equivalent to kTo in the original |
| 138 // message. | 139 // message. |
| 139 scoped_ptr<XmlElement> response; | 140 scoped_ptr<XmlElement> response; |
| 140 EXPECT_TRUE(FormatAndDeliverResponse("USER@domain.com", &response)); | 141 EXPECT_TRUE(FormatAndDeliverResponse("USER@domain.com", &response)); |
| 141 | 142 |
| 142 EXPECT_CALL(callback_, OnReply(request_.get(), XmlEq(response.get()))); | 143 EXPECT_CALL(callback_, OnReply(request_.get(), XmlEq(response.get()))); |
| 143 base::RunLoop().RunUntilIdle(); | 144 base::RunLoop().RunUntilIdle(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 TEST_F(IqSenderTest, InvalidFrom) { | 147 TEST_F(IqSenderTest, InvalidFrom) { |
| 147 ASSERT_NO_FATAL_FAILURE({ | 148 ASSERT_NO_FATAL_FAILURE({ |
| 148 SendTestMessage(); | 149 SendTestMessage(); |
| 149 }); | 150 }); |
| 150 | 151 |
| 151 EXPECT_FALSE(FormatAndDeliverResponse("different_user@domain.com", nullptr)); | 152 EXPECT_FALSE(FormatAndDeliverResponse("different_user@domain.com", nullptr)); |
| 152 | 153 |
| 153 EXPECT_CALL(callback_, OnReply(_, _)).Times(0); | 154 EXPECT_CALL(callback_, OnReply(_, _)).Times(0); |
| 154 base::RunLoop().RunUntilIdle(); | 155 base::RunLoop().RunUntilIdle(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace remoting | 158 } // namespace remoting |
| OLD | NEW |