OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test/test_chromoting_client.h" | 5 #include "remoting/test/test_chromoting_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" |
12 #include "remoting/protocol/fake_connection_to_host.h" | 13 #include "remoting/protocol/fake_connection_to_host.h" |
13 #include "remoting/signaling/fake_signal_strategy.h" | 14 #include "remoting/signaling/fake_signal_strategy.h" |
14 #include "remoting/test/connection_setup_info.h" | 15 #include "remoting/test/connection_setup_info.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 namespace test { | 19 namespace test { |
19 | 20 |
20 using testing::_; | 21 using testing::_; |
21 | 22 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void TestChromotingClientTest::TearDown() { | 80 void TestChromotingClientTest::TearDown() { |
80 test_chromoting_client_->RemoveRemoteConnectionObserver(this); | 81 test_chromoting_client_->RemoveRemoteConnectionObserver(this); |
81 fake_connection_to_host_ = nullptr; | 82 fake_connection_to_host_ = nullptr; |
82 | 83 |
83 // The chromoting instance must be destroyed before the message loop. | 84 // The chromoting instance must be destroyed before the message loop. |
84 test_chromoting_client_.reset(); | 85 test_chromoting_client_.reset(); |
85 | 86 |
86 // The IceTransportFactory destroys the PortAllocator via a DeleteSoon | 87 // The IceTransportFactory destroys the PortAllocator via a DeleteSoon |
87 // operation. If we do not allow the message loop to run here, we run the | 88 // operation. If we do not allow the message loop to run here, we run the |
88 // risk of the DeleteSoon task being dropped and incurring a memory leak. | 89 // risk of the DeleteSoon task being dropped and incurring a memory leak. |
89 message_loop_.RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
90 } | 91 } |
91 | 92 |
92 void TestChromotingClientTest::ConnectionStateChanged( | 93 void TestChromotingClientTest::ConnectionStateChanged( |
93 protocol::ConnectionToHost::State state, | 94 protocol::ConnectionToHost::State state, |
94 protocol::ErrorCode error_code) { | 95 protocol::ErrorCode error_code) { |
95 connection_state_ = state; | 96 connection_state_ = state; |
96 error_code_ = error_code; | 97 error_code_ = error_code; |
97 | 98 |
98 if (state != protocol::ConnectionToHost::State::CONNECTED || | 99 if (state != protocol::ConnectionToHost::State::CONNECTED || |
99 error_code != protocol::OK) { | 100 error_code != protocol::OK) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Close the connection via the TestChromotingClient and verify the error | 196 // Close the connection via the TestChromotingClient and verify the error |
196 // state is persisted. | 197 // state is persisted. |
197 test_chromoting_client_->EndConnection(); | 198 test_chromoting_client_->EndConnection(); |
198 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); | 199 EXPECT_EQ(protocol::ConnectionToHost::State::FAILED, connection_state_); |
199 EXPECT_EQ(protocol::ErrorCode::UNKNOWN_ERROR, error_code_); | 200 EXPECT_EQ(protocol::ErrorCode::UNKNOWN_ERROR, error_code_); |
200 EXPECT_FALSE(is_connected_to_host_); | 201 EXPECT_FALSE(is_connected_to_host_); |
201 } | 202 } |
202 | 203 |
203 } // namespace test | 204 } // namespace test |
204 } // namespace remoting | 205 } // namespace remoting |
OLD | NEW |