| 1 |
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "test_monthgraphiview.h" |
| 6 |
#include "../third-party_stub/stub.h" |
| 7 |
#include "../dialog_stub.h" |
| 8 |
#include "widget/monthWidget/monthscheduleview.h" |
| 9 |
|
| 10 |
static void monthgraphiview_stub_void() |
| 11 |
{ |
| 12 |
} |
| 13 |
|
| 14 |
test_monthgraphiview::test_monthgraphiview() |
| 15 |
{ |
| 16 |
cMonthGraphiview = new CMonthGraphicsview(); |
| 17 |
} |
| 18 |
|
| 19 |
test_monthgraphiview::~test_monthgraphiview() |
| 20 |
{ |
| 21 |
delete cMonthGraphiview; |
| 22 |
} |
| 23 |
|
| 24 |
//void CMonthGraphiview::setTheMe(int type) |
| 25 |
TEST_F(test_monthgraphiview, setTheMe) |
| 26 |
{ |
| 27 |
int type = 1; |
| 28 |
cMonthGraphiview->setTheMe(); |
| 29 |
cMonthGraphiview->setTheMe(type); |
| 30 |
} |
| 31 |
|
| 32 |
//void CMonthGraphiview::setDate(const QVector<QDate> &showDate) |
| 33 |
TEST_F(test_monthgraphiview, setDate) |
| 34 |
{ |
| 35 |
QVector<QDate> showDate; |
| 36 |
QDate date1(2020, 10, 1); |
| 37 |
QDate date2(2020, 12, 1); |
| 38 |
for (int i = 0; i < 42; ++i) { |
| 39 |
if (i % 2 == 0) { |
| 40 |
showDate.append(date1); |
| 41 |
} else { |
| 42 |
showDate.append(date2); |
| 43 |
} |
| 44 |
} |
| 45 |
std::cout << showDate.size() << std::endl; |
| 46 |
cMonthGraphiview->setDate(showDate); |
| 47 |
} |
| 48 |
|
| 49 |
//void CMonthGraphiview::setLunarInfo(const QMap<QDate, CaHuangLiDayInfo> &lunarCache) |
| 50 |
TEST_F(test_monthgraphiview, setLunarInfo) |
| 51 |
{ |
| 52 |
QMap<QDate, CaHuangLiDayInfo> lunarCache = QMap<QDate, CaHuangLiDayInfo> {}; |
| 53 |
cMonthGraphiview->setLunarInfo(lunarCache); |
| 54 |
} |
| 55 |
|
| 56 |
//void CMonthGraphiview::setLunarVisible(bool visible) |
| 57 |
TEST_F(test_monthgraphiview, setLunarVisible) |
| 58 |
{ |
| 59 |
bool visible = false; |
| 60 |
cMonthGraphiview->setLunarVisible(visible); |
| 61 |
} |
| 62 |
|
| 63 |
//void CMonthGraphiview::setScheduleInfo(const QMap<QDate, QVector<ScheduleDataInfo> > &info) |
| 64 |
TEST_F(test_monthgraphiview, setScheduleInfo) |
| 65 |
{ |
| 66 |
QMap<QDate, QVector<ScheduleDataInfo> > info = QMap<QDate, QVector<ScheduleDataInfo> > {}; |
| 67 |
cMonthGraphiview->setScheduleInfo(info); |
| 68 |
} |
| 69 |
|
| 70 |
//void CMonthGraphiview::setSelectSearchSchedule(const ScheduleDataInfo &scheduleInfo) |
| 71 |
TEST_F(test_monthgraphiview, setSelectSearchSchedule) |
| 72 |
{ |
| 73 |
ScheduleDataInfo scheduleInfo = ScheduleDataInfo{}; |
| 74 |
cMonthGraphiview->setSelectSearchSchedule(scheduleInfo); |
| 75 |
} |
| 76 |
|
| 77 |
//QPointF CMonthGraphiview::getItemPos(const QPoint &p, const QRectF &itemRect) |
| 78 |
TEST_F(test_monthgraphiview, getItemPos) |
| 79 |
{ |
| 80 |
QPoint p(100, 100); |
| 81 |
QRectF itemRect; |
| 82 |
cMonthGraphiview->getItemPos(p, itemRect); |
| 83 |
} |
| 84 |
|
| 85 |
//QDateTime CMonthGraphiview::getPosDate(const QPoint &p) |
| 86 |
TEST_F(test_monthgraphiview, getPosDate_01) |
| 87 |
{ |
| 88 |
QPoint p(100, 100); |
| 89 |
cMonthGraphiview->getPosDate(p); |
| 90 |
} |
| 91 |
|
| 92 |
TEST_F(test_monthgraphiview, getPosDate_02) |
| 93 |
{ |
| 94 |
QPoint p(-100, -1); |
| 95 |
cMonthGraphiview->getPosDate(p); |
| 96 |
} |
| 97 |
|
| 98 |
TEST_F(test_monthgraphiview, getPosDate_03) |
| 99 |
{ |
| 100 |
QPoint p(-1, -1); |
| 101 |
cMonthGraphiview->setSceneRect(-2, -2, 100, 100); |
| 102 |
cMonthGraphiview->getPosDate(p); |
| 103 |
} |
| 104 |
|
| 105 |
////void CMonthGraphiview::upDateInfoShow(const CMonthGraphiview::DragStatus &status, const ScheduleDataInfo &info) |
| 106 |
TEST_F(test_monthgraphiview, upDateInfoShow_01) |
| 107 |
{ |
| 108 |
Stub stub; |
| 109 |
stub.set(ADDR(CWeekScheduleView, addData), monthgraphiview_stub_void); |
| 110 |
stub.set(ADDR(CWeekScheduleView, changeDate), monthgraphiview_stub_void); |
| 111 |
ScheduleDataInfo info = ScheduleDataInfo{}; |
| 112 |
cMonthGraphiview->upDateInfoShow(CMonthGraphicsview::IsCreate, info); |
| 113 |
cMonthGraphiview->upDateInfoShow(CMonthGraphicsview::ChangeBegin, info); |
| 114 |
cMonthGraphiview->upDateInfoShow(CMonthGraphicsview::ChangeEnd, info); |
| 115 |
cMonthGraphiview->upDateInfoShow(CMonthGraphicsview::ChangeWhole, info); |
| 116 |
cMonthGraphiview->upDateInfoShow(CMonthGraphicsview::NONE, info); |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
TEST_F(test_monthgraphiview, slideEvent_01) |
| 121 |
{ |
| 122 |
QPointF pos(1, 1); |
| 123 |
QPointF stopPos(2, 2); |
| 124 |
cMonthGraphiview->slideEvent(pos, stopPos); |
| 125 |
} |
| 126 |
|
| 127 |
TEST_F(test_monthgraphiview, mouseDoubleClickEvent_01) |
| 128 |
{ |
| 129 |
QMouseEvent event(QEvent::MouseButtonDblClick, QPointF(0, 0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); |
| 130 |
cMonthGraphiview->mouseDoubleClickEvent(&event); |
| 131 |
} |
| 132 |
|
| 133 |
TEST_F(test_monthgraphiview, mouseDoubleClickEvent_02) |
| 134 |
{ |
| 135 |
QMouseEvent event(QEvent::MouseButtonDblClick, QPointF(0, 0), Qt::RightButton, Qt::RightButton, Qt::NoModifier); |
| 136 |
cMonthGraphiview->mouseDoubleClickEvent(&event); |
| 137 |
} |
| 138 |
|
| 139 |
TEST_F(test_monthgraphiview, mouseDoubleClickEvent_03) |
| 140 |
{ |
| 141 |
QMouseEvent event(QEvent::MouseButtonDblClick, QPointF(1, 1), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); |
| 142 |
cMonthGraphiview->mouseDoubleClickEvent(&event); |
| 143 |
} |
| 144 |
|
| 145 |
TEST_F(test_monthgraphiview, resizeEvent_01) |
| 146 |
{ |
| 147 |
QResizeEvent event(QSize(50, 50), QSize(100, 100)); |
| 148 |
cMonthGraphiview->resizeEvent(&event); |
| 149 |
} |
| 150 |
|
| 151 |
TEST_F(test_monthgraphiview, changeEvent_01) |
| 152 |
{ |
| 153 |
QEvent event(QEvent::FontChange); |
| 154 |
cMonthGraphiview->changeEvent(&event); |
| 155 |
} |
| 156 |
|
| 157 |
TEST_F(test_monthgraphiview, wheelEvent_01) |
| 158 |
{ |
| 159 |
QWheelEvent event(QPointF(1, 1), 0, Qt::LeftButton, Qt::NoModifier); |
| 160 |
cMonthGraphiview->wheelEvent(&event); |
| 161 |
} |
| 162 |
|
| 163 |
TEST_F(test_monthgraphiview, updateBackgroundShowItem_01) |
| 164 |
{ |
| 165 |
cMonthGraphiview->updateBackgroundShowItem(); |
| 166 |
} |
| 167 |
|
| 168 |
TEST_F(test_monthgraphiview, setDragPixmap_01) |
| 169 |
{ |
| 170 |
QDrag drag(cMonthGraphiview); |
| 171 |
CMonthScheduleItem item(QRect(0, 0, 10, 10)); |
| 172 |
cMonthGraphiview->setDragPixmap(&drag, &item); |
| 173 |
} |
| 174 |
|
| 175 |
TEST_F(test_monthgraphiview, MeetCreationConditions_01) |
| 176 |
{ |
| 177 |
QDateTime date; |
| 178 |
EXPECT_TRUE(cMonthGraphiview->MeetCreationConditions(date)); |
| 179 |
} |
| 180 |
|
| 181 |
TEST_F(test_monthgraphiview, IsEqualtime_01) |
| 182 |
{ |
| 183 |
QDateTime date; |
| 184 |
EXPECT_TRUE(cMonthGraphiview->IsEqualtime(date, date)); |
| 185 |
} |
| 186 |
|
| 187 |
TEST_F(test_monthgraphiview, JudgeIsCreate_01) |
| 188 |
{ |
| 189 |
EXPECT_FALSE(cMonthGraphiview->JudgeIsCreate(QPointF(1, 1))); |
| 190 |
} |
| 191 |
|
| 192 |
TEST_F(test_monthgraphiview, RightClickToCreate_01) |
| 193 |
{ |
| 194 |
QPoint pos(1, 1); |
| 195 |
cMonthGraphiview->RightClickToCreate(nullptr, pos); |
| 196 |
} |
| 197 |
|
| 198 |
TEST_F(test_monthgraphiview, MoveInfoProcess_01) |
| 199 |
{ |
| 200 |
QPointF pos(1, 1); |
| 201 |
ScheduleDataInfo info; |
| 202 |
cMonthGraphiview->MoveInfoProcess(info, pos); |
| 203 |
} |
| 204 |
|
| 205 |
TEST_F(test_monthgraphiview, MoveInfoProcess_02) |
| 206 |
{ |
| 207 |
QPointF pos(1, -1); |
| 208 |
ScheduleDataInfo info; |
| 209 |
cMonthGraphiview->MoveInfoProcess(info, pos); |
| 210 |
} |
| 211 |
|
| 212 |
TEST_F(test_monthgraphiview, getDragScheduleInfoBeginTime_02) |
| 213 |
{ |
| 214 |
QPointF pos(1, -1); |
| 215 |
QDateTime time; |
| 216 |
cMonthGraphiview->m_InfoEndTime = time; |
| 217 |
EXPECT_EQ(cMonthGraphiview->getDragScheduleInfoBeginTime(time), time); |
| 218 |
} |
| 219 |
|
| 220 |
TEST_F(test_monthgraphiview, getDragScheduleInfoEndTime_02) |
| 221 |
{ |
| 222 |
QPointF pos(1, -1); |
| 223 |
QDateTime time; |
| 224 |
cMonthGraphiview->m_InfoEndTime = time; |
| 225 |
EXPECT_EQ(cMonthGraphiview->getDragScheduleInfoEndTime(time), time); |
| 226 |
} |
| 227 |
|
| 228 |
TEST_F(test_monthgraphiview, slotCreate_02) |
| 229 |
{ |
| 230 |
Stub stub; |
| 231 |
calendarDDialogExecStub(stub); |
| 232 |
|
| 233 |
QPointF pos(1, -1); |
| 234 |
QDateTime time; |
| 235 |
cMonthGraphiview->m_InfoEndTime = time; |
| 236 |
cMonthGraphiview->slotCreate(time); |
| 237 |
} |
| 238 |
|