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

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

Issue 694463002: Revert of 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();
19 gc.collectGarbage(); // should not crash 18 gc.collectGarbage(); // should not crash
20 this.result = "PASS"; 19 this.result = "PASS";
21 20
22 function runWithMessagePipe(test) { 21 function runWithMessagePipe(test) {
23 var pipe = core.createMessagePipe(); 22 var pipe = core.createMessagePipe();
24 expect(pipe.result).toBe(core.RESULT_OK); 23 expect(pipe.result).toBe(core.RESULT_OK);
25 24
26 test(pipe); 25 test(pipe);
27 26
28 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK); 27 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 pipe.consumerHandle, core.READ_DATA_FLAG_ALL_OR_NONE); 108 pipe.consumerHandle, core.READ_DATA_FLAG_ALL_OR_NONE);
110 109
111 expect(read.result).toBe(core.RESULT_OK); 110 expect(read.result).toBe(core.RESULT_OK);
112 expect(read.buffer.byteLength).toBe(42); 111 expect(read.buffer.byteLength).toBe(42);
113 112
114 var memory = new Uint8Array(read.buffer); 113 var memory = new Uint8Array(read.buffer);
115 for (var i = 0; i < memory.length; ++i) 114 for (var i = 0; i < memory.length; ++i)
116 expect(memory[i]).toBe((i * i) & 0xFF); 115 expect(memory[i]).toBe((i * i) & 0xFF);
117 } 116 }
118 117
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
133 }); 118 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698