1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "components/ui_abstract_progress.h"
16 #include "components/ui_list.h"
17 #include "components/ui_picker.h"
18 #include "components/ui_scroll_view.h"
19 #include "components/ui_slider.h"
20 #include "components/ui_swipe_view.h"
21 #include "components/ui_time_picker.h"
22 #include "dock/focus_manager.h"
23 #include <climits>
24 #include <gtest/gtest.h>
25 
26 using namespace testing::ext;
27 namespace OHOS {
28 class UIRotateInputTest : public testing::Test {
29 public:
UIRotateInputTest()30     UIRotateInputTest() {}
~UIRotateInputTest()31     virtual ~UIRotateInputTest() {}
32 
SetUpTestCase()33     static void SetUpTestCase() {}
TearDownTestCase()34     static void TearDownTestCase() {}
35 };
36 
37 /**
38  * @tc.name: Graphic_RotateInput_Test_SetRotateFactor_001
39  * @tc.desc: Verify UIRotateInput::SetRotateFactor function.
40  * @tc.type: FUNC
41  * @tc.require: SR000ERCQF
42  */
43 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_SetRotateFactor_001, TestSize.Level1)
44 {
45     UIScrollView* scroll = new UIScrollView();
46     scroll->SetRotateFactor(10); // 10 : rotate factor
47     EXPECT_EQ(scroll->GetRotateFactor(), 10);
48     delete scroll;
49 }
50 
51 /**
52  * @tc.name: Graphic_RotateInput_Test_SetRotateFactor_002
53  * @tc.desc: Verify UIRotateInput::SetRotateFactor function.
54  * @tc.type: FUNC
55  * @tc.require: SR000ERCQF
56  */
57 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_SetRotateFactor_002, TestSize.Level1)
58 {
59     UISwipeView* swipe = new UISwipeView();
60     swipe->SetRotateFactor(10); // 10 : rotate factor
61     EXPECT_EQ(swipe->GetRotateFactor(), 10);
62     delete swipe;
63 }
64 
65 /**
66  * @tc.name: Graphic_RotateInput_Test_SetRotateFactor_003
67  * @tc.desc: Verify UIRotateInput::SetRotateFactor function.
68  * @tc.type: FUNC
69  * @tc.require: SR000ERCQF
70  */
71 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_SetRotateFactor_003, TestSize.Level1)
72 {
73     UIList* list = new UIList();
74     list->SetRotateFactor(10); // 10 : rotate factor
75     EXPECT_EQ(list->GetRotateFactor(), 10);
76     delete list;
77 }
78 
79 /**
80  * @tc.name: Graphic_RotateInput_Test_SetRotateFactor_004
81  * @tc.desc: Verify UIRotateInput::SetRotateFactor function.
82  * @tc.type: FUNC
83  * @tc.require: SR000ERCQF
84  */
85 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_SetRotateFactor_004, TestSize.Level1)
86 {
87     UIList* list = new UIList();
88     list->SetRotateFactor(20); // 10 : rotate factor
89     EXPECT_NE(list->GetRotateFactor(), 10);
90     delete list;
91 }
92 
93 /**
94  * @tc.name: Graphic_RotateInput_Test_SetRotateFactor_005
95  * @tc.desc: Verify UIRotateInput::SetRotateFactor function.
96  * @tc.type: FUNC
97  * @tc.require: AR000EVI2R
98  */
99 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_SetRotateFactor_005, TestSize.Level1)
100 {
101     UISlider* slider = new UISlider();
102     slider->SetRotateFactor(10); // 10 : rotate factor
103     EXPECT_EQ(slider->GetRotateFactor(), 10);
104     delete slider;
105 }
106 
107 /**
108  * @tc.name: Graphic_RotateInput_Test_RequestFocus_001
109  * @tc.desc: Verify UIRotateInput::RequestFocus function.
110  * @tc.type: FUNC
111  * @tc.require: SR000FH553
112  */
113 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_001, TestSize.Level0)
114 {
115     UIScrollView* scroll = new UIScrollView();
116     scroll->RequestFocus();
117     EXPECT_EQ(scroll, FocusManager::GetInstance()->GetFocusedView());
118     scroll->ClearFocus();
119     delete scroll;
120 }
121 /**
122  * @tc.name: Graphic_RotateInput_Test_RequestFocus_002
123  * @tc.desc: Verify UIRotateInput::RequestFocus function.
124  * @tc.type: FUNC
125  * @tc.require: AR000FH554
126  */
127 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_002, TestSize.Level1)
128 {
129     UITimePicker* timePicker = new UITimePicker();
130     timePicker->RequestFocus();
131     EXPECT_EQ(timePicker, FocusManager::GetInstance()->GetFocusedView());
132     timePicker->ClearFocus();
133     delete timePicker;
134 }
135 /**
136  * @tc.name: Graphic_RotateInput_Test_RequestFocus_003
137  * @tc.desc: Verify UIRotateInput::RequestFocus function.
138  * @tc.type: FUNC
139  * @tc.require: AR000FH554
140  */
141 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_003, TestSize.Level1)
142 {
143     UISwipeView* swipe = new UISwipeView();
144     swipe->RequestFocus();
145     EXPECT_EQ(swipe, FocusManager::GetInstance()->GetFocusedView());
146     swipe->ClearFocus();
147     delete swipe;
148 }
149 /**
150  * @tc.name: Graphic_RotateInput_Test_RequestFocus_004
151  * @tc.desc: Verify UIList::RequestFocus function.
152  * @tc.type: FUNC
153  * @tc.require: SR000ERCQG
154  */
155 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_004, TestSize.Level1)
156 {
157     UIList* list = new UIList();
158     list->RequestFocus();
159     EXPECT_EQ(list, FocusManager::GetInstance()->GetFocusedView());
160     list->ClearFocus();
161     delete list;
162 }
163 /**
164  * @tc.name: Graphic_RotateInput_Test_RequestFocus_005
165  * @tc.desc: Verify UIRotateInput::RequestFocus function.
166  * @tc.type: FUNC
167  * @tc.require: AR000EVI2S
168  */
169 HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_005, TestSize.Level1)
170 {
171     UISlider* slider = new UISlider();
172     slider->RequestFocus();
173     EXPECT_EQ(slider, FocusManager::GetInstance()->GetFocusedView());
174     slider->ClearFocus();
175     delete slider;
176 }
177 }
178 
179