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

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

Issue 683583002: Update mojo sdk to rev e083961bf11fd0c94d40be8853761da529b6d444 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "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); 12 runWithMessagePipeWithOptions(testNop);
13 runWithMessagePipeWithOptions(testReadAndWriteMessage); 13 runWithMessagePipeWithOptions(testReadAndWriteMessage);
14 runWithDataPipe(testNop); 14 runWithDataPipe(testNop);
15 runWithDataPipe(testReadAndWriteDataPipe); 15 runWithDataPipe(testReadAndWriteDataPipe);
16 runWithDataPipeWithOptions(testNop); 16 runWithDataPipeWithOptions(testNop);
17 runWithDataPipeWithOptions(testReadAndWriteDataPipe); 17 runWithDataPipeWithOptions(testReadAndWriteDataPipe);
18 testHandleToString();
18 gc.collectGarbage(); // should not crash 19 gc.collectGarbage(); // should not crash
19 this.result = "PASS"; 20 this.result = "PASS";
20 21
21 function runWithMessagePipe(test) { 22 function runWithMessagePipe(test) {
22 var pipe = core.createMessagePipe(); 23 var pipe = core.createMessagePipe();
23 expect(pipe.result).toBe(core.RESULT_OK); 24 expect(pipe.result).toBe(core.RESULT_OK);
24 25
25 test(pipe); 26 test(pipe);
26 27
27 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK); 28 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 pipe.consumerHandle, core.READ_DATA_FLAG_ALL_OR_NONE); 109 pipe.consumerHandle, core.READ_DATA_FLAG_ALL_OR_NONE);
109 110
110 expect(read.result).toBe(core.RESULT_OK); 111 expect(read.result).toBe(core.RESULT_OK);
111 expect(read.buffer.byteLength).toBe(42); 112 expect(read.buffer.byteLength).toBe(42);
112 113
113 var memory = new Uint8Array(read.buffer); 114 var memory = new Uint8Array(read.buffer);
114 for (var i = 0; i < memory.length; ++i) 115 for (var i = 0; i < memory.length; ++i)
115 expect(memory[i]).toBe((i * i) & 0xFF); 116 expect(memory[i]).toBe((i * i) & 0xFF);
116 } 117 }
117 118
119 function testHandleToString() {
120 var pipe = core.createDataPipe();
121 expect(pipe.consumerHandle.toString).toBeDefined();
122
123 var openHandleRE = /^\[mojo\:\:Handle \d+\]$/ // e.g. "[mojo::Handle 123]"
124 var openHandleString = pipe.consumerHandle.toString();
125 expect(openHandleString.match(openHandleRE)[0]).toEqual(openHandleString);
126
127 expect(core.close(pipe.producerHandle)).toBe(core.RESULT_OK);
128 expect(core.close(pipe.consumerHandle)).toBe(core.RESULT_OK);
129
130 expect(pipe.consumerHandle.toString()).toEqual("[mojo::Handle null]");
131 }
132
118 }); 133 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698