OLD | NEW |
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/core", | 7 "mojo/public/js/core", |
8 "gc", | 8 "gc", |
9 ], function(expect, core, gc) { | 9 ], function(expect, core, gc) { |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 senderData[i] = i * i; | 149 senderData[i] = i * i; |
150 } | 150 } |
151 | 151 |
152 var write = core.writeData( | 152 var write = core.writeData( |
153 pipe.producerHandle, senderData, | 153 pipe.producerHandle, senderData, |
154 core.WRITE_DATA_FLAG_ALL_OR_NONE); | 154 core.WRITE_DATA_FLAG_ALL_OR_NONE); |
155 | 155 |
156 expect(write.result).toBe(core.RESULT_OK); | 156 expect(write.result).toBe(core.RESULT_OK); |
157 expect(write.numBytes).toBe(42); | 157 expect(write.numBytes).toBe(42); |
158 | 158 |
| 159 var wait = core.wait(pipe.consumerHandle, core.HANDLE_SIGNAL_READABLE, |
| 160 core.DEADLINE_INDEFINITE); |
| 161 expect(wait.result).toBe(core.RESULT_OK); |
159 var peeked = core.readData( | 162 var peeked = core.readData( |
160 pipe.consumerHandle, | 163 pipe.consumerHandle, |
161 core.READ_DATA_FLAG_PEEK | core.READ_DATA_FLAG_ALL_OR_NONE); | 164 core.READ_DATA_FLAG_PEEK | core.READ_DATA_FLAG_ALL_OR_NONE); |
162 expect(peeked.result).toBe(core.RESULT_OK); | 165 expect(peeked.result).toBe(core.RESULT_OK); |
163 expect(peeked.buffer.byteLength).toBe(42); | 166 expect(peeked.buffer.byteLength).toBe(42); |
164 | 167 |
165 var peeked_memory = new Uint8Array(peeked.buffer); | 168 var peeked_memory = new Uint8Array(peeked.buffer); |
166 for (var i = 0; i < peeked_memory.length; ++i) | 169 for (var i = 0; i < peeked_memory.length; ++i) |
167 expect(peeked_memory[i]).toBe((i * i) & 0xFF); | 170 expect(peeked_memory[i]).toBe((i * i) & 0xFF); |
168 | 171 |
(...skipping 19 matching lines...) Expand all Loading... |
188 expect(core.isHandle(pipe.handle1)).toBeTruthy(); | 191 expect(core.isHandle(pipe.handle1)).toBeTruthy(); |
189 expect(core.isHandle(null)).toBeTruthy(); | 192 expect(core.isHandle(null)).toBeTruthy(); |
190 } | 193 } |
191 | 194 |
192 function testIsHandleDataPipe(pipe) { | 195 function testIsHandleDataPipe(pipe) { |
193 expect(core.isHandle(pipe.consumerHandle)).toBeTruthy(); | 196 expect(core.isHandle(pipe.consumerHandle)).toBeTruthy(); |
194 expect(core.isHandle(pipe.producerHandle)).toBeTruthy(); | 197 expect(core.isHandle(pipe.producerHandle)).toBeTruthy(); |
195 } | 198 } |
196 | 199 |
197 }); | 200 }); |
OLD | NEW |