| 1 |
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
#include "logviewitemdelegate.h" |
| 6 |
#include "logtreeview.h" |
| 7 |
|
| 8 |
#include <gtest/gtest.h> |
| 9 |
#include <stub.h> |
| 10 |
|
| 11 |
#include <DStyle> |
| 12 |
|
| 13 |
#include <QDebug> |
| 14 |
#include <QPainter> |
| 15 |
|
| 16 |
DWIDGET_USE_NAMESPACE |
| 17 |
//int stub_pixelMetric001(DStyle::PixelMetric m, const QStyleOption *opt = nullptr, const QWidget *widget = nullptr) |
| 18 |
//{ |
| 19 |
// return 1; |
| 20 |
//} |
| 21 |
|
| 22 |
//void stub_drawPrimitive001(DStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = nullptr) |
| 23 |
//{ |
| 24 |
//} |
| 25 |
|
| 26 |
//bool stub_isValid001() |
| 27 |
//{ |
| 28 |
//} |
| 29 |
|
| 30 |
//class LogViewItemDelegate_paint_UT : public testing::Test |
| 31 |
//{ |
| 32 |
//public: |
| 33 |
// //添加日志 |
| 34 |
// static void SetUpTestCase() |
| 35 |
// { |
| 36 |
// qDebug() << "SetUpTestCase" << endl; |
| 37 |
// } |
| 38 |
// static void TearDownTestCase() |
| 39 |
// { |
| 40 |
// qDebug() << "TearDownTestCase" << endl; |
| 41 |
// } |
| 42 |
// void SetUp() //TEST跑之前会执行SetUp |
| 43 |
// { |
| 44 |
// m_treeview = new LogTreeView(); |
| 45 |
// p = new LogViewItemDelegate(m_treeview); |
| 46 |
// qDebug() << "SetUp" << endl; |
| 47 |
// } |
| 48 |
// void TearDown() //TEST跑完之后会执行TearDown |
| 49 |
// { |
| 50 |
// delete p; |
| 51 |
// } |
| 52 |
// LogViewItemDelegate *p; |
| 53 |
// LogTreeView *m_treeview; |
| 54 |
//}; |
| 55 |
|
| 56 |
////TEST_F(LogViewItemDelegate_paint_UT, LogViewItemDelegate_paint_UT) |
| 57 |
////{ |
| 58 |
//// Stub stub; |
| 59 |
//// stub.set((int (DStyle::*)(DStyle::PixelMetric, const QStyleOption *, const QWidget *) const)ADDR(DStyle, pixelMetric), stub_pixelMetric001); |
| 60 |
//// stub.set((void (DStyle::*)(DStyle::PrimitiveElement, const QStyleOption *, QPainter *, const QWidget *) const)ADDR(DStyle, drawPrimitive), stub_drawPrimitive001); |
| 61 |
//// stub.set(ADDR(QModelIndex, isValid), stub_isValid001); |
| 62 |
//// LogViewItemDelegate *p = new LogViewItemDelegate(nullptr); |
| 63 |
//// EXPECT_NE(p, nullptr); |
| 64 |
//// p->paint(new QPainter, QStyleOptionViewItem(), QModelIndex()); |
| 65 |
////} |
| 66 |
|
| 67 |
//TEST_F(LogViewItemDelegate_paint_UT, LogViewItemDelegate_createEditor_UT) |
| 68 |
//{ |
| 69 |
// EXPECT_NE(p, nullptr); |
| 70 |
// QWidget *w = p->createEditor(nullptr, QStyleOptionViewItem(), QModelIndex()); |
| 71 |
// EXPECT_EQ(w, nullptr); |
| 72 |
//} |
| 73 |
|
| 74 |
//TEST_F(LogViewItemDelegate_paint_UT, LogViewItemDelegate_sizeHint_UT) |
| 75 |
//{ |
| 76 |
// EXPECT_NE(p, nullptr); |
| 77 |
// p->sizeHint(QStyleOptionViewItem(), QModelIndex()); |
| 78 |
//} |
| 79 |
|
| 80 |
//TEST_F(LogViewItemDelegate_paint_UT, LogViewItemDelegate_initStyleOption_UT) |
| 81 |
//{ |
| 82 |
// EXPECT_NE(p, nullptr); |
| 83 |
// p->initStyleOption(new QStyleOptionViewItem(), QModelIndex()); |
| 84 |
// p->deleteLater(); |
| 85 |
//} |