OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/setup/me2me_native_messaging_host.h" | 5 #include "remoting/host/setup/me2me_native_messaging_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.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 "base/run_loop.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/stringize_macros.h" | 14 #include "base/strings/stringize_macros.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "google_apis/gaia/gaia_oauth_client.h" | 16 #include "google_apis/gaia/gaia_oauth_client.h" |
17 #include "net/base/file_stream.h" | 17 #include "net/base/file_stream.h" |
18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
19 #include "remoting/base/auto_thread_task_runner.h" | 19 #include "remoting/base/auto_thread_task_runner.h" |
20 #include "remoting/host/native_messaging/native_messaging_channel.h" | 20 #include "remoting/host/native_messaging/pipe_messaging_channel.h" |
21 #include "remoting/host/pin_hash.h" | 21 #include "remoting/host/pin_hash.h" |
22 #include "remoting/host/setup/test_util.h" | 22 #include "remoting/host/setup/test_util.h" |
23 #include "remoting/protocol/pairing_registry.h" | 23 #include "remoting/protocol/pairing_registry.h" |
24 #include "remoting/protocol/protocol_mock_objects.h" | 24 #include "remoting/protocol/protocol_mock_objects.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 using remoting::protocol::MockPairingRegistryDelegate; | 27 using remoting::protocol::MockPairingRegistryDelegate; |
28 using remoting::protocol::PairingRegistry; | 28 using remoting::protocol::PairingRegistry; |
29 using remoting::protocol::SynchronousPairingRegistry; | 29 using remoting::protocol::SynchronousPairingRegistry; |
30 | 30 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 | 316 |
317 daemon_controller_delegate_ = new MockDaemonControllerDelegate(); | 317 daemon_controller_delegate_ = new MockDaemonControllerDelegate(); |
318 scoped_refptr<DaemonController> daemon_controller( | 318 scoped_refptr<DaemonController> daemon_controller( |
319 new DaemonController( | 319 new DaemonController( |
320 scoped_ptr<DaemonController::Delegate>(daemon_controller_delegate_))); | 320 scoped_ptr<DaemonController::Delegate>(daemon_controller_delegate_))); |
321 | 321 |
322 scoped_refptr<PairingRegistry> pairing_registry = | 322 scoped_refptr<PairingRegistry> pairing_registry = |
323 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>( | 323 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>( |
324 new MockPairingRegistryDelegate())); | 324 new MockPairingRegistryDelegate())); |
325 | 325 |
326 scoped_ptr<NativeMessagingChannel> channel( | 326 scoped_ptr<PipeMessagingChannel> channel( |
Sergey Ulanov
2014/09/18 18:08:36
scoped_ptr<extensions::NativeMessagingChannel>
kelvinp
2014/09/18 19:03:51
Done.
| |
327 new NativeMessagingChannel(input_read_file.Pass(), | 327 new PipeMessagingChannel(input_read_file.Pass(), |
328 output_write_file.Pass())); | 328 output_write_file.Pass())); |
329 | 329 |
330 host_.reset(new Me2MeNativeMessagingHost( | 330 host_.reset(new Me2MeNativeMessagingHost( |
331 false, | 331 false, |
332 0, | 332 0, |
333 channel.Pass(), | 333 channel.PassAs<extensions::NativeMessagingChannel>(), |
334 daemon_controller, | 334 daemon_controller, |
335 pairing_registry, | 335 pairing_registry, |
336 scoped_ptr<remoting::OAuthClient>())); | 336 scoped_ptr<remoting::OAuthClient>())); |
337 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost, | 337 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost, |
338 base::Unretained(this))); | 338 base::Unretained(this))); |
339 | 339 |
340 // Notify the test that the host has finished starting up. | 340 // Notify the test that the host has finished starting up. |
341 test_message_loop_->message_loop_proxy()->PostTask( | 341 test_message_loop_->message_loop_proxy()->PostTask( |
342 FROM_HERE, test_run_loop_->QuitClosure()); | 342 FROM_HERE, test_run_loop_->QuitClosure()); |
343 } | 343 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 | 600 |
601 // Verify rejection if startDaemon request has no "consent" parameter. | 601 // Verify rejection if startDaemon request has no "consent" parameter. |
602 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { | 602 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { |
603 base::DictionaryValue message; | 603 base::DictionaryValue message; |
604 message.SetString("type", "startDaemon"); | 604 message.SetString("type", "startDaemon"); |
605 message.Set("config", base::DictionaryValue().DeepCopy()); | 605 message.Set("config", base::DictionaryValue().DeepCopy()); |
606 TestBadRequest(message); | 606 TestBadRequest(message); |
607 } | 607 } |
608 | 608 |
609 } // namespace remoting | 609 } // namespace remoting |
OLD | NEW |