1 /*
2  * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 
16 #include "gtest/gtest.h"
17 #define protected public
18 #define private public
19 #include "test/mock/base/mock_task_executor.h"
20 #include "test/mock/core/common/mock_container.h"
21 #include "test/mock/core/pipeline/mock_pipeline_context.h"
22 
23 #include "core/components_ng/base/frame_node.h"
24 #include "core/components_ng/base/view_abstract_model_ng.h"
25 #include "core/components_ng/layout/layout_property.h"
26 #include "core/pipeline/base/element_register.h"
27 #include "frameworks/core/components/common/layout/position_param.h"
28 #include "frameworks/core/components_ng/pattern/panel/sliding_panel_model_ng.h"
29 #include "frameworks/core/pipeline/base/element.h"
30 
31 #undef private
32 #undef protected
33 using namespace testing;
34 using namespace testing::ext;
35 
36 namespace OHOS::Ace::NG {
37 namespace {
38 const std::string VALUE_A = "A";
39 const std::string VALUE_C = "C";
40 const std::string VALUE_V = "V";
41 const std::string VALUE_Z = "Z";
42 const std::string VALUE_Y = "Y";
43 const std::string VALUE_X = "X";
44 const std::string VALUE_TAB = "TAB";
45 const std::string VALUE_DPAD_UP = "DPAD_UP";
46 const std::string VALUE_DPAD_DOWN = "DPAD_DOWN";
47 const std::string VALUE_DPAD_LEFT = "DPAD_LEFT";
48 const std::string VALUE_DPAD_RIGHT = "DPAD_RIGHT";
49 ViewAbstractModelNG viewAbstractModelNG;
50 std::string srcImages = "common/images/mmm.jpg";
__anon6975b1f10202() 51 auto callback = []() { srcImages = "test"; };
52 }; // namespace
53 class ShortCutsTestNg : public testing::Test {
54 public:
55     static void SetUpTestSuite();
56     static void TearDownTestCase();
57 };
58 
SetUpTestSuite()59 void ShortCutsTestNg::SetUpTestSuite()
60 {
61     MockPipelineContext::SetUp();
62     MockContainer::SetUp();
63     MockContainer::Current()->taskExecutor_ = AceType::MakeRefPtr<MockTaskExecutor>();
64     MockContainer::Current()->pipelineContext_ = MockPipelineContext::GetCurrentContext();
65     MockContainer::Current()->pipelineContext_->taskExecutor_ = MockContainer::Current()->taskExecutor_;
66 }
67 
TearDownTestCase()68 void ShortCutsTestNg::TearDownTestCase()
69 {
70     MockPipelineContext::TearDown();
71     MockContainer::TearDown();
72 }
73 
74 /**
75  * @tc.name: ShortCutsTest001
76  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for tab key.
77  * @tc.type: FUNC
78  */
79 HWTEST_F(ShortCutsTestNg, ShortCutsTest001, TestSize.Level1)
80 {
81     /**
82      * @tc.steps: step1. Create a FrameNode and get eventManager.
83      */
84     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
85     ViewStackProcessor::GetInstance()->Push(targetNode);
86     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
87     eventManager->keyboardShortcutNode_.clear();
88 
89     /**
90      * @tc.steps: step2. call SetKeyboardShortcut with shift + tab.
91      * @tc.expected: add success
92      */
93     std::vector<ModifierKey> keys;
94     keys.push_back(ModifierKey::SHIFT);
95     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
96     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
97 
98     /**
99      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + tab.
100      * @tc.expected: add success
101      */
102     keys.push_back(ModifierKey::ALT);
103     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
104     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
105 
106     /**
107      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + tab.
108      * @tc.expected: add success
109      */
110     keys.push_back(ModifierKey::CTRL);
111     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
112     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
113     keys.clear();
114 }
115 
116 /**
117  * @tc.name: ShortCutsTest002
118  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for tab key.
119  * @tc.type: FUNC
120  */
121 HWTEST_F(ShortCutsTestNg, ShortCutsTest002, TestSize.Level1)
122 {
123     /**
124      * @tc.steps: step1. Create a FrameNode and get eventManager.
125      */
126     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
127     ViewStackProcessor::GetInstance()->Push(targetNode);
128     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
129     eventManager->keyboardShortcutNode_.clear();
130 
131     /**
132      * @tc.steps: step2. call SetKeyboardShortcut with tab.
133      * @tc.expected: add success
134      */
135     std::vector<ModifierKey> keys;
136     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
137     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
138     keys.clear();
139 }
140 
141 /**
142  * @tc.name: ShortCutsTest003
143  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for tab key.
144  * @tc.type: FUNC
145  */
146 HWTEST_F(ShortCutsTestNg, ShortCutsTest003, TestSize.Level1)
147 {
148     /**
149      * @tc.steps: step1. Create a FrameNode and get eventManager.
150      */
151     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
152     ViewStackProcessor::GetInstance()->Push(targetNode);
153     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
154     eventManager->keyboardShortcutNode_.clear();
155 
156     /**
157      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + tab.
158      * @tc.expected: add success
159      */
160     std::vector<ModifierKey> keys;
161     keys.push_back(ModifierKey::CTRL);
162     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
163     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
164 
165     /**
166      * @tc.steps: step3. call SetKeyboardShortcut with shift + ctrl + tab.
167      * @tc.expected: add success
168      */
169     keys.push_back(ModifierKey::SHIFT);
170     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
171     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
172     keys.clear();
173 }
174 
175 /**
176  * @tc.name: ShortCutsTest004
177  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for tab key.
178  * @tc.type: FUNC
179  */
180 HWTEST_F(ShortCutsTestNg, ShortCutsTest004, TestSize.Level1)
181 {
182     /**
183      * @tc.steps: step1. Create a FrameNode and get eventManager.
184      */
185     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
186     ViewStackProcessor::GetInstance()->Push(targetNode);
187     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
188     eventManager->keyboardShortcutNode_.clear();
189 
190     /**
191      * @tc.steps: step2. call SetKeyboardShortcut with alt + tab.
192      * @tc.expected: add success
193      */
194     std::vector<ModifierKey> keys;
195     keys.push_back(ModifierKey::ALT);
196     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
197     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
198 
199     /**
200      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + tab.
201      * @tc.expected: add success
202      */
203     keys.push_back(ModifierKey::CTRL);
204     ViewAbstract::SetKeyboardShortcut(VALUE_TAB, std::move(keys), callback);
205     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
206     keys.clear();
207 }
208 
209 /**
210  * @tc.name: ShortCutsTest005
211  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Up key.
212  * @tc.type: FUNC
213  */
214 HWTEST_F(ShortCutsTestNg, ShortCutsTest005, TestSize.Level1)
215 {
216     /**
217      * @tc.steps: step1. Create a FrameNode and get eventManager.
218      */
219     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
220     ViewStackProcessor::GetInstance()->Push(targetNode);
221     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
222     eventManager->keyboardShortcutNode_.clear();
223 
224     /**
225      * @tc.steps: step2. call SetKeyboardShortcut with up arrow.
226      * @tc.expected: add success
227      */
228     std::vector<ModifierKey> keys;
229     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
230     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
231     keys.clear();
232 }
233 
234 /**
235  * @tc.name: ShortCutsTest006
236  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Up key.
237  * @tc.type: FUNC
238  */
239 HWTEST_F(ShortCutsTestNg, ShortCutsTest006, TestSize.Level1)
240 {
241     /**
242      * @tc.steps: step1. Create a FrameNode and get eventManager.
243      */
244     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
245     ViewStackProcessor::GetInstance()->Push(targetNode);
246     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
247     eventManager->keyboardShortcutNode_.clear();
248 
249     /**
250      * @tc.steps: step2. call SetKeyboardShortcut with alt + up.
251      * @tc.expected: add success
252      */
253     std::vector<ModifierKey> keys;
254     keys.push_back(ModifierKey::ALT);
255     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
256     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
257 
258     /**
259      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + up.
260      * @tc.expected: add success
261      */
262     keys.push_back(ModifierKey::CTRL);
263     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
264     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
265     keys.clear();
266 }
267 
268 /**
269  * @tc.name: ShortCutsTest007
270  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Up key.
271  * @tc.type: FUNC
272  */
273 HWTEST_F(ShortCutsTestNg, ShortCutsTest007, TestSize.Level1)
274 {
275     /**
276      * @tc.steps: step1. Create a FrameNode and get eventManager.
277      */
278     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
279     ViewStackProcessor::GetInstance()->Push(targetNode);
280     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
281     eventManager->keyboardShortcutNode_.clear();
282 
283     /**
284      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + up.
285      * @tc.expected: add success
286      */
287     std::vector<ModifierKey> keys;
288     keys.push_back(ModifierKey::CTRL);
289     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
290     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
291 
292     /**
293      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + up.
294      * @tc.expected: add success
295      */
296     keys.push_back(ModifierKey::SHIFT);
297     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
298     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
299     keys.clear();
300 }
301 
302 /**
303  * @tc.name: ShortCutsTest008
304  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Up key.
305  * @tc.type: FUNC
306  */
307 HWTEST_F(ShortCutsTestNg, ShortCutsTest008, TestSize.Level1)
308 {
309     /**
310      * @tc.steps: step1. Create a FrameNode and get eventManager.
311      */
312     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
313     ViewStackProcessor::GetInstance()->Push(targetNode);
314     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
315     eventManager->keyboardShortcutNode_.clear();
316 
317     /**
318      * @tc.steps: step2. call SetKeyboardShortcut with shift + up.
319      * @tc.expected: add success
320      */
321     std::vector<ModifierKey> keys;
322     keys.push_back(ModifierKey::SHIFT);
323     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
324     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
325 
326     /**
327      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + up.
328      * @tc.expected: add success
329      */
330     keys.push_back(ModifierKey::ALT);
331     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
332     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
333 
334     /**
335      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + up.
336      * @tc.expected: add success
337      */
338     keys.push_back(ModifierKey::CTRL);
339     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_UP, std::move(keys), callback);
340     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
341     keys.clear();
342 }
343 
344 /**
345  * @tc.name: ShortCutsTest009
346  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Down key.
347  * @tc.type: FUNC
348  */
349 HWTEST_F(ShortCutsTestNg, ShortCutsTest009, TestSize.Level1)
350 {
351     /**
352      * @tc.steps: step1. Create a FrameNode and get eventManager.
353      */
354     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
355     ViewStackProcessor::GetInstance()->Push(targetNode);
356     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
357     eventManager->keyboardShortcutNode_.clear();
358 
359     /**
360      * @tc.steps: step2. call SetKeyboardShortcut with down arrow.
361      * @tc.expected: add success
362      */
363     std::vector<ModifierKey> keys;
364     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
365     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
366     keys.clear();
367 }
368 
369 /**
370  * @tc.name: ShortCutsTest010
371  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Down key.
372  * @tc.type: FUNC
373  */
374 HWTEST_F(ShortCutsTestNg, ShortCutsTest010, TestSize.Level1)
375 {
376     /**
377      * @tc.steps: step1. Create a FrameNode and get eventManager.
378      */
379     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
380     ViewStackProcessor::GetInstance()->Push(targetNode);
381     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
382     eventManager->keyboardShortcutNode_.clear();
383 
384     /**
385      * @tc.steps: step2. call SetKeyboardShortcut with alt + down.
386      * @tc.expected: add success
387      */
388     std::vector<ModifierKey> keys;
389     keys.push_back(ModifierKey::ALT);
390     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
391     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
392 
393     /**
394      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + down.
395      * @tc.expected: add success
396      */
397     keys.push_back(ModifierKey::CTRL);
398     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
399     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
400     keys.clear();
401 }
402 
403 /**
404  * @tc.name: ShortCutsTest011
405  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Down key.
406  * @tc.type: FUNC
407  */
408 HWTEST_F(ShortCutsTestNg, ShortCutsTest011, TestSize.Level1)
409 {
410     /**
411      * @tc.steps: step1. Create a FrameNode and get eventManager.
412      */
413     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
414     ViewStackProcessor::GetInstance()->Push(targetNode);
415     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
416     eventManager->keyboardShortcutNode_.clear();
417 
418     /**
419      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + down.
420      * @tc.expected: add success
421      */
422     std::vector<ModifierKey> keys;
423     keys.push_back(ModifierKey::CTRL);
424     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
425     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
426 
427     /**
428      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + down.
429      * @tc.expected: add success
430      */
431     keys.push_back(ModifierKey::SHIFT);
432     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
433     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
434     keys.clear();
435 }
436 
437 /**
438  * @tc.name: ShortCutsTest012
439  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Down key.
440  * @tc.type: FUNC
441  */
442 HWTEST_F(ShortCutsTestNg, ShortCutsTest012, TestSize.Level1)
443 {
444     /**
445      * @tc.steps: step1. Create a FrameNode and get eventManager.
446      */
447     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
448     ViewStackProcessor::GetInstance()->Push(targetNode);
449     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
450     eventManager->keyboardShortcutNode_.clear();
451 
452     /**
453      * @tc.steps: step2. call SetKeyboardShortcut with shift + down.
454      * @tc.expected: add success
455      */
456     std::vector<ModifierKey> keys;
457     keys.push_back(ModifierKey::SHIFT);
458     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
459     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
460 
461     /**
462      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + down.
463      * @tc.expected: add success
464      */
465     keys.push_back(ModifierKey::ALT);
466     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
467     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
468 
469     /**
470      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + down.
471      * @tc.expected: add success
472      */
473     keys.push_back(ModifierKey::CTRL);
474     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_DOWN, std::move(keys), callback);
475     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
476     keys.clear();
477 }
478 
479 /**
480  * @tc.name: ShortCutsTest013
481  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Left key.
482  * @tc.type: FUNC
483  */
484 HWTEST_F(ShortCutsTestNg, ShortCutsTest013, TestSize.Level1)
485 {
486     /**
487      * @tc.steps: step1. Create a FrameNode and get eventManager.
488      */
489     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
490     ViewStackProcessor::GetInstance()->Push(targetNode);
491     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
492     eventManager->keyboardShortcutNode_.clear();
493 
494     /**
495      * @tc.steps: step2. call SetKeyboardShortcut with left arrow.
496      * @tc.expected: add success
497      */
498     std::vector<ModifierKey> keys;
499     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
500     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
501     keys.clear();
502 }
503 
504 /**
505  * @tc.name: ShortCutsTest014
506  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Left key.
507  * @tc.type: FUNC
508  */
509 HWTEST_F(ShortCutsTestNg, ShortCutsTest014, TestSize.Level1)
510 {
511     /**
512      * @tc.steps: step1. Create a FrameNode and get eventManager.
513      */
514     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
515     ViewStackProcessor::GetInstance()->Push(targetNode);
516     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
517     eventManager->keyboardShortcutNode_.clear();
518 
519     /**
520      * @tc.steps: step2. call SetKeyboardShortcut with alt + left.
521      * @tc.expected: add success
522      */
523     std::vector<ModifierKey> keys;
524     keys.push_back(ModifierKey::ALT);
525     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
526     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
527 
528     /**
529      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + left.
530      * @tc.expected: add success
531      */
532     keys.push_back(ModifierKey::CTRL);
533     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
534     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
535     keys.clear();
536 }
537 
538 /**
539  * @tc.name: ShortCutsTest015
540  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Left key.
541  * @tc.type: FUNC
542  */
543 HWTEST_F(ShortCutsTestNg, ShortCutsTest015, TestSize.Level1)
544 {
545     /**
546      * @tc.steps: step1. Create a FrameNode and get eventManager.
547      */
548     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
549     ViewStackProcessor::GetInstance()->Push(targetNode);
550     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
551     eventManager->keyboardShortcutNode_.clear();
552 
553     /**
554      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + left.
555      * @tc.expected: add success
556      */
557     std::vector<ModifierKey> keys;
558     keys.push_back(ModifierKey::CTRL);
559     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
560     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
561 
562     /**
563      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + left.
564      * @tc.expected: add success
565      */
566     keys.push_back(ModifierKey::SHIFT);
567     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
568     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
569     keys.clear();
570 }
571 
572 /**
573  * @tc.name: ShortCutsTest016
574  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Left key.
575  * @tc.type: FUNC
576  */
577 HWTEST_F(ShortCutsTestNg, ShortCutsTest016, TestSize.Level1)
578 {
579     /**
580      * @tc.steps: step1. Create a FrameNode and get eventManager.
581      */
582     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
583     ViewStackProcessor::GetInstance()->Push(targetNode);
584     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
585     eventManager->keyboardShortcutNode_.clear();
586 
587     /**
588      * @tc.steps: step2. call SetKeyboardShortcut with shift + left.
589      * @tc.expected: add success
590      */
591     std::vector<ModifierKey> keys;
592     keys.push_back(ModifierKey::SHIFT);
593     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
594     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
595 
596     /**
597      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + left.
598      * @tc.expected: add success
599      */
600     keys.push_back(ModifierKey::ALT);
601     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
602     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
603 
604     /**
605      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + left.
606      * @tc.expected: add success
607      */
608     keys.push_back(ModifierKey::CTRL);
609     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_LEFT, std::move(keys), callback);
610     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
611     keys.clear();
612 }
613 
614 /**
615  * @tc.name: ShortCutsTest017
616  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Right key.
617  * @tc.type: FUNC
618  */
619 HWTEST_F(ShortCutsTestNg, ShortCutsTest017, TestSize.Level1)
620 {
621     /**
622      * @tc.steps: step1. Create a FrameNode and get eventManager.
623      */
624     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
625     ViewStackProcessor::GetInstance()->Push(targetNode);
626     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
627     eventManager->keyboardShortcutNode_.clear();
628 
629     /**
630      * @tc.steps: step2. call SetKeyboardShortcut with right arrow.
631      * @tc.expected: add success
632      */
633     std::vector<ModifierKey> keys;
634     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
635     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
636     keys.clear();
637 }
638 
639 /**
640  * @tc.name: ShortCutsTest018
641  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Right key.
642  * @tc.type: FUNC
643  */
644 HWTEST_F(ShortCutsTestNg, ShortCutsTest018, TestSize.Level1)
645 {
646     /**
647      * @tc.steps: step1. Create a FrameNode and get eventManager.
648      */
649     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
650     ViewStackProcessor::GetInstance()->Push(targetNode);
651     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
652     eventManager->keyboardShortcutNode_.clear();
653 
654     /**
655      * @tc.steps: step2. call SetKeyboardShortcut with alt + right.
656      * @tc.expected: add success
657      */
658     std::vector<ModifierKey> keys;
659     keys.push_back(ModifierKey::ALT);
660     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
661     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
662 
663     /**
664      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + right.
665      * @tc.expected: add success
666      */
667     keys.push_back(ModifierKey::CTRL);
668     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
669     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
670     keys.clear();
671 }
672 
673 /**
674  * @tc.name: ShortCutsTest019
675  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Right key.
676  * @tc.type: FUNC
677  */
678 HWTEST_F(ShortCutsTestNg, ShortCutsTest019, TestSize.Level1)
679 {
680     /**
681      * @tc.steps: step1. Create a FrameNode and get eventManager.
682      */
683     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
684     ViewStackProcessor::GetInstance()->Push(targetNode);
685     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
686     eventManager->keyboardShortcutNode_.clear();
687 
688     /**
689      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + right.
690      * @tc.expected: add success
691      */
692     std::vector<ModifierKey> keys;
693     keys.push_back(ModifierKey::CTRL);
694     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
695     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
696 
697     /**
698      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + right.
699      * @tc.expected: add success
700      */
701     keys.push_back(ModifierKey::SHIFT);
702     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
703     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
704     keys.clear();
705 }
706 
707 /**
708  * @tc.name: ShortCutsTest020
709  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for arrow/Right key.
710  * @tc.type: FUNC
711  */
712 HWTEST_F(ShortCutsTestNg, ShortCutsTest020, TestSize.Level1)
713 {
714     /**
715      * @tc.steps: step1. Create a FrameNode and get eventManager.
716      */
717     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
718     ViewStackProcessor::GetInstance()->Push(targetNode);
719     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
720     eventManager->keyboardShortcutNode_.clear();
721 
722     /**
723      * @tc.steps: step2. call SetKeyboardShortcut with shift + right.
724      * @tc.expected: add success
725      */
726     std::vector<ModifierKey> keys;
727     keys.push_back(ModifierKey::SHIFT);
728     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
729     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
730 
731     /**
732      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + right.
733      * @tc.expected: add success
734      */
735     keys.push_back(ModifierKey::ALT);
736     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
737     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
738 
739     /**
740      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + right.
741      * @tc.expected: add success
742      */
743     keys.push_back(ModifierKey::CTRL);
744     ViewAbstract::SetKeyboardShortcut(VALUE_DPAD_RIGHT, std::move(keys), callback);
745     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
746     keys.clear();
747 }
748 
749 /**
750  * @tc.name: ShortCutsTest021
751  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for A key.
752  * @tc.type: FUNC
753  */
754 HWTEST_F(ShortCutsTestNg, ShortCutsTest021, TestSize.Level1)
755 {
756     /**
757      * @tc.steps: step1. Create a FrameNode and get eventManager.
758      */
759     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
760     ViewStackProcessor::GetInstance()->Push(targetNode);
761     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
762     eventManager->keyboardShortcutNode_.clear();
763 
764     /**
765      * @tc.steps: step2. call SetKeyboardShortcut with A.
766      * @tc.expected: add success
767      */
768     std::vector<ModifierKey> keys;
769     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
770     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
771     keys.clear();
772 }
773 
774 /**
775  * @tc.name: ShortCutsTest022
776  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for A key.
777  * @tc.type: FUNC
778  */
779 HWTEST_F(ShortCutsTestNg, ShortCutsTest022, TestSize.Level1)
780 {
781     /**
782      * @tc.steps: step1. Create a FrameNode and get eventManager.
783      */
784     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
785     ViewStackProcessor::GetInstance()->Push(targetNode);
786     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
787     eventManager->keyboardShortcutNode_.clear();
788 
789     /**
790      * @tc.steps: step2. call SetKeyboardShortcut with alt + A.
791      * @tc.expected: add success
792      */
793     std::vector<ModifierKey> keys;
794     keys.push_back(ModifierKey::ALT);
795     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
796     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
797 
798     /**
799      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + A.
800      * @tc.expected: add success
801      */
802     keys.push_back(ModifierKey::CTRL);
803     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
804     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
805     keys.clear();
806 }
807 
808 /**
809  * @tc.name: ShortCutsTest023
810  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for A key.
811  * @tc.type: FUNC
812  */
813 HWTEST_F(ShortCutsTestNg, ShortCutsTest023, TestSize.Level1)
814 {
815     /**
816      * @tc.steps: step1. Create a FrameNode and get eventManager.
817      */
818     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
819     ViewStackProcessor::GetInstance()->Push(targetNode);
820     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
821     eventManager->keyboardShortcutNode_.clear();
822 
823     /**
824      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + A.
825      * @tc.expected: add fail
826      */
827     std::vector<ModifierKey> keys;
828     keys.push_back(ModifierKey::CTRL);
829     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
830     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
831 
832     /**
833      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + A.
834      * @tc.expected: add success
835      */
836     keys.push_back(ModifierKey::SHIFT);
837     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
838     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
839     keys.clear();
840 }
841 
842 /**
843  * @tc.name: ShortCutsTest024
844  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for A key.
845  * @tc.type: FUNC
846  */
847 HWTEST_F(ShortCutsTestNg, ShortCutsTest024, TestSize.Level1)
848 {
849     /**
850      * @tc.steps: step1. Create a FrameNode and get eventManager.
851      */
852     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
853     ViewStackProcessor::GetInstance()->Push(targetNode);
854     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
855     eventManager->keyboardShortcutNode_.clear();
856 
857     /**
858      * @tc.steps: step2. call SetKeyboardShortcut with shift + A.
859      * @tc.expected: add success
860      */
861     std::vector<ModifierKey> keys;
862     keys.push_back(ModifierKey::SHIFT);
863     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
864     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
865 
866     /**
867      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + A.
868      * @tc.expected: add success
869      */
870     keys.push_back(ModifierKey::ALT);
871     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
872     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
873 
874     /**
875      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + A.
876      * @tc.expected: add success
877      */
878     keys.push_back(ModifierKey::CTRL);
879     ViewAbstract::SetKeyboardShortcut(VALUE_A, std::move(keys), callback);
880     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
881     keys.clear();
882 }
883 
884 /**
885  * @tc.name: ShortCutsTest025
886  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for C key.
887  * @tc.type: FUNC
888  */
889 HWTEST_F(ShortCutsTestNg, ShortCutsTest025, TestSize.Level1)
890 {
891     /**
892      * @tc.steps: step1. Create a FrameNode and get eventManager.
893      */
894     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
895     ViewStackProcessor::GetInstance()->Push(targetNode);
896     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
897     eventManager->keyboardShortcutNode_.clear();
898 
899     /**
900      * @tc.steps: step2. call SetKeyboardShortcut with C.
901      * @tc.expected: add success
902      */
903     std::vector<ModifierKey> keys;
904     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
905     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
906     keys.clear();
907 }
908 
909 /**
910  * @tc.name: ShortCutsTest026
911  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for C key.
912  * @tc.type: FUNC
913  */
914 HWTEST_F(ShortCutsTestNg, ShortCutsTest026, TestSize.Level1)
915 {
916     /**
917      * @tc.steps: step1. Create a FrameNode and get eventManager.
918      */
919     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
920     ViewStackProcessor::GetInstance()->Push(targetNode);
921     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
922     eventManager->keyboardShortcutNode_.clear();
923 
924     /**
925      * @tc.steps: step2. call SetKeyboardShortcut with alt + C.
926      * @tc.expected: add success
927      */
928     std::vector<ModifierKey> keys;
929     keys.push_back(ModifierKey::ALT);
930     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
931     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
932 
933     /**
934      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + C.
935      * @tc.expected: add success
936      */
937     keys.push_back(ModifierKey::CTRL);
938     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
939     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
940     keys.clear();
941 }
942 
943 /**
944  * @tc.name: ShortCutsTest027
945  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for C key.
946  * @tc.type: FUNC
947  */
948 HWTEST_F(ShortCutsTestNg, ShortCutsTest027, TestSize.Level1)
949 {
950     /**
951      * @tc.steps: step1. Create a FrameNode and get eventManager.
952      */
953     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
954     ViewStackProcessor::GetInstance()->Push(targetNode);
955     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
956     eventManager->keyboardShortcutNode_.clear();
957 
958     /**
959      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + C.
960      * @tc.expected: add fail
961      */
962     std::vector<ModifierKey> keys;
963     keys.push_back(ModifierKey::CTRL);
964     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
965     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
966 
967     /**
968      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + C.
969      * @tc.expected: add success
970      */
971     keys.push_back(ModifierKey::SHIFT);
972     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
973     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
974     keys.clear();
975 }
976 
977 /**
978  * @tc.name: ShortCutsTest028
979  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for C key.
980  * @tc.type: FUNC
981  */
982 HWTEST_F(ShortCutsTestNg, ShortCutsTest028, TestSize.Level1)
983 {
984     /**
985      * @tc.steps: step1. Create a FrameNode and get eventManager.
986      */
987     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
988     ViewStackProcessor::GetInstance()->Push(targetNode);
989     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
990     eventManager->keyboardShortcutNode_.clear();
991 
992     /**
993      * @tc.steps: step2. call SetKeyboardShortcut with shift + C.
994      * @tc.expected: add success
995      */
996     std::vector<ModifierKey> keys;
997     keys.push_back(ModifierKey::SHIFT);
998     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
999     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1000 
1001     /**
1002      * @tc.steps: step3. call SetKeyboardShortcut with shift + atl + C.
1003      * @tc.expected: add success
1004      */
1005     keys.push_back(ModifierKey::ALT);
1006     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
1007     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1008 
1009     /**
1010      * @tc.steps: step4. call SetKeyboardShortcut with shift + atl + ctrl + C.
1011      * @tc.expected: add success
1012      */
1013     keys.push_back(ModifierKey::CTRL);
1014     ViewAbstract::SetKeyboardShortcut(VALUE_C, std::move(keys), callback);
1015     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1016     keys.clear();
1017 }
1018 
1019 /**
1020  * @tc.name: ShortCutsTest029
1021  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for V key.
1022  * @tc.type: FUNC
1023  */
1024 HWTEST_F(ShortCutsTestNg, ShortCutsTest029, TestSize.Level1)
1025 {
1026     /**
1027      * @tc.steps: step1. Create a FrameNode and get eventManager.
1028      */
1029     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1030     ViewStackProcessor::GetInstance()->Push(targetNode);
1031     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1032     eventManager->keyboardShortcutNode_.clear();
1033 
1034     /**
1035      * @tc.steps: step2. call SetKeyboardShortcut with V.
1036      * @tc.expected: add success
1037      */
1038     std::vector<ModifierKey> keys;
1039     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1040     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1041     keys.clear();
1042 }
1043 
1044 /**
1045  * @tc.name: ShortCutsTest030
1046  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for V key.
1047  * @tc.type: FUNC
1048  */
1049 HWTEST_F(ShortCutsTestNg, ShortCutsTest030, TestSize.Level1)
1050 {
1051     /**
1052      * @tc.steps: step1. Create a FrameNode and get eventManager.
1053      */
1054     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1055     ViewStackProcessor::GetInstance()->Push(targetNode);
1056     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1057     eventManager->keyboardShortcutNode_.clear();
1058 
1059     /**
1060      * @tc.steps: step2. call SetKeyboardShortcut with alt + V.
1061      * @tc.expected: add success
1062      */
1063     std::vector<ModifierKey> keys;
1064     keys.push_back(ModifierKey::ALT);
1065     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1066     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1067 
1068     /**
1069      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + V.
1070      * @tc.expected: add success
1071      */
1072     keys.push_back(ModifierKey::CTRL);
1073     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1074     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1075     keys.clear();
1076 }
1077 
1078 /**
1079  * @tc.name: ShortCutsTest031
1080  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for V key.
1081  * @tc.type: FUNC
1082  */
1083 HWTEST_F(ShortCutsTestNg, ShortCutsTest031, TestSize.Level1)
1084 {
1085     /**
1086      * @tc.steps: step1. Create a FrameNode and get eventManager.
1087      */
1088     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1089     ViewStackProcessor::GetInstance()->Push(targetNode);
1090     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1091     eventManager->keyboardShortcutNode_.clear();
1092 
1093     /**
1094      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + V.
1095      * @tc.expected: add fail
1096      */
1097     std::vector<ModifierKey> keys;
1098     keys.push_back(ModifierKey::CTRL);
1099     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1100     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1101 
1102     /**
1103      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + V.
1104      * @tc.expected: add success
1105      */
1106     keys.push_back(ModifierKey::SHIFT);
1107     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1108     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1109     keys.clear();
1110 }
1111 
1112 /**
1113  * @tc.name: ShortCutsTest032
1114  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for V key.
1115  * @tc.type: FUNC
1116  */
1117 HWTEST_F(ShortCutsTestNg, ShortCutsTest032, TestSize.Level1)
1118 {
1119     /**
1120      * @tc.steps: step1. Create a FrameNode and get eventManager.
1121      */
1122     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1123     ViewStackProcessor::GetInstance()->Push(targetNode);
1124     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1125     eventManager->keyboardShortcutNode_.clear();
1126 
1127     /**
1128      * @tc.steps: step2. call SetKeyboardShortcut with shift + V.
1129      * @tc.expected: add success
1130      */
1131     std::vector<ModifierKey> keys;
1132     keys.push_back(ModifierKey::SHIFT);
1133     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1134     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1135 
1136     /**
1137      * @tc.steps: step3. call SetKeyboardShortcut with shift + atl + V.
1138      * @tc.expected: add success
1139      */
1140     keys.push_back(ModifierKey::ALT);
1141     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1142     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1143 
1144     /**
1145      * @tc.steps: step4. call SetKeyboardShortcut with shift + atl + ctrl + V.
1146      * @tc.expected: add success
1147      */
1148     keys.push_back(ModifierKey::CTRL);
1149     ViewAbstract::SetKeyboardShortcut(VALUE_V, std::move(keys), callback);
1150     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1151     keys.clear();
1152 }
1153 
1154 /**
1155  * @tc.name: ShortCutsTest033
1156  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Z key.
1157  * @tc.type: FUNC
1158  */
1159 HWTEST_F(ShortCutsTestNg, ShortCutsTest033, TestSize.Level1)
1160 {
1161     /**
1162      * @tc.steps: step1. Create a FrameNode and get eventManager.
1163      */
1164     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1165     ViewStackProcessor::GetInstance()->Push(targetNode);
1166     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1167     eventManager->keyboardShortcutNode_.clear();
1168 
1169     /**
1170      * @tc.steps: step2. call SetKeyboardShortcut with Z.
1171      * @tc.expected: add success
1172      */
1173     std::vector<ModifierKey> keys;
1174     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1175     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1176     keys.clear();
1177 }
1178 
1179 /**
1180  * @tc.name: ShortCutsTest034
1181  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Z key.
1182  * @tc.type: FUNC
1183  */
1184 HWTEST_F(ShortCutsTestNg, ShortCutsTest034, TestSize.Level1)
1185 {
1186     /**
1187      * @tc.steps: step1. Create a FrameNode and get eventManager.
1188      */
1189     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1190     ViewStackProcessor::GetInstance()->Push(targetNode);
1191     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1192     eventManager->keyboardShortcutNode_.clear();
1193 
1194     /**
1195      * @tc.steps: step2. call SetKeyboardShortcut with alt + Z.
1196      * @tc.expected: add success
1197      */
1198     std::vector<ModifierKey> keys;
1199     keys.push_back(ModifierKey::ALT);
1200     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1201     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1202 
1203     /**
1204      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + Z.
1205      * @tc.expected: add success
1206      */
1207     keys.push_back(ModifierKey::CTRL);
1208     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1209     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1210     keys.clear();
1211 }
1212 
1213 /**
1214  * @tc.name: ShortCutsTest035
1215  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Z key.
1216  * @tc.type: FUNC
1217  */
1218 HWTEST_F(ShortCutsTestNg, ShortCutsTest035, TestSize.Level1)
1219 {
1220     /**
1221      * @tc.steps: step1. Create a FrameNode and get eventManager.
1222      */
1223     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1224     ViewStackProcessor::GetInstance()->Push(targetNode);
1225     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1226     eventManager->keyboardShortcutNode_.clear();
1227 
1228     /**
1229      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + Z.
1230      * @tc.expected: add fail
1231      */
1232     std::vector<ModifierKey> keys;
1233     keys.push_back(ModifierKey::CTRL);
1234     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1235     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1236 
1237     /**
1238      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + Z.
1239      * @tc.expected: add success
1240      */
1241     keys.push_back(ModifierKey::SHIFT);
1242     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1243     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1244     keys.clear();
1245 }
1246 
1247 /**
1248  * @tc.name: ShortCutsTest036
1249  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Z key.
1250  * @tc.type: FUNC
1251  */
1252 HWTEST_F(ShortCutsTestNg, ShortCutsTest036, TestSize.Level1)
1253 {
1254     /**
1255      * @tc.steps: step1. Create a FrameNode and get eventManager.
1256      */
1257     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1258     ViewStackProcessor::GetInstance()->Push(targetNode);
1259     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1260     eventManager->keyboardShortcutNode_.clear();
1261 
1262     /**
1263      * @tc.steps: step2. call SetKeyboardShortcut with shift + Z.
1264      * @tc.expected: add success
1265      */
1266     std::vector<ModifierKey> keys;
1267     keys.push_back(ModifierKey::SHIFT);
1268     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1269     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1270 
1271     /**
1272      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + Z.
1273      * @tc.expected: add success
1274      */
1275     keys.push_back(ModifierKey::ALT);
1276     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1277     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1278 
1279     /**
1280      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + Z.
1281      * @tc.expected: add success
1282      */
1283     keys.push_back(ModifierKey::CTRL);
1284     ViewAbstract::SetKeyboardShortcut(VALUE_Z, std::move(keys), callback);
1285     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1286     keys.clear();
1287 }
1288 
1289 /**
1290  * @tc.name: ShortCutsTest037
1291  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Y key.
1292  * @tc.type: FUNC
1293  */
1294 HWTEST_F(ShortCutsTestNg, ShortCutsTest037, TestSize.Level1)
1295 {
1296     /**
1297      * @tc.steps: step1. Create a FrameNode and get eventManager.
1298      */
1299     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1300     ViewStackProcessor::GetInstance()->Push(targetNode);
1301     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1302     eventManager->keyboardShortcutNode_.clear();
1303 
1304     /**
1305      * @tc.steps: step2. call SetKeyboardShortcut with Y.
1306      * @tc.expected: add success
1307      */
1308     std::vector<ModifierKey> keys;
1309     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1310     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1311     keys.clear();
1312 }
1313 
1314 /**
1315  * @tc.name: ShortCutsTest038
1316  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Y key.
1317  * @tc.type: FUNC
1318  */
1319 HWTEST_F(ShortCutsTestNg, ShortCutsTest038, TestSize.Level1)
1320 {
1321     /**
1322      * @tc.steps: step1. Create a FrameNode and get eventManager.
1323      */
1324     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1325     ViewStackProcessor::GetInstance()->Push(targetNode);
1326     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1327     eventManager->keyboardShortcutNode_.clear();
1328 
1329     /**
1330      * @tc.steps: step2. call SetKeyboardShortcut with alt + Y.
1331      * @tc.expected: add success
1332      */
1333     std::vector<ModifierKey> keys;
1334     keys.push_back(ModifierKey::ALT);
1335     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1336     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1337 
1338     /**
1339      * @tc.steps: step3. call SetKeyboardShortcut with alt + ctrl + Y.
1340      * @tc.expected: add success
1341      */
1342     keys.push_back(ModifierKey::CTRL);
1343     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1344     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1345     keys.clear();
1346 }
1347 
1348 /**
1349  * @tc.name: ShortCutsTest039
1350  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Y key.
1351  * @tc.type: FUNC
1352  */
1353 HWTEST_F(ShortCutsTestNg, ShortCutsTest039, TestSize.Level1)
1354 {
1355     /**
1356      * @tc.steps: step1. Create a FrameNode and get eventManager.
1357      */
1358     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1359     ViewStackProcessor::GetInstance()->Push(targetNode);
1360     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1361     eventManager->keyboardShortcutNode_.clear();
1362 
1363     /**
1364      * @tc.steps: step2. call SetKeyboardShortcut with ctrl + Y.
1365      * @tc.expected: add fail
1366      */
1367     std::vector<ModifierKey> keys;
1368     keys.push_back(ModifierKey::CTRL);
1369     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1370     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 0);
1371 
1372     /**
1373      * @tc.steps: step3. call SetKeyboardShortcut with ctrl + shift + Y.
1374      * @tc.expected: add success
1375      */
1376     keys.push_back(ModifierKey::SHIFT);
1377     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1378     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1379     keys.clear();
1380 }
1381 
1382 /**
1383  * @tc.name: ShortCutsTest040
1384  * @tc.desc: Test the SetKeyboardShortcut of View_Abstract for Y key.
1385  * @tc.type: FUNC
1386  */
1387 HWTEST_F(ShortCutsTestNg, ShortCutsTest040, TestSize.Level1)
1388 {
1389     /**
1390      * @tc.steps: step1. Create a FrameNode and get eventManager.
1391      */
1392     const RefPtr<FrameNode> targetNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1393     ViewStackProcessor::GetInstance()->Push(targetNode);
1394     auto eventManager = PipelineContext::GetCurrentContext()->GetEventManager();
1395     eventManager->keyboardShortcutNode_.clear();
1396 
1397     /**
1398      * @tc.steps: step2. call SetKeyboardShortcut with shift + Y.
1399      * @tc.expected: add success
1400      */
1401     std::vector<ModifierKey> keys;
1402     keys.push_back(ModifierKey::SHIFT);
1403     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1404     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1405 
1406     /**
1407      * @tc.steps: step3. call SetKeyboardShortcut with shift + alt + Y.
1408      * @tc.expected: add success
1409      */
1410     keys.push_back(ModifierKey::ALT);
1411     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1412     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1413 
1414     /**
1415      * @tc.steps: step4. call SetKeyboardShortcut with shift + alt + ctrl + Y.
1416      * @tc.expected: add success
1417      */
1418     keys.push_back(ModifierKey::CTRL);
1419     ViewAbstract::SetKeyboardShortcut(VALUE_Y, std::move(keys), callback);
1420     EXPECT_EQ(eventManager->keyboardShortcutNode_.size(), 1);
1421     keys.clear();
1422 }
1423 } // namespace OHOS::Ace::NG