• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2024 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@Entry
16@Component
17struct V2ToV2ComponentValidate {
18  build() {}
19}
20
21class A {
22  name: string
23  constructor(name: string) {
24    this.name = name
25  }
26}
27
28enum MemberType {
29  first = 1
30}
31
32@Observed
33class TestObserved {
34
35}
36type DummyNewType = Set<number> | Set<string>
37@ComponentV2
38struct TestV2Parent1 {
39  string_value: string = "hello"
40  @Param string_value1: string | Set<string> = "hello"
41  regular_value: Set<string> = new Set()
42  @Local enum_value1: MemberType = MemberType.first
43  @Provider() local_value: TestObserved
44  @Consumer() enum_value: Set<number> | MemberType = MemberType.first
45  @Event func_value1: Function = () => {}
46  @Event func_value2: () => void  = () => {}
47
48  @Local set_value: Set<number> | Set<string> = new Set<number>()
49  @Local set_value_alias: DummyNewType = new Set<string>()
50  build() {
51    Column() {
52      TestV1Child1({
53        string_value: this.string_value,
54        string_value1: this.string_value1,
55        regular_value: this.regular_value,
56        enum_value1: this.enum_value1,
57        objectLink_value: this.local_value,
58        enum_value: this.enum_value,
59        set_value: this.set_value,
60        set_value_alias: this.set_value_alias,
61        func_value1: this.func_value1,
62        func_value2: this.func_value2
63      })
64    }
65  }
66}
67
68@Component
69struct TestV1Child1 {
70  @State string_value: string = "hello"
71  @State string_value1: string | Set<string> = "hello"
72  @Prop regular_value: Set<string> = new Set()
73  @Link enum_value1: MemberType
74  @Link enum_value: Set<number> | MemberType
75  @Provide set_value: Set<number> | Set<string> = new Set<string>()
76  @State set_value_alias: DummyNewType = new Set<string>()
77  @ObjectLink objectLink_value: TestObserved
78  @Prop func_value1: Function
79  @BuilderParam func_value2: () => void
80
81  build() {
82
83  }
84}
85
86@ComponentV2
87struct TestV2Parent {
88  @Local set_value: Set<string> = new Set()
89  @Param map_value: Map<string, string> = new Map();
90  @Param @Once date_value: Date = new Date()
91  @Require @Param arr_value: Array<string> = new Array()
92  @Param arr_value1: Array<A> = new Array()
93  @Provider() arr_value2: Array<string> = new Array()
94  @Consumer() arr_value3: Array<MemberType> = new Array()
95  build() {
96    Column() {
97      TestV1Child({
98        set_value: this.set_value,
99        map_value: this.map_value,
100        date_value: this.date_value,
101        arr_value: this.arr_value,
102        arr_value1: this.arr_value1,
103        arr_value2: this.arr_value2,
104        arr_value3: this.arr_value3
105      })
106    }
107  }
108}
109
110@Component
111struct TestV1Child {
112  @State set_value: Set<string> = new Set()
113  @Prop map_value: Map<string, string> = new Map();
114  @Link date_value: Date
115  @Provide arr_value: Array<string> = new Array()
116  @State arr_value1: Array<A> = new Array()
117  @State arr_value2: Array<string> = new Array()
118  @State arr_value3: Array<MemberType> = new Array()
119  build() {
120
121  }
122}