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

Side by Side Diff: mojo/public/cpp/bindings/tests/request_response_unittest.cc

Issue 1535943002: Convert Pass()→std::move() in //mojo/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Regenerate correctly Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility>
6 7
7 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
8 #include "mojo/message_pump/message_pump_mojo.h" 9 #include "mojo/message_pump/message_pump_mojo.h"
9 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
10 #include "mojo/public/cpp/test_support/test_utils.h" 11 #include "mojo/public/cpp/test_support/test_utils.h"
11 #include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h" 12 #include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h"
12 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" 13 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace mojo { 16 namespace mojo {
16 namespace test { 17 namespace test {
17 namespace { 18 namespace {
18 19
19 class ProviderImpl : public sample::Provider { 20 class ProviderImpl : public sample::Provider {
20 public: 21 public:
21 explicit ProviderImpl(InterfaceRequest<sample::Provider> request) 22 explicit ProviderImpl(InterfaceRequest<sample::Provider> request)
22 : binding_(this, request.Pass()) {} 23 : binding_(this, std::move(request)) {}
23 24
24 void EchoString(const String& a, 25 void EchoString(const String& a,
25 const Callback<void(String)>& callback) override { 26 const Callback<void(String)>& callback) override {
26 Callback<void(String)> callback_copy; 27 Callback<void(String)> callback_copy;
27 // Make sure operator= is used. 28 // Make sure operator= is used.
28 callback_copy = callback; 29 callback_copy = callback;
29 callback_copy.Run(a); 30 callback_copy.Run(a);
30 } 31 }
31 32
32 void EchoStrings(const String& a, 33 void EchoStrings(const String& a,
33 const String& b, 34 const String& b,
34 const Callback<void(String, String)>& callback) override { 35 const Callback<void(String, String)>& callback) override {
35 callback.Run(a, b); 36 callback.Run(a, b);
36 } 37 }
37 38
38 void EchoMessagePipeHandle( 39 void EchoMessagePipeHandle(
39 ScopedMessagePipeHandle a, 40 ScopedMessagePipeHandle a,
40 const Callback<void(ScopedMessagePipeHandle)>& callback) override { 41 const Callback<void(ScopedMessagePipeHandle)>& callback) override {
41 callback.Run(a.Pass()); 42 callback.Run(std::move(a));
42 } 43 }
43 44
44 void EchoEnum(sample::Enum a, 45 void EchoEnum(sample::Enum a,
45 const Callback<void(sample::Enum)>& callback) override { 46 const Callback<void(sample::Enum)>& callback) override {
46 callback.Run(a); 47 callback.Run(a);
47 } 48 }
48 49
49 void EchoInt(int32_t a, const EchoIntCallback& callback) override { 50 void EchoInt(int32_t a, const EchoIntCallback& callback) override {
50 callback.Run(a); 51 callback.Run(a);
51 } 52 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 PumpMessages(); 120 PumpMessages();
120 121
121 EXPECT_EQ(std::string("hello world"), buf); 122 EXPECT_EQ(std::string("hello world"), buf);
122 } 123 }
123 124
124 TEST_F(RequestResponseTest, EchoMessagePipeHandle) { 125 TEST_F(RequestResponseTest, EchoMessagePipeHandle) {
125 sample::ProviderPtr provider; 126 sample::ProviderPtr provider;
126 ProviderImpl provider_impl(GetProxy(&provider)); 127 ProviderImpl provider_impl(GetProxy(&provider));
127 128
128 MessagePipe pipe2; 129 MessagePipe pipe2;
129 provider->EchoMessagePipeHandle(pipe2.handle1.Pass(), 130 provider->EchoMessagePipeHandle(std::move(pipe2.handle1),
130 MessagePipeWriter("hello")); 131 MessagePipeWriter("hello"));
131 132
132 PumpMessages(); 133 PumpMessages();
133 134
134 std::string value; 135 std::string value;
135 ReadTextMessage(pipe2.handle0.get(), &value); 136 ReadTextMessage(pipe2.handle0.get(), &value);
136 137
137 EXPECT_EQ(std::string("hello"), value); 138 EXPECT_EQ(std::string("hello"), value);
138 } 139 }
139 140
140 TEST_F(RequestResponseTest, EchoEnum) { 141 TEST_F(RequestResponseTest, EchoEnum) {
141 sample::ProviderPtr provider; 142 sample::ProviderPtr provider;
142 ProviderImpl provider_impl(GetProxy(&provider)); 143 ProviderImpl provider_impl(GetProxy(&provider));
143 144
144 sample::Enum value; 145 sample::Enum value;
145 provider->EchoEnum(sample::ENUM_VALUE, EnumRecorder(&value)); 146 provider->EchoEnum(sample::ENUM_VALUE, EnumRecorder(&value));
146 147
147 PumpMessages(); 148 PumpMessages();
148 149
149 EXPECT_EQ(sample::ENUM_VALUE, value); 150 EXPECT_EQ(sample::ENUM_VALUE, value);
150 } 151 }
151 152
152 } // namespace 153 } // namespace
153 } // namespace test 154 } // namespace test
154 } // namespace mojo 155 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/multiplex_router_unittest.cc ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698