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
5 changes: 3 additions & 2 deletions tests/test-prj-running.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# 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 @@ -13,6 +13,7 @@ cppcheck --enable=all --output-file=../build-ut/cppcheck_deepin-screen-recorder.
cppcheck --enable=all --output-file=../build-ut/cppcheck_dde-dock-plugins.xml --xml ../dde-dock-plugins/

./ut_dde_dock_plugins/build_run_ut.sh
./ut_screen_shot_recorder/build_run_ut.sh
# TODO: ut_screen_shot_recorder 需要 3rdparty/libcam 等生产代码完成 Qt6 适配后再启用
#./ut_screen_shot_recorder/build_run_ut.sh

exit 0
6 changes: 3 additions & 3 deletions tests/ut_dde_dock_plugins/ut_record_time/build_run_ut.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# 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,8 +12,8 @@ mkdir ./ut_dde_dock_plugins/ut_record_time/build-ut

cd ./ut_dde_dock_plugins/ut_record_time/build-ut
pwd
export QT_SELECT=qt5
qmake ../
export QT_SELECT=qt6
qmake6 ../
make -j4

workdir=$(cd ../$(dirname $0)/build-ut; pwd)
Expand Down
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 @@ -19,6 +19,8 @@ class TestRecordTimePlugin : public testing::Test
{
m_recordTimePlugin.reset(new RecordTimePlugin());
m_recordTimePlugin->init(&mock_proxy);
if (!m_recordTimePlugin->m_timeWidget)
m_recordTimePlugin->m_timeWidget = new TimeWidget();
}
void TearDown() override
{
Expand Down Expand Up @@ -60,7 +62,7 @@ TEST_F(TestRecordTimePlugin, onStart)

TEST_F(TestRecordTimePlugin, onStop)
{
m_recordTimePlugin->m_checkTimer = new QTimer();
m_recordTimePlugin->m_timer = new QTimer();
emit m_recordTimePlugin->m_dBusService->stop();
}

Expand Down
4 changes: 3 additions & 1 deletion tests/ut_dde_dock_plugins/ut_record_time/ut_record_time.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QT += core widgets dbus
CONFIG += c++11 plugin link_pkgconfig
PKGCONFIG += dtkgui dtkwidget
PKGCONFIG += dtk6gui dtk6widget
include(../../../3rdparty/stub_linux/stub.pri)

TARGET = ut_record_time
Expand Down Expand Up @@ -28,13 +28,15 @@ equals(TSAN_TOOL_ENABLE, true ){
HEADERS += \
ut_mock_pluginproxyinterface.h \
../../../src/dde-dock-plugins/recordtime/timewidget.h \
../../../src/dde-dock-plugins/recordtime/timewidget_interface.h \
../../../src/dde-dock-plugins/recordtime/dbusservice.h \
../../../src/dde-dock-plugins/recordtime/recordtimeplugin.h

SOURCES += \
main.cpp \
../../../src/dde-dock-plugins/recordtime/recordtimeplugin.cpp \
../../../src/dde-dock-plugins/recordtime/timewidget.cpp \
../../../src/dde-dock-plugins/recordtime/timewidget_interface.cpp \
../../../src/dde-dock-plugins/recordtime/dbusservice.cpp \
ut_mock_stub_recordtimeplugin.cpp \
ut_timewidget.cpp \
Expand Down
12 changes: 6 additions & 6 deletions tests/ut_dde_dock_plugins/ut_record_time/ut_timewidget.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 @@ -19,7 +19,7 @@ ACCESS_PRIVATE_FUN(TimeWidget, void(QMouseEvent *e), mouseMoveEvent);
ACCESS_PRIVATE_FUN(TimeWidget, void(QEvent *e), leaveEvent);
ACCESS_PRIVATE_FUN(TimeWidget, void(), onTimeout);
ACCESS_PRIVATE_FUN(TimeWidget, void(int), onPositionChanged);
ACCESS_PRIVATE_FUN(TimeWidget, void(), createCacheFile);
ACCESS_PRIVATE_FUN(TimeWidget, bool(), createCacheFile);

ACCESS_PRIVATE_FIELD(TimeWidget, int, m_position)
ACCESS_PRIVATE_FIELD(TimeWidget, QPixmap, m_pixmap)
Expand Down Expand Up @@ -94,30 +94,30 @@ TEST_F(TestTimeWidget, paintEvent)

TEST_F(TestTimeWidget, mousePressEvent)
{
QMouseEvent *ev = new QMouseEvent(QEvent::MouseButtonPress, QPoint(-10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QMouseEvent *ev = new QMouseEvent(QEvent::MouseButtonPress, QPoint(-10, 10), QPoint(-10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
access_private_field::TimeWidgetm_position(*m_timeWidget) = 0;
call_private_fun::TimeWidgetmousePressEvent(*m_timeWidget, ev);
delete ev;
}

TEST_F(TestTimeWidget, mouseReleaseEvent)
{
QMouseEvent *ev = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QMouseEvent *ev = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(10, 10), QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
call_private_fun::TimeWidgetmouseReleaseEvent(*m_timeWidget, ev);
delete ev;
}

TEST_F(TestTimeWidget, mouseMoveEvent)
{
QMouseEvent *ev = new QMouseEvent(QEvent::MouseMove, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QMouseEvent *ev = new QMouseEvent(QEvent::MouseMove, QPoint(10, 10), QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
call_private_fun::TimeWidgetmouseMoveEvent(*m_timeWidget, ev);
delete ev;
}


TEST_F(TestTimeWidget, leaveEvent)
{
QEvent *ev = new QMouseEvent(QEvent::MouseMove, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QEvent *ev = new QMouseEvent(QEvent::MouseMove, QPoint(10, 10), QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
call_private_fun::TimeWidgetleaveEvent(*m_timeWidget, ev);
delete ev;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ut_dde_dock_plugins/ut_shot_start/build_run_ut.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# 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 @@ -15,8 +15,8 @@ cd ./ut_dde_dock_plugins/ut_shot_start/build-ut
mkdir -p html
mkdir -p report

export QT_SELECT=qt5
qmake ../
export QT_SELECT=qt6
qmake6 ../
make -j4

executable=ut_shot_start #可执行程序的文件名
Expand Down
4 changes: 2 additions & 2 deletions tests/ut_dde_dock_plugins/ut_shot_start/ut_shot_start.pro
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
QT += core widgets dbus testlib
CONFIG += c++11 plugin link_pkgconfig
PKGCONFIG += dtkgui dtkwidget
PKGCONFIG += dtk6gui dtk6widget
DEFINES += UNIT_TEST

include(../../../3rdparty/stub_linux/stub.pri)s
include(../../../3rdparty/stub_linux/stub.pri)

TARGET = ut_shot_start

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# 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 @@ -15,8 +15,8 @@ cd ./ut_dde_dock_plugins/ut_shot_start_record/build-ut
mkdir -p html
mkdir -p report

export QT_SELECT=qt5
qmake ../
export QT_SELECT=qt6
qmake6 ../
make -j4

executable=ut_shot_start_record #可执行程序的文件名
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QT += core widgets dbus testlib
CONFIG += c++11 plugin link_pkgconfig
PKGCONFIG += dtkgui dtkwidget
PKGCONFIG += dtk6gui dtk6widget
DEFINES += UNIT_TEST

include(../../../3rdparty/stub_linux/stub.pri)
Expand Down
2 changes: 1 addition & 1 deletion tests/ut_pin_screenshots/ut_pin_screenshots.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

QT += core widgets dbus
CONFIG += c++11 plugin link_pkgconfig
PKGCONFIG += dtkgui dtkwidget
PKGCONFIG += dtk6gui dtk6widget
include(../../3rdparty/stub_linux/stub.pri)

TARGET = ut_pin_screenshots
Expand Down
6 changes: 3 additions & 3 deletions tests/ut_screen_shot_recorder/build_run_ut.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# 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 @@ -16,8 +16,8 @@ rm -rf ./ut_screen_shot_recorder/build-ut
mkdir ./ut_screen_shot_recorder/build-ut

cd ./ut_screen_shot_recorder/build-ut
export QT_SELECT=qt5
qmake ../
export QT_SELECT=qt6
qmake6 ../
make -j4

#workdir=$(cd ../../$(dirname $0)/build-filemanager-unknown-Debug/test; pwd)
Expand Down
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 @@ -7,7 +7,6 @@
#include <QScreen>
#include <QPixmap>
#include <QApplication>
#include <QDesktopWidget>
#include <gtest/gtest.h>
#include "../dbusinterface/drawinterface.h"

Expand Down Expand Up @@ -47,7 +46,7 @@ TEST_F(DrawInterfaceTest, openImages)
{
QList<QImage> list;
QScreen *t_primaryScreen = QGuiApplication::primaryScreen();
QPixmap pix = t_primaryScreen->grabWindow(QApplication::desktop()->winId());
QPixmap pix = t_primaryScreen->grabWindow(0);
list.append(pix.toImage());
m_draw->openImages(list);
}
13 changes: 7 additions & 6 deletions tests/ut_screen_shot_recorder/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// 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

#include <QApplication>

Check warning on line 5 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <gtest/gtest.h>

Check warning on line 6 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <gtest/gtest.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>

Check warning on line 7 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 8 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 9 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in tests/ut_screen_shot_recorder/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtDBus> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#ifdef ENABLE_TSAN_TOOL
#include <sanitizer/asan_interface.h>
#endif
Expand All @@ -18,9 +19,9 @@

static Stub globalStub;

QList<QCameraInfo> availableCameras_stub(void* obj, QCamera::Position position = QCamera::UnspecifiedPosition)
QList<QCameraDevice> availableCameras_stub(void* obj)
{
return QList<QCameraInfo>();
return QList<QCameraDevice>();
}

int quit_stub(void* obj)
Expand Down Expand Up @@ -49,8 +50,8 @@
{
QApplication app(argc, argv);
qDebug() << "start test cases ..............";
globalStub.set(ADDR(QCameraInfo, availableCameras), availableCameras_stub);
globalStub.set(ADDR(QCameraInfo, isNull), isNull_stub);
globalStub.set(ADDR(QMediaDevices, availableCameras), availableCameras_stub);
globalStub.set(ADDR(QCameraDevice, isNull), isNull_stub);
globalStub.set(get_private_fun::MainWindowsaveImg(), MainWindow_saveImg_stub);
globalStub.set(ADDR(QDBusInterface, callWithArgumentList), callWithArgumentList_stub);
//testing::GTEST_FLAG(output) = "xml:./report/report.xml";
Expand Down
9 changes: 4 additions & 5 deletions tests/ut_screen_shot_recorder/ut_button_feedback.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// 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

#pragma once
#include <gtest/gtest.h>
#include <QEventLoop>

Check warning on line 7 in tests/ut_screen_shot_recorder/ut_button_feedback.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 8 in tests/ut_screen_shot_recorder/ut_button_feedback.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>
#include <QDesktopWidget>
#include <QPixmap>
#include <QPaintEvent>
#include "stub.h"
Expand Down Expand Up @@ -75,7 +74,7 @@
access_private_field::ButtonFeedbacktimer(*buttonFeedback) = new QTimer();
buttonFeedback->showPressFeedback(50, 150);
QEventLoop loop;
QTimer::singleShot(1000, &loop, SLOT(quit()));
QTimer::singleShot(1000, &loop, [&](){ loop.quit(); });
loop.exec();
access_private_field::ButtonFeedbacktimer(*buttonFeedback)->stop();
delete access_private_field::ButtonFeedbacktimer(*buttonFeedback);
Expand All @@ -89,7 +88,7 @@
buttonFeedback->showDragFeedback(50, 150);
access_private_field::ButtonFeedbacktimer(*buttonFeedback)->start();
QEventLoop loop;
QTimer::singleShot(1000, &loop, SLOT(quit()));
QTimer::singleShot(1000, &loop, [&](){ loop.quit(); });
loop.exec();
delete access_private_field::ButtonFeedbacktimer(*buttonFeedback);
access_private_field::ButtonFeedbacktimer(*buttonFeedback) = nullptr;
Expand All @@ -102,7 +101,7 @@
access_private_field::ButtonFeedbacktimer(*buttonFeedback) = new QTimer();
buttonFeedback->showReleaseFeedback(50, 150);
QEventLoop loop;
QTimer::singleShot(1000, &loop, SLOT(quit()));
QTimer::singleShot(1000, &loop, [&](){ loop.quit(); });
loop.exec();
access_private_field::ButtonFeedbacktimer(*buttonFeedback)->stop();
delete access_private_field::ButtonFeedbacktimer(*buttonFeedback);
Expand Down
7 changes: 3 additions & 4 deletions tests/ut_screen_shot_recorder/ut_countdown_tooltip.h
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 @@ -7,7 +7,6 @@
#include <QTest>
#include <QObject>
#include <QScreen>
#include <QDesktopWidget>
#include <QDebug>
#include <QPainter>
#include "stub.h"
Expand Down Expand Up @@ -45,7 +44,7 @@ TEST_F(CountdownTooltipTest, start)
m_countTip->show();
m_countTip->start();
QEventLoop loop;
QTimer::singleShot(5000, &loop, SLOT(quit()));
QTimer::singleShot(5000, &loop, [&](){ loop.quit(); });
loop.exec();
}
void CountdownTooltipTest::startRecord()
Expand All @@ -58,7 +57,7 @@ QPixmap getFullscreenPixmap_stub()

QScreen *t_primaryScreen = QGuiApplication::primaryScreen();
// 在多屏模式下, winId 不是0
return t_primaryScreen->grabWindow(QApplication::desktop()->winId(), 0, 0, 1920, 1080);
return t_primaryScreen->grabWindow(0, 0, 0, 1920, 1080);

}

Expand Down
Loading
Loading