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

Side by Side Diff: mojo/public/js/tests/validation_unittest.js

Issue 2744963002: Introduce InterfaceEndpointClient(IEC), InterfaceEndpointHandle and (Closed)
Patch Set: Throw the error with the string being the stack trace needed to debug layouts which don't output an… Created 3 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 | « mojo/public/js/router.js ('k') | mojo/public/js/validator.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 define([ 5 define([
6 "console", 6 "console",
7 "file", 7 "file",
8 "gin/test/expect", 8 "gin/test/expect",
9 "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom", 9 "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom",
10 "mojo/public/js/bindings", 10 "mojo/public/js/bindings",
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 function testIntegratedMessageValidation(testFilesPattern, endpoint) { 273 function testIntegratedMessageValidation(testFilesPattern, endpoint) {
274 var testFiles = getMessageTestFiles(testFilesPattern); 274 var testFiles = getMessageTestFiles(testFilesPattern);
275 expect(testFiles.length).toBeGreaterThan(0); 275 expect(testFiles.length).toBeGreaterThan(0);
276 276
277 var testMessagePipe = core.createMessagePipe(); 277 var testMessagePipe = core.createMessagePipe();
278 expect(testMessagePipe.result).toBe(core.RESULT_OK); 278 expect(testMessagePipe.result).toBe(core.RESULT_OK);
279 279
280 endpoint.bind(testMessagePipe.handle1); 280 endpoint.bind(testMessagePipe.handle1);
281 var testingController = endpoint.enableTestingMode(); 281 var observer = validator.ValidationErrorObserverForTesting.getInstance();
282
283 var validationError;
284 testingController.setInvalidIncomingMessageHandler(function(error) {
285 validationError = error;
286 });
287 282
288 for (var i = 0; i < testFiles.length; i++) { 283 for (var i = 0; i < testFiles.length; i++) {
289 validationError = noError;
290 var testMessage = readTestMessage(testFiles[i]); 284 var testMessage = readTestMessage(testFiles[i]);
291 var handles = new Array(testMessage.handleCount); 285 var handles = new Array(testMessage.handleCount);
292 286
293 var writeMessageValue = core.writeMessage( 287 var writeMessageValue = core.writeMessage(
294 testMessagePipe.handle0, 288 testMessagePipe.handle0,
295 new Uint8Array(testMessage.buffer.arrayBuffer), 289 new Uint8Array(testMessage.buffer.arrayBuffer),
296 new Array(testMessage.handleCount), 290 new Array(testMessage.handleCount),
297 core.WRITE_MESSAGE_FLAG_NONE); 291 core.WRITE_MESSAGE_FLAG_NONE);
298 expect(writeMessageValue).toBe(core.RESULT_OK); 292 expect(writeMessageValue).toBe(core.RESULT_OK);
299 293
300 testingController.waitForNextMessage(); 294 endpoint.waitForNextMessageForTesting();
301 checkValidationResult(testFiles[i], validationError); 295 checkValidationResult(testFiles[i], observer.lastError);
296 observer.reset();
302 } 297 }
303 298
304 expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK); 299 expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK);
305 } 300 }
306 301
307 function testIntegratedMessageHeaderValidation() { 302 function testIntegratedMessageHeaderValidation() {
308 testIntegratedMessageValidation( 303 testIntegratedMessageValidation(
309 "integration_msghdr", 304 "integration_msghdr",
310 new bindings.Binding(testInterface.IntegrationTestInterface, {})); 305 new bindings.Binding(testInterface.IntegrationTestInterface, {}));
311 testIntegratedMessageValidation( 306 testIntegratedMessageValidation(
(...skipping 14 matching lines...) Expand all
326 } 321 }
327 322
328 expect(checkTestMessageParser()).toBeNull(); 323 expect(checkTestMessageParser()).toBeNull();
329 testConformanceMessageValidation(); 324 testConformanceMessageValidation();
330 testBoundsCheckMessageValidation(); 325 testBoundsCheckMessageValidation();
331 testResponseConformanceMessageValidation(); 326 testResponseConformanceMessageValidation();
332 testResponseBoundsCheckMessageValidation(); 327 testResponseBoundsCheckMessageValidation();
333 testIntegratedMessageHeaderValidation(); 328 testIntegratedMessageHeaderValidation();
334 testIntegratedResponseMessageValidation(); 329 testIntegratedResponseMessageValidation();
335 testIntegratedRequestMessageValidation(); 330 testIntegratedRequestMessageValidation();
331 validator.clearTestingMode();
336 332
337 this.result = "PASS"; 333 this.result = "PASS";
338 }); 334 });
OLDNEW
« no previous file with comments | « mojo/public/js/router.js ('k') | mojo/public/js/validator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698