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

Side by Side Diff: mojo/public/cpp/bindings/tests/validation_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, 11 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <stdio.h> 7 #include <stdio.h>
8
9 #include <algorithm> 8 #include <algorithm>
10 #include <string> 9 #include <string>
10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "mojo/message_pump/message_pump_mojo.h" 14 #include "mojo/message_pump/message_pump_mojo.h"
15 #include "mojo/public/c/system/macros.h" 15 #include "mojo/public/c/system/macros.h"
16 #include "mojo/public/cpp/bindings/binding.h" 16 #include "mojo/public/cpp/bindings/binding.h"
17 #include "mojo/public/cpp/bindings/interface_ptr.h" 17 #include "mojo/public/cpp/bindings/interface_ptr.h"
18 #include "mojo/public/cpp/bindings/lib/connector.h" 18 #include "mojo/public/cpp/bindings/lib/connector.h"
19 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 19 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
20 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 20 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 : loop_(common::MessagePumpMojo::Create()), 197 : loop_(common::MessagePumpMojo::Create()),
198 test_message_receiver_(nullptr) {} 198 test_message_receiver_(nullptr) {}
199 199
200 ~ValidationIntegrationTest() override {} 200 ~ValidationIntegrationTest() override {}
201 201
202 void SetUp() override { 202 void SetUp() override {
203 ScopedMessagePipeHandle tester_endpoint; 203 ScopedMessagePipeHandle tester_endpoint;
204 ASSERT_EQ(MOJO_RESULT_OK, 204 ASSERT_EQ(MOJO_RESULT_OK,
205 CreateMessagePipe(nullptr, &tester_endpoint, &testee_endpoint_)); 205 CreateMessagePipe(nullptr, &tester_endpoint, &testee_endpoint_));
206 test_message_receiver_ = 206 test_message_receiver_ =
207 new TestMessageReceiver(this, tester_endpoint.Pass()); 207 new TestMessageReceiver(this, std::move(tester_endpoint));
208 } 208 }
209 209
210 void TearDown() override { 210 void TearDown() override {
211 delete test_message_receiver_; 211 delete test_message_receiver_;
212 test_message_receiver_ = nullptr; 212 test_message_receiver_ = nullptr;
213 213
214 // Make sure that the other end receives the OnConnectionError() 214 // Make sure that the other end receives the OnConnectionError()
215 // notification. 215 // notification.
216 PumpMessages(); 216 PumpMessages();
217 } 217 }
218 218
219 MessageReceiver* test_message_receiver() { return test_message_receiver_; } 219 MessageReceiver* test_message_receiver() { return test_message_receiver_; }
220 220
221 ScopedMessagePipeHandle testee_endpoint() { return testee_endpoint_.Pass(); } 221 ScopedMessagePipeHandle testee_endpoint() {
222 return std::move(testee_endpoint_);
223 }
222 224
223 private: 225 private:
224 class TestMessageReceiver : public MessageReceiver { 226 class TestMessageReceiver : public MessageReceiver {
225 public: 227 public:
226 TestMessageReceiver(ValidationIntegrationTest* owner, 228 TestMessageReceiver(ValidationIntegrationTest* owner,
227 ScopedMessagePipeHandle handle) 229 ScopedMessagePipeHandle handle)
228 : owner_(owner), 230 : owner_(owner),
229 connector_(handle.Pass(), 231 connector_(std::move(handle),
230 mojo::internal::Connector::SINGLE_THREADED_SEND) { 232 mojo::internal::Connector::SINGLE_THREADED_SEND) {
231 connector_.set_enforce_errors_from_incoming_receiver(false); 233 connector_.set_enforce_errors_from_incoming_receiver(false);
232 } 234 }
233 ~TestMessageReceiver() override {} 235 ~TestMessageReceiver() override {}
234 236
235 bool Accept(Message* message) override { 237 bool Accept(Message* message) override {
236 bool rv = connector_.Accept(message); 238 bool rv = connector_.Accept(message);
237 owner_->PumpMessages(); 239 owner_->PumpMessages();
238 return rv; 240 return rv;
239 } 241 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 415
414 RunValidationTests("resp_boundscheck_", validators.GetHead()); 416 RunValidationTests("resp_boundscheck_", validators.GetHead());
415 } 417 }
416 418
417 // Test that InterfacePtr<X> applies the correct validators and they don't 419 // Test that InterfacePtr<X> applies the correct validators and they don't
418 // conflict with each other: 420 // conflict with each other:
419 // - MessageHeaderValidator 421 // - MessageHeaderValidator
420 // - X::ResponseValidator_ 422 // - X::ResponseValidator_
421 TEST_F(ValidationIntegrationTest, InterfacePtr) { 423 TEST_F(ValidationIntegrationTest, InterfacePtr) {
422 IntegrationTestInterfacePtr interface_ptr = MakeProxy( 424 IntegrationTestInterfacePtr interface_ptr = MakeProxy(
423 InterfacePtrInfo<IntegrationTestInterface>(testee_endpoint().Pass(), 0u)); 425 InterfacePtrInfo<IntegrationTestInterface>(testee_endpoint(), 0u));
424 interface_ptr.internal_state()->EnableTestingMode(); 426 interface_ptr.internal_state()->EnableTestingMode();
425 427
426 RunValidationTests("integration_intf_resp", test_message_receiver()); 428 RunValidationTests("integration_intf_resp", test_message_receiver());
427 RunValidationTests("integration_msghdr", test_message_receiver()); 429 RunValidationTests("integration_msghdr", test_message_receiver());
428 } 430 }
429 431
430 // Test that Binding<X> applies the correct validators and they don't 432 // Test that Binding<X> applies the correct validators and they don't
431 // conflict with each other: 433 // conflict with each other:
432 // - MessageHeaderValidator 434 // - MessageHeaderValidator
433 // - X::RequestValidator_ 435 // - X::RequestValidator_
434 TEST_F(ValidationIntegrationTest, Binding) { 436 TEST_F(ValidationIntegrationTest, Binding) {
435 IntegrationTestInterfaceImpl interface_impl; 437 IntegrationTestInterfaceImpl interface_impl;
436 Binding<IntegrationTestInterface> binding( 438 Binding<IntegrationTestInterface> binding(
437 &interface_impl, 439 &interface_impl,
438 MakeRequest<IntegrationTestInterface>(testee_endpoint().Pass())); 440 MakeRequest<IntegrationTestInterface>(testee_endpoint()));
439 binding.EnableTestingMode(); 441 binding.EnableTestingMode();
440 442
441 RunValidationTests("integration_intf_rqst", test_message_receiver()); 443 RunValidationTests("integration_intf_rqst", test_message_receiver());
442 RunValidationTests("integration_msghdr", test_message_receiver()); 444 RunValidationTests("integration_msghdr", test_message_receiver());
443 } 445 }
444 446
445 // Test pointer validation (specifically, that the encoded offset is 32-bit) 447 // Test pointer validation (specifically, that the encoded offset is 32-bit)
446 TEST_F(ValidationTest, ValidateEncodedPointer) { 448 TEST_F(ValidationTest, ValidateEncodedPointer) {
447 uint64_t offset; 449 uint64_t offset;
448 450
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 static_cast<StructWithEnum::EnumWithin>(2))); 488 static_cast<StructWithEnum::EnumWithin>(2)));
487 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue( 489 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue(
488 static_cast<StructWithEnum::EnumWithin>(3))); 490 static_cast<StructWithEnum::EnumWithin>(3)));
489 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue( 491 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue(
490 static_cast<StructWithEnum::EnumWithin>(4))); 492 static_cast<StructWithEnum::EnumWithin>(4)));
491 } 493 }
492 494
493 } // namespace 495 } // namespace
494 } // namespace test 496 } // namespace test
495 } // namespace mojo 497 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/union_unittest.cc ('k') | mojo/public/cpp/system/tests/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698