718c41634f
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
109 lines
3.0 KiB
C++
109 lines
3.0 KiB
C++
/*
|
|
* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
|
|
*
|
|
* Author: ZhangYong <zhangyong@uniontech.com>
|
|
*
|
|
* Maintainer: ZhangYong <ZhangYong@uniontech.com>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include <gtest/gtest.h>
|
|
#include <gmock/gmock-matchers.h>
|
|
|
|
#include <QTestEventList>
|
|
#include <QObject>
|
|
#include <QStandardPaths>
|
|
|
|
#define private public
|
|
#define protected public
|
|
|
|
#include "ocrapplication.h"
|
|
#include "mainwidget.h"
|
|
#include "view/imageview.h"
|
|
//初始拉起主界面
|
|
TEST(MainWindow, mainwindow)
|
|
{
|
|
OcrApplication instance;
|
|
instance.openFile("");
|
|
QTest::qWait(2000);
|
|
}
|
|
|
|
//其余case
|
|
//初始拉起主界面,带有参数的
|
|
TEST(MainWindow, mainwindow_openFile)
|
|
{
|
|
QString picPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/ocr_test/testResource/test.png";
|
|
OcrApplication instance;
|
|
instance.openFile(picPath);
|
|
bool bRet = false;
|
|
while (!bRet) {
|
|
if (!PaddleOCRApp::instance()->isRunning()) {
|
|
bRet = true;
|
|
QTest::qWait(1000);
|
|
}
|
|
}
|
|
|
|
instance.openImage(QImage(picPath).scaled(200, 200));
|
|
|
|
bRet = false;
|
|
while (!bRet) {
|
|
if (!PaddleOCRApp::instance()->isRunning()) {
|
|
bRet = true;
|
|
QTest::qWait(1000);
|
|
}
|
|
}
|
|
|
|
instance.openImageAndName(QImage(picPath).scaled(10, 10), picPath);
|
|
QTest::qWait(2000);
|
|
}
|
|
|
|
//初始拉起主界面,带有参数的
|
|
TEST(MainWidget, MainWidget_show)
|
|
{
|
|
MainWidget *a = new MainWidget();
|
|
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::LightType;
|
|
a->setIcons(themeType);
|
|
a->loadHtml("");
|
|
a->loadHtml("test");
|
|
a->loadString("");
|
|
a->loadString("test");
|
|
a->slotCopy();
|
|
a->resultEmpty();
|
|
a->deleteLater();
|
|
a = nullptr;
|
|
QTest::qWait(2000);
|
|
}
|
|
|
|
TEST(ImageView, ImageView_show)
|
|
{
|
|
QString picPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/Wallpapers/luca-micheli-ruWkmt3nU58-unsplash.jpg";
|
|
ImageView *imageView = new ImageView();
|
|
imageView->openImage(picPath);
|
|
imageView->fitImage();
|
|
imageView->fitWindow();
|
|
imageView->autoFit();
|
|
imageView->imageRelativeScale();
|
|
imageView->setScaleValue(1.1);
|
|
imageView->setScaleValue(0.9);
|
|
imageView->RotateImage(90);
|
|
|
|
imageView->scaleAtPoint(QPoint(10, 10), 1.2);
|
|
QPinchGesture *gesture = new QPinchGesture;
|
|
imageView->pinchTriggered(gesture);
|
|
delete gesture;
|
|
|
|
QTest::qWait(2000);
|
|
delete imageView;
|
|
}
|