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
2 changes: 2 additions & 0 deletions reader/uiframe/DocTabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,13 @@ void DocTabBar::dragEnterEvent(QDragEnterEvent *event)
DTabBar::dragEnterEvent(event);
if (event->mimeData()->hasFormat("deepin_reader/tabbar")) {
qCDebug(appLog) << "DocTabBar::dragEnterEvent - hasFormat";
// LCOV_EXCL_START
QTimer::singleShot(1, [this]() {
DPlatformWindowHandle::setDisableWindowOverrideCursor(dragIconWindow(), false);
QGuiApplication::changeOverrideCursor(Qt::DragCopyCursor);
DPlatformWindowHandle::setDisableWindowOverrideCursor(dragIconWindow(), true);
});
// LCOV_EXCL_STOP
}
qCDebug(appLog) << "DocTabBar::dragEnterEvent end";
}
Expand Down
43 changes: 43 additions & 0 deletions tests/uiframe/ut_centraldocpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,3 +1325,46 @@ TEST_F(TestCentralDocPage, UT_CentralDocPage_zoomOut_001)
delete g_docsheet;
g_docsheet = nullptr;
}

TEST_F(TestCentralDocPage, UT_CentralDocPage_onSheetOperationChanged_invoke)
{
QString strPath = UTSOURCEDIR;
strPath += "/files/normal.pdf";
DocSheet *sheet = new DocSheet(Dr::FileType::PDF, strPath, nullptr);

QSignalSpy spy(m_tester, SIGNAL(sigCurSheetChanged(DocSheet *)));
m_tester->onSheetOperationChanged(sheet);
EXPECT_TRUE(spy.count() == 1);

delete sheet;
}

TEST_F(TestCentralDocPage, UT_CentralDocPage_onSheetOperationChanged_nullptr)
{
// nullptr sheet with no current sheet -> signal still emitted
Stub s;
s.set(ADDR(CentralDocPage, getCurSheet), getCurSheet_stub_nullptr);

QSignalSpy spy(m_tester, SIGNAL(sigCurSheetChanged(DocSheet *)));
m_tester->onSheetOperationChanged(nullptr);
EXPECT_TRUE(spy.count() == 1);
}

TEST_F(TestCentralDocPage, UT_CentralDocPage_onCentralMoveIn_invoke)
{
Stub s;
s.set(ADDR(DocTabBar, insertSheet), insertSheet_stub);
s.set(ADDR(CentralDocPage, enterSheet), enterSheet_stub);

QString strPath = UTSOURCEDIR;
strPath += "/files/normal.pdf";
DocSheet *sheet = new DocSheet(Dr::FileType::PDF, strPath, nullptr);

m_tester->onCentralMoveIn(sheet);
EXPECT_TRUE(g_funcName == "enterSheet_stub");

delete sheet;
}

// Note: isFullScreen/openFullScreen require MainWindow in parent hierarchy
// which is not available in this test fixture - skipping to avoid crash.
17 changes: 17 additions & 0 deletions tests/uiframe/ut_doctabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,20 @@ TEST_F(UT_DocTabBar, UT_DocTabBar_resizeEvent)
m_tester->resizeEvent(&event);
SUCCEED();
}

TEST_F(UT_DocTabBar, UT_DocTabBar_onDragActionChanged_nullDrag)
{
// No drag in progress - dragIconWindow() returns nullptr, function returns early
m_tester->onDragActionChanged(Qt::IgnoreAction);
m_tester->onDragActionChanged(Qt::CopyAction);
m_tester->onDragActionChanged(Qt::MoveAction);
SUCCEED();
}

TEST_F(UT_DocTabBar, UT_DocTabBar_dragEnterEvent_emptyMime)
{
QMimeData mimeData;
QDragEnterEvent event(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, Qt::NoModifier);
m_tester->dragEnterEvent(&event);
SUCCEED();
}
22 changes: 22 additions & 0 deletions tests/uiframe/ut_sheetrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
#include <DWidget>
#include <gtest/gtest.h>
#include <QMutex>
#include <QImage>

Check warning on line 14 in tests/uiframe/ut_sheetrenderer.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QImage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointF>

Check warning on line 15 in tests/uiframe/ut_sheetrenderer.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointF> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QRectF>

Check warning on line 16 in tests/uiframe/ut_sheetrenderer.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QRectF> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTest>

Check warning on line 17 in tests/uiframe/ut_sheetrenderer.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTest> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 18 in tests/uiframe/ut_sheetrenderer.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DWIDGET_USE_NAMESPACE

Expand Down Expand Up @@ -265,3 +267,23 @@
m_tester->loadPageLable();
SUCCEED();
}

TEST_F(TestSheetRenderer, testOpenFileAsync)
{
// Call openFileAsync - it just appends a task to the render thread
m_tester->openFileAsync("test");
// Wait briefly for the task to be processed
QTest::qWait(100);
SUCCEED();
}

TEST_F(TestSheetRenderer, testOpenFileExec)
{
// Schedule sigOpened emission to break the event loop in openFileExec
QTimer::singleShot(50, m_tester, [this]() {
emit m_tester->sigOpened(deepin_reader::Document::NoError);
});
bool result = m_tester->openFileExec("test");
Q_UNUSED(result);
SUCCEED();
}
Loading