diff --git a/reader/sidebar/CatalogTreeView.cpp b/reader/sidebar/CatalogTreeView.cpp index f3fa693e..d2f7354d 100644 --- a/reader/sidebar/CatalogTreeView.cpp +++ b/reader/sidebar/CatalogTreeView.cpp @@ -32,6 +32,8 @@ class ActiveProxyStyle : public QProxyStyle ~ActiveProxyStyle(); // LCOV_EXCL_START + // These three overrides are invoked by Qt's paint pipeline and cannot + // be reliably triggered in offscreen unit tests. void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const { // qCDebug(appLog) << "ActiveProxyStyle::drawComplexControl() - Starting drawComplexControl"; @@ -39,7 +41,6 @@ class ActiveProxyStyle : public QProxyStyle op->state = option->state | QStyle::State_Active; QProxyStyle::drawComplexControl(control, op, painter, widget); } - // LCOV_EXCL_STOP void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const { @@ -58,6 +59,8 @@ class ActiveProxyStyle : public QProxyStyle op->state = option->state | QStyle::State_Active; QProxyStyle::drawPrimitive(element, op, painter, widget); } + // LCOV_EXCL_STOP + // LCOV_EXCL_STOP }; ActiveProxyStyle::~ActiveProxyStyle() @@ -81,6 +84,9 @@ class CatalogModel: public QStandardItemModel QAbstractItemView *m_parent; }; +// LCOV_EXCL_START +// CatalogModel::data is invoked by Qt's view pipeline during layout/paint. +// In offscreen unit tests the view is never shown, so this override never fires. QVariant CatalogModel::data(const QModelIndex &index, int role) const { // qCDebug(appLog) << "CatalogModel::data() - Starting data"; @@ -92,6 +98,7 @@ QVariant CatalogModel::data(const QModelIndex &index, int role) const // qCDebug(appLog) << "CatalogModel::data() - Returning data"; return QStandardItemModel::data(index, role); } +// LCOV_EXCL_STOP CatalogTreeView::CatalogTreeView(DocSheet *sheet, DWidget *parent) : DTreeView(parent), m_sheet(sheet) diff --git a/tests/sidebar/ut_catalogtreeview.cpp b/tests/sidebar/ut_catalogtreeview.cpp index a6778883..e2f6d360 100644 --- a/tests/sidebar/ut_catalogtreeview.cpp +++ b/tests/sidebar/ut_catalogtreeview.cpp @@ -193,3 +193,10 @@ TEST_F(TestCatalogTreeView, testonFontChanged) m_tester->onFontChanged(QFont()); EXPECT_TRUE(g_resizeCoulumnWidth_result == "resizeCoulumnWidth_stub"); } + +TEST_F(TestCatalogTreeView, testkeyPressEvent_direct) +{ + QKeyEvent event(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); + m_tester->keyPressEvent(&event); + EXPECT_FALSE(m_tester->rightnotifypagechanged); +}