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

Side by Side Diff: third_party/WebKit/LayoutTests/mojo/message-pipe.html

Issue 2400563002: Adds Mojo IDL. (Closed)
Patch Set: fixes typo Created 3 years, 10 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Mojo message pipe tests</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6
7 let testData = (() => {
8 let dataIn = new Uint8Array(42);
9 for (let i = 0; i < dataIn.length; ++i)
10 dataIn[i] = i * i;
11
12 return {
13 read: (handle) => {
jbroman 2017/01/27 20:35:16 super-nit: while you're being fancy with JavaScrip
alokp 2017/01/27 23:54:46 Nice. Done.
14 let {result, buffer, handles} = handle.readMessage();
15 assert_equals(result, Mojo.RESULT_OK);
16 assert_array_equals(handles, []);
17 let dataOut = new Uint8Array(buffer);
18 assert_equals(dataOut.length, dataIn.length);
19 dataOut.every((value, index) => { assert_equals(value, dataIn[index]); });
jbroman 2017/01/27 20:35:16 nit: isn't this (and the previous line) what asser
alokp 2017/01/27 23:54:46 I was not sure if assert_array_equals works on typ
20 },
21 write: (handle) => {
22 let result = handle.writeMessage(dataIn, []);
23 assert_equals(result, Mojo.RESULT_OK);
24 }
25 };
26 })();
27
28 test(() => {
29 let {result, handle0, handle1} = Mojo.createMessagePipe();
30 assert_equals(result, Mojo.RESULT_OK);
31 assert_true(handle0 instanceof MojoHandle);
32 assert_true(handle1 instanceof MojoHandle);
33 }, "Create pipe");
34
35 test(() => {
36 let {result, handle0, handle1} = Mojo.createMessagePipe();
jbroman 2017/01/27 20:35:16 nit: either check result or remove it from the des
alokp 2017/01/27 23:54:46 I thought it was necessary to extract all keys. Re
37 handle0.close();
38 {
39 let {result, buffer, handles} = handle0.readMessage();
40 assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
41 }
42 }, "Read from invalid handle");
43
44 test(() => {
45 let {result, handle0, handle1} = Mojo.createMessagePipe();
46 {
47 let {result, buffer, handles} = handle0.readMessage();
48 assert_equals(result, Mojo.RESULT_SHOULD_WAIT);
49 }
50 }, "Read from empty pipe");
51
52 test(() => {
53 let {result, handle0, handle1} = Mojo.createMessagePipe();
54 handle0.close();
55 {
56 let result = handle0.writeMessage(new ArrayBuffer(4), []);
57 assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
58 }
59 }, "Write to invalid handle");
60
61 async_test((test) => {
62 let {result, handle0, handle1} = Mojo.createMessagePipe();
63
64 handle0.watch({readable: true}, test.step_func_done((result) => {
65 assert_equals(result, Mojo.RESULT_OK);
66 {
67 let {result, buffer, handles} = handle0.readMessage();
68 assert_equals(result, Mojo.RESULT_OK);
69 assert_equals(buffer, undefined);
70 assert_equals(handles, undefined);
71 }
72 }));
73 {
74 let result = handle1.writeMessage(new ArrayBuffer(0), []);
75 assert_equals(result, Mojo.RESULT_OK);
76 }
77 }, "Send empty message");
78
79 async_test((test) => {
80 let {result, handle0, handle1} = Mojo.createMessagePipe();
81
82 handle0.watch({readable: true}, test.step_func_done((result) => {
83 assert_equals(result, Mojo.RESULT_OK);
84 testData.read(handle0);
85 }));
86 testData.write(handle1);
87 }, "Send buffer");
88
89 async_test((test) => {
90 let pipe1 = Mojo.createMessagePipe();
91 let pipe2 = Mojo.createMessagePipe();
92 pipe2.handle0.watch({readable: true}, test.step_func_done((result) => {
93 assert_equals(result, Mojo.RESULT_OK);
94 testData.read(pipe2.handle0);
95 }));
96 pipe1.handle0.watch({readable: true}, test.step_func((result) => {
97 assert_equals(result, Mojo.RESULT_OK);
98 {
99 let {result, buffer, handles} = pipe1.handle0.readMessage();
100 assert_equals(result, Mojo.RESULT_OK);
101 assert_equals(1, handles.length);
102 testData.write(handles[0]);
103 }
104 }));
105 pipe1.handle1.writeMessage(new ArrayBuffer(0), [pipe2.handle1]);
106 }, "Send handle");
107
108 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/mojo/watch.html » ('j') | third_party/WebKit/Source/core/mojo/MojoWatcher.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698