• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16exports.source = `
17
18@Entry
19@Component
20struct Banner {
21@Builder textBuilder() {
22  Text("文本")
23  .fontSize(30)
24}
25@Builder NavigationTitle(label:string) {
26  Column() {
27    Text(label)
28      .width(10)
29      .bindMenu(this.textBuilder)
30  }
31}
32  build() {
33    Column() {
34      Text("111")
35        .bindMenu(this.NavigationTitle("111"))
36    }
37  }
38}
39`
40exports.expectResult =
41`"use strict";
42class Banner extends View {
43    constructor(compilerAssignedUniqueChildId, parent, params) {
44        super(compilerAssignedUniqueChildId, parent);
45        this.updateWithValueParams(params);
46    }
47    updateWithValueParams(params) {
48    }
49    aboutToBeDeleted() {
50        SubscriberManager.Get().delete(this.id());
51    }
52    textBuilder() {
53        Text.create("文本");
54        Text.fontSize(30);
55        Text.pop();
56    }
57    NavigationTitle(label) {
58        Column.create();
59        Text.create(label);
60        Text.width(10);
61        Text.bindMenu({ builder: this.textBuilder.bind(this) });
62        Text.pop();
63        Column.pop();
64    }
65    render() {
66        Column.create();
67        Text.create("111");
68        Text.bindMenu({ builder: () => {
69                this.NavigationTitle("111");
70            } });
71        Text.pop();
72        Column.pop();
73    }
74}
75loadDocument(new Banner("1", undefined, {}));
76`
77