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
10 changes: 8 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ if(DOTEST)
aux_source_directory(./../tests/ allTestSource)
aux_source_directory(./view allTestSource)
aux_source_directory(./service allTestSource)
aux_source_directory(./paddleocr-ncnn allTestSource)
aux_source_directory(../3rdparty/clipper allTestSource)
aux_source_directory(./engine allTestSource)
aux_source_directory(./util allTestSource)
aux_source_directory(./utils allTestSource)

FILE(GLOB allTestSource1
"./frame.cpp"
Expand Down Expand Up @@ -186,13 +187,18 @@ target_link_libraries(${PROJECT_NAME}
)

if(DOTEST)
target_include_directories(${PROJECT_NAME_TEST} PUBLIC ${ocr_lib_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME_TEST} PUBLIC ${InferenceEngine_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME_TEST}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Test
Qt${QT_VERSION_MAJOR}::DBus
Dtk${DTK_VERSION_MAJOR}::Core
Dtk${DTK_VERSION_MAJOR}::Widget
${ocr_lib_LIBRARIES}
${InferenceEngine_LIBRARIES}
pthread
)
endif()
Expand Down
8 changes: 5 additions & 3 deletions src/mainwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -287,7 +287,8 @@ void MainWidget::setupUi(QWidget *Widget)
pLay->addWidget(undoBtn);
pLay->addSpacing(10);
pLay->addWidget(redoBtn);
mainWindow->titlebar()->addWidget(pWidget, Qt::AlignRight);
if (mainWindow)
mainWindow->titlebar()->addWidget(pWidget, Qt::AlignRight);

if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) {
languageSelectBox->setFixedSize(160, 24);
Expand Down Expand Up @@ -315,7 +316,8 @@ void MainWidget::setupUi(QWidget *Widget)
//占位用空白控件
m_emptyWidget = new QWidget;
m_emptyWidget->setMinimumSize(36 * 2, 36 * 2);
mainWindow->titlebar()->addWidget(m_emptyWidget, Qt::AlignRight);
if (mainWindow)
mainWindow->titlebar()->addWidget(m_emptyWidget, Qt::AlignRight);
}

void MainWidget::setupConnect()
Expand Down
7 changes: 4 additions & 3 deletions tests/test_mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -12,9 +12,10 @@
#define private public
#define protected public

#include "ocrapplication.h"

Check warning on line 15 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "ocrapplication.h" not found.

Check warning on line 15 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "ocrapplication.h" not found.
#include "engine/OCREngine.h"

Check warning on line 16 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "engine/OCREngine.h" not found.

Check warning on line 16 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "engine/OCREngine.h" not found.
#include "mainwidget.h"

Check warning on line 17 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "mainwidget.h" not found.

Check warning on line 17 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "mainwidget.h" not found.
#include "view/imageview.h"

Check warning on line 18 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "view/imageview.h" not found.

Check warning on line 18 in tests/test_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "view/imageview.h" not found.
//初始拉起主界面
TEST(MainWindow, mainwindow)
{
Expand All @@ -32,7 +33,7 @@
instance.openFile(picPath);
bool bRet = false;
while (!bRet) {
if (!PaddleOCRApp::instance()->isRunning()) {
if (!OCREngine::instance()->isRunning()) {
bRet = true;
QTest::qWait(1000);
}
Expand All @@ -42,7 +43,7 @@

bRet = false;
while (!bRet) {
if (!PaddleOCRApp::instance()->isRunning()) {
if (!OCREngine::instance()->isRunning()) {
bRet = true;
QTest::qWait(1000);
}
Expand Down
9 changes: 1 addition & 8 deletions tests/test_qtestmain.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -25,20 +25,13 @@ using namespace Dtk::Core;
using namespace Dtk::Widget;

#define QMYTEST_MAIN(TestObject) \
QT_BEGIN_NAMESPACE \
QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
QT_END_NAMESPACE \
int main(int argc, char *argv[]) \
{ \
DApplication *dAppNew = new DApplication(argc, argv); \
dAppNew->setAttribute(Qt::AA_UseHighDpiPixmaps); \
dAppNew->setOrganizationName("deepin"); \
dAppNew->setApplicationName("deepin-ocr"); \
dAppNew->loadTranslator(QList<QLocale>() << QLocale::system()); \
QTEST_DISABLE_KEYPAD_NAVIGATION \
QTEST_ADD_GPU_BLACKLIST_SUPPORT \
TestObject tc; \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
} \

Expand Down
15 changes: 14 additions & 1 deletion tests/test_resulttextview.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -10,9 +10,10 @@
#include <QStandardPaths>
#include <QResizeEvent>
#include <QSize>
#include <QGesture>

Check warning on line 13 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 13 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 14 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 15 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 16 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 16 in tests/test_resulttextview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

#define private public
#define protected public
Expand Down Expand Up @@ -61,7 +62,11 @@
QResizeEvent resizeEvent(QSize(500, 200), QSize(500, 400));
reTextView->resizeEvent(&resizeEvent);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMouseEvent *ev = new QMouseEvent(QEvent::MouseMove, QPoint(15,36), QPoint(25,40), QPoint(60,80), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
#else
QMouseEvent *ev = new QMouseEvent(QEvent::MouseMove, QPoint(15,36), QPoint(25,40), QPoint(60,80), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt);
#endif
reTextView->m_gestureAction = ResultTextView::GA_slide;
reTextView->mouseMoveEvent(ev);
delete ev;
Expand All @@ -72,11 +77,19 @@
reTextView->contextMenuEvent(nullptr);
stub.reset((QAction*(QMenu::*)(const QPoint &, QAction *))ADDR(QMenu, exec));

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMouseEvent *evPress = new QMouseEvent(QEvent::MouseButtonPress, QPoint(15,36), QPoint(25,40), QPoint(60,80), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
#else
QMouseEvent *evPress = new QMouseEvent(QEvent::MouseButtonPress, QPoint(15,36), QPoint(25,40), QPoint(60,80), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt);
#endif
reTextView->mousePressEvent(evPress);
delete evPress;

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMouseEvent *evRele = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(15,36), QPoint(25,40), QPoint(60,80), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
#else
QMouseEvent *evRele = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(15,36), QPoint(25,40), QPoint(60,80), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier, Qt::MouseEventSynthesizedByQt);
#endif
reTextView->mouseReleaseEvent(evRele);
delete evRele;

Expand Down
Loading