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

Side by Side Diff: mojo/public/js/bindings/validation_unittests.js

Issue 628763002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed template indentation Created 6 years, 2 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/buffer", 10 "mojo/public/js/bindings/buffer",
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 var err = messageValidator.validateMessageHeader(); 239 var err = messageValidator.validateMessageHeader();
240 for (var j = 0; err === noError && j < filters.length; ++j) 240 for (var j = 0; err === noError && j < filters.length; ++j)
241 err = filters[j](messageValidator); 241 err = filters[j](messageValidator);
242 242
243 checkValidationResult(testFiles[i], err); 243 checkValidationResult(testFiles[i], err);
244 } 244 }
245 } 245 }
246 246
247 function testConformanceMessageValidation() { 247 function testConformanceMessageValidation() {
248 testMessageValidation("conformance_", [ 248 testMessageValidation("conformance_", [
249 testInterface.ConformanceTestInterfaceStub.prototype.validator]); 249 testInterface.ConformanceTestInterface.validateRequest]);
250 } 250 }
251 251
252 function testNotImplementedMessageValidation() { 252 function testNotImplementedMessageValidation() {
253 testMessageValidation("not_implemented_", [ 253 testMessageValidation("not_implemented_", [
254 testInterface.ConformanceTestInterfaceStub.prototype.validator]); 254 testInterface.ConformanceTestInterface.validateRequest]);
255 } 255 }
256 256
257 function testIntegratedMessageValidation() { 257 function testIntegratedMessageValidation() {
258 var testFiles = getMessageTestFiles("integration_"); 258 var testFiles = getMessageTestFiles("integration_");
259 expect(testFiles.length).toBeGreaterThan(0); 259 expect(testFiles.length).toBeGreaterThan(0);
260 260
261 for (var i = 0; i < testFiles.length; i++) { 261 for (var i = 0; i < testFiles.length; i++) {
262 // TODO(hansmuller): Temporarily skipping array pointer overflow tests. 262 // TODO(hansmuller): Temporarily skipping array pointer overflow tests.
263 if (testFiles[i].indexOf("overflow") != -1) { 263 if (testFiles[i].indexOf("overflow") != -1) {
264 console.log("[Skipping " + testFiles[i] + "]"); 264 console.log("[Skipping " + testFiles[i] + "]");
265 continue; 265 continue;
266 } 266 }
267 267
268 var testMessage = readTestMessage(testFiles[i]); 268 var testMessage = readTestMessage(testFiles[i]);
269 var handles = new Array(testMessage.handleCount); 269 var handles = new Array(testMessage.handleCount);
270 var testMessagePipe = new core.createMessagePipe(); 270 var testMessagePipe = new core.createMessagePipe();
271 expect(testMessagePipe.result).toBe(core.RESULT_OK); 271 expect(testMessagePipe.result).toBe(core.RESULT_OK);
272 272
273 var writeMessageValue = core.writeMessage( 273 var writeMessageValue = core.writeMessage(
274 testMessagePipe.handle0, 274 testMessagePipe.handle0,
275 new Uint8Array(testMessage.buffer.arrayBuffer), 275 new Uint8Array(testMessage.buffer.arrayBuffer),
276 new Array(testMessage.handleCount), 276 new Array(testMessage.handleCount),
277 core.WRITE_MESSAGE_FLAG_NONE); 277 core.WRITE_MESSAGE_FLAG_NONE);
278 expect(writeMessageValue).toBe(core.RESULT_OK); 278 expect(writeMessageValue).toBe(core.RESULT_OK);
279 279
280 var testConnection = new connection.TestConnection( 280 var testConnection = new connection.TestConnection(
281 testMessagePipe.handle1, 281 testMessagePipe.handle1,
282 testInterface.IntegrationTestInterface1Stub, 282 testInterface.IntegrationTestInterface1.stubClass,
283 testInterface.IntegrationTestInterface2Proxy); 283 testInterface.IntegrationTestInterface2.proxyClass);
284 284
285 var validationError = noError; 285 var validationError = noError;
286 testConnection.router_.validationErrorHandler = function(err) { 286 testConnection.router_.validationErrorHandler = function(err) {
287 validationError = err; 287 validationError = err;
288 } 288 }
289 289
290 testConnection.router_.connector_.deliverMessage(); 290 testConnection.router_.connector_.deliverMessage();
291 checkValidationResult(testFiles[i], validationError); 291 checkValidationResult(testFiles[i], validationError);
292 292
293 testConnection.close(); 293 testConnection.close();
294 expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK); 294 expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK);
295 } 295 }
296 } 296 }
297 297
298 expect(checkTestMessageParser()).toBeNull(); 298 expect(checkTestMessageParser()).toBeNull();
299 testConformanceMessageValidation(); 299 testConformanceMessageValidation();
300 testIntegratedMessageValidation(); 300 testIntegratedMessageValidation();
301 this.result = "PASS"; 301 this.result = "PASS";
302 }); 302 });
OLDNEW
« no previous file with comments | « mojo/public/js/bindings/struct_unittests.js ('k') | mojo/public/tools/bindings/generators/js_templates/enum_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698