Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion reader/sidebar/CatalogTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ 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";
QStyleOptionComplex *op = const_cast<QStyleOptionComplex *>(option);
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
{
Expand All @@ -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()
Expand All @@ -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";
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions tests/sidebar/ut_catalogtreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading