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

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

Issue 83143002: [Mojo] Improve JavaScript API for MojoReadMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup 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
« no previous file with comments | « mojo/public/bindings/js/core.cc ('k') | mojo/public/bindings/mojom_bindings_generator.gypi » ('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 "gtest", 6 "gtest",
7 "mojo/public/bindings/js/core", 7 "mojo/public/bindings/js/core",
8 ], function(gtest, core) { 8 ], function(gtest, core) {
9 runWithPipe(testNop); 9 runWithPipe(testNop);
10 runWithPipe(testReadAndWriteMessage); 10 runWithPipe(testReadAndWriteMessage);
(...skipping 24 matching lines...) Expand all
35 35
36 var result = core.writeMessage( 36 var result = core.writeMessage(
37 pipe.handle0, senderData, [], 37 pipe.handle0, senderData, [],
38 core.WRITE_MESSAGE_FLAG_NONE); 38 core.WRITE_MESSAGE_FLAG_NONE);
39 39
40 gtest.expectEqual(result, core.RESULT_OK, 40 gtest.expectEqual(result, core.RESULT_OK,
41 "writeMessage returned RESULT_OK: " + result); 41 "writeMessage returned RESULT_OK: " + result);
42 42
43 var receiverData = new Uint8Array(50); 43 var receiverData = new Uint8Array(50);
44 44
45 var mesage = core.readMessage( 45 var read = core.readMessage(
46 pipe.handle1, receiverData, 10, 46 pipe.handle1, core.READ_MESSAGE_FLAG_NONE)
47 core.READ_MESSAGE_FLAG_NONE)
48 47
49 gtest.expectEqual(mesage.result, core.RESULT_OK, 48 gtest.expectEqual(read.result, core.RESULT_OK,
50 "mesage.result is " + mesage.result); 49 "read.result is " + read.result);
51 gtest.expectEqual(mesage.bytesRead, 42, 50 gtest.expectEqual(read.buffer.byteLength, 42,
52 "mesage.bytesRead is " + mesage.bytesRead); 51 "read.buffer.byteLength is " + read.buffer.byteLength);
53 gtest.expectEqual(mesage.handles.length, 0, 52 gtest.expectEqual(read.handles.length, 0,
54 "mesage.handles.length is " + mesage.handles.length); 53 "read.handles.length is " + read.handles.length);
55 54
56 for (var i = 0; i < mesage.bytesRead; ++i) { 55 var memory = new Uint8Array(read.buffer);
57 gtest.expectEqual(receiverData[i], (i * i) & 0xFF, 56 for (var i = 0; i < memory.length; ++i) {
58 "receiverData[" + i + "] is " + receiverData[i]); 57 gtest.expectEqual(memory[i], (i * i) & 0xFF,
58 "memory[" + i + "] is " + memory[i]);
59 } 59 }
60 } 60 }
61 }); 61 });
OLDNEW
« no previous file with comments | « mojo/public/bindings/js/core.cc ('k') | mojo/public/bindings/mojom_bindings_generator.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698