Commit 1370a3c2 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

mojo: Add closure compiler tests for old and new names

Before we only had tests for the old names.

Bug: 968369
Change-Id: Id6296bc490c9eb87c1ae5446817d1408274dc52d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692184Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675881}
parent ae032e3d
......@@ -10,10 +10,20 @@ mojom("mojo_bindings") {
sources = [
"test.test-mojom",
]
use_old_js_lite_bindings_names = false
}
mojom("mojo_old_names_bindings") {
testonly = true
sources = [
"test_old_names.test-mojom",
]
}
js_type_check("closure_compile") {
deps = [
":old_names_test",
":test",
]
}
......@@ -21,5 +31,12 @@ js_type_check("closure_compile") {
js_library("test") {
deps = [
":mojo_bindings_js_library_for_compile",
":mojo_old_names_bindings_js_library_for_compile",
]
}
js_library("old_names_test") {
deps = [
":mojo_old_names_bindings_js_library_for_compile",
]
}
// Copyright 2018 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.
(() => {
async function testFunction() {
/** @type {oldNameTest.mojom.TestPageHandlerProxy} */
let proxy = oldNameTest.mojom.TestPageHandler.getProxy()
// Type infers {?{values: !Array<!string>}} from Promise return type.
let result = await proxy.method1(' ', 5);
/** @type {Array<string>} */
let values = result.values;
/** @type {oldNameTest.mojom.TestStruct} */
let testStruct = result.ts
}
/** @implements {oldNameTest.mojom.TestPageInterface} */
class TestPageImpl {
/** @override */
onEvent1(s) {
/** @type {oldNameTest.mojom.TestStruct} */ let t = s;
/** @type {string} */ let id = t.id;
/** @type {string|undefined} */ let title = t.title;
/** @type {oldNameTest.mojom.TestEnum} */ let enumValue = t.enums[0];
/** @type {string} */ let numberToStringMapValue = t.numberToStringMap[5];
/** @type {oldNameTest.mojom.Message} */
let messageToMessageArrayValue =
t.messageToArrayMap.get({message: 'asdf'})[0];
/** @type {oldNameTest.mojom.TestEnum} */ let enumToMapMapValue =
t.enumToMapMap[oldNameTest.mojom.TestEnum.FIRST]
[oldNameTest.mojom.TestEnum.SECOND];
/** @type {oldNameTest.mojom.TestPageInterface} */
let handler = t.numberToInterfaceProxyMap[3];
handler.onEvent1(t);
}
}
})();
......@@ -3,11 +3,11 @@
// found in the LICENSE file.
async function testFunction() {
/** @type {test.mojom.TestPageHandlerProxy} */
let proxy = test.mojom.TestPageHandler.getProxy()
/** @type {test.mojom.TestPageHandlerRemote} */
let remote = test.mojom.TestPageHandler.getRemote()
// Type infers {?{values: !Array<!string>}} from Promise return type.
let result = await proxy.method1(' ', 5);
let result = await remote.method1(' ', 5);
/** @type {Array<string>} */
let values = result.values;
......
// Copyright 2018 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.
module old_name_test.mojom;
enum TestEnum {
FIRST,
SECOND,
};
struct Message {
string message;
};
struct TestStruct {
string id;
string? title;
array<TestEnum> enums;
map<uint32, string> numberToStringMap;
map<Message, array<Message>> messageToArrayMap;
map<TestEnum, map<TestEnum, TestEnum>> enumToMapMap;
map<uint32, TestPage> numberToInterfaceProxyMap;
};
interface TestPageHandler {
Method1(string p1, int32 p2) => (array<string> values, TestStruct ts);
};
interface TestPage {
OnEvent1(TestStruct s);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment