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

Side by Side Diff: mojo/bindings/js/core_unittests.js

Issue 392923002: Add support for MojoCreateMessagePipeOptions struct to JS bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « mojo/bindings/js/core.cc ('k') | mojo/public/js/bindings/core.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "gin/test/expect", 6 "gin/test/expect",
7 "mojo/public/js/bindings/core", 7 "mojo/public/js/bindings/core",
8 "gc", 8 "gc",
9 ], function(expect, core, gc) { 9 ], function(expect, core, gc) {
10 runWithMessagePipe(testNop); 10 runWithMessagePipe(testNop);
11 runWithMessagePipe(testReadAndWriteMessage); 11 runWithMessagePipe(testReadAndWriteMessage);
12 runWithMessagePipeWithOptions(testNop);
13 runWithMessagePipeWithOptions(testReadAndWriteMessage);
12 runWithDataPipe(testNop); 14 runWithDataPipe(testNop);
13 runWithDataPipe(testReadAndWriteDataPipe); 15 runWithDataPipe(testReadAndWriteDataPipe);
16 runWithDataPipeWithOptions(testNop);
17 runWithDataPipeWithOptions(testReadAndWriteDataPipe);
14 gc.collectGarbage(); // should not crash 18 gc.collectGarbage(); // should not crash
15 this.result = "PASS"; 19 this.result = "PASS";
16 20
17 function runWithMessagePipe(test) { 21 function runWithMessagePipe(test) {
18 var pipe = core.createMessagePipe(); 22 var pipe = core.createMessagePipe();
23 expect(pipe.result).toBe(core.RESULT_OK);
19 24
20 test(pipe); 25 test(pipe);
21 26
27 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK);
28 expect(core.close(pipe.handle1)).toBe(core.RESULT_OK);
29 }
30
31 function runWithMessagePipeWithOptions(test) {
32 var pipe = core.createMessagePipe({
33 flags: core.CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE
34 });
35 expect(pipe.result).toBe(core.RESULT_OK);
36
37 test(pipe);
38
22 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK); 39 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK);
23 expect(core.close(pipe.handle1)).toBe(core.RESULT_OK); 40 expect(core.close(pipe.handle1)).toBe(core.RESULT_OK);
24 } 41 }
25 42
26 function runWithDataPipe(test) { 43 function runWithDataPipe(test) {
44 var pipe = core.createDataPipe();
45 expect(pipe.result).toBe(core.RESULT_OK);
46
47 test(pipe);
48
49 expect(core.close(pipe.producerHandle)).toBe(core.RESULT_OK);
50 expect(core.close(pipe.consumerHandle)).toBe(core.RESULT_OK);
51 }
52
53 function runWithDataPipeWithOptions(test) {
27 var pipe = core.createDataPipe({ 54 var pipe = core.createDataPipe({
28 flags: core.CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, 55 flags: core.CREATE_DATA_PIPE_OPTIONS_FLAG_NONE,
29 elementNumBytes: 1, 56 elementNumBytes: 1,
30 capacityNumBytes: 64 57 capacityNumBytes: 64
31 }); 58 });
32 expect(pipe.result).toBe(core.RESULT_OK); 59 expect(pipe.result).toBe(core.RESULT_OK);
33 60
34 test(pipe); 61 test(pipe);
35 62
36 expect(core.close(pipe.producerHandle)).toBe(core.RESULT_OK); 63 expect(core.close(pipe.producerHandle)).toBe(core.RESULT_OK);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 109
83 expect(read.result).toBe(core.RESULT_OK); 110 expect(read.result).toBe(core.RESULT_OK);
84 expect(read.buffer.byteLength).toBe(42); 111 expect(read.buffer.byteLength).toBe(42);
85 112
86 var memory = new Uint8Array(read.buffer); 113 var memory = new Uint8Array(read.buffer);
87 for (var i = 0; i < memory.length; ++i) 114 for (var i = 0; i < memory.length; ++i)
88 expect(memory[i]).toBe((i * i) & 0xFF); 115 expect(memory[i]).toBe((i * i) & 0xFF);
89 } 116 }
90 117
91 }); 118 });
OLDNEW
« no previous file with comments | « mojo/bindings/js/core.cc ('k') | mojo/public/js/bindings/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698