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

Unified Diff: mojo/public/bindings/js/core_unittests.js

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar testing Created 7 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/bindings/js/core_unittests.js
diff --git a/mojo/public/bindings/js/core_unittests.js b/mojo/public/bindings/js/core_unittests.js
index 2c085489c59180fa8dc54b2d106de1dd8a352790..6f4e30c9e41984f780929bcf19b45e079b93b44b 100644
--- a/mojo/public/bindings/js/core_unittests.js
+++ b/mojo/public/bindings/js/core_unittests.js
@@ -2,56 +2,57 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-function runWithPipe(mojo, test) {
- var pipe = mojo.core.createMessagePipe();
+define(["gtest", "core"], function(gtest, core) {
+ runWithPipe(testNop);
+ runWithPipe(testReadAndWriteMessage);
+ this.result = "PASS";
- test(mojo, pipe);
+ function runWithPipe(test) {
+ var pipe = core.createMessagePipe();
- var result0 = mojo.core.close(pipe.handle0);
- mojo.gtest.expectEqual(result0, mojo.core.RESULT_OK,
- "result0 is " + result0);
+ test(pipe);
- var result1 = mojo.core.close(pipe.handle1);
- mojo.gtest.expectEqual(result1, mojo.core.RESULT_OK,
- "result1 is " + result1);
-}
+ var result0 = core.close(pipe.handle0);
+ gtest.expectEqual(result0, core.RESULT_OK,
+ "result0 is " + result0);
-function testNop(mojo, pipe) {
-}
+ var result1 = core.close(pipe.handle1);
+ gtest.expectEqual(result1, core.RESULT_OK,
+ "result1 is " + result1);
+ }
-function testReadAndWriteMessage(mojo, pipe) {
- var senderData = new Uint8Array(42);
- for (var i = 0; i < senderData.length; ++i) {
- senderData[i] = i * i;
+ function testNop(pipe) {
}
- var result = mojo.core.writeMessage(
- pipe.handle0, senderData, [],
- mojo.core.WRITE_MESSAGE_FLAG_NONE);
+ function testReadAndWriteMessage(pipe) {
+ var senderData = new Uint8Array(42);
+ for (var i = 0; i < senderData.length; ++i) {
+ senderData[i] = i * i;
+ }
- mojo.gtest.expectEqual(result, mojo.core.RESULT_OK,
- "writeMessage returned RESULT_OK: " + result);
+ var result = core.writeMessage(
+ pipe.handle0, senderData, [],
+ core.WRITE_MESSAGE_FLAG_NONE);
- var receiverData = new Uint8Array(50);
+ gtest.expectEqual(result, core.RESULT_OK,
+ "writeMessage returned RESULT_OK: " + result);
- var mesage = mojo.core.readMessage(
- pipe.handle1, receiverData, 10,
- mojo.core.READ_MESSAGE_FLAG_NONE)
+ var receiverData = new Uint8Array(50);
- mojo.gtest.expectEqual(mesage.result, mojo.core.RESULT_OK,
- "mesage.result is " + mesage.result);
- mojo.gtest.expectEqual(mesage.bytesRead, 42,
- "mesage.bytesRead is " + mesage.bytesRead);
- mojo.gtest.expectEqual(mesage.handles.length, 0,
- "mesage.handles.length is " + mesage.handles.length);
+ var mesage = core.readMessage(
+ pipe.handle1, receiverData, 10,
+ core.READ_MESSAGE_FLAG_NONE)
- for (var i = 0; i < mesage.bytesRead; ++i) {
- mojo.gtest.expectEqual(receiverData[i], (i * i) & 0xFF,
- "receiverData[" + i + "] is " + receiverData[i]);
- }
-}
+ gtest.expectEqual(mesage.result, core.RESULT_OK,
+ "mesage.result is " + mesage.result);
+ gtest.expectEqual(mesage.bytesRead, 42,
+ "mesage.bytesRead is " + mesage.bytesRead);
+ gtest.expectEqual(mesage.handles.length, 0,
+ "mesage.handles.length is " + mesage.handles.length);
-function main(mojo) {
- runWithPipe(mojo, testNop);
- runWithPipe(mojo, testReadAndWriteMessage);
-}
+ for (var i = 0; i < mesage.bytesRead; ++i) {
+ gtest.expectEqual(receiverData[i], (i * i) & 0xFF,
+ "receiverData[" + i + "] is " + receiverData[i]);
+ }
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698