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

Side by Side Diff: remoting/host/native_messaging/native_messaging_writer_unittest.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: include <utility> Created 5 years 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/native_messaging/native_messaging_writer.h" 5 #include "remoting/host/native_messaging/native_messaging_writer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility>
10
9 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/stl_util.h" 13 #include "base/stl_util.h"
12 #include "base/values.h" 14 #include "base/values.h"
13 #include "remoting/host/setup/test_util.h" 15 #include "remoting/host/setup/test_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace remoting { 18 namespace remoting {
17 19
18 class NativeMessagingWriterTest : public testing::Test { 20 class NativeMessagingWriterTest : public testing::Test {
19 public: 21 public:
20 NativeMessagingWriterTest(); 22 NativeMessagingWriterTest();
21 ~NativeMessagingWriterTest() override; 23 ~NativeMessagingWriterTest() override;
22 24
23 void SetUp() override; 25 void SetUp() override;
24 26
25 protected: 27 protected:
26 scoped_ptr<NativeMessagingWriter> writer_; 28 scoped_ptr<NativeMessagingWriter> writer_;
27 base::File read_file_; 29 base::File read_file_;
28 base::File write_file_; 30 base::File write_file_;
29 }; 31 };
30 32
31 NativeMessagingWriterTest::NativeMessagingWriterTest() {} 33 NativeMessagingWriterTest::NativeMessagingWriterTest() {}
32
33 NativeMessagingWriterTest::~NativeMessagingWriterTest() {} 34 NativeMessagingWriterTest::~NativeMessagingWriterTest() {}
34 35
35 void NativeMessagingWriterTest::SetUp() { 36 void NativeMessagingWriterTest::SetUp() {
36 ASSERT_TRUE(MakePipe(&read_file_, &write_file_)); 37 ASSERT_TRUE(MakePipe(&read_file_, &write_file_));
37 writer_.reset(new NativeMessagingWriter(write_file_.Pass())); 38 writer_.reset(new NativeMessagingWriter(std::move(write_file_)));
38 } 39 }
39 40
40 TEST_F(NativeMessagingWriterTest, GoodMessage) { 41 TEST_F(NativeMessagingWriterTest, GoodMessage) {
41 base::DictionaryValue message; 42 base::DictionaryValue message;
42 message.SetInteger("foo", 42); 43 message.SetInteger("foo", 42);
43 EXPECT_TRUE(writer_->WriteMessage(message)); 44 EXPECT_TRUE(writer_->WriteMessage(message));
44 45
45 // Read from the pipe and verify the content. 46 // Read from the pipe and verify the content.
46 uint32_t length; 47 uint32_t length;
47 int read = read_file_.ReadAtCurrentPos(reinterpret_cast<char*>(&length), 4); 48 int read = read_file_.ReadAtCurrentPos(reinterpret_cast<char*>(&length), 4);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 TEST_F(NativeMessagingWriterTest, FailedWrite) { 91 TEST_F(NativeMessagingWriterTest, FailedWrite) {
91 // Close the read end so that writing fails immediately. 92 // Close the read end so that writing fails immediately.
92 read_file_.Close(); 93 read_file_.Close();
93 94
94 base::DictionaryValue message; 95 base::DictionaryValue message;
95 EXPECT_FALSE(writer_->WriteMessage(message)); 96 EXPECT_FALSE(writer_->WriteMessage(message));
96 } 97 }
97 98
98 } // namespace remoting 99 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/native_messaging/native_messaging_writer.cc ('k') | remoting/host/native_messaging/pipe_messaging_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698