Debian Codegraph @

tests/dde-calendar-client-test/src/test_view/test_alldayeventview.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_alldayeventview.h"
6 //#include "../dialog_stub.h"
7
8 //#include <QTest>
9 //#include <QEvent>
10 //#include <QMenu>
11
12 //test_alldayeventview::test_alldayeventview()
13 //{
14 //}
15
16 //void test_alldayeventview::SetUp()
17 //{
18 // cAllDayEventWeekView = new CAllDayEventWeekView();
19 // cAllDayEventWeekView->setFixedSize(QSize(800, 300));
20 //}
21
22 //void test_alldayeventview::TearDown()
23 //{
24 // delete cAllDayEventWeekView;
25 // cAllDayEventWeekView = nullptr;
26 //}
27
28 ////void CAllDayEventWeekView::setTheMe(int type)
29 //TEST_F(test_alldayeventview, setTheMe)
30 //{
31 // int type = 1;
32 // cAllDayEventWeekView->setTheMe();
33 // cAllDayEventWeekView->setTheMe(type);
34 //}
35
36 ////bool CAllDayEventWeekView::MeetCreationConditions(const QDateTime &date)
37 //TEST_F(test_alldayeventview, MeetCreationConditions)
38 //{
39 // QString begin = "2020-12-01 12:24:36";
40 // QDateTime date = QDateTime::fromString(begin, "yyyy-MM-dd hh:mm:ss");
41 // cAllDayEventWeekView->MeetCreationConditions(date);
42 //}
43
44 ////bool CAllDayEventWeekView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond)
45 //TEST_F(test_alldayeventview, IsEqualtime)
46 //{
47 // QString begin = "2020-12-01 12:24:36";
48 // QDateTime begindate = QDateTime::fromString(begin, "yyyy-MM-dd hh:mm:ss");
49 // QString end = "2020-12-21 12:24:36";
50 // QDateTime enddate = QDateTime::fromString(end, "yyyy-MM-dd hh:mm:ss");
51
52 // assert(false == cAllDayEventWeekView->IsEqualtime(begindate, enddate));
53
54 // enddate = QDateTime::fromString(begin, "yyyy-MM-dd hh:mm:ss");
55 // assert(true == cAllDayEventWeekView->IsEqualtime(begindate, enddate));
56 //}
57
58 ////void CAllDayEventWeekView::setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin)
59 //TEST_F(test_alldayeventview, setRange)
60 //{
61 // int w = 3;
62 // int h = 2;
63 // QDate begindate(2020, 12, 01);
64 // QDate enddate(2020, 12, 21);
65 // int rightmagin = 2;
66 // cAllDayEventWeekView->setRange(w, h, begindate, enddate, rightmagin);
67 //}
68
69 //QVector<ScheduleDataInfo> getTestScheduleDataInfo()
70 //{
71 // ScheduleDataInfo info1;
72 // info1.setID(1);
73 // info1.setType(2);
74 // info1.setAllDay(true);
75 // info1.setRecurID(2);
76 // info1.setTitleName("测试1");
77 // QString strDate = "2020-12-02 12:24:36";
78 // QDateTime ignoreDate = QDateTime::fromString(strDate, "yyyy-MM-dd hh:mm:ss");
79 // QVector<QDateTime> ignoreDateList;
80 // ignoreDateList.append(ignoreDate);
81 // info1.setIgnoreTime(ignoreDateList);
82 // QString begin = "2020-12-01 12:24:36";
83 // QDateTime begindate = QDateTime::fromString(begin, "yyyy-MM-dd hh:mm:ss");
84 // QString end = "2020-12-03 12:24:36";
85 // QDateTime enddate = QDateTime::fromString(end, "yyyy-MM-dd hh:mm:ss");
86 // info1.setBeginDateTime(begindate);
87 // info1.setEndDateTime(enddate);
88
89 // ScheduleDataInfo info2;
90 // info2.setID(1);
91 // info2.setType(2);
92 // info2.setAllDay(true);
93 // info2.setRecurID(2);
94 // info2.setTitleName("测试2");
95 // QString strDate2 = "2020-12-12 12:24:36";
96 // QDateTime ignoreDate2 = QDateTime::fromString(strDate2, "yyyy-MM-dd hh:mm:ss");
97 // QVector<QDateTime> ignoreDateList2;
98 // ignoreDateList2.append(ignoreDate2);
99 // info2.setIgnoreTime(ignoreDateList2);
100 // QString begin2 = "2020-12-11 12:24:36";
101 // QDateTime begindate2 = QDateTime::fromString(begin2, "yyyy-MM-dd hh:mm:ss");
102 // QString end2 = "2020-12-13 12:24:36";
103 // QDateTime enddate2 = QDateTime::fromString(end2, "yyyy-MM-dd hh:mm:ss");
104 // info2.setBeginDateTime(begindate2);
105 // info2.setEndDateTime(enddate2);
106
107 // ScheduleDataInfo info3;
108 // info3.setID(1);
109 // info3.setType(2);
110 // info3.setAllDay(true);
111 // info3.setRecurID(2);
112 // info3.setTitleName("测试3");
113 // QString strDate3 = "2020-12-22 12:24:36";
114 // QDateTime ignoreDate3 = QDateTime::fromString(strDate3, "yyyy-MM-dd hh:mm:ss");
115 // QVector<QDateTime> ignoreDateList3;
116 // ignoreDateList3.append(ignoreDate3);
117 // info3.setIgnoreTime(ignoreDateList3);
118 // QString begin3 = "2020-12-21 12:24:36";
119 // QDateTime begindate3 = QDateTime::fromString(begin3, "yyyy-MM-dd hh:mm:ss");
120 // QString end3 = "2020-12-23 12:24:36";
121 // QDateTime enddate3 = QDateTime::fromString(end3, "yyyy-MM-dd hh:mm:ss");
122 // info3.setBeginDateTime(begindate3);
123 // info3.setEndDateTime(enddate3);
124
125 // QVector<ScheduleDataInfo> infoList;
126 // infoList.append(info1);
127 // infoList.append(info2);
128 // infoList.append(info3);
129
130 // return infoList;
131 //}
132
133 ////void CAllDayEventWeekView::setDayData(const QVector<QVector<ScheduleDataInfo>> &vlistData)
134 //TEST_F(test_alldayeventview, setDayData)
135 //{
136 // QVector<QVector<ScheduleDataInfo>> vlistData;
137
138 // QVector<ScheduleDataInfo> infoList1;
139 // infoList1.append(getTestScheduleDataInfo().at(0));
140 // infoList1.append(getTestScheduleDataInfo().at(1));
141
142 // QVector<ScheduleDataInfo> infoList2;
143 // infoList2.append(getTestScheduleDataInfo().at(2));
144
145 // vlistData.append(infoList1);
146 // vlistData.append(infoList2);
147
148 // cAllDayEventWeekView->setDayData(vlistData);
149 //}
150
151
152 ////void CAllDayEventWeekView::setInfo(const QVector<ScheduleDataInfo> &info)
153 //TEST_F(test_alldayeventview, setInfo)
154 //{
155 // cAllDayEventWeekView->setInfo(getTestScheduleDataInfo());
156 //}
157
158 ////void CAllDayEventWeekView::slotDoubleEvent()
159 //TEST_F(test_alldayeventview, slotDoubleEvent)
160 //{
161 // cAllDayEventWeekView->slotDoubleEvent();
162 //}
163
164 ////void CAllDayEventWeekView::createItemWidget(int index, bool average)
165 //TEST_F(test_alldayeventview, createItemWidget)
166 //{
167 // QVector<QVector<ScheduleDataInfo>> vlistData;
168
169 // QVector<ScheduleDataInfo> infoList1;
170 // infoList1.append(getTestScheduleDataInfo().at(0));
171 // infoList1.append(getTestScheduleDataInfo().at(1));
172
173 // QVector<ScheduleDataInfo> infoList2;
174 // infoList2.append(getTestScheduleDataInfo().at(2));
175
176 // vlistData.append(infoList1);
177 // vlistData.append(infoList2);
178
179 // cAllDayEventWeekView->setDayData(vlistData);
180
181 // int w = 1000;
182 // int h = 900;
183 // QDate begindate(2020, 12, 01);
184 // QDate enddate(2020, 12, 21);
185 // int rightmagin = 2;
186 // cAllDayEventWeekView->setRange(w, h, begindate, enddate, rightmagin);
187
188 // int index = 0;
189 // bool average = true;
190 // cAllDayEventWeekView->createItemWidget(index, average);
191 // cAllDayEventWeekView->updateHeight();
192 // //setSelectSearchSchedule
193 // cAllDayEventWeekView->setSelectSearchSchedule(getTestScheduleDataInfo().at(1));
194 //}
195
196 ////void CAllDayEventWeekView::updateItemHeightByFontSize()
197 //TEST_F(test_alldayeventview, updateItemHeightByFontSize)
198 //{
199 // cAllDayEventWeekView->updateItemHeightByFontSize();
200 //}
201
202
203 ////void CAllDayEventWeekView::upDateInfoShow(const DragStatus &status, const ScheduleDataInfo &info)
204 //TEST_F(test_alldayeventview, upDateInfoShow)
205 //{
206 // cAllDayEventWeekView->setInfo(getTestScheduleDataInfo());
207 // cAllDayEventWeekView->upDateInfoShow(DragInfoGraphicsView::DragStatus::ChangeEnd, getTestScheduleDataInfo().at(1));
208 // cAllDayEventWeekView->upDateInfoShow(DragInfoGraphicsView::DragStatus::ChangeBegin, getTestScheduleDataInfo().at(1));
209 // cAllDayEventWeekView->upDateInfoShow(DragInfoGraphicsView::DragStatus::ChangeWhole, getTestScheduleDataInfo().at(1));
210 // cAllDayEventWeekView->upDateInfoShow(DragInfoGraphicsView::DragStatus::IsCreate, getTestScheduleDataInfo().at(1));
211 //}
212
213 ////
214 //TEST_F(test_alldayeventview, getPixmap)
215 //{
216 // cAllDayEventWeekView->setFixedSize(500, 800);
217 // QPixmap pixmap(cAllDayEventWeekView->size());
218 // pixmap = cAllDayEventWeekView->grab();
219 //}
220
221 ////
222 //TEST_F(test_alldayeventview, eventTest)
223 //{
224 // QTest::keyEvent(QTest::Press, cAllDayEventWeekView, Qt::Key::Key_Enter);
225 // cAllDayEventWeekView->setFixedSize(500, 100);
226 // QTest::mouseDClick(cAllDayEventWeekView, Qt::LeftButton, Qt::NoModifier, QPoint(200, 50));
227 //}
228
229 ////slotCreate
230 //TEST_F(test_alldayeventview, slotCreate)
231 //{
232 // calendarDDialogExecReturn = 1;
233 // Stub stub;
234 // calendarDDialogExecStub(stub);
235 // cAllDayEventWeekView->slotCreate(QDateTime::currentDateTime());
236 //}
237
238 ////getDragScheduleInfoBeginTime
239 //TEST_F(test_alldayeventview, getDragScheduleInfoBeginTime)
240 //{
241 // cAllDayEventWeekView->getDragScheduleInfoBeginTime(QDateTime::currentDateTime());
242 //}
243
244 ////changeEvent
245 //TEST_F(test_alldayeventview, changeEvent)
246 //{
247 // QEvent event(QEvent::FontChange);
248 // QApplication::sendEvent(cAllDayEventWeekView, &event);
249 //}
250
251 ////mousePressEvent
252 //TEST_F(test_alldayeventview, mousePressEvent)
253 //{
254 // QMouseEvent event(QEvent::MouseButtonPress, QPointF(32, 13), QPointF(646, 438), QPointF(646, 438),
255 // Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt);
256 // QApplication::sendEvent(cAllDayEventWeekView->viewport(), &event);
257 //}
258
259 //TEST_F(test_alldayeventview, JudgeIsCreate)
260 //{
261 // QPointF point(32, 13);
262 // cAllDayEventWeekView->JudgeIsCreate(point);
263 //}
264
265 //QAction *stub_exec(const QPoint &pos, QAction *at = nullptr)
266 //{
267 // Q_UNUSED(pos)
268 // Q_UNUSED(at)
269 // return nullptr;
270 //}
271
272 ////RightClickToCreate
273 //TEST_F(test_alldayeventview, RightClickToCreate)
274 //{
275 // Stub stub;
276 // stub.set((QAction * (QMenu::*)(const QPoint &, QAction *)) ADDR(QMenu, exec), stub_exec);
277 // cAllDayEventWeekView->RightClickToCreate(nullptr, QPoint(30, 50));
278 //}
279
280 ////MoveInfoProcess
281 //TEST_F(test_alldayeventview, MoveInfoProcess)
282 //{
283 // ScheduleDataInfo info;
284 // QDateTime currentTime = QDateTime::currentDateTime();
285 // info.setBeginDateTime(currentTime);
286 // info.setEndDateTime(currentTime.addDays(1));
287 // info.setAllDay(true);
288 // cAllDayEventWeekView->MoveInfoProcess(info, QPointF(0, 0));
289 // info.setAllDay(false);
290 // cAllDayEventWeekView->MoveInfoProcess(info, QPointF(0, 0));
291 //}
292
293 ////getDragScheduleInfoEndTime
294 //TEST_F(test_alldayeventview, getDragScheduleInfoEndTime)
295 //{
296 // cAllDayEventWeekView->getDragScheduleInfoEndTime(QDateTime::currentDateTime());
297 //}
298
299 ////slotUpdateScene
300 //TEST_F(test_alldayeventview, slotUpdateScene)
301 //{
302 // cAllDayEventWeekView->slotUpdateScene();
303 //}
304
305 //TEST_F(test_alldayeventview, updateInfo)
306 //{
307 // cAllDayEventWeekView->updateInfo();
308 // cAllDayEventWeekView->m_DragStatus = DragInfoGraphicsView::IsCreate;
309 // cAllDayEventWeekView->updateInfo();
310 //}
311
312 ////mouseDoubleClickEvent
313 //TEST_F(test_alldayeventview, mouseDoubleClickEvent)
314 //{
315 // Stub stub;
316 // calendarDDialogExecStub(stub);
317 // QTest::mouseDClick(cAllDayEventWeekView->viewport(), Qt::LeftButton);
318 //}
319
320 ////
321 //TEST_F(test_alldayeventview, setSceneRect)
322 //{
323 // cAllDayEventWeekView->setSceneRect(20, 20, 1000, 1500);
324 // cAllDayEventWeekView->updateBackgroundShowItem();
325 //}
326
327 ////slotPosOnView
328 //TEST_F(test_alldayeventview, slotPosOnView)
329 //{
330 // cAllDayEventWeekView->slotPosOnView(1);
331 //}
332
333 ////mouseReleaseEvent
334 //TEST_F(test_alldayeventview, mouseReleaseEvent)
335 //{
336 // QMouseEvent event(QEvent::MouseButtonRelease, QPointF(32, 13), QPointF(646, 438), QPointF(646, 438),
337 // Qt::RightButton, Qt::RightButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt);
338 // QApplication::sendEvent(cAllDayEventWeekView->viewport(), &event);
339 //}
340
341 ////mouseReleaseEvent
342 //TEST_F(test_alldayeventview, mouseReleaseEvent1)
343 //{
344 // cAllDayEventWeekView->m_TouchBeginTime = QDateTime::currentDateTime().toMSecsSinceEpoch() - 10;
345 // QMouseEvent event(QEvent::MouseButtonRelease, QPointF(32, 13), QPointF(646, 438), QPointF(646, 438),
346 // Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt);
347 // QApplication::sendEvent(cAllDayEventWeekView->viewport(), &event);
348 //}
349
350 ////mouseMoveEvent
351 //TEST_F(test_alldayeventview, mouseMoveEvent)
352 //{
353 // cAllDayEventWeekView->m_touchState = DragInfoGraphicsView::TS_PRESS;
354 // QTest::mouseMove(cAllDayEventWeekView->viewport());
355 //}
356
357 ////wheelEvent
358 //TEST_F(test_alldayeventview, wheelEvent)
359 //{
360 // QEvent event(QEvent::Wheel);
361 // QApplication::sendEvent(cAllDayEventWeekView->viewport(), &event);
362 //}
363
364 ////contextMenuEvent
365 //TEST_F(test_alldayeventview, contextMenuEvent)
366 //{
367 // // QEvent event(QEvent::ContextMenu);
368 // QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(20, 20), QPoint(120, 120), Qt::NoModifier);
369 // Stub stub;
370 // stub.set((QAction * (QMenu::*)(const QPoint &, QAction *)) ADDR(QMenu, exec), stub_exec);
371 // calendarDDialogExecStub(stub);
372 // QApplication::sendEvent(cAllDayEventWeekView->viewport(), &event);
373 //}