• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 #include "updater_ui_unittest.h"
17 #include <dirent.h>
18 #include <fstream>
19 #include <iostream>
20 #include <string>
21 #include "log/log.h"
22 #include "securec.h"
23 #include "updater_ui.h"
24 #include "text_label.h"
25 #include "frame.h"
26 #include "surface_dev.h"
27 #include "utils.h"
28 #include "input_event.h"
29 
30 using namespace updater;
31 using namespace testing::ext;
32 using namespace std;
33 using namespace updater::utils;
34 static constexpr int EV_VALUE_15 = 15;
35 static constexpr int EV_VALUE_80 = 80;
36 static constexpr int EV_VALUE_500 = 500;
37 
38 namespace updater_ut {
39 // do something at the each function begining
SetUp(void)40 void UpdaterUiUnitTest::SetUp(void)
41 {
42     cout << "Updater Unit UpdaterUiUnitTest Begin!" << endl;
43 }
44 
45 // do something at the each function end
TearDown(void)46 void UpdaterUiUnitTest::TearDown(void)
47 {
48     cout << "Updater Unit UpdaterUiUnitTest End!" << endl;
49 }
50 
51 // init
SetUpTestCase(void)52 void UpdaterUiUnitTest::SetUpTestCase(void)
53 {
54     cout << "SetUpTestCase" << endl;
55 }
56 
57 // end
TearDownTestCase(void)58 void UpdaterUiUnitTest::TearDownTestCase(void)
59 {
60     cout << "TearDownTestCase" << endl;
61     unlink("/data/updater.log");
62     unlink("/data/updater_stage.log");
63 }
64 
65 HWTEST_F(UpdaterUiUnitTest, updater_ui_test_HandleInputEvent, TestSize.Level1)
66 {
67     UpdaterUiInit();
68     struct input_event ev {};
69     ev.value = EV_VALUE_15;
70     HandleInputEvent(&ev);
71     ev.value = EV_VALUE_80;
72     HandleInputEvent(&ev);
73     ev.value = EV_VALUE_500;
74     HandleInputEvent(&ev);
75     DeleteView();
76 }
77 } // namespace updater_ut
78