| 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/native_messaging/native_messaging_writer.h" | 5 #include "remoting/host/native_messaging/native_messaging_writer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 base::File read_file_; | 26 base::File read_file_; |
| 27 base::File write_file_; | 27 base::File write_file_; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 NativeMessagingWriterTest::NativeMessagingWriterTest() {} | 30 NativeMessagingWriterTest::NativeMessagingWriterTest() {} |
| 31 | 31 |
| 32 NativeMessagingWriterTest::~NativeMessagingWriterTest() {} | 32 NativeMessagingWriterTest::~NativeMessagingWriterTest() {} |
| 33 | 33 |
| 34 void NativeMessagingWriterTest::SetUp() { | 34 void NativeMessagingWriterTest::SetUp() { |
| 35 ASSERT_TRUE(MakePipe(&read_file_, &write_file_)); | 35 ASSERT_TRUE(MakePipe(&read_file_, &write_file_)); |
| 36 writer_.reset(new NativeMessagingWriter(write_file_.Pass())); | 36 writer_.reset(new NativeMessagingWriter(std::move(write_file_))); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TEST_F(NativeMessagingWriterTest, GoodMessage) { | 39 TEST_F(NativeMessagingWriterTest, GoodMessage) { |
| 40 base::DictionaryValue message; | 40 base::DictionaryValue message; |
| 41 message.SetInteger("foo", 42); | 41 message.SetInteger("foo", 42); |
| 42 EXPECT_TRUE(writer_->WriteMessage(message)); | 42 EXPECT_TRUE(writer_->WriteMessage(message)); |
| 43 | 43 |
| 44 // Read from the pipe and verify the content. | 44 // Read from the pipe and verify the content. |
| 45 uint32 length; | 45 uint32 length; |
| 46 int read = read_file_.ReadAtCurrentPos(reinterpret_cast<char*>(&length), 4); | 46 int read = read_file_.ReadAtCurrentPos(reinterpret_cast<char*>(&length), 4); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 TEST_F(NativeMessagingWriterTest, FailedWrite) { | 89 TEST_F(NativeMessagingWriterTest, FailedWrite) { |
| 90 // Close the read end so that writing fails immediately. | 90 // Close the read end so that writing fails immediately. |
| 91 read_file_.Close(); | 91 read_file_.Close(); |
| 92 | 92 |
| 93 base::DictionaryValue message; | 93 base::DictionaryValue message; |
| 94 EXPECT_FALSE(writer_->WriteMessage(message)); | 94 EXPECT_FALSE(writer_->WriteMessage(message)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace remoting | 97 } // namespace remoting |
| OLD | NEW |