| 1 |
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
//#include "test_monthdayview.h" |
| 6 |
//#include "touchgestureoperation.h" |
| 7 |
//#include "../third-party_stub/stub.h" |
| 8 |
|
| 9 |
//#include <QMouseEvent> |
| 10 |
//#include <QPainter> |
| 11 |
|
| 12 |
//static int monthdayview_int = 0; |
| 13 |
|
| 14 |
//static int monthdayview_stub_int() |
| 15 |
//{ |
| 16 |
// return monthdayview_int; |
| 17 |
//} |
| 18 |
|
| 19 |
//test_monthdayview::test_monthdayview() |
| 20 |
//{ |
| 21 |
// mMonthDayView = new CMonthDayView(); |
| 22 |
// mMonthWidget = new CMonthWidget(); |
| 23 |
// mMonthRect = new CMonthRect(); |
| 24 |
// mMonthRect->setDate(QDate()); |
| 25 |
// CMonthRect::setSelectRect(mMonthRect); |
| 26 |
//} |
| 27 |
|
| 28 |
//test_monthdayview::~test_monthdayview() |
| 29 |
//{ |
| 30 |
// delete mMonthDayView; |
| 31 |
// mMonthDayView = nullptr; |
| 32 |
// delete mMonthWidget; |
| 33 |
// mMonthWidget = nullptr; |
| 34 |
// delete mMonthRect; |
| 35 |
// mMonthRect = nullptr; |
| 36 |
//} |
| 37 |
|
| 38 |
////void CMonthDayView::setSelectDate(const QDate &date) |
| 39 |
//TEST_F(test_monthdayview, setSelectdate) |
| 40 |
//{ |
| 41 |
// mMonthDayView->setSelectDate(QDate::currentDate()); |
| 42 |
//} |
| 43 |
|
| 44 |
////void CMonthDayView::setTheMe(int type) |
| 45 |
//TEST_F(test_monthdayview, setTheMe) |
| 46 |
//{ |
| 47 |
// mMonthDayView->setTheMe(1); |
| 48 |
// mMonthDayView->setTheMe(2); |
| 49 |
//} |
| 50 |
|
| 51 |
////void CMonthDayView::setSearchflag(bool flag) |
| 52 |
//TEST_F(test_monthdayview, setSearchflag) |
| 53 |
//{ |
| 54 |
// mMonthDayView->setSearchflag(false); |
| 55 |
//} |
| 56 |
|
| 57 |
//TEST_F(test_monthdayview, event_01) |
| 58 |
//{ |
| 59 |
// Stub stub; |
| 60 |
// stub.set(ADDR(touchGestureOperation, getTouchState), monthdayview_stub_int); |
| 61 |
// QMouseEvent e(QEvent::MouseButtonPress, QPointF(1, 1), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); |
| 62 |
// mMonthDayView->event(&e); |
| 63 |
//} |
| 64 |
|
| 65 |
////void CMonthWidget::setDate(const QDate date[12]) |
| 66 |
//TEST_F(test_monthdayview, setDate) |
| 67 |
//{ |
| 68 |
// QDate m_days[12]; |
| 69 |
// QDate currentDate = QDate::currentDate(); |
| 70 |
// for (int i = 0; i < 12; i++) { |
| 71 |
// m_days[i] = currentDate.addDays(i); |
| 72 |
// } |
| 73 |
// mMonthWidget->setDate(m_days); |
| 74 |
//} |
| 75 |
|
| 76 |
////void CMonthWidget::updateSize() |
| 77 |
//TEST_F(test_monthdayview, updateSize) |
| 78 |
//{ |
| 79 |
// mMonthWidget->updateSize(); |
| 80 |
//} |
| 81 |
|
| 82 |
////void CMonthRect::setDate(const QDate &date) |
| 83 |
//TEST_F(test_monthdayview, setRectDate) |
| 84 |
//{ |
| 85 |
// mMonthRect->setDate(QDate::currentDate()); |
| 86 |
// mMonthRect->getDate(); |
| 87 |
//} |
| 88 |
|
| 89 |
////void CMonthRect::setRect(const QRectF &rect) |
| 90 |
//TEST_F(test_monthdayview, setRect) |
| 91 |
//{ |
| 92 |
// mMonthRect->setRect(QRectF()); |
| 93 |
// mMonthRect->rect(); |
| 94 |
//} |
| 95 |
|
| 96 |
////void CMonthRect::setDevicePixelRatio(const qreal pixel) |
| 97 |
//TEST_F(test_monthdayview, setDevicePixelRatio) |
| 98 |
//{ |
| 99 |
// mMonthRect->setDevicePixelRatio(1.2); |
| 100 |
//} |
| 101 |
|
| 102 |
////void CMonthRect::setTheMe(int type) |
| 103 |
//TEST_F(test_monthdayview, setRTheMe) |
| 104 |
//{ |
| 105 |
// mMonthRect->setTheMe(1); |
| 106 |
// mMonthRect->setTheMe(2); |
| 107 |
//} |
| 108 |
|
| 109 |
//TEST_F(test_monthdayview, paintEvent_01) |
| 110 |
//{ |
| 111 |
// QPaintEvent paint(QRect(0, 0, 1, 1)); |
| 112 |
// mMonthWidget->paintEvent(&paint); |
| 113 |
//} |
| 114 |
|
| 115 |
//TEST_F(test_monthdayview, mouseReleaseEvent_01) |
| 116 |
//{ |
| 117 |
// QMouseEvent e(QEvent::MouseButtonPress, QPointF(1, 1), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); |
| 118 |
// mMonthWidget->mouseReleaseEvent(&e); |
| 119 |
//} |
| 120 |
|
| 121 |
//TEST_F(test_monthdayview, keyPressEvent_01) |
| 122 |
//{ |
| 123 |
// QKeyEvent e(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); |
| 124 |
// mMonthWidget->keyPressEvent(&e); |
| 125 |
//} |
| 126 |
|
| 127 |
//TEST_F(test_monthdayview, keyPressEvent_02) |
| 128 |
//{ |
| 129 |
// QKeyEvent e(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); |
| 130 |
// mMonthWidget->keyPressEvent(&e); |
| 131 |
//} |
| 132 |
|
| 133 |
//TEST_F(test_monthdayview, keyPressEvent_03) |
| 134 |
//{ |
| 135 |
// QKeyEvent e(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); |
| 136 |
// mMonthWidget->keyPressEvent(&e); |
| 137 |
//} |
| 138 |
|
| 139 |
//TEST_F(test_monthdayview, focusInEvent_01) |
| 140 |
//{ |
| 141 |
// QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason); |
| 142 |
// mMonthWidget->focusInEvent(&e); |
| 143 |
// EXPECT_TRUE(mMonthWidget->m_isFocus); |
| 144 |
//} |
| 145 |
|
| 146 |
//TEST_F(test_monthdayview, focusInEvent_02) |
| 147 |
//{ |
| 148 |
// QFocusEvent e(QEvent::FocusIn, Qt::OtherFocusReason); |
| 149 |
// mMonthWidget->focusInEvent(&e); |
| 150 |
// EXPECT_FALSE(mMonthWidget->m_isFocus); |
| 151 |
//} |
| 152 |
|
| 153 |
//TEST_F(test_monthdayview, focusOutEvent_01) |
| 154 |
//{ |
| 155 |
// QFocusEvent e(QEvent::FocusIn, Qt::OtherFocusReason); |
| 156 |
// mMonthWidget->focusOutEvent(&e); |
| 157 |
// EXPECT_FALSE(mMonthWidget->m_isFocus); |
| 158 |
//} |
| 159 |
|
| 160 |
//TEST_F(test_monthdayview, mousePress_01) |
| 161 |
//{ |
| 162 |
// mMonthWidget->mousePress(QPoint(0, 0)); |
| 163 |
// EXPECT_FALSE(mMonthWidget->m_isFocus); |
| 164 |
//} |
| 165 |
|
| 166 |
//TEST_F(test_monthdayview, updateSize_01) |
| 167 |
//{ |
| 168 |
// mMonthWidget->updateSize(); |
| 169 |
//} |
| 170 |
|
| 171 |
//TEST_F(test_monthdayview, getMousePosItem_01) |
| 172 |
//{ |
| 173 |
// mMonthWidget->getMousePosItem(QPointF()); |
| 174 |
//} |
| 175 |
|
| 176 |
//TEST_F(test_monthdayview, updateShowDate_01) |
| 177 |
//{ |
| 178 |
// mMonthWidget->updateShowDate(QDate()); |
| 179 |
//} |
| 180 |
|
| 181 |
//TEST_F(test_monthdayview, paintItem_01) |
| 182 |
//{ |
| 183 |
// mMonthRect->m_Date = QDate(2022, 4, 22); |
| 184 |
// QPainter pa(mMonthWidget); |
| 185 |
// mMonthRect->paintItem(&pa, QRect(), true); |
| 186 |
//} |
| 187 |
|
| 188 |
//TEST_F(test_monthdayview, paintItem_02) |
| 189 |
//{ |
| 190 |
// mMonthRect->m_Date = QDate(2022, 4, 22); |
| 191 |
// mMonthRect->m_SelectRect = mMonthRect; |
| 192 |
// QPainter pa(mMonthWidget); |
| 193 |
// mMonthRect->paintItem(&pa, QRect(), true); |
| 194 |
//} |
| 195 |
|
| 196 |
//TEST_F(test_monthdayview, setDevicePixelRatio_01) |
| 197 |
//{ |
| 198 |
// mMonthRect->setDevicePixelRatio(10); |
| 199 |
// EXPECT_EQ(mMonthRect->m_DevicePixelRatio, 10); |
| 200 |
//} |
| 201 |
|
| 202 |
//TEST_F(test_monthdayview, setTheMe_01) |
| 203 |
//{ |
| 204 |
// mMonthRect->setTheMe(0); |
| 205 |
// EXPECT_EQ(mMonthRect->m_defaultTextColor, Qt::black); |
| 206 |
//} |
| 207 |
|
| 208 |
//TEST_F(test_monthdayview, setTheMe_02) |
| 209 |
//{ |
| 210 |
// mMonthRect->setTheMe(2); |
| 211 |
// EXPECT_EQ(mMonthRect->m_defaultTextColor, QColor("#C0C6D4")); |
| 212 |
//} |