Debian Codegraph @

tests/dde-calendar-client-test/src/test_widget/test_yearWidget/test_yearwindow.cpp

raw
1 // SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4
5 #include "test_yearwindow.h"
6 #include "customWidget/customframe.h"
7 #include "widget/yearWidget/yearscheduleview.h"
8 #include "calendarglobalenv.h"
9 #include "constants.h"
10
11 test_yearwindow::test_yearwindow()
12 {
13 CalendarGlobalEnv::getGlobalEnv()->registerKey(DDECalendar::CursorPointKey, QPoint(20, 20));
14 mYearWindow = new CYearWindow();
15 dateaManger = new CalendarDateDataManager();
16 }
17
18 test_yearwindow::~test_yearwindow()
19 {
20 delete mYearWindow;
21 mYearWindow = nullptr;
22 delete dateaManger;
23 dateaManger = nullptr;
24 }
25
26 //void CYearWindow::setTheMe(int type)
27 TEST_F(test_yearwindow, setTheMe)
28 {
29 int type = 1;
30 mYearWindow->setTheMe(type);
31 type = 2;
32 mYearWindow->setTheMe(type);
33 }
34
35 TEST_F(test_yearwindow, slotMousePress)
36 {
37 CalendarGlobalEnv::getGlobalEnv()->reviseValue(DDECalendar::CursorPointKey, QPoint(20, 20));
38 QDate currentDate = QDate::currentDate();
39 mYearWindow->slotMousePress(currentDate, 0);
40 ASSERT_EQ(mYearWindow->getSelectDate(), currentDate);
41 mYearWindow->slotMousePress(currentDate, 1);
42 mYearWindow->slotMousePress(currentDate, 2);
43 mYearWindow->slotMousePress(currentDate, 3);
44 mYearWindow->slotMousePress(currentDate, 4);
45 }
46
47 TEST_F(test_yearwindow, calculateAzimuthAngle)
48 {
49 QPointF startPoint(0, 0);
50 QPointF stopPoint(30, 20);
51 mYearWindow->calculateAzimuthAngle(startPoint, stopPoint);
52 stopPoint.setX(20);
53 stopPoint.setY(30);
54 mYearWindow->calculateAzimuthAngle(startPoint, stopPoint);
55 stopPoint.setX(-20);
56 stopPoint.setY(30);
57 mYearWindow->calculateAzimuthAngle(startPoint, stopPoint);
58 stopPoint.setX(-30);
59 stopPoint.setY(20);
60 mYearWindow->calculateAzimuthAngle(startPoint, stopPoint);
61 }