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

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

Issue 100573003: [Mojo] Move JS bindings out of public (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 define([
6 "gin/test/expect",
7 "mojo/public/bindings/js/core",
8 ], function(expect, core) {
9 runWithPipe(testNop);
10 runWithPipe(testReadAndWriteMessage);
11 this.result = "PASS";
12
13 function runWithPipe(test) {
14 var pipe = core.createMessagePipe();
15
16 test(pipe);
17
18 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK);
19 expect(core.close(pipe.handle1)).toBe(core.RESULT_OK);
20 }
21
22 function testNop(pipe) {
23 }
24
25 function testReadAndWriteMessage(pipe) {
26 var senderData = new Uint8Array(42);
27 for (var i = 0; i < senderData.length; ++i) {
28 senderData[i] = i * i;
29 }
30
31 var result = core.writeMessage(
32 pipe.handle0, senderData, [],
33 core.WRITE_MESSAGE_FLAG_NONE);
34
35 expect(result).toBe(core.RESULT_OK);
36
37 var receiverData = new Uint8Array(50);
38
39 var read = core.readMessage(
40 pipe.handle1, core.READ_MESSAGE_FLAG_NONE)
41
42 expect(read.result).toBe(core.RESULT_OK);
43 expect(read.buffer.byteLength).toBe(42);
44 expect(read.handles.length).toBe(0);
45
46 var memory = new Uint8Array(read.buffer);
47 for (var i = 0; i < memory.length; ++i)
48 expect(memory[i]).toBe((i * i) & 0xFF);
49 }
50 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698