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

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

Issue 2744963002: Introduce InterfaceEndpointClient(IEC), InterfaceEndpointHandle and (Closed)
Patch Set: Add binding.html layout test for connection error with reason. Reset IEC when reset() or close()… Created 3 years, 9 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 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; 284 observer.reset();
yzshen1 2017/03/24 21:20:13 nit: you could move this line to the end of the fo
wangjimmy 2017/03/27 16:51:28 Done.
290 var testMessage = readTestMessage(testFiles[i]); 285 var testMessage = readTestMessage(testFiles[i]);
291 var handles = new Array(testMessage.handleCount); 286 var handles = new Array(testMessage.handleCount);
292 287
293 var writeMessageValue = core.writeMessage( 288 var writeMessageValue = core.writeMessage(
294 testMessagePipe.handle0, 289 testMessagePipe.handle0,
295 new Uint8Array(testMessage.buffer.arrayBuffer), 290 new Uint8Array(testMessage.buffer.arrayBuffer),
296 new Array(testMessage.handleCount), 291 new Array(testMessage.handleCount),
297 core.WRITE_MESSAGE_FLAG_NONE); 292 core.WRITE_MESSAGE_FLAG_NONE);
298 expect(writeMessageValue).toBe(core.RESULT_OK); 293 expect(writeMessageValue).toBe(core.RESULT_OK);
299 294
300 testingController.waitForNextMessage(); 295 endpoint.waitForNextMessageForTesting();
301 checkValidationResult(testFiles[i], validationError); 296 checkValidationResult(testFiles[i], observer.lastError);
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

Powered by Google App Engine
This is Rietveld 408576698