| 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/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_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 "net/base/file_stream.h" | 16 #include "net/base/file_stream.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 #include "remoting/base/auto_thread_task_runner.h" | 18 #include "remoting/base/auto_thread_task_runner.h" |
| 19 #include "remoting/host/chromoting_host_context.h" | 19 #include "remoting/host/chromoting_host_context.h" |
| 20 #include "remoting/host/native_messaging/native_messaging_channel.h" | 20 #include "remoting/host/native_messaging/native_messaging_channel.h" |
| 21 #include "remoting/host/setup/test_util.h" | 21 #include "remoting/host/setup/test_util.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 namespace remoting { |
| 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 const char kTestAccessCode[] = "888888"; | 28 const char kTestAccessCode[] = "888888"; |
| 27 const int kTestAccessCodeLifetimeInSeconds = 666; | 29 const int kTestAccessCodeLifetimeInSeconds = 666; |
| 28 const char kTestClientUsername[] = "some_user@gmail.com"; | 30 const char kTestClientUsername[] = "some_user@gmail.com"; |
| 29 | 31 |
| 30 void VerifyId(scoped_ptr<base::DictionaryValue> response, int expected_value) { | 32 void VerifyId(scoped_ptr<base::DictionaryValue> response, int expected_value) { |
| 31 ASSERT_TRUE(response); | 33 ASSERT_TRUE(response); |
| 32 | 34 |
| 33 int value; | 35 int value; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 EXPECT_TRUE(response->GetString("type", &string_value)); | 57 EXPECT_TRUE(response->GetString("type", &string_value)); |
| 56 EXPECT_EQ(type, string_value); | 58 EXPECT_EQ(type, string_value); |
| 57 | 59 |
| 58 int int_value; | 60 int int_value; |
| 59 EXPECT_TRUE(response->GetInteger("id", &int_value)); | 61 EXPECT_TRUE(response->GetInteger("id", &int_value)); |
| 60 EXPECT_EQ(id, int_value); | 62 EXPECT_EQ(id, int_value); |
| 61 } | 63 } |
| 62 | 64 |
| 63 } // namespace | 65 } // namespace |
| 64 | 66 |
| 65 namespace remoting { | |
| 66 | |
| 67 class MockIt2MeHost : public It2MeHost { | 67 class MockIt2MeHost : public It2MeHost { |
| 68 public: | 68 public: |
| 69 MockIt2MeHost(ChromotingHostContext* context, | 69 MockIt2MeHost(ChromotingHostContext* context, |
| 70 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 70 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 71 base::WeakPtr<It2MeHost::Observer> observer, | 71 base::WeakPtr<It2MeHost::Observer> observer, |
| 72 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 72 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 73 const std::string& directory_bot_jid) | 73 const std::string& directory_bot_jid) |
| 74 : It2MeHost(context, | 74 : It2MeHost(context, |
| 75 task_runner, | 75 task_runner, |
| 76 observer, | 76 observer, |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 545 } |
| 546 | 546 |
| 547 // Verify rejection if type is unrecognized. | 547 // Verify rejection if type is unrecognized. |
| 548 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { | 548 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { |
| 549 base::DictionaryValue message; | 549 base::DictionaryValue message; |
| 550 message.SetString("type", "xxx"); | 550 message.SetString("type", "xxx"); |
| 551 TestBadRequest(message, true); | 551 TestBadRequest(message, true); |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace remoting | 554 } // namespace remoting |
| 555 |
| OLD | NEW |