• 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@Entry
18@Component
19struct MyComponent {
20  build() {
21    Column() {
22      Text("222").width(12)
23        .gesture(
24          GestureGroup(
25            GestureMode.Sequence,
26            LongPressGesture()
27              .onAction(()=> {
28                console.error('long press gesture recognized')
29              })
30              ,
31            PanGesture()
32              .onActionStart(()=> {
33                  console.error('pan gesture start')
34                }),
35            GestureGroup(
36              GestureMode.Sequence,
37              LongPressGesture()
38                .onAction(()=> {
39                  console.error('long press gesture recognized')
40                })
41                ,
42              PanGesture()
43                .onActionStart(()=> {
44                    console.error('pan gesture start')
45                  })
46            )
47          )
48          .onCancel(()=> {
49            console.error('sequence gesture canceled')
50          })
51        )
52        .height(21)
53      Text("333").width(33).parallelGesture(
54        TapGesture({count: 1, fingers:2})
55          .onAction((event)=> {
56             console.error('parallel gesture tap gesture recognized')
57          })
58        )
59      Text("444").priorityGesture(
60        TapGesture({count: 1, fingers:2})
61          .onAction((event)=> {
62            console.error('two fingers tap gesture recognized')
63          }),
64         GestureMask.IgnoreInternal
65        )
66    }
67    .width(12)
68    .gesture(
69            GestureGroup(
70              GestureMode.Sequence,
71              LongPressGesture()
72                .onAction(()=> {
73                  console.error('long press gesture recognized')
74                })
75                ,
76              PanGesture()
77                .onActionStart(()=> {
78                    console.error('pan gesture start')
79                  })
80            )
81            .onCancel(()=> {
82               console.error('sequence gesture canceled')
83            })
84        )
85    .height(21)
86  }
87}`
88
89exports.expectResult =
90`"use strict";
91class MyComponent extends View {
92    constructor(compilerAssignedUniqueChildId, parent, params) {
93        super(compilerAssignedUniqueChildId, parent);
94        this.updateWithValueParams(params);
95    }
96    updateWithValueParams(params) {
97    }
98    aboutToBeDeleted() {
99        SubscriberManager.Get().delete(this.id());
100    }
101    render() {
102        Column.create();
103        Column.width(12);
104        Gesture.create(GesturePriority.Low);
105        GestureGroup.create(GestureMode.Sequence);
106        GestureGroup.onCancel(() => {
107            console.error('sequence gesture canceled');
108        });
109        LongPressGesture.create();
110        LongPressGesture.onAction(() => {
111            console.error('long press gesture recognized');
112        });
113        LongPressGesture.pop();
114        PanGesture.create();
115        PanGesture.onActionStart(() => {
116            console.error('pan gesture start');
117        });
118        PanGesture.pop();
119        GestureGroup.pop();
120        Gesture.pop();
121        Column.height(21);
122        Text.create("222");
123        Text.width(12);
124        Gesture.create(GesturePriority.Low);
125        GestureGroup.create(GestureMode.Sequence);
126        GestureGroup.onCancel(() => {
127            console.error('sequence gesture canceled');
128        });
129        LongPressGesture.create();
130        LongPressGesture.onAction(() => {
131            console.error('long press gesture recognized');
132        });
133        LongPressGesture.pop();
134        PanGesture.create();
135        PanGesture.onActionStart(() => {
136            console.error('pan gesture start');
137        });
138        PanGesture.pop();
139        GestureGroup.create(GestureMode.Sequence);
140        LongPressGesture.create();
141        LongPressGesture.onAction(() => {
142            console.error('long press gesture recognized');
143        });
144        LongPressGesture.pop();
145        PanGesture.create();
146        PanGesture.onActionStart(() => {
147            console.error('pan gesture start');
148        });
149        PanGesture.pop();
150        GestureGroup.pop();
151        GestureGroup.pop();
152        Gesture.pop();
153        Text.height(21);
154        Text.pop();
155        Text.create("333");
156        Text.width(33);
157        Gesture.create(GesturePriority.Parallel);
158        TapGesture.create({ count: 1, fingers: 2 });
159        TapGesture.onAction((event) => {
160            console.error('parallel gesture tap gesture recognized');
161        });
162        TapGesture.pop();
163        Gesture.pop();
164        Text.pop();
165        Text.create("444");
166        Gesture.create(GesturePriority.High, GestureMask.IgnoreInternal);
167        TapGesture.create({ count: 1, fingers: 2 });
168        TapGesture.onAction((event) => {
169            console.error('two fingers tap gesture recognized');
170        });
171        TapGesture.pop();
172        Gesture.pop();
173        Text.pop();
174        Column.pop();
175    }
176}
177loadDocument(new MyComponent("1", undefined, {}));
178`
179