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

Side by Side Diff: mojo/edk/js/tests/js_to_cpp_tests.cc

Issue 2844143002: Mojo C++ bindings: reject messages version 2 with null payload pointer. (Closed)
Patch Set: . Created 3 years, 7 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 | « mojo/edk/js/tests/js_to_cpp.mojom ('k') | mojo/edk/js/tests/js_to_cpp_tests.js » ('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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void StartTest() override { NOTREACHED(); } 232 void StartTest() override { NOTREACHED(); }
233 233
234 void TestFinished() override { NOTREACHED(); } 234 void TestFinished() override { NOTREACHED(); }
235 235
236 void PingResponse() override { mishandled_messages_ += 1; } 236 void PingResponse() override { mishandled_messages_ += 1; }
237 237
238 void EchoResponse(js_to_cpp::EchoArgsListPtr list) override { 238 void EchoResponse(js_to_cpp::EchoArgsListPtr list) override {
239 mishandled_messages_ += 1; 239 mishandled_messages_ += 1;
240 } 240 }
241 241
242 void BitFlipResponse(js_to_cpp::EchoArgsListPtr list) override { 242 void BitFlipResponse(
243 js_to_cpp::EchoArgsListPtr list,
244 js_to_cpp::ForTestingAssociatedPtrInfo not_used) override {
243 mishandled_messages_ += 1; 245 mishandled_messages_ += 1;
244 } 246 }
245 247
246 void BackPointerResponse(js_to_cpp::EchoArgsListPtr list) override { 248 void BackPointerResponse(js_to_cpp::EchoArgsListPtr list) override {
247 mishandled_messages_ += 1; 249 mishandled_messages_ += 1;
248 } 250 }
249 251
250 protected: 252 protected:
251 base::RunLoop* run_loop_; 253 base::RunLoop* run_loop_;
252 js_to_cpp::JsSide* js_side_; 254 js_to_cpp::JsSide* js_side_;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 327
326 // Test that corrupted messages don't wreak havoc. 328 // Test that corrupted messages don't wreak havoc.
327 class BitFlipCppSideConnection : public CppSideConnection { 329 class BitFlipCppSideConnection : public CppSideConnection {
328 public: 330 public:
329 BitFlipCppSideConnection() : termination_seen_(false) {} 331 BitFlipCppSideConnection() : termination_seen_(false) {}
330 ~BitFlipCppSideConnection() override {} 332 ~BitFlipCppSideConnection() override {}
331 333
332 // js_to_cpp::CppSide: 334 // js_to_cpp::CppSide:
333 void StartTest() override { js_side_->BitFlip(BuildSampleEchoArgs()); } 335 void StartTest() override { js_side_->BitFlip(BuildSampleEchoArgs()); }
334 336
335 void BitFlipResponse(js_to_cpp::EchoArgsListPtr list) override { 337 void BitFlipResponse(
338 js_to_cpp::EchoArgsListPtr list,
339 js_to_cpp::ForTestingAssociatedPtrInfo not_used) override {
336 CheckCorruptedEchoArgsList(list); 340 CheckCorruptedEchoArgsList(list);
337 } 341 }
338 342
339 void TestFinished() override { 343 void TestFinished() override {
340 termination_seen_ = true; 344 termination_seen_ = true;
341 run_loop()->Quit(); 345 run_loop()->Quit();
342 } 346 }
343 347
344 bool DidSucceed() { 348 bool DidSucceed() {
345 return termination_seen_; 349 return termination_seen_;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 mojo::internal::ScopedSuppressValidationErrorLoggingForTests log_suppression; 450 mojo::internal::ScopedSuppressValidationErrorLoggingForTests log_suppression;
447 451
448 BackPointerCppSideConnection cpp_side_connection; 452 BackPointerCppSideConnection cpp_side_connection;
449 RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection); 453 RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection);
450 EXPECT_TRUE(cpp_side_connection.DidSucceed()); 454 EXPECT_TRUE(cpp_side_connection.DidSucceed());
451 } 455 }
452 456
453 } // namespace js 457 } // namespace js
454 } // namespace edk 458 } // namespace edk
455 } // namespace mojo 459 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/js/tests/js_to_cpp.mojom ('k') | mojo/edk/js/tests/js_to_cpp_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698