• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 
16 #include "patternlock_test_ng.h"
17 
SetUpTestSuite()18 void PatternLockTestNg::SetUpTestSuite()
19 {
20     TestNG::SetUpTestSuite();
21     MockPipelineContext::GetCurrent()->SetUseFlushUITasks(true);
22     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
23     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
24     auto themeConstants = CreateThemeConstants(THEME_PATTERN_SCROLL_BAR);
25     auto scrollBarTheme = ScrollBarTheme::Builder().Build(themeConstants);
26     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(scrollBarTheme));
27     auto patternLockThemeConstants = CreateThemeConstants(THEME_PATTERN_PATTERN_LOCK);
28     auto patternLockTheme = V2::PatternLockTheme::Builder().Build(patternLockThemeConstants);
29     EXPECT_CALL(*themeManager, GetTheme(V2::PatternLockTheme::TypeId())).WillRepeatedly(Return(patternLockTheme));
30     MockPipelineContext::GetCurrentContext()->taskExecutor_ = AceType::MakeRefPtr<MockTaskExecutor>();
31 }
32 
TearDownTestSuite()33 void PatternLockTestNg::TearDownTestSuite()
34 {
35     TestNG::TearDownTestSuite();
36 }
37 
SetUp()38 void PatternLockTestNg::SetUp() {}
39 
TearDown()40 void PatternLockTestNg::TearDown()
41 {
42     frameNode_ = nullptr;
43     pattern_ = nullptr;
44     eventHub_ = nullptr;
45     layoutProperty_ = nullptr;
46     paintProperty_ = nullptr;
47 }
48 
GetInstance()49 void PatternLockTestNg::GetInstance()
50 {
51     RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
52     frameNode_ = AceType::DynamicCast<FrameNode>(element);
53     pattern_ = frameNode_->GetPattern<PatternLockPattern>();
54     eventHub_ = frameNode_->GetEventHub<PatternLockEventHub>();
55     layoutProperty_ = frameNode_->GetLayoutProperty<PatternLockLayoutProperty>();
56     paintProperty_ = frameNode_->GetPaintProperty<PatternLockPaintProperty>();
57 }
58 
Create(const std::function<void (PatternLockModelNG)> & callback)59 void PatternLockTestNg::Create(const std::function<void(PatternLockModelNG)>& callback)
60 {
61     PatternLockModelNG model;
62     model.Create();
63     ViewAbstract::SetWidth(CalcLength(PATTERNLOCK_WIDTH));
64     ViewAbstract::SetHeight(CalcLength(PATTERNLOCK_HEIGHT));
65     if (callback) {
66         callback(model);
67     }
68     GetInstance();
69     FlushUITasks(frameNode_);
70 }
71 
72 /**
73  * @tc.name: PaintProperty001
74  * @tc.desc: Set PatternLock value into PatternLockPaintProperty and get it.
75  * @tc.type: FUNC
76  */
77 HWTEST_F(PatternLockTestNg, PaintProperty001, TestSize.Level1)
78 {
__anonb32113cb1e02(PatternLockModelNG model) 79     Create([](PatternLockModelNG model) {
80         model.SetCircleRadius(CIRCLE_RADIUS);
81         model.SetRegularColor(REGULAR_COLOR);
82         model.SetSelectedColor(SELECTED_COLOR);
83         model.SetActiveColor(ACTIVE_COLOR);
84         model.SetPathColor(PATH_COLOR);
85         model.SetStrokeWidth(PATH_STROKE_WIDTH);
86         model.SetAutoReset(true);
87         model.SetSideLength(SIDE_LENGTH);
88         model.SetActiveCircleColor(ACTIVE_CIRCLE_COLOR);
89         model.SetActiveCircleRadius(ACTIVE_CIRCLE_RADIUS);
90         model.SetEnableWaveEffect(false);
91     });
92     EXPECT_EQ(paintProperty_->GetCircleRadiusValue(), CIRCLE_RADIUS);
93     EXPECT_EQ(paintProperty_->GetRegularColorValue(), REGULAR_COLOR);
94     EXPECT_EQ(paintProperty_->GetSelectedColorValue(), SELECTED_COLOR);
95     EXPECT_EQ(paintProperty_->GetActiveColorValue(), ACTIVE_COLOR);
96     EXPECT_EQ(paintProperty_->GetPathColorValue(), PATH_COLOR);
97     EXPECT_EQ(paintProperty_->GetPathStrokeWidthValue(), PATH_STROKE_WIDTH);
98     EXPECT_TRUE(paintProperty_->GetAutoResetValue());
99     EXPECT_EQ(layoutProperty_->GetSideLength(), SIDE_LENGTH);
100     EXPECT_EQ(paintProperty_->GetActiveCircleColorValue(), ACTIVE_CIRCLE_COLOR);
101     EXPECT_EQ(paintProperty_->GetActiveCircleRadiusValue(), ACTIVE_CIRCLE_RADIUS);
102     EXPECT_FALSE(paintProperty_->GetEnableWaveEffectValue());
103 }
104 
105 /**
106  * @tc.name: PatternLockEventTest001
107  * @tc.desc: Test PatternLock onComplete event.
108  * @tc.type: FUNC
109  */
110 HWTEST_F(PatternLockTestNg, PatternLockEventTest001, TestSize.Level1)
111 {
112     std::vector<int> chooseCellVec;
113     std::vector<int> afterComplete;
114     chooseCellVec.push_back(1);
115     chooseCellVec.push_back(2);
116     chooseCellVec.push_back(3);
117     chooseCellVec.push_back(4);
118     chooseCellVec.push_back(5);
119     chooseCellVec.push_back(6);
120     auto patternCompleteEvent = V2::PatternCompleteEvent(chooseCellVec);
__anonb32113cb1f02(const BaseEventInfo* completeResult) 121     auto onComplete = [&afterComplete](const BaseEventInfo* completeResult) {
122         const auto* eventInfo = TypeInfoHelper::DynamicCast<V2::PatternCompleteEvent>(completeResult);
123         afterComplete = eventInfo->GetInput();
124     };
__anonb32113cb2002(PatternLockModelNG model) 125     Create([onComplete](PatternLockModelNG model) {
126         model.SetPatternComplete(onComplete);
127     });
128 
129     /**
130      * @tc.steps: step1. Get event hub and call UpdateCompleteEvent function
131      */
132     eventHub_->UpdateCompleteEvent(&patternCompleteEvent);
133     EXPECT_FALSE(afterComplete.empty());
134     EXPECT_EQ(afterComplete.back(), 6);
135     afterComplete.pop_back();
136     EXPECT_EQ(afterComplete.back(), 5);
137     afterComplete.pop_back();
138     EXPECT_EQ(afterComplete.back(), 4);
139     afterComplete.pop_back();
140     EXPECT_EQ(afterComplete.back(), 3);
141     afterComplete.pop_back();
142     EXPECT_EQ(afterComplete.back(), 2);
143     afterComplete.pop_back();
144     EXPECT_EQ(afterComplete.back(), 1);
145 }
146 
147 /**
148  * @tc.name: PatternLockEventTest002
149  * @tc.desc: Test PatternLock onDotConnect event.
150  * @tc.type: FUNC
151  */
152 HWTEST_F(PatternLockTestNg, PatternLockEventTest002, TestSize.Level1)
153 {
154     int32_t connectedDot = -1;
__anonb32113cb2102(int32_t currentIndex) 155     auto onDotConnect = [&connectedDot](int32_t currentIndex) { connectedDot = currentIndex; };
__anonb32113cb2202(PatternLockModelNG model) 156     Create([onDotConnect](PatternLockModelNG model) {
157         model.SetDotConnect(onDotConnect);
158     });
159 
160     /**
161      * @tc.steps: step1. Get event hub and call UpdateDotConnectEvent function
162      */
163     eventHub_->UpdateDotConnectEvent(1);
164     EXPECT_EQ(connectedDot, 1);
165 }
166 
167 /**
168  * @tc.name: PatternLockPatternTest001
169  * @tc.desc: Test PatternLock pattern method HandleReset.
170  * @tc.type: FUNC
171  */
172 HWTEST_F(PatternLockTestNg, PatternLockPatternTest001, TestSize.Level1)
173 {
__anonb32113cb2302(PatternLockModelNG model) 174     Create([](PatternLockModelNG model) {});
175     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
176 
177     /**
178      * @tc.steps: step3. Set PatternLock pattern variable and call HandleReset
179      * @tc.expected: step3. Check the PatternLock pattern variable
180      */
181     pattern_->isMoveEventValid_ = true;
182     pattern_->choosePoint_.push_back(PatternLockCell(1, 2));
183     pattern_->cellCenter_ = OffsetF(1.0, 1.0);
184     pattern_->HandleReset();
185     EXPECT_FALSE(pattern_->isMoveEventValid_);
186     EXPECT_TRUE(pattern_->choosePoint_.empty());
187     EXPECT_EQ(pattern_->cellCenter_, OffsetF(0, 0));
188 
189     /**
190      * @tc.steps: step4. PatternLock Init PatternLockController.
191      */
192     pattern_->InitPatternLockController();
193     ASSERT_NE(pattern_->patternLockController_->resetImpl_, nullptr);
194     pattern_->patternLockController_->resetImpl_();
195     EXPECT_FALSE(pattern_->isMoveEventValid_);
196     EXPECT_TRUE(pattern_->choosePoint_.empty());
197     EXPECT_EQ(pattern_->cellCenter_, OffsetF(0, 0));
198 }
199 
200 /**
201  * @tc.name: PatternLockPatternTest002
202  * @tc.desc: Test PatternLock pattern method CheckAutoReset.
203  * @tc.type: FUNC
204  */
205 HWTEST_F(PatternLockTestNg, PatternLockPatternTest002, TestSize.Level1)
206 {
__anonb32113cb2402(PatternLockModelNG model) 207     Create([](PatternLockModelNG model) {
208         model.SetAutoReset(true);
209     });
210 
211     /**
212      * @tc.steps: step1. Set PatternLock pattern variable and call CheckAutoReset
213      * @tc.expected: step1. Check the return value of PatternLock pattern method CheckAutoReset
214      */
215     bool result1 = pattern_->CheckAutoReset();
216     EXPECT_TRUE(pattern_->autoReset_);
217     EXPECT_TRUE(result1);
218     auto paintProperty_ = frameNode_->GetPaintProperty<PatternLockPaintProperty>();
219     paintProperty_->Reset();
220     bool result2 = pattern_->CheckAutoReset();
221     EXPECT_TRUE(result2);
222     pattern_->autoReset_ = false;
223     pattern_->choosePoint_ = { PatternLockCell(1, 2) };
224     pattern_->isMoveEventValid_ = false;
225     bool result3 = pattern_->CheckAutoReset();
226     EXPECT_FALSE(result3);
227 }
228 
229 /**
230  * @tc.name: PatternLockPatternTest003
231  * @tc.desc: Test PatternLock pattern method AddPassPoint.
232  * @tc.type: FUNC
233  */
234 HWTEST_F(PatternLockTestNg, PatternLockPatternTest003, TestSize.Level1)
235 {
__anonb32113cb2502(PatternLockModelNG model) 236     Create([](PatternLockModelNG model) {});
237     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
238 
239     /**
240      * @tc.case: case1: choosePoint_ vec is empty.
241      */
242     pattern_->AddPassPoint(1, 2);
243     EXPECT_TRUE(pattern_->choosePoint_.empty());
244     /**
245      * @tc.case: case2: choosePoint_ vec is not empty.
246      */
247     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
248     pattern_->AddPassPoint(1, 2);
249     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 1);
250     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
251     /**
252      * @tc.case: case3: lastPoint(1, 2), add Point(2, 2), no passPoint.
253      */
254     pattern_->choosePoint_.clear();
255     pattern_->choosePoint_.push_back(PatternLockCell(1, 2));
256     pattern_->AddPassPoint(2, 2);
257     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 2);
258     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
259     /**
260      * @tc.case: case4: lastPoint(0, 2), add Point(2, 2), passPoint(1, 2)
261      */
262     pattern_->choosePoint_.clear();
263     pattern_->choosePoint_.push_back(PatternLockCell(0, 2));
264     pattern_->AddPassPoint(2, 2);
265     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
266     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 2);
267     EXPECT_EQ(pattern_->choosePoint_.size(), 2);
268     /**
269      * @tc.case: case5: lastPoint(2, 2), add Point(0, 0), passPoint(1, 1)
270      */
271     pattern_->choosePoint_.clear();
272     pattern_->choosePoint_.push_back(PatternLockCell(2, 2));
273     pattern_->AddPassPoint(0, 0);
274     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
275     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 1);
276     EXPECT_EQ(pattern_->choosePoint_.size(), 2);
277 }
278 
279 /**
280  * @tc.name: PatternLockPatternTest004
281  * @tc.desc: Test PatternLock pattern method CheckChoosePoint.
282  * @tc.type: FUNC
283  */
284 HWTEST_F(PatternLockTestNg, PatternLockPatternTest004, TestSize.Level1)
285 {
__anonb32113cb2602(PatternLockModelNG model) 286     Create([](PatternLockModelNG model) {});
287 
288     /**
289      * @tc.steps: step1. Set PatternLock pattern variable and call CheckChoosePoint
290      * @tc.expected: step1. Check the return value of PatternLock pattern method CheckChoosePoint
291      */
292     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
293     pattern_->choosePoint_.push_back(PatternLockCell(1, 2));
294     auto result1 = pattern_->CheckChoosePoint(1, 2);
295     EXPECT_TRUE(result1);
296     auto result2 = pattern_->CheckChoosePoint(2, 2);
297     EXPECT_FALSE(result2);
298 }
299 
300 /**
301  * @tc.name: PatternLockPatternTest005
302  * @tc.desc: Test PatternLock pattern method AddChoosePoint.
303  * @tc.type: FUNC
304  */
305 HWTEST_F(PatternLockTestNg, PatternLockPatternTest005, TestSize.Level1)
306 {
__anonb32113cb2702(PatternLockModelNG model) 307     Create([](PatternLockModelNG model) {});
308 
309     frameNode_->GetGeometryNode()->SetContentSize(SizeF(300.0f, 300.0f));
310     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
311     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
312     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
313     auto patternlockTheme = AceType::MakeRefPtr<V2::PatternLockTheme>();
314     patternlockTheme->hotSpotCircleRadius_ = HOTSPOT_CIRCLE_RADIUS;
315     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(patternlockTheme));
316 
317     /**
318      * @tc.cases: when distance is unvalid, Point(x, y) will not AddChoosePoint.
319      */
320     float offsetX = 75.0f;
321     float offsetY = 75.0f;
322     OffsetF offset(offsetX, offsetY);
323     bool result1 = pattern_->AddChoosePoint(offset, 1, 1);
324     EXPECT_FALSE(result1);
325     auto paintProperty_ = frameNode_->GetPaintProperty<PatternLockPaintProperty>();
326     paintProperty_->UpdateCircleRadius(CIRCLE_RADIUS);
327     bool result2 = pattern_->AddChoosePoint(offset, 1, 1);
328     EXPECT_FALSE(result2);
329 
330     /**
331      * @tc.cases: when distance is valid, Point(x, y) will AddChoosePoint.
332      */
333     paintProperty_->UpdateCircleRadius(Dimension(200.0));
334     EXPECT_EQ(pattern_->choosePoint_.size(), 0);
335     EXPECT_FALSE(pattern_->CheckChoosePoint(1, 1));
336     bool result3 = pattern_->AddChoosePoint(offset, 1, 1);
337     EXPECT_EQ(pattern_->choosePoint_.size(), 1);
338     EXPECT_TRUE(result3);
339 
340     EXPECT_TRUE(pattern_->CheckChoosePoint(1, 1));
341     bool result4 = pattern_->AddChoosePoint(offset, 1, 1);
342     EXPECT_EQ(pattern_->choosePoint_.size(), 1);
343     EXPECT_TRUE(result4);
344 
345     EXPECT_EQ(frameNode_->GetGeometryNode()->GetFrameSize(), SizeF(400.f, 400.f));
346     offsetX = 200.f;
347     offsetY = 200.f;
348     offset.SetX(offsetX);
349     offset.SetY(offsetY);
350     EXPECT_FALSE(pattern_->CheckChoosePoint(2, 2));
351     bool result5 = pattern_->AddChoosePoint(offset, 2, 2);
352     EXPECT_EQ(pattern_->choosePoint_.size(), 2);
353     EXPECT_TRUE(result5);
354 }
355 
356 /**
357  * @tc.name: PatternLockPatternTest006
358  * @tc.desc: Test PatternLock pattern method OnTouchUp.
359  * @tc.type: FUNC
360  */
361 HWTEST_F(PatternLockTestNg, PatternLockPatternTest006, TestSize.Level1)
362 {
__anonb32113cb2802(PatternLockModelNG model) 363     Create([](PatternLockModelNG model) {});
364     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
365 
366     /**
367      * @tc.steps: step3. Set PatternLock pattern variable and call OnTouchUp
368      * @tc.expected: step3. Check the PatternLock pattern value
369      */
370     pattern_->autoReset_ = false;
371     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
372     pattern_->patternLockModifier_->choosePoint_.push_back(PatternLockCell(1, 1));
373     pattern_->patternLockModifier_->choosePoint_.push_back(PatternLockCell(2, 2));
374     pattern_->isMoveEventValid_ = false;
375     pattern_->OnTouchUp();
376     pattern_->isMoveEventValid_ = true;
377     pattern_->OnTouchUp();
378     EXPECT_FALSE(pattern_->isMoveEventValid_);
379 }
380 
381 /**
382  * @tc.name: PatternLockPatternTest007
383  * @tc.desc: Test PatternLock pattern method OnTouchMove.
384  * @tc.type: FUNC
385  */
386 HWTEST_F(PatternLockTestNg, PatternLockPatternTest007, TestSize.Level1)
387 {
__anonb32113cb2902(PatternLockModelNG model) 388     Create([](PatternLockModelNG model) {});
389 
390     /**
391      * @tc.steps: step3. Set PatternLock pattern variable and call OnTouchMove
392      * @tc.expected: step3. Check the PatternLock pattern value
393      */
394     float offsetX = 1.0f;
395     float offsetY = 1.0f;
396     Offset offset(offsetX, offsetY);
397     pattern_->isMoveEventValid_ = false;
398     TouchLocationInfo locationInfo(0);
399     locationInfo.SetTouchType(TouchType::MOVE);
400     locationInfo.SetLocalLocation(offset);
401     pattern_->OnTouchMove(locationInfo);
402     EXPECT_EQ(pattern_->cellCenter_.GetX(), .0f);
403     EXPECT_EQ(pattern_->cellCenter_.GetY(), .0f);
404     pattern_->isMoveEventValid_ = true;
405     pattern_->OnTouchMove(locationInfo);
406     EXPECT_EQ(pattern_->cellCenter_.GetX(), offset.GetX());
407     EXPECT_EQ(pattern_->cellCenter_.GetY(), offset.GetY());
408 }
409 
410 /**
411  * @tc.name: PatternLockPatternTest008
412  * @tc.desc: Test PatternLock pattern method OnTouchDown.
413  * @tc.type: FUNC
414  */
415 HWTEST_F(PatternLockTestNg, PatternLockPatternTest008, TestSize.Level1)
416 {
__anonb32113cb2a02(PatternLockModelNG model) 417     Create([](PatternLockModelNG model) {});
418     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
419 
420     /**
421      * @tc.steps: step3. Set PatternLock pattern variable and call OnTouchDown
422      * @tc.expected: step3. Check the PatternLock pattern value
423      */
424     float offsetX = 1.0f;
425     float offsetY = 1.0f;
426     Offset offset(offsetX, offsetY);
427     pattern_->autoReset_ = false;
428     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
429     pattern_->isMoveEventValid_ = false;
430     TouchLocationInfo locationInfo(0);
431     locationInfo.SetLocalLocation(offset);
432     pattern_->isMoveEventValid_ = true;
433     pattern_->OnTouchDown(locationInfo);
434     EXPECT_EQ(pattern_->cellCenter_.GetX(), offset.GetX());
435     EXPECT_EQ(pattern_->cellCenter_.GetY(), offset.GetY());
436 }
437 
438 /**
439  * @tc.name: PatternLockPatternTest009
440  * @tc.desc: Test PatternLock pattern method HandleTouchEvent.
441  * @tc.type: FUNC
442  */
443 HWTEST_F(PatternLockTestNg, PatternLockPatternTest009, TestSize.Level1)
444 {
__anonb32113cb2b02(PatternLockModelNG model) 445     Create([](PatternLockModelNG model) {});
446     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
447 
448     /**
449      * @tc.steps: step3. Set PatternLock pattern variable and call HandleTouchEvent
450      * @tc.expected: step3. Check the PatternLock pattern value
451      */
452     float offsetX = 1.0f;
453     float offsetY = 1.0f;
454     Offset offset(offsetX, offsetY);
455     TouchLocationInfo locationInfoTouchDown(0);
456     locationInfoTouchDown.SetLocalLocation(offset);
457     locationInfoTouchDown.SetTouchType(TouchType::DOWN);
458     TouchEventInfo touchEventInfoTouchDown("onTouchDown");
459     touchEventInfoTouchDown.AddChangedTouchLocationInfo(std::move(locationInfoTouchDown));
460     pattern_->HandleTouchEvent(touchEventInfoTouchDown);
461     EXPECT_EQ(pattern_->fingerId_, 0);
462     EXPECT_EQ(pattern_->cellCenter_.GetX(), offset.GetX());
463     EXPECT_EQ(pattern_->cellCenter_.GetY(), offset.GetY());
464     pattern_->cellCenter_.Reset();
465 
466     pattern_->isMoveEventValid_ = true;
467     TouchLocationInfo locationInfoTouchMove(0);
468     locationInfoTouchMove.SetLocalLocation(offset);
469     locationInfoTouchMove.SetTouchType(TouchType::MOVE);
470     TouchEventInfo touchEventInfoTouchMove("onTouchMove");
471     touchEventInfoTouchMove.AddChangedTouchLocationInfo(std::move(locationInfoTouchMove));
472     pattern_->HandleTouchEvent(touchEventInfoTouchMove);
473     EXPECT_EQ(pattern_->cellCenter_.GetX(), offset.GetX());
474     EXPECT_EQ(pattern_->cellCenter_.GetY(), offset.GetY());
475     pattern_->cellCenter_.Reset();
476 
477     pattern_->isMoveEventValid_ = true;
478     TouchLocationInfo locationInfoTouchUp(0);
479     locationInfoTouchUp.SetLocalLocation(offset);
480     locationInfoTouchUp.SetTouchType(TouchType::UP);
481     TouchEventInfo touchEventInfoUp("onTouchUp");
482     touchEventInfoUp.AddChangedTouchLocationInfo(std::move(locationInfoTouchUp));
483     pattern_->patternLockModifier_->choosePoint_.push_back(PatternLockCell(2, 1));
484     pattern_->patternLockModifier_->choosePoint_.push_back(PatternLockCell(2, 2));
485     pattern_->HandleTouchEvent(touchEventInfoUp);
486     EXPECT_FALSE(pattern_->isMoveEventValid_);
487     EXPECT_EQ(pattern_->fingerId_, -1);
488 
489     pattern_->isMoveEventValid_ = true;
490     TouchLocationInfo locationInfoTouchUnkown(0);
491     locationInfoTouchUnkown.SetLocalLocation(offset);
492     locationInfoTouchUnkown.SetTouchType(TouchType::UNKNOWN);
493     TouchEventInfo touchEventInfoTouchUnkown("onTouchUnkown");
494     touchEventInfoTouchUnkown.AddChangedTouchLocationInfo(std::move(locationInfoTouchUnkown));
495     pattern_->HandleTouchEvent(touchEventInfoTouchUnkown);
496 }
497 
498 /**
499  * @tc.name: PatternLockPatternTest010
500  * @tc.desc: Test PatternLock pattern method InitTouchEvent.
501  * @tc.type: FUNC
502  */
503 HWTEST_F(PatternLockTestNg, PatternLockPatternTest010, TestSize.Level1)
504 {
__anonb32113cb2c02(PatternLockModelNG model) 505     Create([](PatternLockModelNG model) {});
506 
507     /**
508      * @tc.steps: step3. Set PatternLock pattern variable and call InitTouchEvent
509      * @tc.expected: step3. Check the PatternLock pattern value
510      */
511     auto gestureHub = frameNode_->GetOrCreateGestureEventHub();
512     pattern_->InitTouchEvent(gestureHub, pattern_->touchDownListener_);
513     ASSERT_NE(pattern_->touchDownListener_, nullptr);
514     auto touchEvent = gestureHub->touchEventActuator_->touchEvents_.back();
515     ASSERT_NE(touchEvent, nullptr);
516     auto info = TouchEventInfo("");
517     touchEvent->callback_(info);
518     pattern_->InitTouchEvent(gestureHub, pattern_->touchDownListener_);
519     EXPECT_EQ(gestureHub->touchEventActuator_->touchEvents_.back(), touchEvent);
520 }
521 
522 /**
523  * @tc.name: PatternLockPatternTest011
524  * @tc.desc: Test PatternLock pattern method HandleFocusEvent, HandleBlurEvent and GetInnerFocusPaintRect.
525  * @tc.type: FUNC
526  */
527 HWTEST_F(PatternLockTestNg, PatternLockPatternTest011, TestSize.Level1)
528 {
__anonb32113cb2d02(PatternLockModelNG model) 529     Create([](PatternLockModelNG model) {});
530 
531     auto focushub = frameNode_->GetFocusHub();
532     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
533     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
534     auto patternlockTheme = AceType::MakeRefPtr<V2::PatternLockTheme>();
535     patternlockTheme->hotSpotCircleRadius_ = HOTSPOT_CIRCLE_RADIUS;
536     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(patternlockTheme));
537     /**
538      * @tc.steps: step3. Set PatternLock pattern variable and Init FocusHub.
539      */
540     pattern_->isMoveEventValid_ = false;
541     pattern_->choosePoint_.push_back(PatternLockCell(1, 2));
542     pattern_->cellCenter_ = OffsetF(1.0f, 1.0f);
543     pattern_->currentPoint_ = { 0, 0 };
544     pattern_->InitFocusEvent();
545     /**
546      * @tc.steps: step4. Call HandleFocusEvent function.
547      */
548     ASSERT_NE(focushub->onFocusInternal_, nullptr);
549     focushub->onFocusInternal_();
550     EXPECT_TRUE(pattern_->isMoveEventValid_);
551     EXPECT_TRUE(pattern_->choosePoint_.empty());
552     EXPECT_EQ(pattern_->cellCenter_, OffsetF(0.0f, 0.0f));
553     EXPECT_EQ(pattern_->currentPoint_, std::make_pair(1, 1));
554     /**
555      * @tc.steps: step5. Call HandleBlurEvent function.
556      */
557     ASSERT_NE(focushub->onBlurInternal_, nullptr);
558     focushub->onBlurInternal_();
559     EXPECT_FALSE(pattern_->isMoveEventValid_);
560     /**
561      * @tc.steps: step6. Call GetInnerFocusPaintRect function.
562      */
563     ASSERT_NE(focushub->getInnerFocusRectFunc_, nullptr);
564     RoundRect focusRectInner;
565     focushub->getInnerFocusRectFunc_(focusRectInner);
566     EXPECT_FALSE(focusRectInner.radius_.data_.empty());
567 }
568 
569 /**
570  * @tc.name: PatternLockPatternTest012
571  * @tc.desc: Test PatternLock pattern method HandleFocusEvent, HandleBlurEvent and GetInnerFocusPaintRect.
572  * @tc.type: FUNC
573  */
574 HWTEST_F(PatternLockTestNg, PatternLockPatternTest012, TestSize.Level1)
575 {
__anonb32113cb2e02(PatternLockModelNG model) 576     Create([](PatternLockModelNG model) {});
577     auto focushub = frameNode_->GetFocusHub();
578     pattern_->InitFocusEvent();
579     ASSERT_NE(focushub->onKeyEventsInternal_[OnKeyEventType::DEFAULT], nullptr);
580     /**
581      * @tc.steps: step3. Call OnKeyEvent function.
582      */
583     auto event = KeyEvent();
584     /**
585      * @tc.case: case1: KeyAction is UNKNOWN.
586      */
587     event.action = KeyAction::UNKNOWN;
588     EXPECT_FALSE(focushub->onKeyEventsInternal_[OnKeyEventType::DEFAULT](event));
589     /**
590      * @tc.case: case2: KeyAction is DOWN and KeyCode is KEY_SPACE.
591      */
592     event.action = KeyAction::DOWN;
593     event.code = KeyCode::KEY_SPACE;
594     EXPECT_TRUE(pattern_->OnKeyEvent(event));
595     /**
596      * @tc.case: case3: KeyAction is DOWN, KeyCode is KEY_ENTER and isMoveEventValid_ is true.
597      */
598     event.code = KeyCode::KEY_ENTER;
599     EXPECT_TRUE(pattern_->OnKeyEvent(event));
600     /**
601      * @tc.case: case4: KeyAction is DOWN, KeyCode is KEY_ENTER and isMoveEventValid_ is false.
602      */
603     EXPECT_TRUE(pattern_->OnKeyEvent(event));
604     /**
605      * @tc.case: case5: KeyAction is DOWN, KeyCode is KEY_DPAD_UP and current point is first point.
606      */
607     event.code = KeyCode::KEY_DPAD_UP;
608     pattern_->currentPoint_ = { 1, 1 };
609     EXPECT_TRUE(pattern_->OnKeyEvent(event));
610     /**
611      * @tc.case: case6: KeyAction is DOWN, KeyCode is KEY_DPAD_UP and current point is last point.
612      */
613     pattern_->currentPoint_ = { 3, 3 };
614     EXPECT_TRUE(pattern_->OnKeyEvent(event));
615     /**
616      * @tc.case: case7: KeyAction is DOWN, KeyCode is KEY_DPAD_DOWN and current point is first point.
617      */
618     event.code = KeyCode::KEY_DPAD_DOWN;
619     pattern_->currentPoint_ = { 1, 1 };
620     EXPECT_TRUE(pattern_->OnKeyEvent(event));
621     /**
622      * @tc.case: case8: KeyAction is DOWN, KeyCode is KEY_DPAD_DOWN and current point is last point.
623      */
624     pattern_->currentPoint_ = { 3, 3 };
625     EXPECT_TRUE(pattern_->OnKeyEvent(event));
626     /**
627      * @tc.case: case9: KeyAction is DOWN, KeyCode is KEY_DPAD_LEFT and current point is first point.
628      */
629     event.code = KeyCode::KEY_DPAD_LEFT;
630     pattern_->currentPoint_ = { 1, 1 };
631     EXPECT_TRUE(pattern_->OnKeyEvent(event));
632     /**
633      * @tc.case: case10: KeyAction is DOWN, KeyCode is KEY_DPAD_LEFT and current point is last point.
634      */
635     pattern_->currentPoint_ = { 3, 3 };
636     EXPECT_TRUE(pattern_->OnKeyEvent(event));
637     /**
638      * @tc.case: case11: KeyAction is DOWN, KeyCode is KEY_DPAD_RIGHT and current point is first point.
639      */
640     event.code = KeyCode::KEY_DPAD_RIGHT;
641     pattern_->currentPoint_ = { 1, 1 };
642     EXPECT_TRUE(pattern_->OnKeyEvent(event));
643     /**
644      * @tc.case: case12: KeyAction is DOWN, KeyCode is KEY_DPAD_RIGHT and current point is last point.
645      */
646     pattern_->currentPoint_ = { 3, 3 };
647     EXPECT_TRUE(pattern_->OnKeyEvent(event));
648     /**
649      * @tc.case: case13: KeyAction is DOWN, KeyCode is KEY_MOVE_HOME and current point is last point.
650      */
651     event.code = KeyCode::KEY_MOVE_HOME;
652     EXPECT_TRUE(pattern_->OnKeyEvent(event));
653     /**
654      * @tc.case: case14: KeyAction is DOWN, KeyCode is KEY_MOVE_END and current point is first point.
655      */
656     event.code = KeyCode::KEY_MOVE_END;
657     EXPECT_TRUE(pattern_->OnKeyEvent(event));
658     /**
659      * @tc.case: case15: KeyAction is DOWN and KeyCode is KEY_ESCAPE.
660      */
661     event.code = KeyCode::KEY_ESCAPE;
662     EXPECT_TRUE(pattern_->OnKeyEvent(event));
663     /**
664      * @tc.case: case16: KeyAction is DOWN and KeyCode is illegal.
665      */
666     event.code = KeyCode::KEY_FORWARD_DEL;
667     EXPECT_FALSE(pattern_->OnKeyEvent(event));
668 }
669 
670 /**
671  * @tc.name: PatternLockPatternTest013
672  * @tc.desc: Test PatternLock pattern OnFocusClick.
673  * @tc.type: FUNC
674  */
675 HWTEST_F(PatternLockTestNg, PatternLockPatternTest013, TestSize.Level1)
676 {
__anonb32113cb2f02(PatternLockModelNG model) 677     Create([](PatternLockModelNG model) {});
678 
679     /**
680      * @tc.case: case1: CheckAutoReset is false.
681      */
682     pattern_->autoReset_ = false;
683     pattern_->choosePoint_ = { PatternLockCell(1, 2) };
684     pattern_->isMoveEventValid_ = false;
685     EXPECT_FALSE(pattern_->CheckAutoReset());
686     pattern_->OnFocusClick();
687     EXPECT_FALSE(pattern_->isMoveEventValid_);
688     /**
689      * @tc.case: case2: CheckAutoReset is true and isMoveEventValid_ is false.
690      */
691     pattern_->autoReset_ = true;
692     pattern_->currentPoint_ = std::make_pair(1, 1);
693     pattern_->OnFocusClick();
694     EXPECT_TRUE(pattern_->isMoveEventValid_);
695     EXPECT_FALSE(pattern_->choosePoint_.empty());
696     /**
697      * @tc.case: case3: CheckAutoReset is true, isMoveEventValid_ is false current point is checked.
698      */
699     pattern_->OnFocusClick();
700     EXPECT_TRUE(pattern_->isMoveEventValid_);
701 }
702 
703 /**
704  * @tc.name: PatternLockPatternTest014
705  * @tc.desc: Test PatternLock pattern method HandleHoverEvent and HandleMouseEvent.
706  * @tc.type: FUNC
707  */
708 HWTEST_F(PatternLockTestNg, PatternLockPatternTest014, TestSize.Level1)
709 {
__anonb32113cb3002(PatternLockModelNG model) 710     Create([](PatternLockModelNG model) {});
711 
712     frameNode_->GetGeometryNode()->SetContentSize(SizeF(CONTENT_SIZE_FLOAT, CONTENT_SIZE_FLOAT));
713     frameNode_->GetGeometryNode()->SetContentOffset(OffsetF(CONTENT_OFFSET_FLOAT, CONTENT_OFFSET_FLOAT));
714     auto eventHub = frameNode_->GetEventHub<EventHub>();
715     CHECK_NULL_VOID(eventHub);
716     auto inputEventHub = eventHub->GetOrCreateInputEventHub();
717     CHECK_NULL_VOID(inputEventHub);
718     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
719     auto paintProperty_ = frameNode_->GetPaintProperty<PatternLockPaintProperty>();
720     paintProperty_->UpdateCircleRadius(Dimension(CIRCLE_RADIUS_FLOAT));
721     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
722     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
723     auto patternlockTheme = AceType::MakeRefPtr<V2::PatternLockTheme>();
724     patternlockTheme->hotSpotCircleRadius_ = HOTSPOT_CIRCLE_RADIUS;
725     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(patternlockTheme));
726     pattern_->InitMouseEvent();
727     ASSERT_FALSE(inputEventHub->hoverEventActuator_->inputEvents_.empty());
728     ASSERT_FALSE(inputEventHub->mouseEventActuator_->inputEvents_.empty());
729     /**
730      * @tc.steps: step3. Call HandleHoverEvent function.
731      */
732     for (const auto& hoverCallback : inputEventHub->hoverEventActuator_->inputEvents_) {
733         ASSERT_NE(hoverCallback, nullptr);
734         (*hoverCallback)(false);
735     }
736     EXPECT_FALSE(pattern_->patternLockModifier_->isHover_->Get());
737     /**
738      * @tc.steps: step4. Call HandleMouseEvent function and hover not on point.
739      */
740     auto info = MouseInfo();
741     info.SetLocalLocation(Offset(0.0f, 0.0f));
742     for (const auto& mouseCallback : inputEventHub->mouseEventActuator_->inputEvents_) {
743         ASSERT_NE(mouseCallback, nullptr);
744         (*mouseCallback)(info);
745     }
746     EXPECT_EQ(pattern_->patternLockModifier_->hoverIndex_->Get(), -1);
747     /**
748      * @tc.steps: step5. Call HandleMouseEvent function and hover on point.
749      */
750     info.SetLocalLocation(Offset(FIRST_POINT_CHECK_FLOAT, FIRST_POINT_CHECK_FLOAT));
751     for (const auto& mouseCallback : inputEventHub->mouseEventActuator_->inputEvents_) {
752         ASSERT_NE(mouseCallback, nullptr);
753         (*mouseCallback)(info);
754     }
755     EXPECT_EQ(pattern_->patternLockModifier_->hoverIndex_->Get(), 0);
756 }
757 
758 /**
759  * @tc.name: PatternLockPatternTest015
760  * @tc.desc: Test PatternLock pattern method SetChallengeResult.
761  * @tc.type: FUNC
762  */
763 HWTEST_F(PatternLockTestNg, PatternLockPatternTest015, TestSize.Level1)
764 {
__anonb32113cb3102(PatternLockModelNG model) 765     Create([](PatternLockModelNG model) {});
766     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
767     ASSERT_NE(pattern_->patternLockController_->setChallengeResultImpl_, nullptr);
768 
769     /**
770      * @tc.steps: step3. Call SetChallengeResult function and challenge result set CORRECT.
771      */
772     pattern_->patternLockController_->SetChallengeResult(V2::PatternLockChallengeResult::CORRECT);
773     ASSERT_TRUE(pattern_->patternLockModifier_->challengeResult_.has_value());
774     EXPECT_EQ(pattern_->patternLockModifier_->challengeResult_.value(), NG::PatternLockChallengeResult::CORRECT);
775 
776     /**
777      * @tc.steps: step4. Call SetChallengeResult function and challenge result set WRONG.
778      */
779     pattern_->patternLockController_->SetChallengeResult(V2::PatternLockChallengeResult::WRONG);
780     ASSERT_TRUE(pattern_->patternLockModifier_->challengeResult_.has_value());
781     EXPECT_EQ(pattern_->patternLockModifier_->challengeResult_.value(), NG::PatternLockChallengeResult::WRONG);
782 
783     /**
784      * @tc.steps: step5. When isMoveEventValid_ is true call SetChallengeResult function and challenge result set
785      * CORRECT.
786      */
787     EXPECT_EQ(pattern_->patternLockModifier_->challengeResult_, NG::PatternLockChallengeResult::WRONG);
788     pattern_->isMoveEventValid_ = true;
789     pattern_->patternLockController_->SetChallengeResult(V2::PatternLockChallengeResult::CORRECT);
790     ASSERT_TRUE(pattern_->patternLockModifier_->challengeResult_.has_value());
791     EXPECT_EQ(pattern_->patternLockModifier_->challengeResult_.value(), NG::PatternLockChallengeResult::WRONG);
792 
793     /**
794      * @tc.steps: step6. Call SetChallengeResult function and challenge result illegal.
795      */
796     pattern_->isMoveEventValid_ = false;
797     pattern_->patternLockController_->SetChallengeResult(V2::PatternLockChallengeResult(0));
798     ASSERT_FALSE(pattern_->patternLockModifier_->challengeResult_.has_value());
799 }
800 
801 /**
802  * @tc.name: PatternLockPatternTest016
803  * @tc.desc: Test PatternLock pattern method CreateNodePaintMethod.
804  * @tc.type: FUNC
805  */
806 HWTEST_F(PatternLockTestNg, PatternLockPatternTest016, TestSize.Level1)
807 {
__anonb32113cb3202(PatternLockModelNG model) 808     Create([](PatternLockModelNG model) {});
809 
810     /**
811      * @tc.steps: step3. Set PatternLock pattern variables and call CreateNodePaintMethod.
812      * @tc.expected: step3. Check the PatternLock paintMethod cellCenter_ value.
813      */
814     pattern_->screenTouchPoint_ = OffsetF(TOUCHPOINT_OFFSET_FLOAT, TOUCHPOINT_OFFSET_FLOAT);
815     auto paintMethod = AceType::DynamicCast<PatternLockPaintMethod>(pattern_->CreateNodePaintMethod());
816     EXPECT_EQ(paintMethod->cellCenter_, OffsetF(TOUCHPOINT_OFFSET_FLOAT, TOUCHPOINT_OFFSET_FLOAT));
817 }
818 
819 /**
820  * @tc.name: PatternLockPatternTest017
821  * @tc.desc: Test PatternLock pattern method CalculateCellCenter and GetLastChoosePointOffset.
822  * @tc.type: FUNC
823  */
824 HWTEST_F(PatternLockTestNg, PatternLockPatternTest017, TestSize.Level1)
825 {
__anonb32113cb3302(PatternLockModelNG model) 826     Create([](PatternLockModelNG model) {});
827 
828     /**
829      * @tc.steps: step3. Set PatternLock pattern variables and call CalculateCellCenter.
830      * @tc.expected: step3. Check the PatternLock cellCenter_ value.
831      */
832     pattern_->screenTouchPoint_ = OffsetF(TOUCHPOINT_OFFSET_FLOAT, TOUCHPOINT_OFFSET_FLOAT);
833     pattern_->CalculateCellCenter();
834     EXPECT_EQ(pattern_->cellCenter_, OffsetF(TOUCHPOINT_OFFSET_FLOAT, TOUCHPOINT_OFFSET_FLOAT));
835 
836     /**
837      * @tc.steps: step4. Set PatternLock pattern variables and call CalculateCellCenter.
838      * @tc.expected: step4. Check the PatternLock cellCenter_ value is not changed.
839      */
840     pattern_->cellCenter_ = OffsetF();
841     pattern_->isOnKeyEventState_ = true;
842     pattern_->CalculateCellCenter();
843     EXPECT_EQ(pattern_->cellCenter_, OffsetF());
844 
845     /**
846      * @tc.steps: step5. Set PatternLock pattern variables and call CalculateCellCenter
847      * @tc.expected: step5. Check the PatternLock cellCenter_ value.
848      */
849     auto geometryNode = frameNode_->GetGeometryNode();
850     geometryNode->SetContentSize(SizeF(CONTENT_SIZE_FLOAT, CONTENT_SIZE_FLOAT));
851     geometryNode->SetContentOffset(OffsetF(CONTENT_OFFSET_FLOAT, CONTENT_OFFSET_FLOAT));
852     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
853     pattern_->CalculateCellCenter();
854     auto calculateOffsetResult = CONTENT_OFFSET_FLOAT + CONTENT_SIZE_FLOAT / PATTERN_LOCK_COL_COUNT /
855                                                             RADIUS_TO_DIAMETER * (RADIUS_TO_DIAMETER - 1);
856     EXPECT_EQ(pattern_->cellCenter_, OffsetF(calculateOffsetResult, calculateOffsetResult));
857 }
858 
859 /**
860  * @tc.name: PatternLockPatternTest018
861  * @tc.desc: Test PatternLock in scrollNode
862  * @tc.type: FUNC
863  */
864 HWTEST_F(PatternLockTestNg, PatternLockPatternTest018, TestSize.Level1)
865 {
866     ScrollModelNG model;
867     model.Create();
868     ViewAbstract::SetWidth(CalcLength(SCROLL_WIDTH));
869     ViewAbstract::SetHeight(CalcLength(SCROLL_HEIGHT));
870     {
871         ColumnModelNG colModel;
872         colModel.Create(Dimension(0), nullptr, "");
873         ViewAbstract::SetWidth(CalcLength(FILL_LENGTH));
874         ViewAbstract::SetHeight(CalcLength(SCROLL_HEIGHT + 100));
875         PaddingProperty padding;
876         padding.top = CalcLength(100);
877         ViewAbstract::SetPadding(padding);
878         {
879             PatternLockModelNG patternLockModelNG;
880             patternLockModelNG.Create();
881             ViewAbstract::SetWidth(CalcLength(PATTERNLOCK_WIDTH));
882             ViewAbstract::SetHeight(CalcLength(PATTERNLOCK_HEIGHT));
883             ViewStackProcessor::GetInstance()->Pop();
884         }
885         ViewStackProcessor::GetInstance()->Pop();
886     }
887     auto scrollNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
888     FlushUITasks(scrollNode);
889 
890     /**
891      * @tc.steps: step1. because colNode padding, patternLockNode offsetY is 100
892      */
893     auto colNode = GetChildFrameNode(scrollNode, 0);
894     auto patternLockNode = GetChildFrameNode(colNode, 0);
895     auto scrollPattern = scrollNode->GetPattern<ScrollPattern>();
896     auto patternLockPattern = patternLockNode->GetPattern<PatternLockPattern>();
897     EXPECT_TRUE(IsEqual(patternLockNode->GetGeometryNode()->GetFrameOffset(), OffsetF(40, 100)));
898 
899     /**
900      * @tc.steps: step3. Call OnTouchDown
901      * @tc.expected: cellCenter_ is equal to locationInfo
902      */
903     auto mockRenderContext = AceType::DynamicCast<MockRenderContext>(patternLockNode->renderContext_);
904     mockRenderContext->rect_ = RectF(40, 100, PATTERNLOCK_WIDTH, PATTERNLOCK_HEIGHT);
905 
906     TouchLocationInfo locationInfo(0);
907     locationInfo.SetLocalLocation(Offset(200, 200));
908     patternLockPattern->OnTouchDown(locationInfo);
909     EXPECT_TRUE(IsEqual(patternLockPattern->cellCenter_, OffsetF(200, 200)));
910 
911     locationInfo.SetLocalLocation(Offset(300, 300));
912     patternLockPattern->OnTouchMove(locationInfo);
913     EXPECT_TRUE(IsEqual(patternLockPattern->cellCenter_, OffsetF(300, 300)));
914     patternLockPattern->OnTouchUp();
915 
916     /**
917      * @tc.steps: step2. Scroll view and Call OnTouchDown
918      * @tc.expected: cellCenter_ is equal to locationInfo
919      */
920     scrollPattern->UpdateCurrentOffset(-100, SCROLL_FROM_UPDATE); // scroll view
921     FlushUITasks(scrollNode);
922     EXPECT_EQ(scrollPattern->GetTotalOffset(), 100);
923     mockRenderContext->rect_ = RectF(40, 0, PATTERNLOCK_WIDTH, PATTERNLOCK_HEIGHT);
924 
925     locationInfo.SetLocalLocation(Offset(200, 200));
926     patternLockPattern->OnTouchDown(locationInfo);
927     EXPECT_TRUE(IsEqual(patternLockPattern->cellCenter_, OffsetF(200, 200)));
928 
929     locationInfo.SetLocalLocation(Offset(300, 300));
930     patternLockPattern->OnTouchMove(locationInfo);
931     EXPECT_TRUE(IsEqual(patternLockPattern->cellCenter_, OffsetF(300, 300)));
932     patternLockPattern->OnTouchUp();
933 }
934 
935 /**
936  * @tc.name: PatternLockPatternTest019
937  * @tc.desc: Test cellCenter_ when patternlock size change
938  * @tc.type: FUNC
939  */
940 HWTEST_F(PatternLockTestNg, PatternLockPatternTest019, TestSize.Level1)
941 {
__anonb32113cb3402(PatternLockModelNG model) 942     Create([](PatternLockModelNG model) {});
943 
944     /**
945      * @tc.steps: step1. OnTouchDown a point
946      * @tc.expected: cellCenter_ is relative to patternlock
947      */
948     auto mockRenderContext = AceType::DynamicCast<MockRenderContext>(frameNode_->renderContext_);
949     mockRenderContext->paintRect_ = RectF(40, 0, PATTERNLOCK_WIDTH, PATTERNLOCK_HEIGHT);
950 
951     TouchLocationInfo locationInfo(0);
952     locationInfo.SetLocalLocation(Offset(200, 200));
953     pattern_->OnTouchDown(locationInfo);
954     EXPECT_TRUE(IsEqual(pattern_->cellCenter_, OffsetF(200, 200)));
955 
956     /**
957      * @tc.steps: step2. Reduce patternloack size, call OnTouchMove
958      * @tc.expected: cellCenter_ will change with patternlock
959      */
960     float width = 300.f;
961     float height = 300.f;
962     ViewAbstract::SetWidth(AceType::RawPtr(frameNode_), CalcLength(width));
963     ViewAbstract::SetHeight(AceType::RawPtr(frameNode_), CalcLength(height));
964     FlushUITasks(frameNode_);
965     EXPECT_TRUE(IsEqual(frameNode_->GetGeometryNode()->GetFrameRect().Width(), width));
966     EXPECT_TRUE(IsEqual(frameNode_->GetGeometryNode()->GetFrameRect().Height(), height));
967 
968     mockRenderContext->paintRect_ = RectF(90, 0, width, height);
969     locationInfo.SetLocalLocation(Offset(300, 300));
970     pattern_->OnTouchMove(locationInfo);
971     EXPECT_TRUE(IsEqual(pattern_->cellCenter_, OffsetF(300, 300)));
972     pattern_->OnTouchUp();
973 }
974 
975 /**
976  * @tc.name: PatternLockPaintMethodTest001
977  * @tc.desc: Test PatternLockPaintMethod GetThemeProp and UpdateContentModifier Function.
978  * @tc.type: FUNC
979  */
980 HWTEST_F(PatternLockTestNg, PatternLockPaintMethodTest001, TestSize.Level1)
981 {
982     /**
983      * @tc.step: step1. create patternLock PaintMethod and PatternLockTheme.
984      */
985     std::vector<PatternLockCell> vecCell;
986     auto modifier = AceType::MakeRefPtr<PatternLockModifier>();
987     PatternLockPaintMethod paintMethod(OffsetF(), false, vecCell, modifier);
988     auto paintProperty_ = AceType::MakeRefPtr<PatternLockPaintProperty>();
989     RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
990     ASSERT_NE(geometryNode, nullptr);
991     geometryNode->SetContentSize(SizeF());
992     // create mock theme manager
993     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
994     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
995     auto patternlockTheme = AceType::MakeRefPtr<V2::PatternLockTheme>();
996     patternlockTheme->regularColor_ = REGULAR_COLOR;
997     patternlockTheme->selectedColor_ = SELECTED_COLOR;
998     patternlockTheme->activeColor_ = ACTIVE_COLOR;
999     patternlockTheme->pathColor_ = PATH_COLOR;
1000     patternlockTheme->circleRadius_ = CIRCLE_RADIUS;
1001     patternlockTheme->pathStrokeWidth_ = PATH_STROKE_WIDTH;
1002     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(patternlockTheme));
1003     /**
1004      * @tc.case: case1. call GetThemeProp with PatternLockTheme.
1005      */
1006     paintMethod.GetThemeProp();
1007     EXPECT_EQ(paintMethod.sideLength_, .0f);
1008     EXPECT_EQ(paintMethod.circleRadius_, CIRCLE_RADIUS);
1009     EXPECT_EQ(paintMethod.pathStrokeWidth_, PATH_STROKE_WIDTH);
1010     EXPECT_EQ(paintMethod.regularColor_, REGULAR_COLOR);
1011     EXPECT_EQ(paintMethod.selectedColor_, SELECTED_COLOR);
1012     EXPECT_EQ(paintMethod.activeColor_, ACTIVE_COLOR);
1013     EXPECT_EQ(paintMethod.pathColor_, PATH_COLOR);
1014     /**
1015      * @tc.case: case2. call UpdateContentModifier with unvalid PatternLockPaintProperty.
1016      */
1017     PaintWrapper paintWrapper(nullptr, geometryNode, paintProperty_);
1018     paintMethod.UpdateContentModifier(&paintWrapper);
1019     EXPECT_EQ(paintMethod.sideLength_, paintWrapper.GetContentSize().Width());
1020     EXPECT_EQ(paintMethod.circleRadius_, CIRCLE_RADIUS);
1021     EXPECT_EQ(paintMethod.pathStrokeWidth_, PATH_STROKE_WIDTH);
1022     EXPECT_EQ(paintMethod.regularColor_, REGULAR_COLOR);
1023     EXPECT_EQ(paintMethod.selectedColor_, SELECTED_COLOR);
1024     EXPECT_EQ(paintMethod.activeColor_, ACTIVE_COLOR);
1025     EXPECT_EQ(paintMethod.pathColor_, PATH_COLOR);
1026     /**
1027      * @tc.case: case3. call UpdateContentModifier with valid PatternLockPaintProperty.
1028      */
1029     paintProperty_->UpdateCircleRadius(Dimension(20.0));
1030     paintProperty_->UpdatePathStrokeWidth(Dimension(10.0));
1031     paintProperty_->UpdateAutoReset(false);
1032     paintProperty_->UpdateRegularColor(Color::RED);
1033     paintProperty_->UpdateSelectedColor(Color::GREEN);
1034     paintProperty_->UpdateActiveColor(Color::BLACK);
1035     paintProperty_->UpdatePathColor(Color::WHITE);
1036     paintMethod.UpdateContentModifier(&paintWrapper);
1037     EXPECT_EQ(paintMethod.circleRadius_, paintProperty_->GetCircleRadiusValue());
1038     EXPECT_EQ(paintMethod.pathStrokeWidth_, paintProperty_->GetPathStrokeWidthValue());
1039     EXPECT_EQ(paintMethod.regularColor_, paintProperty_->GetRegularColorValue());
1040     EXPECT_EQ(paintMethod.selectedColor_, paintProperty_->GetSelectedColorValue());
1041     EXPECT_EQ(paintMethod.activeColor_, paintProperty_->GetActiveColorValue());
1042     EXPECT_EQ(paintMethod.pathColor_, paintProperty_->GetPathColorValue());
1043 }
1044 
1045 /**
1046  * @tc.name: PatternLockPaintMethodTest002
1047  * @tc.desc: Test PatternLockPaintMethod GetThemeProp and UpdateContentModifier Function.
1048  * @tc.type: FUNC
1049  */
1050 HWTEST_F(PatternLockTestNg, PatternLockPaintMethodTest002, TestSize.Level1)
1051 {
1052     /**
1053      * @tc.step: step1. create patternLock PaintMethod and PatternLockTheme.
1054      */
1055     std::vector<PatternLockCell> vecCell;
1056     auto modifier = AceType::MakeRefPtr<PatternLockModifier>();
1057     PatternLockPaintMethod paintMethod(OffsetF(), false, vecCell, modifier);
1058     auto paintProperty_ = AceType::MakeRefPtr<PatternLockPaintProperty>();
1059     RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
1060     ASSERT_NE(geometryNode, nullptr);
1061     geometryNode->SetContentSize(SizeF());
1062     // create mock theme manager
1063     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
1064     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
1065     auto patternlockTheme = AceType::MakeRefPtr<V2::PatternLockTheme>();
1066     patternlockTheme->activeColor_ = ACTIVE_COLOR;
1067     patternlockTheme->pathColor_ = PATH_COLOR;
1068     patternlockTheme->circleRadius_ = CIRCLE_RADIUS;
1069     patternlockTheme->backgroundCircleRadius_ = ACTIVE_CIRCLE_RADIUS;
1070     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(patternlockTheme));
1071     /**
1072      * @tc.case: case1. call GetThemeProp with PatternLockTheme.
1073      */
1074     paintMethod.GetThemeProp();
1075     EXPECT_EQ(paintMethod.circleRadius_, CIRCLE_RADIUS);
1076     EXPECT_EQ(paintMethod.activeColor_, ACTIVE_COLOR);
1077     EXPECT_EQ(paintMethod.pathColor_, PATH_COLOR);
1078     EXPECT_EQ(paintMethod.backgroundCircleRadius_, Dimension(.0));
1079     /**
1080      * @tc.case: case2. call UpdateContentModifier with unvalid PatternLockPaintProperty.
1081      */
1082     PaintWrapper paintWrapper(nullptr, geometryNode, paintProperty_);
1083     paintMethod.UpdateContentModifier(&paintWrapper);
1084     EXPECT_EQ(paintMethod.circleRadius_, CIRCLE_RADIUS);
1085     EXPECT_EQ(paintMethod.activeColor_, ACTIVE_COLOR);
1086     EXPECT_EQ(paintMethod.pathColor_, PATH_COLOR);
1087     EXPECT_EQ(paintMethod.activeCircleColor_, PATH_COLOR);
1088     /**
1089      * @tc.case: case3. call UpdateContentModifier with valid PatternLockPaintProperty.
1090      */
1091     paintProperty_->UpdateCircleRadius(Dimension(20.0));
1092     paintProperty_->UpdateActiveColor(Color::BLACK);
1093     paintProperty_->UpdatePathColor(Color::WHITE);
1094     paintProperty_->UpdateActiveCircleColor(Color::BLUE);
1095     paintProperty_->UpdateActiveCircleRadius(Dimension(25.0));
1096     paintMethod.UpdateContentModifier(&paintWrapper);
1097     EXPECT_EQ(paintMethod.circleRadius_, paintProperty_->GetCircleRadiusValue());
1098     EXPECT_EQ(paintMethod.activeColor_, paintProperty_->GetActiveColorValue());
1099     EXPECT_EQ(paintMethod.pathColor_, paintProperty_->GetPathColorValue());
1100     EXPECT_EQ(paintMethod.activeCircleColor_, paintProperty_->GetActiveCircleColor());
1101     EXPECT_EQ(paintMethod.backgroundCircleRadius_, paintProperty_->GetActiveCircleRadius());
1102 }
1103 
1104 /**
1105  * @tc.name: PatternLockLayoutAlgorithmTest001
1106  * @tc.desc: Test MeasureContent function .
1107  * @tc.type: FUNC
1108  */
1109 HWTEST_F(PatternLockTestNg, PatternLockLayoutAlgorithmTest001, TestSize.Level1)
1110 {
1111     PatternLockLayoutAlgorithm layoutAlgorithm;
1112     auto layoutProperty = AceType::MakeRefPtr<PatternLockLayoutProperty>();
1113     LayoutWrapperNode layoutWrapper(nullptr, nullptr, layoutProperty);
1114     /**
1115      * @tc.case: case1.
1116      */
1117     layoutProperty->UpdateSideLength(Dimension(DEFAULT_SIDE_LENGTH));
1118     LayoutConstraintF constraint1;
1119     auto size1 = layoutAlgorithm.MeasureContent(constraint1, &layoutWrapper);
1120     EXPECT_EQ(size1.value(), SizeF(20.0f, 20.0f));
1121     /**
1122      * @tc.case: case2.
1123      */
1124     LayoutConstraintF constraint2;
1125     constraint2.maxSize = SizeF(10.0f, 25.0f);
1126     constraint2.minSize = SizeF(15.0f, 20.0f);
1127     auto size2 = layoutAlgorithm.MeasureContent(constraint2, &layoutWrapper);
1128     EXPECT_EQ(size2.value(), SizeF(15.0f, 15.0f));
1129     /**
1130      * @tc.case: case3.
1131      */
1132     LayoutConstraintF constraint3;
1133     constraint3.maxSize = SizeF(40.0f, 30.0f);
1134     constraint3.minSize = SizeF(15.0f, 20.0f);
1135     layoutProperty->UpdateSideLength(Dimension(30.0));
1136     auto size3 = layoutAlgorithm.MeasureContent(constraint3, &layoutWrapper);
1137     EXPECT_EQ(size3.value(), SizeF(30.0f, 30.0f));
1138 }
1139 
1140 /**
1141  * @tc.name: PatternLockAccessibilityTest001
1142  * @tc.desc: Test PatternLockAccessibility .
1143  * @tc.type: FUNC
1144  */
1145 HWTEST_F(PatternLockTestNg, PatternLockAccessibilityTest001, TestSize.Level1)
1146 {
__anonb32113cb3502(PatternLockModelNG model) 1147     Create([](PatternLockModelNG model) {
1148         model.SetCircleRadius(CIRCLE_RADIUS);
1149         model.SetRegularColor(REGULAR_COLOR);
1150         model.SetSelectedColor(SELECTED_COLOR);
1151         model.SetActiveColor(ACTIVE_COLOR);
1152         model.SetPathColor(PATH_COLOR);
1153         model.SetStrokeWidth(PATH_STROKE_WIDTH);
1154         model.SetAutoReset(true);
1155         model.SetSideLength(SIDE_LENGTH);
1156         model.SetActiveCircleColor(ACTIVE_CIRCLE_COLOR);
1157         model.SetActiveCircleRadius(ACTIVE_CIRCLE_RADIUS);
1158         model.SetEnableWaveEffect(false);
1159     });
1160     /**
1161      * @tc.case: case1 InitVirtualNode .
1162      */
1163     AceApplicationInfo::GetInstance().SetAccessibilityEnabled(true);
1164     pattern_->CreateNodePaintMethod();
1165     pattern_->OnModifyDone();
1166     EXPECT_TRUE(pattern_->accessibilityPropertyVec_.size() > 0);
1167     /**
1168      * @tc.case: case2 HandleAccessibilityHoverEvent 1.
1169      */
1170     AccessibilityHoverInfo info;
1171     info.SetActionType(AccessibilityHoverAction::HOVER_ENTER);
1172     pattern_->HandleAccessibilityHoverEvent(true, info);
1173     EXPECT_TRUE(pattern_->accessibilityPropertyVec_[0]->GetAccessibilityLevel() ==
1174         AccessibilityProperty::Level::YES_STR);
1175     /**
1176      * @tc.case: case3 HandleTextOnAccessibilityFocusCallback 1.
1177      */
1178     pattern_->HandleTextOnAccessibilityFocusCallback(0, 0);
1179     auto accessibilityProperty = frameNode_->GetAccessibilityProperty<AccessibilityProperty>();
1180     EXPECT_TRUE(accessibilityProperty->GetAccessibilityLevel() == AccessibilityProperty::Level::NO_STR);
1181     /**
1182      * @tc.case: case4 HandleTextOnAccessibilityFocusCallback 2.
1183      */
1184     pattern_->HandleTextOnAccessibilityFocusCallback(0, 1);
1185     pattern_->HandleTextOnAccessibilityFocusCallback(0, 2);
1186     pattern_->HandleTextOnAccessibilityFocusCallback(1, 0);
1187     pattern_->HandleTextOnAccessibilityFocusCallback(1, 1);
1188     pattern_->HandleTextOnAccessibilityFocusCallback(1, 2);
1189     pattern_->HandleTextOnAccessibilityFocusCallback(2, 0);
1190     pattern_->HandleTextOnAccessibilityFocusCallback(2, 1);
1191     pattern_->HandleTextOnAccessibilityFocusCallback(2, 2);
1192     EXPECT_TRUE(pattern_->choosePoint_.size() == 9);
1193     EXPECT_TRUE(pattern_->choosePoint_[0].GetColumn() == 0);
1194     EXPECT_TRUE(pattern_->choosePoint_[0].GetRow() == 0);
1195     EXPECT_TRUE(pattern_->choosePoint_[3].GetColumn() == 1);
1196     EXPECT_TRUE(pattern_->choosePoint_[3].GetRow() == 0);
1197     EXPECT_TRUE(pattern_->choosePoint_[8].GetColumn() == 2);
1198     EXPECT_TRUE(pattern_->choosePoint_[8].GetRow() == 2);
1199     /**
1200      * @tc.case: case5 HandleAccessibilityHoverEvent 2.
1201      */
1202     info.SetActionType(AccessibilityHoverAction::HOVER_MOVE);
1203     pattern_->HandleAccessibilityHoverEvent(false, info);
1204     EXPECT_TRUE(pattern_->accessibilityPropertyVec_[0]->GetAccessibilityLevel() ==
1205         AccessibilityProperty::Level::NO_STR);
1206     EXPECT_TRUE(accessibilityProperty->GetAccessibilityLevel() == AccessibilityProperty::Level::YES_STR);
1207     /**
1208      * @tc.case: case6 HandleAccessibilityHoverEvent 3.
1209      */
1210     info.SetActionType(AccessibilityHoverAction::HOVER_ENTER);
1211     pattern_->HandleAccessibilityHoverEvent(true, info);
1212     info.SetActionType(AccessibilityHoverAction::HOVER_MOVE);
1213     pattern_->HandleAccessibilityHoverEvent(false, info);
1214     EXPECT_TRUE(pattern_->choosePoint_.size() == 0);
1215 }
1216 
1217 /**
1218  * @tc.name: StartModifierCanceledAnimate
1219  * @tc.desc: Test MeasureContent function .
1220  * @tc.type: FUNC
1221  */
1222 HWTEST_F(PatternLockTestNg, StartModifierCanceledAnimate, TestSize.Level1)
1223 {
1224     ScrollModelNG model;
1225     model.Create();
1226     ViewAbstract::SetWidth(CalcLength(SCROLL_WIDTH));
1227     ViewAbstract::SetHeight(CalcLength(SCROLL_HEIGHT));
1228     {
1229         ColumnModelNG colModel;
1230         colModel.Create(Dimension(0), nullptr, "");
1231         ViewAbstract::SetWidth(CalcLength(FILL_LENGTH));
1232         ViewAbstract::SetHeight(CalcLength(SCROLL_HEIGHT + 100));
1233         PaddingProperty padding;
1234         padding.top = CalcLength(100);
1235         ViewAbstract::SetPadding(padding);
1236         {
1237             PatternLockModelNG patternLockModelNG;
1238             patternLockModelNG.Create();
1239             ViewAbstract::SetWidth(CalcLength(PATTERNLOCK_WIDTH));
1240             ViewAbstract::SetHeight(CalcLength(PATTERNLOCK_HEIGHT));
1241             ViewStackProcessor::GetInstance()->Pop();
1242         }
1243         ViewStackProcessor::GetInstance()->Pop();
1244     }
1245     auto scrollNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
1246     FlushUITasks(scrollNode);
1247 
1248     /**
1249      * @tc.steps: step1. because colNode padding, patternLockNode offsetY is 100
1250      */
1251     auto colNode = GetChildFrameNode(scrollNode, 0);
1252     auto patternLockNode = GetChildFrameNode(colNode, 0);
1253     auto scrollPattern = scrollNode->GetPattern<ScrollPattern>();
1254     auto patternLockPattern = patternLockNode->GetPattern<PatternLockPattern>();
1255     patternLockPattern->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
1256     patternLockPattern->isMoveEventValid_ = true;
1257     patternLockPattern->StartModifierCanceledAnimate();
1258     EXPECT_TRUE(patternLockPattern->isMoveEventValid_);
1259     patternLockPattern->isMoveEventValid_ = false;
1260     patternLockPattern->StartModifierCanceledAnimate();
1261     EXPECT_FALSE(patternLockPattern->isMoveEventValid_);
1262 }
1263 
1264 /**
1265  * @tc.name: AddPassPointToChoosePoint
1266  * @tc.desc: Test MeasureContent function .
1267  * @tc.type: FUNC
1268  */
1269 HWTEST_F(PatternLockTestNg, AddPassPointToChoosePoint, TestSize.Level1)
1270 {
1271     ScrollModelNG model;
1272     model.Create();
1273     ViewAbstract::SetWidth(CalcLength(SCROLL_WIDTH));
1274     ViewAbstract::SetHeight(CalcLength(SCROLL_HEIGHT));
1275     {
1276         ColumnModelNG colModel;
1277         colModel.Create(Dimension(0), nullptr, "");
1278         ViewAbstract::SetWidth(CalcLength(FILL_LENGTH));
1279         ViewAbstract::SetHeight(CalcLength(SCROLL_HEIGHT + 100));
1280         PaddingProperty padding;
1281         padding.top = CalcLength(100);
1282         ViewAbstract::SetPadding(padding);
1283         {
1284             PatternLockModelNG patternLockModelNG;
1285             patternLockModelNG.Create();
1286             ViewAbstract::SetWidth(CalcLength(PATTERNLOCK_WIDTH));
1287             ViewAbstract::SetHeight(CalcLength(PATTERNLOCK_HEIGHT));
1288             ViewStackProcessor::GetInstance()->Pop();
1289         }
1290         ViewStackProcessor::GetInstance()->Pop();
1291     }
1292     auto scrollNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
1293     FlushUITasks(scrollNode);
1294 
1295     /**
1296      * @tc.steps: step1. because colNode padding, patternLockNode offsetY is 100
1297      */
1298     auto colNode = GetChildFrameNode(scrollNode, 0);
1299     auto patternLockNode = GetChildFrameNode(colNode, 0);
1300     auto scrollPattern = scrollNode->GetPattern<ScrollPattern>();
1301     auto patternLockPattern = patternLockNode->GetPattern<PatternLockPattern>();
1302     std::vector<PatternLockCell> choosePoint;
1303     choosePoint.push_back(PatternLockCell(1, 1));
1304     choosePoint.push_back(PatternLockCell(2, 2));
1305     patternLockPattern->AddPassPointToChoosePoint(2, 1, choosePoint);
1306     EXPECT_EQ(patternLockPattern->choosePoint_.back().GetColumn(), 1);
1307     EXPECT_EQ(patternLockPattern->choosePoint_.back().GetRow(), 1);
1308 
1309     patternLockPattern->AddPassPointToChoosePoint(1, 2, choosePoint);
1310     EXPECT_EQ(patternLockPattern->choosePoint_.back().GetColumn(), 2);
1311     EXPECT_EQ(patternLockPattern->choosePoint_.back().GetRow(), 2);
1312 }
1313 
1314 /**
1315  * @tc.name: PatternLockReplacePlaceHolderTest001
1316  * @tc.desc: Test ReplacePlaceHolder function .
1317  * @tc.type: FUNC
1318  */
1319 HWTEST_F(PatternLockTestNg, PatternLockReplacePlaceHolderTest001, TestSize.Level1)
1320 {
__anonb32113cb3602(PatternLockModelNG model) 1321     Create([](PatternLockModelNG model) {});
1322 
1323     std::string bo_CN = "སྒོར་ཚེག་ %d ལ་སྦྲེལ་ཟིན།";
1324     std::string ug = "نۇقتا %d ئۇلاندى";
1325     std::string zh_CN = "已连接圆点%d";
1326     std::string en_US = "Connected to dot %d";
1327     std::string zh_CN_ = "已连接圆点%d";
1328     std::string zh_CN_nod = "已连接圆点";
1329 
1330     std::string bo_CN_replace = "སྒོར་ཚེག་ 5 ལ་སྦྲེལ་ཟིན།";
1331     std::string ug_replace = "نۇقتا 1 ئۇلاندى";
1332     std::string zh_CN_replace = "已连接圆点0";
1333     std::string en_US_replace = "Connected to dot 9";
1334     std::string zh_CN_replace2 = "已连接圆点88";
1335     std::string zh_CN_replace_nod = "已连接圆点4";
1336 
1337     std::string bo_CN_result = pattern_->ReplacePlaceHolder(bo_CN, 5);
1338     std::string ug_result = pattern_->ReplacePlaceHolder(ug, 1);
1339     std::string zh_CN_result = pattern_->ReplacePlaceHolder(zh_CN, 0);
1340     std::string en_US_result = pattern_->ReplacePlaceHolder(en_US, 9);
1341     std::string zh_CN_result2 = pattern_->ReplacePlaceHolder(zh_CN, 88);
1342     std::string zh_CN_result_nod = pattern_->ReplacePlaceHolder(zh_CN, 4);
1343 
1344     EXPECT_EQ(bo_CN_result, bo_CN_replace);
1345     EXPECT_EQ(ug_result, ug_replace);
1346     EXPECT_EQ(zh_CN_result, zh_CN_replace);
1347     EXPECT_EQ(en_US_result, en_US_replace);
1348     EXPECT_EQ(zh_CN_result2, zh_CN_replace2);
1349     EXPECT_EQ(zh_CN_result_nod, zh_CN_replace_nod);
1350 }
1351 
1352 /**
1353  * @tc.name: PatternLockSkipUnselectedPointTest001
1354  * @tc.desc: Test PatternLockAccessibility .
1355  * @tc.type: FUNC
1356  */
1357 HWTEST_F(PatternLockTestNg, PatternLockSkipUnselectedPointTest001, TestSize.Level1)
1358 {
__anonb32113cb3702(PatternLockModelNG model) 1359     Create([](PatternLockModelNG model) {
1360         model.SetCircleRadius(CIRCLE_RADIUS);
1361         model.SetRegularColor(REGULAR_COLOR);
1362         model.SetSelectedColor(SELECTED_COLOR);
1363         model.SetActiveColor(ACTIVE_COLOR);
1364         model.SetPathColor(PATH_COLOR);
1365         model.SetStrokeWidth(PATH_STROKE_WIDTH);
1366         model.SetAutoReset(true);
1367         model.SetSideLength(SIDE_LENGTH);
1368         model.SetActiveCircleColor(ACTIVE_CIRCLE_COLOR);
1369         model.SetActiveCircleRadius(ACTIVE_CIRCLE_RADIUS);
1370         model.SetEnableWaveEffect(false);
1371         model.SetSkipUnselectedPoint(true);
1372     });
1373     /**
1374      * @tc.case: case1 InitVirtualNode .
1375      */
1376     AceApplicationInfo::GetInstance().SetAccessibilityEnabled(true);
1377     pattern_->CreateNodePaintMethod();
1378     pattern_->OnModifyDone();
1379     EXPECT_EQ(pattern_->skipUnselectedPoint_, true);
1380 }
1381 
1382 /**
1383  * @tc.name: PatternLockSkipUnselectedPointTest002
1384  * @tc.desc: Test PatternLock pattern method AddPassPoint.
1385  * @tc.type: FUNC
1386  */
1387 HWTEST_F(PatternLockTestNg, PatternLockSkipUnselectedPointTest002, TestSize.Level1)
1388 {
__anonb32113cb3802(PatternLockModelNG model) 1389     Create([](PatternLockModelNG model) {
1390         model.SetSkipUnselectedPoint(false);
1391     });
1392     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
1393     pattern_->InitSkipUnselectedPoint();
1394 
1395     /**
1396      * @tc.case: case1: selectedPoint(1, 1) and link Point(1, 3) auto select Point(1, 2)
1397      */
1398     pattern_->choosePoint_.clear();
1399     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
1400     pattern_->AddPassPoint(1, 3);
1401     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
1402     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 2);
1403     /**
1404      * @tc.case: case2: selectedPoint(1, 1) and link Point(3, 1) auto select Point(2, 1)
1405      */
1406     pattern_->choosePoint_.clear();
1407     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
1408     pattern_->AddPassPoint(3, 1);
1409     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 2);
1410     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 1);
1411     /**
1412      * @tc.case: case3: selectedPoint(1, 1) and link Point(3, 3) auto select Point(2, 2)
1413      */
1414     pattern_->choosePoint_.clear();
1415     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
1416     pattern_->AddPassPoint(3, 3);
1417     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 2);
1418     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 2);
1419 }
1420 
1421 /**
1422  * @tc.name: PatternLockSkipUnselectedPointTest003
1423  * @tc.desc: Test PatternLock pattern method AddPassPoint.
1424  * @tc.type: FUNC
1425  */
1426 HWTEST_F(PatternLockTestNg, PatternLockSkipUnselectedPointTest003, TestSize.Level1)
1427 {
__anonb32113cb3902(PatternLockModelNG model) 1428     Create([](PatternLockModelNG model) {
1429         model.SetSkipUnselectedPoint(true);
1430     });
1431     pattern_->patternLockModifier_ = AceType::MakeRefPtr<PatternLockModifier>();
1432     pattern_->InitSkipUnselectedPoint();
1433 
1434     /**
1435      * @tc.case: case1: selectedPoint(1, 1) and link Point(1, 3), skip unselected Point(1, 2)
1436      */
1437     pattern_->choosePoint_.clear();
1438     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
1439     pattern_->AddPassPoint(1, 3);
1440     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
1441     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 1);
1442     /**
1443      * @tc.case: case2: selectedPoint(1, 1) and link Point(3, 1), skip unselected Point(1, 2)
1444      */
1445     pattern_->choosePoint_.clear();
1446     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
1447     pattern_->AddPassPoint(3, 1);
1448     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
1449     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 1);
1450     /**
1451      * @tc.case: case3: selectedPoint(1, 1) and link Point(3, 3), skip unselected Point(1, 2)
1452      */
1453     pattern_->choosePoint_.clear();
1454     pattern_->choosePoint_.push_back(PatternLockCell(1, 1));
1455     pattern_->AddPassPoint(3, 3);
1456     EXPECT_EQ(pattern_->choosePoint_.back().GetColumn(), 1);
1457     EXPECT_EQ(pattern_->choosePoint_.back().GetRow(), 1);
1458 }
1459 
1460 
1461 /**
1462  * @tc.name: PatternLockEnableForegroundTest001
1463  * @tc.desc: Test PatternLockAccessibility .
1464  * @tc.type: FUNC
1465  */
1466 HWTEST_F(PatternLockTestNg, PatternLockEnableForegroundTest001, TestSize.Level1)
1467 {
__anonb32113cb3a02(PatternLockModelNG model) 1468     Create([](PatternLockModelNG model) {
1469         model.SetCircleRadius(CIRCLE_RADIUS);
1470         model.SetRegularColor(REGULAR_COLOR);
1471         model.SetSelectedColor(SELECTED_COLOR);
1472         model.SetActiveColor(ACTIVE_COLOR);
1473         model.SetPathColor(PATH_COLOR);
1474         model.SetStrokeWidth(PATH_STROKE_WIDTH);
1475         model.SetAutoReset(true);
1476         model.SetSideLength(SIDE_LENGTH);
1477         model.SetActiveCircleColor(ACTIVE_CIRCLE_COLOR);
1478         model.SetActiveCircleRadius(ACTIVE_CIRCLE_RADIUS);
1479         model.SetEnableWaveEffect(false);
1480         model.SetEnableForeground(true);
1481     });
1482     EXPECT_TRUE(paintProperty_->GetEnableForegroundValue());
1483 }
1484 } // namespace OHOS::Ace::NG
1485