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

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

Issue 1052993010: Adds method ordinal off-by-one error detection testing to ValidationTest. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebased. Created 5 years, 8 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
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/data/validation/boundscheck_msghdr_no_such_method.data » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 TEST_F(ValidationTest, Conformance) { 365 TEST_F(ValidationTest, Conformance) {
366 DummyMessageReceiver dummy_receiver; 366 DummyMessageReceiver dummy_receiver;
367 mojo::internal::FilterChain validators(&dummy_receiver); 367 mojo::internal::FilterChain validators(&dummy_receiver);
368 validators.Append<mojo::internal::MessageHeaderValidator>(); 368 validators.Append<mojo::internal::MessageHeaderValidator>();
369 validators.Append<ConformanceTestInterface::RequestValidator_>(); 369 validators.Append<ConformanceTestInterface::RequestValidator_>();
370 370
371 RunValidationTests("conformance_", validators.GetHead()); 371 RunValidationTests("conformance_", validators.GetHead());
372 } 372 }
373 373
374 // This test is similar to Conformance test but its goal is specifically
375 // do bounds-check testing of message validation. For example we test the
376 // detection of off-by-one errors in method ordinals.
377 TEST_F(ValidationTest, BoundsCheck) {
378 DummyMessageReceiver dummy_receiver;
379 mojo::internal::FilterChain validators(&dummy_receiver);
380 validators.Append<mojo::internal::MessageHeaderValidator>();
381 validators.Append<BoundsCheckTestInterface::RequestValidator_>();
382
383 RunValidationTests("boundscheck_", validators.GetHead());
384 }
385
374 // This test is similar to the Conformance test but for responses. 386 // This test is similar to the Conformance test but for responses.
375 TEST_F(ValidationTest, ResponseConformance) { 387 TEST_F(ValidationTest, ResponseConformance) {
376 DummyMessageReceiver dummy_receiver; 388 DummyMessageReceiver dummy_receiver;
377 mojo::internal::FilterChain validators(&dummy_receiver); 389 mojo::internal::FilterChain validators(&dummy_receiver);
378 validators.Append<mojo::internal::MessageHeaderValidator>(); 390 validators.Append<mojo::internal::MessageHeaderValidator>();
379 validators.Append<ConformanceTestInterface::ResponseValidator_>(); 391 validators.Append<ConformanceTestInterface::ResponseValidator_>();
380 392
381 RunValidationTests("resp_conformance_", validators.GetHead()); 393 RunValidationTests("resp_conformance_", validators.GetHead());
382 } 394 }
383 395
396 // This test is similar to the BoundsCheck test but for responses.
397 TEST_F(ValidationTest, ResponseBoundsCheck) {
398 DummyMessageReceiver dummy_receiver;
399 mojo::internal::FilterChain validators(&dummy_receiver);
400 validators.Append<mojo::internal::MessageHeaderValidator>();
401 validators.Append<BoundsCheckTestInterface::ResponseValidator_>();
402
403 RunValidationTests("resp_boundscheck_", validators.GetHead());
404 }
405
384 // Test that InterfacePtr<X> applies the correct validators and they don't 406 // Test that InterfacePtr<X> applies the correct validators and they don't
385 // conflict with each other: 407 // conflict with each other:
386 // - MessageHeaderValidator 408 // - MessageHeaderValidator
387 // - X::ResponseValidator_ 409 // - X::ResponseValidator_
388 TEST_F(ValidationIntegrationTest, InterfacePtr) { 410 TEST_F(ValidationIntegrationTest, InterfacePtr) {
389 IntegrationTestInterfacePtr interface_ptr = 411 IntegrationTestInterfacePtr interface_ptr =
390 MakeProxy<IntegrationTestInterface>(testee_endpoint().Pass()); 412 MakeProxy<IntegrationTestInterface>(testee_endpoint().Pass());
391 interface_ptr.internal_state()->router_for_testing()->EnableTestingMode(); 413 interface_ptr.internal_state()->router_for_testing()->EnableTestingMode();
392 414
393 RunValidationTests("integration_intf_resp", test_message_receiver()); 415 RunValidationTests("integration_intf_resp", test_message_receiver());
(...skipping 11 matching lines...) Expand all
405 MakeRequest<IntegrationTestInterface>(testee_endpoint().Pass())); 427 MakeRequest<IntegrationTestInterface>(testee_endpoint().Pass()));
406 binding.internal_router()->EnableTestingMode(); 428 binding.internal_router()->EnableTestingMode();
407 429
408 RunValidationTests("integration_intf_rqst", test_message_receiver()); 430 RunValidationTests("integration_intf_rqst", test_message_receiver());
409 RunValidationTests("integration_msghdr", test_message_receiver()); 431 RunValidationTests("integration_msghdr", test_message_receiver());
410 } 432 }
411 433
412 } // namespace 434 } // namespace
413 } // namespace test 435 } // namespace test
414 } // namespace mojo 436 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/data/validation/boundscheck_msghdr_no_such_method.data » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698