Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: remoting/host/security_key/security_key_ipc_client_unittest.cc

Issue 2620633004: Remove mojo::edk::test::ScopedIPCSupport (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/security_key_ipc_client.h" 5 #include "remoting/host/security_key/security_key_ipc_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "ipc/ipc_channel.h" 14 #include "ipc/ipc_channel.h"
15 #include "mojo/edk/embedder/named_platform_handle_utils.h" 15 #include "mojo/edk/embedder/named_platform_handle_utils.h"
16 #include "mojo/edk/test/scoped_ipc_support.h" 16 #include "mojo/edk/embedder/scoped_ipc_support.h"
17 #include "remoting/host/security_key/fake_security_key_ipc_server.h" 17 #include "remoting/host/security_key/fake_security_key_ipc_server.h"
18 #include "remoting/host/security_key/security_key_ipc_constants.h" 18 #include "remoting/host/security_key/security_key_ipc_constants.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace { 21 namespace {
22 const int kTestConnectionId = 1; 22 const int kTestConnectionId = 1;
23 const char kNonexistentIpcChannelName[] = "Nonexistent_IPC_Channel"; 23 const char kNonexistentIpcChannelName[] = "Nonexistent_IPC_Channel";
24 const char kValidIpcChannelName[] = "SecurityKeyIpcClientTest"; 24 const char kValidIpcChannelName[] = "SecurityKeyIpcClientTest";
25 const int kLargeMessageSizeBytes = 256 * 1024; 25 const int kLargeMessageSizeBytes = 256 * 1024;
26 } // namespace 26 } // namespace
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // a response from |fake_ipc_server_| and verifies the payloads for both. 67 // a response from |fake_ipc_server_| and verifies the payloads for both.
68 void SendRequestAndResponse(const std::string& request_data, 68 void SendRequestAndResponse(const std::string& request_data,
69 const std::string& response_data); 69 const std::string& response_data);
70 70
71 // Creates a unique IPC channel name to use for testing. 71 // Creates a unique IPC channel name to use for testing.
72 std::string GenerateUniqueTestChannelName(); 72 std::string GenerateUniqueTestChannelName();
73 73
74 // IPC tests require a valid MessageLoop to run. 74 // IPC tests require a valid MessageLoop to run.
75 base::MessageLoopForIO message_loop_; 75 base::MessageLoopForIO message_loop_;
76 76
77 mojo::edk::test::ScopedIPCSupport ipc_support_; 77 mojo::edk::ScopedIPCSupport ipc_support_;
78 78
79 // Used to allow |message_loop_| to run during tests. The instance is reset 79 // Used to allow |message_loop_| to run during tests. The instance is reset
80 // after each stage of the tests has been completed. 80 // after each stage of the tests has been completed.
81 std::unique_ptr<base::RunLoop> run_loop_; 81 std::unique_ptr<base::RunLoop> run_loop_;
82 82
83 // The object under test. 83 // The object under test.
84 SecurityKeyIpcClient security_key_ipc_client_; 84 SecurityKeyIpcClient security_key_ipc_client_;
85 85
86 // Used to send/receive security key IPC messages for testing. 86 // Used to send/receive security key IPC messages for testing.
87 FakeSecurityKeyIpcServer fake_ipc_server_; 87 FakeSecurityKeyIpcServer fake_ipc_server_;
(...skipping 15 matching lines...) Expand all
103 int last_connection_id_received_ = -1; 103 int last_connection_id_received_ = -1;
104 104
105 // Stores the contents of the last IPC message received for validation. 105 // Stores the contents of the last IPC message received for validation.
106 std::string last_message_received_; 106 std::string last_message_received_;
107 107
108 private: 108 private:
109 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcClientTest); 109 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcClientTest);
110 }; 110 };
111 111
112 SecurityKeyIpcClientTest::SecurityKeyIpcClientTest() 112 SecurityKeyIpcClientTest::SecurityKeyIpcClientTest()
113 : ipc_support_(message_loop_.task_runner()), 113 : ipc_support_(message_loop_.task_runner(),
114 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST),
114 run_loop_(new base::RunLoop()), 115 run_loop_(new base::RunLoop()),
115 fake_ipc_server_( 116 fake_ipc_server_(
116 kTestConnectionId, 117 kTestConnectionId,
117 /*client_session_details=*/nullptr, 118 /*client_session_details=*/nullptr,
118 /*initial_connect_timeout=*/base::TimeDelta::FromMilliseconds(500), 119 /*initial_connect_timeout=*/base::TimeDelta::FromMilliseconds(500),
119 base::Bind(&SecurityKeyIpcClientTest::SendMessageToClient, 120 base::Bind(&SecurityKeyIpcClientTest::SendMessageToClient,
120 base::Unretained(this)), 121 base::Unretained(this)),
121 base::Bind(&SecurityKeyIpcClientTest::SendConnectionMessage, 122 base::Bind(&SecurityKeyIpcClientTest::SendConnectionMessage,
122 base::Unretained(this)), 123 base::Unretained(this)),
123 base::Bind(&SecurityKeyIpcClientTest::OperationComplete, 124 base::Bind(&SecurityKeyIpcClientTest::OperationComplete,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 ASSERT_TRUE(operation_failed_); 400 ASSERT_TRUE(operation_failed_);
400 401
401 // Send a third message to ensure no crash occurs both callbacks will have 402 // Send a third message to ensure no crash occurs both callbacks will have
402 // been called and cleared so we don't wait for the operation to complete. 403 // been called and cleared so we don't wait for the operation to complete.
403 SendConnectionMessage(); 404 SendConnectionMessage();
404 ASSERT_TRUE(operation_failed_); 405 ASSERT_TRUE(operation_failed_);
405 } 406 }
406 #endif // defined(OS_WIN) 407 #endif // defined(OS_WIN)
407 408
408 } // namespace remoting 409 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698