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/native_messaging_host.h" | 5 #include "remoting/host/setup/native_messaging_host.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/stringize_macros.h" | 13 #include "base/strings/stringize_macros.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "net/base/file_stream.h" | 15 #include "net/base/file_stream.h" |
16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
17 #include "remoting/host/pin_hash.h" | 17 #include "remoting/host/pin_hash.h" |
18 #include "remoting/host/setup/test_util.h" | 18 #include "remoting/host/setup/test_util.h" |
19 #include "remoting/protocol/pairing_registry.h" | 19 #include "remoting/protocol/pairing_registry.h" |
20 #include "remoting/protocol/protocol_mock_objects.h" | 20 #include "remoting/protocol/protocol_mock_objects.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
| 23 using remoting::protocol::MockPairingRegistryDelegate; |
23 using remoting::protocol::PairingRegistry; | 24 using remoting::protocol::PairingRegistry; |
24 using remoting::protocol::MockPairingRegistryDelegate; | 25 using remoting::protocol::SynchronousPairingRegistry; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 void VerifyHelloResponse(const base::DictionaryValue* response) { | 29 void VerifyHelloResponse(const base::DictionaryValue* response) { |
29 ASSERT_TRUE(response); | 30 ASSERT_TRUE(response); |
30 std::string value; | 31 std::string value; |
31 EXPECT_TRUE(response->GetString("type", &value)); | 32 EXPECT_TRUE(response->GetString("type", &value)); |
32 EXPECT_EQ("helloResponse", value); | 33 EXPECT_EQ("helloResponse", value); |
33 EXPECT_TRUE(response->GetString("version", &value)); | 34 EXPECT_TRUE(response->GetString("version", &value)); |
34 EXPECT_EQ(STRINGIZE(VERSION), value); | 35 EXPECT_EQ(STRINGIZE(VERSION), value); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 260 |
260 NativeMessagingHostTest::~NativeMessagingHostTest() {} | 261 NativeMessagingHostTest::~NativeMessagingHostTest() {} |
261 | 262 |
262 void NativeMessagingHostTest::SetUp() { | 263 void NativeMessagingHostTest::SetUp() { |
263 ASSERT_TRUE(MakePipe(&input_read_handle_, &input_write_handle_)); | 264 ASSERT_TRUE(MakePipe(&input_read_handle_, &input_write_handle_)); |
264 ASSERT_TRUE(MakePipe(&output_read_handle_, &output_write_handle_)); | 265 ASSERT_TRUE(MakePipe(&output_read_handle_, &output_write_handle_)); |
265 | 266 |
266 daemon_controller_ = new MockDaemonController(); | 267 daemon_controller_ = new MockDaemonController(); |
267 scoped_ptr<DaemonController> daemon_controller(daemon_controller_); | 268 scoped_ptr<DaemonController> daemon_controller(daemon_controller_); |
268 | 269 |
269 scoped_refptr<PairingRegistry> pairing_registry = new PairingRegistry( | 270 scoped_refptr<PairingRegistry> pairing_registry = |
270 scoped_ptr<PairingRegistry::Delegate>(new MockPairingRegistryDelegate)); | 271 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>( |
| 272 new MockPairingRegistryDelegate())); |
271 | 273 |
272 host_.reset(new NativeMessagingHost(daemon_controller.Pass(), | 274 host_.reset(new NativeMessagingHost(daemon_controller.Pass(), |
273 pairing_registry, | 275 pairing_registry, |
274 input_read_handle_, output_write_handle_, | 276 input_read_handle_, output_write_handle_, |
275 message_loop_.message_loop_proxy(), | 277 message_loop_.message_loop_proxy(), |
276 run_loop_.QuitClosure())); | 278 run_loop_.QuitClosure())); |
277 } | 279 } |
278 | 280 |
279 void NativeMessagingHostTest::TearDown() { | 281 void NativeMessagingHostTest::TearDown() { |
280 // The NativeMessagingHost dtor closes the handles that are passed to it. | 282 // The NativeMessagingHost dtor closes the handles that are passed to it. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 516 |
515 // Verify rejection if startDaemon request has no "consent" parameter. | 517 // Verify rejection if startDaemon request has no "consent" parameter. |
516 TEST_F(NativeMessagingHostTest, StartDaemonNoConsent) { | 518 TEST_F(NativeMessagingHostTest, StartDaemonNoConsent) { |
517 base::DictionaryValue message; | 519 base::DictionaryValue message; |
518 message.SetString("type", "startDaemon"); | 520 message.SetString("type", "startDaemon"); |
519 message.Set("config", base::DictionaryValue().DeepCopy()); | 521 message.Set("config", base::DictionaryValue().DeepCopy()); |
520 TestBadRequest(message); | 522 TestBadRequest(message); |
521 } | 523 } |
522 | 524 |
523 } // namespace remoting | 525 } // namespace remoting |
OLD | NEW |