| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/security_key/remote_security_key_message_handler.h" | 5 #include "remoting/host/security_key/remote_security_key_message_handler.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "remoting/host/security_key/fake_remote_security_key_ipc_client.h" | 15 #include "remoting/host/security_key/fake_remote_security_key_ipc_client.h" |
| 16 #include "remoting/host/security_key/fake_remote_security_key_message_reader.h" | 16 #include "remoting/host/security_key/fake_remote_security_key_message_reader.h" |
| 17 #include "remoting/host/security_key/fake_remote_security_key_message_writer.h" | 17 #include "remoting/host/security_key/fake_remote_security_key_message_writer.h" |
| 18 #include "remoting/host/security_key/remote_security_key_ipc_constants.h" | 18 #include "remoting/host/security_key/remote_security_key_ipc_constants.h" |
| 19 #include "remoting/host/security_key/security_key_message.h" | 19 #include "remoting/host/security_key/security_key_message.h" |
| 20 #include "remoting/host/setup/test_util.h" | 20 #include "remoting/host/setup/test_util.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 const std::string& message_payload); | 43 const std::string& message_payload); |
| 44 | 44 |
| 45 bool last_operation_failed_ = false; | 45 bool last_operation_failed_ = false; |
| 46 RemoteSecurityKeyMessageType last_message_type_received_ = | 46 RemoteSecurityKeyMessageType last_message_type_received_ = |
| 47 RemoteSecurityKeyMessageType::INVALID; | 47 RemoteSecurityKeyMessageType::INVALID; |
| 48 std::string last_message_payload_received_; | 48 std::string last_message_payload_received_; |
| 49 | 49 |
| 50 base::WeakPtr<FakeRemoteSecurityKeyIpcClient> ipc_client_weak_ptr_; | 50 base::WeakPtr<FakeRemoteSecurityKeyIpcClient> ipc_client_weak_ptr_; |
| 51 base::WeakPtr<FakeRemoteSecurityKeyMessageReader> reader_weak_ptr_; | 51 base::WeakPtr<FakeRemoteSecurityKeyMessageReader> reader_weak_ptr_; |
| 52 base::WeakPtr<FakeRemoteSecurityKeyMessageWriter> writer_weak_ptr_; | 52 base::WeakPtr<FakeRemoteSecurityKeyMessageWriter> writer_weak_ptr_; |
| 53 scoped_ptr<RemoteSecurityKeyMessageHandler> message_handler_; | 53 std::unique_ptr<RemoteSecurityKeyMessageHandler> message_handler_; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 base::MessageLoopForIO message_loop_; | 56 base::MessageLoopForIO message_loop_; |
| 57 scoped_ptr<base::RunLoop> run_loop_; | 57 std::unique_ptr<base::RunLoop> run_loop_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageHandlerTest); | 59 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageHandlerTest); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 RemoteSecurityKeyMessageHandlerTest::RemoteSecurityKeyMessageHandlerTest() {} | 62 RemoteSecurityKeyMessageHandlerTest::RemoteSecurityKeyMessageHandlerTest() {} |
| 63 | 63 |
| 64 RemoteSecurityKeyMessageHandlerTest::~RemoteSecurityKeyMessageHandlerTest() {} | 64 RemoteSecurityKeyMessageHandlerTest::~RemoteSecurityKeyMessageHandlerTest() {} |
| 65 | 65 |
| 66 void RemoteSecurityKeyMessageHandlerTest::OperationComplete() { | 66 void RemoteSecurityKeyMessageHandlerTest::OperationComplete() { |
| 67 run_loop_->Quit(); | 67 run_loop_->Quit(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void RemoteSecurityKeyMessageHandlerTest::SetUp() { | 70 void RemoteSecurityKeyMessageHandlerTest::SetUp() { |
| 71 run_loop_.reset(new base::RunLoop()); | 71 run_loop_.reset(new base::RunLoop()); |
| 72 message_handler_.reset(new RemoteSecurityKeyMessageHandler()); | 72 message_handler_.reset(new RemoteSecurityKeyMessageHandler()); |
| 73 | 73 |
| 74 scoped_ptr<FakeRemoteSecurityKeyIpcClient> ipc_client( | 74 std::unique_ptr<FakeRemoteSecurityKeyIpcClient> ipc_client( |
| 75 new FakeRemoteSecurityKeyIpcClient( | 75 new FakeRemoteSecurityKeyIpcClient( |
| 76 base::Bind(&RemoteSecurityKeyMessageHandlerTest::OperationComplete, | 76 base::Bind(&RemoteSecurityKeyMessageHandlerTest::OperationComplete, |
| 77 base::Unretained(this)))); | 77 base::Unretained(this)))); |
| 78 ipc_client_weak_ptr_ = ipc_client->AsWeakPtr(); | 78 ipc_client_weak_ptr_ = ipc_client->AsWeakPtr(); |
| 79 | 79 |
| 80 scoped_ptr<FakeRemoteSecurityKeyMessageReader> reader( | 80 std::unique_ptr<FakeRemoteSecurityKeyMessageReader> reader( |
| 81 new FakeRemoteSecurityKeyMessageReader()); | 81 new FakeRemoteSecurityKeyMessageReader()); |
| 82 reader_weak_ptr_ = reader->AsWeakPtr(); | 82 reader_weak_ptr_ = reader->AsWeakPtr(); |
| 83 | 83 |
| 84 scoped_ptr<FakeRemoteSecurityKeyMessageWriter> writer( | 84 std::unique_ptr<FakeRemoteSecurityKeyMessageWriter> writer( |
| 85 new FakeRemoteSecurityKeyMessageWriter( | 85 new FakeRemoteSecurityKeyMessageWriter( |
| 86 base::Bind(&RemoteSecurityKeyMessageHandlerTest::OperationComplete, | 86 base::Bind(&RemoteSecurityKeyMessageHandlerTest::OperationComplete, |
| 87 base::Unretained(this)))); | 87 base::Unretained(this)))); |
| 88 writer_weak_ptr_ = writer->AsWeakPtr(); | 88 writer_weak_ptr_ = writer->AsWeakPtr(); |
| 89 | 89 |
| 90 message_handler_->SetRemoteSecurityKeyMessageReaderForTest(std::move(reader)); | 90 message_handler_->SetRemoteSecurityKeyMessageReaderForTest(std::move(reader)); |
| 91 | 91 |
| 92 message_handler_->SetRemoteSecurityKeyMessageWriterForTest(std::move(writer)); | 92 message_handler_->SetRemoteSecurityKeyMessageWriterForTest(std::move(writer)); |
| 93 | 93 |
| 94 base::File read_file; | 94 base::File read_file; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 reader_weak_ptr_->message_callback().Run( | 291 reader_weak_ptr_->message_callback().Run( |
| 292 SecurityKeyMessage::CreateMessageForTest( | 292 SecurityKeyMessage::CreateMessageForTest( |
| 293 RemoteSecurityKeyMessageType::UNKNOWN_ERROR, std::string())); | 293 RemoteSecurityKeyMessageType::UNKNOWN_ERROR, std::string())); |
| 294 WaitForOperationComplete(); | 294 WaitForOperationComplete(); |
| 295 | 295 |
| 296 ASSERT_EQ(RemoteSecurityKeyMessageType::UNKNOWN_COMMAND, | 296 ASSERT_EQ(RemoteSecurityKeyMessageType::UNKNOWN_COMMAND, |
| 297 writer_weak_ptr_->last_message_type()); | 297 writer_weak_ptr_->last_message_type()); |
| 298 } | 298 } |
| 299 | 299 |
| 300 } // namespace remoting | 300 } // namespace remoting |
| OLD | NEW |