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

Unified Diff: ios/web/test/data/mojo_test.js

Issue 2028013003: [ios Mojo] Integration test for Mojo WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/test/data/mojo_test.html ('k') | ios/web/test/test_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/test/data/mojo_test.js
diff --git a/ios/web/test/data/mojo_test.js b/ios/web/test/data/mojo_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..2de75fb8d53e40aeea0ce46086fb82750b1fa6b8
--- /dev/null
+++ b/ios/web/test/data/mojo_test.js
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This module provides the test page for WebUIMojoTest. Once the page is
+// loaded it sends "syn" message to the native code. Once page receives "ack"
+// from the native code, the page then sends "fin". Test succeeds only when
+// "fin" is received by the native page. Refer to
+// ios/web/webui/web_ui_mojo_inttest.mm for testing code.
+
+define('main', [
+ 'mojo/public/js/bindings',
+ 'mojo/public/js/core',
+ 'mojo/public/js/connection',
+ 'ios/web/test/mojo_test.mojom',
+ 'content/public/renderer/service_provider',
+], function(bindings, core, connection, browser, serviceProvider) {
+
+ var page;
+
+ function TestPageImpl(browser) {
+ this.browser_ = browser;
+ };
+
+ TestPageImpl.prototype = Object.create(browser.TestPage.stubClass.prototype);
+
+ /**
+ * Sends message as a string to the native code.
+ *
+ * @param {string} message Message to send.
+ */
+ TestPageImpl.prototype.sendMessage = function(message) {
+ var pipe = core.createMessagePipe();
+ var stub = connection.bindHandleToStub(pipe.handle0, browser.TestPage);
+ bindings.StubBindings(stub).delegate = page;
+ page.stub_ = stub;
+ this.browser_.handleJsMessage(message, pipe.handle1);
+ };
+
+ /**
+ * Called by native code with "ack" message.
+ *
+ * @param {!NativeMessageResultMojo} result Object received from the native
+ code.
+ */
+ TestPageImpl.prototype.handleNativeMessage = function(result) {
+ if (result.message == 'ack') {
+ // Native code has replied with "ack", send "fin" to complete the test.
+ this.sendMessage('fin');
+ }
+ };
+
+ return function() {
+ var browserProxy = connection.bindHandleToProxy(
+ serviceProvider.connectToService(browser.TestUIHandlerMojo.name),
+ browser.TestUIHandlerMojo);
+
+ page = new TestPageImpl(browserProxy);
+
+ // Send "syn" so native code should reply with "ack".
+ page.sendMessage('syn');
+ };
+});
« no previous file with comments | « ios/web/test/data/mojo_test.html ('k') | ios/web/test/test_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698