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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host_unittest.cc

Issue 558403002: Remote Assistance on Chrome OS Part II - Native Messaging renaming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows host Created 6 years, 3 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 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/pipe_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 { 24 namespace remoting {
25 25
26 namespace { 26 namespace {
27 27
28 const char kTestAccessCode[] = "888888"; 28 const char kTestAccessCode[] = "888888";
29 const int kTestAccessCodeLifetimeInSeconds = 666; 29 const int kTestAccessCodeLifetimeInSeconds = 666;
30 const char kTestClientUsername[] = "some_user@gmail.com"; 30 const char kTestClientUsername[] = "some_user@gmail.com";
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 base::File input_read_file; 425 base::File input_read_file;
426 base::File output_write_file; 426 base::File output_write_file;
427 427
428 ASSERT_TRUE(MakePipe(&input_read_file, &input_write_file_)); 428 ASSERT_TRUE(MakePipe(&input_read_file, &input_write_file_));
429 ASSERT_TRUE(MakePipe(&output_read_file_, &output_write_file)); 429 ASSERT_TRUE(MakePipe(&output_read_file_, &output_write_file));
430 430
431 // Creating a native messaging host with a mock It2MeHostFactory. 431 // Creating a native messaging host with a mock It2MeHostFactory.
432 scoped_ptr<It2MeHostFactory> factory(new MockIt2MeHostFactory()); 432 scoped_ptr<It2MeHostFactory> factory(new MockIt2MeHostFactory());
433 433
434 scoped_ptr<NativeMessagingChannel> channel( 434 scoped_ptr<PipeMessagingChannel> channel(new PipeMessagingChannel(
Sergey Ulanov 2014/09/18 18:08:35 scoped_ptr<extensions::NativeMessagingChannel>
kelvinp 2014/09/18 19:03:50 Done.
435 new NativeMessagingChannel(input_read_file.Pass(), 435 input_read_file.Pass(), output_write_file.Pass()));
436 output_write_file.Pass()));
437 436
438 host_.reset( 437 host_.reset(new It2MeNativeMessagingHost(
439 new It2MeNativeMessagingHost( 438 host_task_runner_,
440 host_task_runner_, channel.Pass(), factory.Pass())); 439 channel.PassAs<extensions::NativeMessagingChannel>(),
440 factory.Pass()));
441 host_->Start(base::Bind(&It2MeNativeMessagingHostTest::StopHost, 441 host_->Start(base::Bind(&It2MeNativeMessagingHostTest::StopHost,
442 base::Unretained(this))); 442 base::Unretained(this)));
443 443
444 // Notify the test that the host has finished starting up. 444 // Notify the test that the host has finished starting up.
445 test_message_loop_->message_loop_proxy()->PostTask( 445 test_message_loop_->message_loop_proxy()->PostTask(
446 FROM_HERE, test_run_loop_->QuitClosure()); 446 FROM_HERE, test_run_loop_->QuitClosure());
447 } 447 }
448 448
449 void It2MeNativeMessagingHostTest::StopHost() { 449 void It2MeNativeMessagingHostTest::StopHost() {
450 DCHECK(host_task_runner_->RunsTasksOnCurrentThread()); 450 DCHECK(host_task_runner_->RunsTasksOnCurrentThread());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 555
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698