deepin-ocr/tests/test_dbus_service.cpp
hemingyang c0961accf8 chore(CI): 单元测试
Description: 单元测试覆盖率提升

Log: 添加单元测试
Change-Id: Ia03c3bd2b7cd676dd32a5b4484d17876831e0124
2021-12-28 20:27:11 +08:00

60 lines
1.8 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>
#include <QDBusConnection>
#define private public
#define protected public
#include "ocrapplication.h"
#include "service/dbusocr_adaptor.h"
#include "service/ocrinterface.h"
//初始拉起主界面
TEST(OcrInterface, mainwindow)
{
OcrInterface *pOcr = new OcrInterface("com.deepin.Ocr", "/com/deepin/Ocr", QDBusConnection::sessionBus());
qDebug() << __FUNCTION__ << __LINE__;
QString imagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/Wallpapers/marian-kroell-qElMHWePpok-unsplash.jpg";;
pOcr->openFile(imagePath);
QTest::qWait(2000);
QImage img = QImage(imagePath);
pOcr->openImage(img);
QTest::qWait(2000);
pOcr->openImageAndName(img, "TestName");
QTest::qWait(2000);
delete pOcr;
}
TEST(DbusOcrAdaptor, MainWidget_show)
{
//DbusOcrAdaptor *adaptor = new DbusOcrAdaptor(nullptr);
//delete adaptor;
}