From ec12eb265e8eb4bfa4502bb449c85a851f2f41d0 Mon Sep 17 00:00:00 2001
From: "transifex-integration[bot]"
<43880903+transifex-integration[bot]@users.noreply.github.com>
Date: Sat, 21 Sep 2024 10:32:48 +0800
Subject: [PATCH 01/13] [deepin-terminal] Updates for project Deepin Terminal
(#362)
* [skip CI] Translate deepin-terminal.ts in gl_ES
70% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
71% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
71% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
72% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
73% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
73% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
74% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
74% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
75% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
76% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
76% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
77% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
77% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
78% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
78% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
79% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
79% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
80% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
80% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
80% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
81% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
82% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
82% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
84% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
84% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
85% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
85% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
86% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
86% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
87% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
88% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
89% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
90% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
90% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
91% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
92% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
92% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
93% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
93% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
93% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
94% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
94% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
95% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
95% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
96% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
96% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
97% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
97% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
97% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
98% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
98% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
99% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
99% of minimum 50% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
Sync of partially translated files:
untranslated content is included with an empty translation
or source language content depending on file format
* [skip CI] Translate deepin-terminal.ts in gl_ES
100% translated source file: 'deepin-terminal.ts'
on 'gl_ES'.
---------
Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
---
translations/deepin-terminal_gl_ES.ts | 134 +++++++++++++-------------
1 file changed, 67 insertions(+), 67 deletions(-)
diff --git a/translations/deepin-terminal_gl_ES.ts b/translations/deepin-terminal_gl_ES.ts
index ab9cad7ba..a93f88c45 100644
--- a/translations/deepin-terminal_gl_ES.ts
+++ b/translations/deepin-terminal_gl_ES.ts
@@ -94,7 +94,7 @@
No commands yet
-
+ Aínda non hai comandos
@@ -118,12 +118,12 @@
Custom Theme
-
+ Tema personalizado
Style:
-
+ Estilo:
@@ -138,22 +138,22 @@
Fore color:
-
+ Cor dianteira:
Back color:
-
+ Cor traseira:
Prompt PS1:
-
+ Pregunta PS1:
Prompt PS2:
-
+ Pregunta PS2:
@@ -173,17 +173,17 @@
Group Name(Required)
-
+ Nome do grupo (requerido)
Add Group
-
+ Engadir grupo
Edit Group
-
+ Editar grupo
@@ -203,12 +203,12 @@
Please enter a group name
-
+ Insira un nome de grupo
The name should be no more than 30 characters
-
+ O nome non debe ter máis de 30 caracteres
@@ -221,17 +221,17 @@
Delete Custom Command
-
+ Eliminar comando personalizado
Cancel Server Group
-
+ Cancelar grupo de servidores
Ungrouped servers will go back to server list!
-
+ Os servidores desagrupados volverán á lista de servidores.
@@ -273,7 +273,7 @@
Custom Theme
-
+ Tema personalizado
@@ -311,7 +311,7 @@
Quake window animation speed
-
+ Velocidade de animación da xanela Quake
@@ -415,122 +415,122 @@
New tab
-
+ Nova lapela
Next tab
-
+ Seguinte lapela
Previous tab
-
+ Lapela anterior
Select left workspace
-
+ Selecciona o espazo de traballo esquerdo
Select lower workspace
-
+ Selecciona o espazo de traballo inferior
Select right workspace
-
+ Selecciona o espazo de traballo dereito
Select upper workspace
-
+ Seleccione o espazo de traballo superior
Tab titles
-
+ Títulos das lapelas
Go to tab 1
-
+ Ir á lapela 1
Go to tab 2
-
+ Ir á lapela 2
Go to tab 3
-
+ Ir á lapela 3
Go to tab 4
-
+ Ir á lapela 4
Go to tab 5
-
+ Ir á lapela 5
Go to tab 6
-
+ Ir á lapela 6
Go to tab 7
-
+ Ir á lapela 7
Go to tab 8
-
+ Ir á lapela 8
Go to tab 9
-
+ Ir á lapela 9
Disable flow control using Ctrl+S, Ctrl+Q
-
+ Desactive o control de fluxo usando Ctrl+S, Ctrl+Q
Shell profile
-
+ Perfil de Shell
History size
-
+ Tamaño da historia
Include special character(s) in double click selections
-
+ Inclúe caractere(s) especiais nas seleccións de dobre clic
@@ -612,22 +612,22 @@
Could not find "%1", starting "%2" instead. Please check your shell profile.
-
+ Non foi posíbel atopar "% 1", comezando "% 2" no seu lugar. Comproba o teu perfil de shell.
Could not open "%1", unable to run it
-
+ Non foi posíbel abrir "% 1", non foi posíbel executalo
Could not find "%1", unable to run it
-
+ Non foi posíbel atopar "% 1", non foi posíbel executalo
Output has been suspended by pressing Ctrl+S. Pressing Ctrl+Q to resume.
-
+ A saída suspendeuse premendo Ctrl+S. Prema Ctrl+Q para retomar.
@@ -674,23 +674,23 @@
Tabs
-
+ Lapelas
Close tab
-
+ Pechar lapela
Select tab
-
+ Seleccionar lapela
Switch focus to "+" icon
-
+ Cambia o foco á icona "+".
@@ -719,13 +719,13 @@
There is still a process running in this terminal. Closing the terminal will terminate it.
-
+ Aínda hai un proceso en execución neste terminal. Ao pechar o terminal finalizarase.
There are still %1 processes running in this terminal. Closing the terminal will terminate all of them.
-
+ Aínda hai %1 procesos en execución neste terminal. Pechar o terminal dará todos por finalizados.
@@ -737,7 +737,7 @@
There are still processes running in this window. Closing the window will terminate all of them.
-
+ Aínda hai procesos en execución nesta xanela. Ao pechar a xanela rematará con todos.
@@ -830,19 +830,19 @@
Tab title format
-
+ Fomato do título da lapela
Remote tab title format
-
+ Formato de título da lapela remota
Close other tabs
-
+ Pechar outras lapelas
@@ -863,7 +863,7 @@
Add Group
-
+ Engadir grupo
@@ -873,7 +873,7 @@
No servers yet
-
+ Ainda non hai servidores
@@ -902,12 +902,12 @@
Groups
-
+ Grupos
Servers
-
+ Servidores
@@ -1101,55 +1101,55 @@
Insert
-
+ Insirir
username: %u
-
+ nome de usuario: %u
username@: %U
-
+ nome de usuario/a: %U
remote host: %h
-
+ host remoto: %h
session number: %#
-
+ número de sesión: %#
title set by shell: %w
-
+ título definido por shell: %w
program name: %n
-
+ nome de programa: %n
current directory (short): %d
-
+ directorio actual (curto): %d
current directory (long): %D
-
+ directorio actual (longo): %D
local host: %h
-
+ host local: %h
@@ -1190,7 +1190,7 @@
New tab
-
+ Nova lapela
From 2712168f56377e338a6b0adec095d639c3c0628e Mon Sep 17 00:00:00 2001
From: Hualet Wang
Date: Sun, 29 Sep 2024 20:52:05 +0800
Subject: [PATCH 02/13] chore: remove useless unit tests (#361)
remove useless unit tests, low-carbon and environmentally friendly
---
CMakeLists.txt | 7 +-
tests/CMakeLists.txt | 157 --
tests/cmake-lcov-test.sh | 31 -
.../terminalwidget/lib/qtermwidget_export.h | 46 -
tests/src/common/ut_defines.h | 91 -
tests/src/common/ut_settingio_test.cpp | 97 -
tests/src/common/ut_settingio_test.h | 33 -
tests/src/common/ut_stub_defines.h | 377 ----
tests/src/common/ut_utils_test.cpp | 383 ----
tests/src/common/ut_utils_test.h | 32 -
.../ut_customcommandoptdlg_test.cpp | 311 ----
.../ut_customcommandoptdlg_test.h | 35 -
.../ut_customcommandpanel_test.cpp | 142 --
.../ut_customcommandplugin_test.cpp | 83 -
.../ut_customcommandplugin_test.h | 31 -
.../ut_customcommandsearchrstpanel_test.cpp | 100 --
.../ut_customcommandsearchrstpanel_test.h | 37 -
.../ut_customcommandtoppanel_test.cpp | 73 -
.../ut_customcommandtoppanel_test.h | 36 -
.../encodeplugin/ut_encodelistview_test.cpp | 245 ---
.../src/encodeplugin/ut_encodepanel_test.cpp | 52 -
tests/src/encodeplugin/ut_encodepanel_test.h | 37 -
tests/src/main/main.cpp | 47 -
tests/src/main/ut_dbusmanager_test.cpp | 89 -
tests/src/main/ut_dbusmanager_test.h | 30 -
tests/src/main/ut_mainwindow_test.cpp | 1579 -----------------
tests/src/main/ut_mainwindow_test.h | 70 -
tests/src/main/ut_service_test.cpp | 380 ----
tests/src/main/ut_service_test.h | 35 -
.../src/main/ut_terminalapplication_test.cpp | 114 --
tests/src/main/ut_terminalapplication_test.h | 31 -
tests/src/main/ut_termproperties_test.cpp | 63 -
tests/src/main/ut_termproperties_test.h | 29 -
tests/src/main/ut_windowsmanager_test.cpp | 225 ---
tests/src/main/ut_windowsmanager_test.h | 38 -
.../ut_remotemanagementpanel_test.cpp | 378 ----
.../ut_remotemanagementpanel_test.h | 36 -
.../ut_remotemanagementplugn_test.cpp | 205 ---
.../ut_remotemanagementplugn_test.h | 36 -
.../ut_remotemanagementsearchpanel_test.cpp | 289 ---
.../ut_remotemanagementsearchpanel_test.h | 36 -
.../ut_remotemanagementtoppanel_test.cpp | 220 ---
.../ut_remotemanagementtoppanel_test.h | 36 -
.../ut_serverconfiggrouppanel_test.cpp | 248 ---
.../ut_serverconfiggrouppanel_test.h | 36 -
.../ut_serverconfigmanager_test.cpp | 225 ---
.../ut_serverconfigmanager_test.h | 30 -
.../ut_serverconfigoptdlg_test.cpp | 174 --
.../remotemanage/ut_serverconfigoptdlg_test.h | 28 -
tests/src/settings/ut_newdspinbox_test.cpp | 81 -
tests/src/settings/ut_newdspinbox_test.h | 31 -
tests/src/settings/ut_settings_test.cpp | 230 ---
.../src/settings/ut_shortcutmanager_test.cpp | 136 --
tests/src/settings/ut_shortcutmanager_test.h | 33 -
tests/src/stub.h | 295 ---
.../ut_customthemesettingdialog_test.cpp | 357 ----
.../views/ut_customthemesettingdialog_test.h | 36 -
tests/src/views/ut_focusframe_test.cpp | 88 -
tests/src/views/ut_focusframe_test.h | 29 -
tests/src/views/ut_iconbutton_test.cpp | 103 --
tests/src/views/ut_iconbutton_test.h | 29 -
tests/src/views/ut_itemwidget_test.cpp | 365 ----
tests/src/views/ut_itemwidget_test.h | 29 -
tests/src/views/ut_listview_test.cpp | 326 ----
tests/src/views/ut_listview_test.h | 29 -
tests/src/views/ut_pagesearchbar_test.cpp | 131 --
tests/src/views/ut_pagesearchbar_test.h | 37 -
tests/src/views/ut_tabbar_test.cpp | 546 ------
tests/src/views/ut_tabbar_test.h | 33 -
tests/src/views/ut_tabrenamedlg_test.cpp | 31 -
tests/src/views/ut_tabrenamedlg_test.h | 32 -
tests/src/views/ut_tabrenamewidget_test.cpp | 73 -
tests/src/views/ut_tabrenamewidget_test.h | 30 -
tests/src/views/ut_termwidget_test.cpp | 1002 -----------
tests/src/views/ut_termwidget_test.h | 30 -
tests/src/views/ut_termwidgetpage_test.cpp | 468 -----
tests/src/views/ut_termwidgetpage_test.h | 35 -
tests/src/views/ut_titlebar_test.cpp | 89 -
tests/src/views/ut_titlebar_test.h | 28 -
tests/test-prj-running.sh | 40 -
80 files changed, 1 insertion(+), 11944 deletions(-)
delete mode 100644 tests/CMakeLists.txt
delete mode 100644 tests/cmake-lcov-test.sh
delete mode 100644 tests/src/3rdparty/terminalwidget/lib/qtermwidget_export.h
delete mode 100644 tests/src/common/ut_defines.h
delete mode 100644 tests/src/common/ut_settingio_test.cpp
delete mode 100644 tests/src/common/ut_settingio_test.h
delete mode 100644 tests/src/common/ut_stub_defines.h
delete mode 100644 tests/src/common/ut_utils_test.cpp
delete mode 100644 tests/src/common/ut_utils_test.h
delete mode 100644 tests/src/customcommand/ut_customcommandoptdlg_test.cpp
delete mode 100644 tests/src/customcommand/ut_customcommandoptdlg_test.h
delete mode 100644 tests/src/customcommand/ut_customcommandpanel_test.cpp
delete mode 100644 tests/src/customcommand/ut_customcommandplugin_test.cpp
delete mode 100644 tests/src/customcommand/ut_customcommandplugin_test.h
delete mode 100644 tests/src/customcommand/ut_customcommandsearchrstpanel_test.cpp
delete mode 100644 tests/src/customcommand/ut_customcommandsearchrstpanel_test.h
delete mode 100644 tests/src/customcommand/ut_customcommandtoppanel_test.cpp
delete mode 100644 tests/src/customcommand/ut_customcommandtoppanel_test.h
delete mode 100644 tests/src/encodeplugin/ut_encodelistview_test.cpp
delete mode 100644 tests/src/encodeplugin/ut_encodepanel_test.cpp
delete mode 100644 tests/src/encodeplugin/ut_encodepanel_test.h
delete mode 100644 tests/src/main/main.cpp
delete mode 100644 tests/src/main/ut_dbusmanager_test.cpp
delete mode 100644 tests/src/main/ut_dbusmanager_test.h
delete mode 100644 tests/src/main/ut_mainwindow_test.cpp
delete mode 100644 tests/src/main/ut_mainwindow_test.h
delete mode 100644 tests/src/main/ut_service_test.cpp
delete mode 100644 tests/src/main/ut_service_test.h
delete mode 100644 tests/src/main/ut_terminalapplication_test.cpp
delete mode 100644 tests/src/main/ut_terminalapplication_test.h
delete mode 100644 tests/src/main/ut_termproperties_test.cpp
delete mode 100644 tests/src/main/ut_termproperties_test.h
delete mode 100644 tests/src/main/ut_windowsmanager_test.cpp
delete mode 100644 tests/src/main/ut_windowsmanager_test.h
delete mode 100644 tests/src/remotemanage/ut_remotemanagementpanel_test.cpp
delete mode 100644 tests/src/remotemanage/ut_remotemanagementpanel_test.h
delete mode 100644 tests/src/remotemanage/ut_remotemanagementplugn_test.cpp
delete mode 100644 tests/src/remotemanage/ut_remotemanagementplugn_test.h
delete mode 100644 tests/src/remotemanage/ut_remotemanagementsearchpanel_test.cpp
delete mode 100644 tests/src/remotemanage/ut_remotemanagementsearchpanel_test.h
delete mode 100644 tests/src/remotemanage/ut_remotemanagementtoppanel_test.cpp
delete mode 100644 tests/src/remotemanage/ut_remotemanagementtoppanel_test.h
delete mode 100644 tests/src/remotemanage/ut_serverconfiggrouppanel_test.cpp
delete mode 100644 tests/src/remotemanage/ut_serverconfiggrouppanel_test.h
delete mode 100644 tests/src/remotemanage/ut_serverconfigmanager_test.cpp
delete mode 100644 tests/src/remotemanage/ut_serverconfigmanager_test.h
delete mode 100644 tests/src/remotemanage/ut_serverconfigoptdlg_test.cpp
delete mode 100644 tests/src/remotemanage/ut_serverconfigoptdlg_test.h
delete mode 100644 tests/src/settings/ut_newdspinbox_test.cpp
delete mode 100644 tests/src/settings/ut_newdspinbox_test.h
delete mode 100644 tests/src/settings/ut_settings_test.cpp
delete mode 100644 tests/src/settings/ut_shortcutmanager_test.cpp
delete mode 100644 tests/src/settings/ut_shortcutmanager_test.h
delete mode 100644 tests/src/stub.h
delete mode 100644 tests/src/views/ut_customthemesettingdialog_test.cpp
delete mode 100644 tests/src/views/ut_customthemesettingdialog_test.h
delete mode 100644 tests/src/views/ut_focusframe_test.cpp
delete mode 100644 tests/src/views/ut_focusframe_test.h
delete mode 100644 tests/src/views/ut_iconbutton_test.cpp
delete mode 100644 tests/src/views/ut_iconbutton_test.h
delete mode 100644 tests/src/views/ut_itemwidget_test.cpp
delete mode 100644 tests/src/views/ut_itemwidget_test.h
delete mode 100644 tests/src/views/ut_listview_test.cpp
delete mode 100644 tests/src/views/ut_listview_test.h
delete mode 100644 tests/src/views/ut_pagesearchbar_test.cpp
delete mode 100644 tests/src/views/ut_pagesearchbar_test.h
delete mode 100644 tests/src/views/ut_tabbar_test.cpp
delete mode 100644 tests/src/views/ut_tabbar_test.h
delete mode 100644 tests/src/views/ut_tabrenamedlg_test.cpp
delete mode 100644 tests/src/views/ut_tabrenamedlg_test.h
delete mode 100644 tests/src/views/ut_tabrenamewidget_test.cpp
delete mode 100644 tests/src/views/ut_tabrenamewidget_test.h
delete mode 100644 tests/src/views/ut_termwidget_test.cpp
delete mode 100644 tests/src/views/ut_termwidget_test.h
delete mode 100644 tests/src/views/ut_termwidgetpage_test.cpp
delete mode 100644 tests/src/views/ut_termwidgetpage_test.h
delete mode 100644 tests/src/views/ut_titlebar_test.cpp
delete mode 100644 tests/src/views/ut_titlebar_test.h
delete mode 100644 tests/test-prj-running.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c6fcb401..d71b2aba5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -276,9 +276,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-terminal
install(FILES ${DTNG_QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-terminal/translations)
install(DIRECTORY src/assets/deepin-terminal
- DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-manual/manual-assets/application/)
-
-# Unit Test
-if (CMAKE_BUILD_TYPE MATCHES Debug)
- add_subdirectory(tests)
-endif()
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-manual/manual-assets/application/)
\ No newline at end of file
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
deleted file mode 100644
index d51eaab8f..000000000
--- a/tests/CMakeLists.txt
+++ /dev/null
@@ -1,157 +0,0 @@
-# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-
-project(deepin-terminal-test)
-
-configure_file(../src/environments.h.in environments.h @ONLY)
-
-# 设置添加gocv相关信息的输出
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage -fno-inline")
-#安全编译参数
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong -D_FORTITY_SOURCE=1 -z noexecstack -pie -fPIC -z lazy")
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(PROJECT_NAME_TEST ${PROJECT_NAME})
-
-add_compile_options(-fno-access-control)
-
-find_package(Qt5Test REQUIRED)
-find_package(GTest REQUIRED)
-
-add_definitions(${Qt5Test_DEFINITIONS})
-add_definitions(-D UNIT_TEST)
-
-include_directories(${GTEST_INCLUDE_DIRS})
-include_directories("src/common")
-include_directories("src/customcommand")
-include_directories("src/encodeplugin")
-include_directories("src/remotemanage")
-include_directories("src/views")
-include_directories("src/main")
-include_directories("src/3rdparty/terminalwidget/lib/")
-include_directories("src/3rdparty/terminalwidget/lib/history")
-include_directories("src/3rdparty/terminalwidget/lib/history/compact")
-
-FILE(GLOB allSource
- ../src/common/*.cpp
- ../src/customcommand/*.cpp
- ../src/encodeplugin/*.cpp
- ../src/remotemanage/*.cpp
- ../src/settings/*.cpp
- ../src/views/*.cpp
- ../src/main/service.cpp
- ../src/main/windowsmanager.cpp
- ../src/main/mainwindow.cpp
- ../src/main/terminalapplication.cpp
- ../src/main/termproperties.cpp
- ../src/main/dbusmanager.cpp
-)
-
-FILE(GLOB allHeaders
- ../src/common/*.h
- ../src/customcommand/*.h
- ../src/encodeplugin/*.h
- ../src/main/*.h
- ../src/remotemanage/*.h
- ../src/settings/*.h
- ../src/views/*.h
-)
-
-FILE(GLOB allThirdPartySource
- ../3rdparty/terminalwidget/lib/*.cpp
- ../3rdparty/terminalwidget/lib/history/*.cpp
- ../3rdparty/terminalwidget/lib/history/compact/*.cpp
-)
-
-FILE(GLOB qrcFiles
- ../src/assets/resources.qrc
-)
-
-FILE(GLOB allTestHeader
- src/common/*.h
- src/customcommand/*.h
- src/encodeplugin/*.h
- src/main/*.h
- src/remotemanage/*.h
- src/settings/*.h
- src/views/*.h
- src/3rdparty/terminalwidget/lib/*.h
-)
-
-FILE(GLOB allTestSource
- src/common/*.cpp
- src/customcommand/*.cpp
- src/encodeplugin/*.cpp
- src/main/*.cpp
- src/remotemanage/*.cpp
- src/settings/*.cpp
- src/views/*.cpp
-)
-
-set(UI ../3rdparty/terminalwidget/lib/SearchBar.ui)
-qt5_wrap_ui(UI_SRCS ${UI})
-
-set(KB_LAYOUT_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${TERMINALWIDGET_LIBRARY_NAME}/kb-layouts")
-set(COLORSCHEMES_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${TERMINALWIDGET_LIBRARY_NAME}/color-schemes")
-set(TRANSLATIONS_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${TERMINALWIDGET_LIBRARY_NAME}/translations")
-
-add_definitions("-DHAVE_POSIX_OPENPT")
-add_definitions("-DKB_LAYOUT_DIR=\"${KB_LAYOUT_DIR}\"")
-add_definitions("-DCOLORSCHEMES_DIR=\"${COLORSCHEMES_DIR}\"")
-add_definitions("-DTRANSLATIONS_DIR=\"${TRANSLATIONS_DIR}\"")
-
-add_executable(${PROJECT_NAME_TEST}
- ${UI_SRCS}
- ${allThirdPartySource}
- ${allHeaders}
- ${allSource}
- ${allTestHeader}
- ${allTestSource}
- ${qrcFiles}
- ${uiFiles}
-)
-
-target_include_directories(${PROJECT_NAME_TEST} PUBLIC ${Qt5Widgets_LIBRARIES}
- ${Qt5DBus_LIBRARIES}
- ${Qt5TestLib_LIBRARIES}
- ${Qt5Widgets_PRIVATE_INCLUDE_DIRS}
- ${Qt5Core_PRIVATE_INCLUDE_DIRS}
- ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
- ${PROJECT_BINARY_DIR}
- ${DtkWidget_INCLUDE_DIRS}
- ${DtkCore_LIBRARIES}
- ${DtkGUI_INCLUDE_DIRS}
- ${GOBJECT_INCLUDE_DIRS}
- ${LIBSECRET_INCLUDE_DIRS})
-
-target_link_libraries(${PROJECT_NAME_TEST} PUBLIC ${LINK_LIBS} Qt5::Test ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} -lpthread -lm)
-
-#------------------------------ 创建'make test'指令---------------------------------------
-add_custom_target(test
-# #执行mkdir -p 创建 coverageResult
-# COMMAND mkdir -p coverageResult
-# #设置工作目录
-# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-)
-
-add_custom_command(TARGET test
- COMMAND ${CMAKE_BINARY_DIR}/tests/${PROJECT_NAME_TEST}
-)
-
-#'make test'命令依赖与我们的测试程序
-add_dependencies(test ${PROJECT_NAME_TEST})
-
-#ASAN安全性检测标志
-set(CMAKE_SAFETYTEST "${CMAKE_SAFETYTEST_ARG}")
-if(CMAKE_SAFETYTEST STREQUAL "")
- set(CMAKE_SAFETYTEST "CMAKE_SAFETYTEST_ARG_OFF")
-endif()
-
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${CMAKE_SAFETYTEST}")
-if(CMAKE_SAFETYTEST STREQUAL "CMAKE_SAFETYTEST_ARG_ON")
- #安全测试选项
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=undefined,address -O2")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=undefined,address -O2")
-endif()
-
diff --git a/tests/cmake-lcov-test.sh b/tests/cmake-lcov-test.sh
deleted file mode 100644
index 7ed8fb360..000000000
--- a/tests/cmake-lcov-test.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-
-utdir=build-ut
-rm -r $utdir
-rm -r ../$utdir
-mkdir ../$utdir
-cd ../$utdir
-
-cmake -DCMAKE_BUILD_TYPE=Debug ..
-make -j16
-
-workdir=$(cd ../$(dirname $0)/$utdir; pwd)
-
-app_name=deepin-terminal-test
-
-mkdir -p report
-
-./tests/$app_name --gtest_output=xml:./report/report.xml
-
-lcov -d $workdir -c -o ./report/coverage.info
-
-#以下几行是过滤一些我们不感兴趣的文件的覆盖率信息
-lcov --extract ./report/coverage.info '*/src/*' -o ./report/coverage.info
-
-lcov --remove ./report/coverage.info '*/tests/*' -o ./report/coverage.info
-
-genhtml -o ./report ./report/coverage.info
-
-exit 0
diff --git a/tests/src/3rdparty/terminalwidget/lib/qtermwidget_export.h b/tests/src/3rdparty/terminalwidget/lib/qtermwidget_export.h
deleted file mode 100644
index a457e3b18..000000000
--- a/tests/src/3rdparty/terminalwidget/lib/qtermwidget_export.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef TERMINALWIDGET_EXPORT_H
-#define TERMINALWIDGET_EXPORT_H
-
-#ifdef TERMINALWIDGET5_STATIC_DEFINE
-# define TERMINALWIDGET_EXPORT
-# define TERMINALWIDGET5_NO_EXPORT
-#else
-# ifndef TERMINALWIDGET_EXPORT
-# ifdef terminalwidget5_EXPORTS
- /* We are building this library */
-# define TERMINALWIDGET_EXPORT __attribute__((visibility("default")))
-# else
- /* We are using this library */
-# define TERMINALWIDGET_EXPORT __attribute__((visibility("default")))
-# endif
-# endif
-
-# ifndef TERMINALWIDGET5_NO_EXPORT
-# define TERMINALWIDGET5_NO_EXPORT __attribute__((visibility("hidden")))
-# endif
-#endif
-
-#ifndef TERMINALWIDGET5_DEPRECATED
-# define TERMINALWIDGET5_DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-#ifndef TERMINALWIDGET5_DEPRECATED_EXPORT
-# define TERMINALWIDGET5_DEPRECATED_EXPORT TERMINALWIDGET_EXPORT TERMINALWIDGET5_DEPRECATED
-#endif
-
-#ifndef TERMINALWIDGET5_DEPRECATED_NO_EXPORT
-# define TERMINALWIDGET5_DEPRECATED_NO_EXPORT TERMINALWIDGET5_NO_EXPORT TERMINALWIDGET5_DEPRECATED
-#endif
-
-#if 0 /* DEFINE_NO_DEPRECATED */
-# ifndef TERMINALWIDGET5_NO_DEPRECATED
-# define TERMINALWIDGET5_NO_DEPRECATED
-# endif
-#endif
-
-#endif /* TERMINALWIDGET_EXPORT_H */
diff --git a/tests/src/common/ut_defines.h b/tests/src/common/ut_defines.h
deleted file mode 100644
index 8cbc29ca9..000000000
--- a/tests/src/common/ut_defines.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_DEFINES_TEST_H
-#define UT_DEFINES_TEST_H
-
-//UI测试等待时间间隔
-#define UT_WAIT_TIME 10
-
-//是否开启UI测试
-#define ENABLE_UI_TEST
-
-#define UT_UTILS_TEST
-#define UT_SETTINGIO_TEST
-
-#define UT_ENCODELISTVIEW_TEST
-#define UT_ENCODEPANEL_TEST
-
-//#define UT_SWITCHTHEMEMENU_TEST
-//#define UT_MAINWINDOW_TEST
-#define UT_SERVICE_TEST
-#define UT_TERMPROPERTIES_TEST
-#define UT_TERMINALAPPLICATION_TEST
-#define UI_WINDOWSMANAGER_TEST
-
-#define UT_SERVERCONFIGMANAGER_TEST
-#define UT_SERVERCONFIGGROUPPANEL_TEST
-#define UT_REMOTEMANAGEMENTTOPPANEL_TEST
-#define UT_REMOTEMANAGEMENTSEARCHPANEL_TEST
-#define UT_REMOTEMANAGEMENTPLUGIN_TEST
-#define UT_REMOTEMANAGEMENTPANEL_TEST
-#define UT_SERVERCONFIGOPTDLG_TEST
-
-#define UT_SETTINGS_TEST
-#define UT_SHORTCUTMANAGER_TEST
-
-#define UT_THEMELISTVIEW_TEST
-#define UT_THEMEPANEL_TEST
-
-#define UT_LISTVIEW_TEST
-#define UT_TABBAR_TEST
-#define UT_ICONBUTTON_TEST
-#define UT_MYICONBUTTON_TEST
-#define UT_FOCUSFRAME_TEST
-#define UT_ITEMWIDGET_TEST
-#define UT_MYICONBUTTON_TEST
-#define UT_OPERATIONCONFIRMDLG_TEST
-#define UT_TERMINPUTDIALOG_TEST
-#define UT_NEWDSPINBOX_TEST
-#define UT_CUSTOMTHEMESETTINGDIALOG_TEST
-#define UT_TITLE_STYLE_RADIOBUTTON_TEST
-#define UT_COLOR_PUSHBUTTON_TEST
-
-#define UT_DBUSMANAGER_TEST
-
-#define UT_TERMWIDGETPAGE_TEST
-#define UT_TERMWIDGET_TEST
-#define UT_TITLEBAR_TEST
-#define UT_PAGESEARCHBAR_TEST
-
-#define UT_CUSTOMCOMMANDOPTDLG_TEST
-#define UT_CUSTOMCOMMANDPANEL_TEST
-#define UT_CUSTOMCOMMANDPLUGIN_TEST
-#define UT_CUSTOMCOMMANDSEARCHRSTPANEL_TEST
-#define UT_CUSTOMCOMMANDTOPPANEL_TEST
-
-#define UT_TERMARGUMENTPARSER_TEST
-
-//第三方库 QTermWidget 单元测试开关
-#define UT_TERMINALDISPLAY_TEST
-#define UT_VT102EMULATION_TEST
-#define UT_SHELLCOMMAND_TEST
-#define UT_SESSION_TEST
-#define UT_SCREEN_TEST
-#define UT_PTY_TEST
-#define UT_HISTORY_TEST
-#define UT_CHARACTER_TEST
-#define UT_CHARACTERCOLOR_TEST
-#define UT_COLORSCHEME_TEST
-#define UT_QTERMWIDGET_TEST
-#define UT_FILTER_TEST
-#define UT_BLOCKARRAY_TEST
-#define UT_SEARCHBAR_TEST
-#define UT_KEYBOARDTRANSLATOR_TEST
-#define UT_KPROCESS_TEST
-#define UT_KPTY_TEST
-
-#endif // UT_DEFINES_TEST_H
-
diff --git a/tests/src/common/ut_settingio_test.cpp b/tests/src/common/ut_settingio_test.cpp
deleted file mode 100644
index 5818d148c..000000000
--- a/tests/src/common/ut_settingio_test.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_settingio_test.h"
-#include "settingio.h"
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-
-//DTK相关头文件
-#include
-
-//Google GTest
-#include
-
-//system
-#include
-#include
-
-DWIDGET_USE_NAMESPACE
-
-UT_SettingIO_Test::UT_SettingIO_Test()
-{
-
-}
-
-void UT_SettingIO_Test::SetUp()
-{
-}
-
-void UT_SettingIO_Test::TearDown()
-{
-}
-
-#ifdef UT_SETTINGIO_TEST
-
-/*******************************************************************************
- 1. @函数: canTransferTest
- 2. @作者: ut000125 孙成熙
- 3. @日期: 2020-12-15
- 4. @说明: canTransfer函数测试
-*******************************************************************************/
-TEST_F(UT_SettingIO_Test, canTransferTest)
-{
- //"%U4E2D%U56FD%U4EBA" Unicode编码 对应中文为"中国人"
- QString strUnicode = "%U4E2D%U56FD%U4EBA";
- QString strResut = SettingIO::canTransfer(strUnicode);
- EXPECT_EQ(strResut, QString("中国人"));
- qDebug() << strResut;
-
- //"%%E4%B8%AD%E5%9B%BD%E4%BA%BA"Latin1格式的字符串 编码 对应中文为"中国人"
- QString strLatin1 = "%E4%B8%AD%E5%9B%BD%E4%BA%BA";
- strResut = SettingIO::canTransfer(strLatin1);
- EXPECT_EQ(strResut, QString("中国人"));
- qDebug() << strResut;
-}
-
-/*******************************************************************************
- 1. @函数: canTransferTest
- 2. @作者: ut000125 孙成熙
- 3. @日期: 2020-12-15
- 4. @说明: escapedString函数测试
-*******************************************************************************/
-TEST_F(UT_SettingIO_Test, escapedStringTest)
-{
- QString strTest = "a;b,c=d#e\\0";
- QString strResut = SettingIO::escapedString(strTest);
- EXPECT_EQ(strResut, "\"a;b,c=d#e\\\\0\"");
- qDebug() << strResut;
-
- strTest = "!@#$%^&*()-+=\???bB0\n\r\t\\\0\0";
- strResut = SettingIO::escapedString(strTest);
- EXPECT_EQ(strResut, "\"!@#$%^&*()-+=???bB0\\n\\r\\t\\\\\"");
- qDebug() << strResut;
-}
-
-/*******************************************************************************
- 1. @函数: unescapedStringTest
- 2. @作者: ut000125 孙成熙
- 3. @日期: 2020-12-15
- 4. @说明: unescapedString函数测试
-*******************************************************************************/
-TEST_F(UT_SettingIO_Test, unescapedStringTest)
-{
- QString strTest = "123\1?\\t\\x1Bb\a\t ";
- QString strResut = SettingIO::unescapedString(strTest);
- EXPECT_EQ(strResut, "123\u0001?\tƻ\u0007\t ");
- qDebug() << strResut;
-}
-
-#endif
diff --git a/tests/src/common/ut_settingio_test.h b/tests/src/common/ut_settingio_test.h
deleted file mode 100644
index d7a84029f..000000000
--- a/tests/src/common/ut_settingio_test.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_SETTINGIO_TEST_H
-#define UT_SETTINGIO_TEST_H
-
-#include "ut_defines.h"
-
-#include
-/*******************************************************************************
- 1. @类名: UT_SettingIO_Test
- 2. @作者: ut000125 孙成熙
- 3. @日期: 2020-12-15
- 4. @说明: SettingIO类测试
-*******************************************************************************/
-class UT_SettingIO_Test : public ::testing::Test
-{
-public:
- UT_SettingIO_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-};
-
-#endif // UT_SETTINGIO_TEST_H
diff --git a/tests/src/common/ut_stub_defines.h b/tests/src/common/ut_stub_defines.h
deleted file mode 100644
index 5eb949e4c..000000000
--- a/tests/src/common/ut_stub_defines.h
+++ /dev/null
@@ -1,377 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_STUB_DEFINES_H
-#define UT_STUB_DEFINES_H
-
-#include "../stub.h"
-
-#include
-#include
-#include
-#include
-
-class ut_stub_defines
-{
-public:
- ut_stub_defines();
-};
-
-/**
- * 本文件为打桩函数的相关整理,通过RESULT来判断 函数是否被触发
- * ut_CLASS_function 如:ut_QDBusMessage_call 函数:打桩函数
- * ut_CLASS_function_hasRuned 如:ut_QDBusMessage_call_hasRuned 变量:函数是否触发
- * UT_STUB_CLASS_FUNCTION_CREATE 如:UT_STUB_QDBUS_CALL_CREATE 宏:实例化打桩函数
- * UT_STUB_CLASS_FUNCTION_APPEND 如:UT_STUB_QDBUS_CALL_APPEND 宏:只添加stub.set部分
- * UT_STUB_CLASS_FUNCTION_RESULT 如:UT_STUB_QDBUS_CALL_RESULT 宏:函数是否被触发
- * UT_STUB_CLASS_FUNCTION_PREPARE 如:UT_STUB_QDBUS_CALL_PREPARE 宏:初始化hasRuned变量
- */
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QDBusMessage_call_hasRuned = false;
-static QDBusMessage ut_QDBusMessage_call(const QDBusMessage &, QDBus::CallMode,
- int){
- ut_QDBusMessage_call_hasRuned = true;
- return QDBusMessage();
-}
-#define UT_STUB_QDBUS_CALL_APPEND \
- stub.set((QDBusMessage (QDBusConnection::*)(QDBusMessage, QDBus::CallMode,int) const)ADDR(QDBusConnection, call),\
- ut_QDBusMessage_call);\
- ut_QDBusMessage_call_hasRuned = false;
-
-#define UT_STUB_QDBUS_CALL_CREATE\
- Stub stub;\
- UT_STUB_QDBUS_CALL_APPEND
-
-#define UT_STUB_QDBUS_CALL_RESULT ut_QDBusMessage_call_hasRuned
-#define UT_STUB_QDBUS_CALL_PREPARE ut_QDBusMessage_call_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QDBusConnection_connect_hasRuned = false;
-static bool ut_QDBusConnection_connect(const QString &, const QString &, const QString & , const QString &, QObject *, const char *){
- ut_QDBusConnection_connect_hasRuned = true;
- return true;
-}
-#define UT_STUB_QDBUS_CONNECT_APPEND \
- stub.set((bool (QDBusConnection::*)(const QString &, const QString &, const QString & , const QString &, QObject *, const char *) )ADDR(QDBusConnection, connect),\
- ut_QDBusConnection_connect);\
- ut_QDBusConnection_connect_hasRuned = false;
-
-#define UT_STUB_QDBUS_CONNECT_CREATE\
- Stub stub;\
- UT_STUB_QDBUS_CONNECT_APPEND
-
-#define UT_STUB_QDBUS_CONNECT_RESULT ut_QDBusConnection_connect_hasRuned
-#define UT_STUB_QDBUS_CONNECT_PREPARE ut_QDBusConnection_connect_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QWidget_setFocus_hasRuned = false;
-static void ut_QWidget_setFocus(Qt::FocusReason){
- ut_QWidget_setFocus_hasRuned = true;
-}
-#define UT_STUB_QWIDGET_SETFOCUS_APPEND\
- stub.set((void (QWidget::*)(Qt::FocusReason))ADDR(QWidget, setFocus), ut_QWidget_setFocus);\
- ut_QWidget_setFocus_hasRuned = false;\
-
-#define UT_STUB_QWIDGET_SETFOCUS_CREATE\
- Stub stub;\
- UT_STUB_QWIDGET_SETFOCUS_APPEND
-
-#define UT_STUB_QWIDGET_SETFOCUS_RESULT ut_QWidget_setFocus_hasRuned
-#define UT_STUB_QWIDGET_SETFOCUS_PREPARE ut_QWidget_setFocus_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QWidget_update_hasRuned = false;
-static void ut_QWidget_update(){
- ut_QWidget_update_hasRuned = true;
-}
-#define UT_STUB_QWIDGET_UPDATES_APPEND\
- stub.set((void (QWidget::*)())ADDR(QWidget, update), ut_QWidget_update);\
- ut_QWidget_update_hasRuned = false;\
-
-#define UT_STUB_QWIDGET_UPDATES_CREATE\
- Stub stub;\
- UT_STUB_QWIDGET_UPDATES_APPEND
-
-#define UT_STUB_QWIDGET_UPDATES_RESULT ut_QWidget_update_hasRuned
-#define UT_STUB_QWIDGET_UPDATES_PREPARE ut_QWidget_update_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QWidget_hasFocus_hasRuned = false;
-static bool ut_QWidget_hasFocus(){
- ut_QWidget_hasFocus_hasRuned = true;
- return true;
-}
-#define UT_STUB_QWIDGET_HASFOCUS_APPEND\
- stub.set((bool (QWidget::*)())ADDR(QWidget, hasFocus), ut_QWidget_hasFocus);\
- ut_QWidget_hasFocus_hasRuned = false;\
-
-#define UT_STUB_QWIDGET_HASFOCUS_CREATE\
- Stub stub;\
- UT_STUB_QWIDGET_HASFOCUS_APPEND
-
-#define UT_STUB_QWIDGET_HASFOCUS_RESULT ut_QWidget_hasFocus_hasRuned
-#define UT_STUB_QWIDGET_HASFOCUS_PREPARE ut_QWidget_hasFocus_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QWidget_isVisible_hasRuned = false;
-static bool ut_QWidget_isVisible(){
- ut_QWidget_isVisible_hasRuned = true;
- return true;
-}
-
-#define UT_STUB_QWIDGET_ISVISIBLE_APPEND\
- stub.set((bool (QWidget::*)() const)ADDR(QWidget, isVisible), ut_QWidget_isVisible);\
- ut_QWidget_isVisible_hasRuned = false;\
-
-#define UT_STUB_QWIDGET_ISVISIBLE_CREATE\
- Stub stub;\
- UT_STUB_QWIDGET_ISVISIBLE_APPEND
-
-#define UT_STUB_QWIDGET_ISVISIBLE_RESULT ut_QWidget_isVisible_hasRuned
-#define UT_STUB_QWIDGET_ISVISIBLE_PREPARE ut_QWidget_isVisible_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QProcess_startDetached_hasRuned = false;
-static bool ut_QProcess_startDetached(qint64 *){
- ut_QProcess_startDetached_hasRuned = true;
- return true;
-}
-
-#define UT_STUB_QPROCESS_STARTDETACHED_APPEND\
- stub.set((bool (QProcess::*)(qint64 *))ADDR(QProcess, startDetached), ut_QProcess_startDetached);\
- ut_QProcess_startDetached_hasRuned = false;\
-
-#define UT_STUB_QPROCESS_STARTDETACHED_CREATE\
- Stub stub;\
- UT_STUB_QPROCESS_STARTDETACHED_APPEND
-
-#define UT_STUB_QPROCESS_STARTDETACHED_RESULT ut_QProcess_startDetached_hasRuned
-#define UT_STUB_QPROCESS_STARTDETACHED_PREPARE ut_QProcess_startDetached_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QWidget_setVisible_hasRuned = false;
-static void ut_QWidget_setVisible(void *, bool){
- ut_QWidget_setVisible_hasRuned = true;
-}
-#define UT_STUB_QWIDGET_SETVISIBLE_APPEND\
- typedef void (*ut_QWidget_setVisible_ptr)(QWidget*, bool); \
- ut_QWidget_setVisible_ptr ptr = (ut_QWidget_setVisible_ptr)(&QWidget::setVisible); \
- stub.set(ptr, ut_QWidget_setVisible); \
- ut_QWidget_setVisible_hasRuned = false;\
-
-#define UT_STUB_QWIDGET_SETVISIBLE_CREATE\
- Stub stub;\
- UT_STUB_QWIDGET_SETVISIBLE_APPEND
-
-#define UT_STUB_QWIDGET_SETVISIBLE_RESULT ut_QWidget_setVisible_hasRuned
-#define UT_STUB_QWIDGET_SETVISIBLE_PREPARE ut_QWidget_setVisible_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QDialog_open_hasRuned = false;
-static void ut_QDialog_open(void *){
- ut_QDialog_open_hasRuned = true;
-}
-#define UT_STUB_QDIALOG_OPEN_APPEND\
- typedef void (*ut_QDialog_open_ptr)(QDialog*); \
- ut_QDialog_open_ptr ptr = (ut_QDialog_open_ptr)(&QDialog::open); \
- stub.set(ptr, ut_QDialog_open); \
- ut_QDialog_open_hasRuned = false;\
-
-#define UT_STUB_QDIALOG_OPEN_CREATE\
- Stub stub;\
- UT_STUB_QDIALOG_OPEN_APPEND
-
-#define UT_STUB_QDIALOG_OPEN_RESULT ut_QDialog_open_hasRuned
-#define UT_STUB_QDIALOG_OPEN_PREPARE ut_QDialog_open_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QTranslator_translate_hasRuned = false;
-static QString ut_QTranslator_translate(void *, const char *, const char *, const char *, int){
- ut_QTranslator_translate_hasRuned = true;
- return QString();
-}
-
-typedef QString (*ut_QTranslator_translate_ptr)(QTranslator*, const char *, const char *, const char *, int) ;
-
-#define UT_STUB_QTRANSLATE_TRANSLATE_APPEND\
- ut_QTranslator_translate_ptr ptr = (ut_QTranslator_translate_ptr)(&QTranslator::translate); \
- stub.set(ptr, ut_QTranslator_translate); \
- ut_QTranslator_translate_hasRuned = false;\
-
-#define UT_STUB_QTRANSLATE_TRANSLATE_CREATE\
- Stub stub;\
- UT_STUB_QTRANSLATE_TRANSLATE_APPEND
-
-#define UT_STUB_QTRANSLATE_TRANSLATE_RESULT ut_QTranslator_translate_hasRuned
-#define UT_STUB_QTRANSLATE_TRANSLATE_PREPARE ut_QTranslator_translate_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QWidget_show_hasRuned = false;
-static void ut_QWidget_show(){
- ut_QWidget_show_hasRuned = true;
-}
-
-#define UT_STUB_QWIDGET_SHOW_APPEND\
- stub.set((void (QWidget::*)())ADDR(QWidget, show), ut_QWidget_show); \
- ut_QWidget_show_hasRuned = false;\
-
-#define UT_STUB_QWIDGET_SHOW_CREATE\
- Stub stub;\
- UT_STUB_QWIDGET_SHOW_APPEND
-
-#define UT_STUB_QWIDGET_SHOW_RESULT ut_QWidget_show_hasRuned
-#define UT_STUB_QWIDGET_SHOW_PREPARE ut_QWidget_show_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QUrl_isValid_hasRuned = false;
-static bool ut_QUrl_isValid(){
- ut_QUrl_isValid_hasRuned = true;
- return false;
-}
-
-#define UT_STUB_QURL_ISVALID_APPEND\
- stub.set((bool (QUrl::*)() const)ADDR(QUrl, isValid), ut_QUrl_isValid); \
- ut_QUrl_isValid_hasRuned = false;\
-
-#define UT_STUB_QURL_ISVALID_CREATE\
- Stub stub;\
- UT_STUB_QURL_ISVALID_APPEND
-
-#define UT_STUB_QURL_ISVALID_RESULT ut_QUrl_isValid_hasRuned
-#define UT_STUB_QURL_ISVALID_PREPARE ut_QUrl_isValid_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QApplication_sendEvent_hasRuned = false;
-static bool ut_QApplication_sendEvent(QObject *, QEvent *){
- ut_QApplication_sendEvent_hasRuned = true;
- return false;
-}
-
-#define UT_STUB_QAPPLICATION_SENDEVENT_APPEND\
- stub.set(ADDR(QApplication, sendEvent), ut_QApplication_sendEvent); \
- ut_QApplication_sendEvent_hasRuned = false;\
-
-#define UT_STUB_QAPPLICATION_SENDEVENT_CREATE\
- Stub stub;\
- UT_STUB_QAPPLICATION_SENDEVENT_APPEND
-
-#define UT_STUB_QAPPLICATION_SENDEVENT_RESULT ut_QApplication_sendEvent_hasRuned
-#define UT_STUB_QAPPLICATION_SENDEVENT_PREPARE ut_QApplication_sendEvent_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_DSettingsOption_value_hasRuned = false;
-static QVariant ut_DSettingsOption_value(){
- ut_DSettingsOption_value_hasRuned = true;
- return QVariant();
-}
-
-#define UT_STUB_DSETTINGSOPTION_VALUE_APPEND\
- stub.set(ADDR(DSettingsOption, value), ut_DSettingsOption_value); \
- ut_DSettingsOption_value_hasRuned = false;\
-
-#define UT_STUB_DSETTINGSOPTION_VALUE_CREATE\
- Stub stub;\
- UT_STUB_DSETTINGSOPTION_VALUE_APPEND
-
-#define UT_STUB_DSETTINGSOPTION_VALUE_RESULT ut_DSettingsOption_value_hasRuned
-#define UT_STUB_DSETTINGSOPTION_VALUE_PREPARE ut_DSettingsOption_value_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QDir_exists_hasRuned = false;
-static bool ut_QDir_exists(){
- ut_QDir_exists_hasRuned = true;
- return true;
-}
-
-#define UT_STUB_QDIR_EXISTS_APPEND\
- stub.set((bool (QDir::*)()const)ADDR(QDir, exists), ut_QDir_exists); \
- ut_QDir_exists_hasRuned = false;\
-
-#define UT_STUB_QDIR_EXISTS_CREATE\
- Stub stub;\
- UT_STUB_QDIR_EXISTS_APPEND
-
-#define UT_STUB_QDIR_EXISTS_RESULT ut_QDir_exists_hasRuned
-#define UT_STUB_QDIR_EXISTS_PREPARE ut_QDir_exists_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QFile_remove_hasRuned = false;
-static bool ut_QFile_remove(){
- ut_QFile_remove_hasRuned = true;
- return true;
-}
-
-#define UT_STUB_QFILE_REMOVE_APPEND\
- stub.set((bool (QFile::*)())ADDR(QFile, remove), ut_QFile_remove); \
- ut_QFile_remove_hasRuned = false;\
-
-#define UT_STUB_QFILE_REMOVE_CREATE\
- Stub stub;\
- UT_STUB_QFILE_REMOVE_APPEND
-
-#define UT_STUB_QFILE_REMOVE_RESULT ut_QFile_remove_hasRuned
-#define UT_STUB_QFILE_REMOVE_PREPARE ut_QFile_remove_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-/******** Add by ut003135 Begin***************/
-static bool ut_QObject_findChild_QWidget_hasRuned = false;
-static QWidget *ut_QObject_findChild_QWidget(void* , const QString &, Qt::FindChildOptions)
-{
- ut_QObject_findChild_QWidget_hasRuned = true;
- return nullptr;
-}
-
-
-#define UT_STUB_QOBJECT_FINDCHILD_QWIDGET_APPEND\
- stub.set((QWidget *(QObject::*)(const QString &, Qt::FindChildOptions) const)ADDR(QObject, findChild), ut_QObject_findChild_QWidget); \
- ut_QObject_findChild_QWidget_hasRuned = false;\
-
-#define UT_STUB_QOBJECT_FINDCHILD_QWIDGET_CREATE\
- Stub stub;\
- UT_STUB_QOBJECT_FINDCHILD_QWIDGET_APPEND
-
-#define UT_STUB_QOBJECT_FINDCHILD_QWIDGET_RESULT ut_QObject_findChild_QWidget_hasRuned
-#define UT_STUB_QOBJECT_FINDCHILD_QWIDGET_PREPARE ut_QObject_findChild_QWidget_hasRuned = false;
-/******** Add by ut003135 End***************/
-
-#define DELETE_PTR(ptr) \
- if(ptr) {\
- delete ptr;\
- ptr = nullptr;\
- }
-
-#define DELETE_PTR_LATER(ptr) \
- if(ptr) {\
- ptr->deleteLater();\
- ptr = nullptr;\
- }
-
-#endif // UT_STUB_DEFINES_H
diff --git a/tests/src/common/ut_utils_test.cpp b/tests/src/common/ut_utils_test.cpp
deleted file mode 100644
index 0840410d9..000000000
--- a/tests/src/common/ut_utils_test.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-// Copyright (C) 2019 ~ 2023 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_utils_test.h"
-#include "termproperties.h"
-#include "ut_stub_defines.h"
-#include "utils.h"
-
-//DTK相关头文件
-#include
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-//system
-#include
-#include
-
-DWIDGET_USE_NAMESPACE
-
-UT_Utils_Test::UT_Utils_Test()
-{
-}
-
-void UT_Utils_Test::SetUp()
-{
-}
-
-void UT_Utils_Test::TearDown()
-{
-}
-
-#ifdef UT_UTILS_TEST
-
-TEST_F(UT_Utils_Test, getQssContentEmpty)
-{
- EXPECT_TRUE(Utils::getQssContent(QString()).isEmpty());
-}
-
-TEST_F(UT_Utils_Test, getQssContentNoFile)
-{
- EXPECT_TRUE(Utils::getQssContent(QString("/opt/qt.qss")).isEmpty());
-}
-
-TEST_F(UT_Utils_Test, getQssContentOKFile)
-{
- system("echo '' > qts.qss");
- EXPECT_FALSE(Utils::getQssContent(QString("./qts.qss")).isEmpty());
-}
-
-
-TEST_F(UT_Utils_Test, getConfigPath)
-{
- EXPECT_FALSE(Utils::getConfigPath().isEmpty());
-}
-
-
-TEST_F(UT_Utils_Test, suffixList)
-{
- EXPECT_FALSE(Utils::suffixList().isEmpty());
-}
-
-TEST_F(UT_Utils_Test, getRandString)
-{
- EXPECT_FALSE(Utils::getRandString().isEmpty());
-
- QString allGenText = "";
- for (int i = 0; i < 20; i++) {
- QString str = Utils::getRandString();
- allGenText.append(str);
- EXPECT_EQ(str.length(), 6);
- //加个延时用于提高Utils::getRandString()函数生成的随机性,因为随机函数使用时间作为随机数的种子
- QTest::qWait(UT_WAIT_TIME);
- }
-}
-
-TEST_F(UT_Utils_Test, showDirDialog)
-{
-#ifdef ENABLE_UI_TEST
- QWidget parentWidget;
-
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- QString dirName = Utils::showDirDialog(&parentWidget);
- EXPECT_GE(dirName.length(), 0);
-#endif
-}
-
-TEST_F(UT_Utils_Test, showFilesSelectDialog)
-{
-#ifdef ENABLE_UI_TEST
- QWidget *parentWidget = new QWidget;
-
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- parentWidget->deleteLater();
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- QStringList fileList = Utils::showFilesSelectDialog(parentWidget);
- EXPECT_GE(fileList.size(), 0);
-
-
-#endif
-}
-
-TEST_F(UT_Utils_Test, showExitConfirmDialogTab_CloseTypeTab)
-{
-#ifdef ENABLE_UI_TEST
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
-
- bool isAccepted = Utils::showExitConfirmDialog(Utils::CloseType::CloseType_Tab);
- EXPECT_EQ(isAccepted, false);
-
-
-#endif
-}
-
-TEST_F(UT_Utils_Test, showExitConfirmDialog_CloseTypeWindow)
-{
-#ifdef ENABLE_UI_TEST
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- bool isAccepted = Utils::showExitConfirmDialog(Utils::CloseType::CloseType_Window);
- EXPECT_EQ(isAccepted, false);
-
-
-#endif
-}
-
-TEST_F(UT_Utils_Test, getExitDialogText)
-{
- QString title;
- QString txt;
- Utils::CloseType temtype = Utils::CloseType::CloseType_Window;
- Utils::getExitDialogText(temtype, title, txt, 0);
-
- QString titleWindow = QObject::tr("Close this window?");
- QString txtWindow = QObject::tr("There are still processes running in this window. Closing the window will terminate all of them.");
-
- EXPECT_NE(title, titleWindow);
- EXPECT_NE(txt, txtWindow);
-
- Utils::getExitDialogText(temtype, title, txt, 1);
- EXPECT_EQ(title, titleWindow);
- EXPECT_EQ(txt, txtWindow);
-
-
- QString titleDefault = QObject::tr("Close this terminal?");
- QString txtDefault = QObject::tr("There is still a process running in this terminal. "
- "Closing the terminal will terminate it.");
- temtype = Utils::CloseType::CloseType_Terminal;
- Utils::getExitDialogText(temtype, title, txt, 1);
- EXPECT_EQ(title, titleDefault);
- EXPECT_EQ(txt, txtDefault);
-
- Utils::getExitDialogText(temtype, title, txt, 2);
- EXPECT_EQ(title, titleDefault);
- EXPECT_NE(txt, txtDefault);
-}
-
-
-TEST_F(UT_Utils_Test, showExitUninstallConfirmDialog)
-{
-#ifdef ENABLE_UI_TEST
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- bool isAccepted = Utils::showExitUninstallConfirmDialog();
- EXPECT_EQ(isAccepted, false);
-
-
-#endif
-}
-
-
-TEST_F(UT_Utils_Test, showUninstallConfirmDialog)
-{
-#ifdef ENABLE_UI_TEST
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- QString commandName = "python";
- bool isAccepted = Utils::showUninstallConfirmDialog(commandName);
- EXPECT_EQ(isAccepted, false);
-
-
-#endif
-}
-
-
-TEST_F(UT_Utils_Test, showShortcutConflictMsgbox)
-{
-#ifdef ENABLE_UI_TEST
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- QString shortcutName = "Ctrl+C";
- bool isAccepted = Utils::showShortcutConflictMsgbox(shortcutName);
- EXPECT_EQ(isAccepted, true);
-
-
-#endif
-}
-
-TEST_F(UT_Utils_Test, showSameNameDialog)
-{
-#ifdef ENABLE_UI_TEST
- UT_STUB_QWIDGET_SHOW_CREATE;
- Utils::showSameNameDialog(parentWidget, "servername1", "servername1");
- //会触发dialog的show函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SHOW_RESULT);
-
-#endif
-}
-
-// 参数解析
-TEST_F(UT_Utils_Test, parseCommandLine)
-{
- TermProperties properties;
- Utils::parseCommandLine(QStringList() << "deepin-terminal" << QString("-h"), properties, false);
- EXPECT_TRUE(4 == properties.m_properties.count());
-
- properties = TermProperties();
- Utils::parseCommandLine(QStringList() << "deepin-terminal" << QString("-v"), properties, false);
- EXPECT_TRUE(4 == properties.m_properties.count());
-
- properties = TermProperties();
- Utils::parseCommandLine(QStringList() << "deepin-terminal" << QString("-q"), properties, false);
- EXPECT_TRUE(4 == properties.m_properties.count());
-
- properties = TermProperties();
- Utils::parseCommandLine(QStringList() << "deepin-terminal" << "-e" << "ls" << "-w" << "/home/", properties, false);
- EXPECT_TRUE(5 == properties.m_properties.count());
-}
-
-TEST_F(UT_Utils_Test, parseExecutePara)
-{
- QStringList appArguments;
- appArguments << "deepin-terminal" << "-e" << "ls /home/";
- QStringList paraList = Utils::parseExecutePara(appArguments);
- EXPECT_EQ(paraList.size(), 2);
-
- appArguments.clear();
- appArguments << "deepin-terminal" << "-e" << "ping 127.0.0.1 -c 5";
- paraList = Utils::parseExecutePara(appArguments);
- EXPECT_EQ(paraList.size(), 4);
-
- appArguments.clear();
- appArguments << "deepin-terminal" << "-e" << "bash -c 'ping 127.0.0.1 -c 5'";
- paraList = Utils::parseExecutePara(appArguments);
- EXPECT_EQ(paraList.size(), 3);
-}
-
-TEST_F(UT_Utils_Test, parseNestedQString)
-{
- QString str = QString("bash -c 'ping 127.0.0.1'");
- QStringList paraList = Utils::parseNestedQString(str);
- EXPECT_EQ(paraList.size(), 3);
-
- str = QString("bash -c ping 127.0.0.1");
- QStringList paraList2 = Utils::parseNestedQString(str);
- EXPECT_EQ(paraList.size(), 3);
-}
-
-#endif
diff --git a/tests/src/common/ut_utils_test.h b/tests/src/common/ut_utils_test.h
deleted file mode 100644
index 59cac3293..000000000
--- a/tests/src/common/ut_utils_test.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_UTILS_TEST_H
-#define UT_UTILS_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class QWidget;
-class UT_Utils_Test : public ::testing::Test
-{
-public:
- UT_Utils_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
- QWidget *parentWidget = nullptr;
-};
-
-#endif // UT_UTILS_TEST_H
-
diff --git a/tests/src/customcommand/ut_customcommandoptdlg_test.cpp b/tests/src/customcommand/ut_customcommandoptdlg_test.cpp
deleted file mode 100644
index 3a2115d70..000000000
--- a/tests/src/customcommand/ut_customcommandoptdlg_test.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_customcommandoptdlg_test.h"
-#include "ut_defines.h"
-#include "customcommandoptdlg.h"
-#include "mainwindow.h"
-#include "../stub.h"
-#include "service.h"
-
-//dtk
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-UT_CustomCommandOptDlg_Test::UT_CustomCommandOptDlg_Test()
-{
- QAction *ac = new QAction;
- ac->setText(m_validCmdName);
- ac->setData(m_validCmdText);
- ac->setShortcut(m_validCmdShortcut);
- //ShortcutManager::instance()负责释放ac的空间
- ShortcutManager::instance()->m_customCommandActionList.append(ac);
-}
-
-UT_CustomCommandOptDlg_Test::~UT_CustomCommandOptDlg_Test()
-{
-}
-
-void UT_CustomCommandOptDlg_Test::SetUp()
-{
-}
-
-void UT_CustomCommandOptDlg_Test::TearDown()
-{
-}
-
-static void doDeleteLater(CustomCommandOptDlg *obj)
-{
- obj->deleteLater();
-}
-
-static bool ut_ShortcutManager_checkShortcutValid(const QString &, const QString &, QString &)
-{
- return false;
-}
-
-#ifdef UT_CUSTOMCOMMANDOPTDLG_TEST
-
-//TEST_F(UT_CustomCommandOptDlg_Test, CustomCommandOptDlgTest)
-//{
-// DApplicationHelper::instance()->setPaletteType(DApplicationHelper::DarkType);
-// QSharedPointer cmdDlg_new(new CustomCommandOptDlg, doDeleteLater);
-// cmdDlg_new->setIconPixmap(QPixmap());
-// cmdDlg_new->show();
-// emit DApplicationHelper::instance()->themeTypeChanged(DApplicationHelper::DarkType);
-// emit DApplicationHelper::instance()->themeTypeChanged(DApplicationHelper::LightType);
-// DApplicationHelper::instance()->setPaletteType(DApplicationHelper::LightType);
-
-// QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
-
-// cmdDlg->show();
-
-// QList lineEditList = cmdDlg->findChildren();
-// EXPECT_EQ(lineEditList.size(), 2);
-
-// DLineEdit *cmdNameEdit = lineEditList.first();
-// DLineEdit *cmdTextEdit = lineEditList.last();
-
-// QString str = Utils::getRandString();
-// cmdNameEdit->setText(str.toLower());
-// cmdTextEdit->setText("ls -al");
-
-// DKeySequenceEdit *shortcutEdit = cmdDlg->findChild();
-// EXPECT_NE(shortcutEdit, nullptr);
-// shortcutEdit->setKeySequence(QKeySequence("Ctrl+Shift+K"));
-//}
-
-//TEST_F(UT_CustomCommandOptDlg_Test, setCancelBtnText)
-//{
-// QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
-
-// cmdDlg->addCancelConfirmButtons();
-// EXPECT_NE(cmdDlg->m_cancelBtn, nullptr);
-// EXPECT_NE(cmdDlg->m_confirmBtn, nullptr);
-
-// QString cancelText("Cancel");
-// cmdDlg->setCancelBtnText(cancelText);
-// EXPECT_EQ(cmdDlg->m_cancelBtn->text(), cancelText);
-//}
-
-TEST_F(UT_CustomCommandOptDlg_Test, setConfirmBtnText)
-{
- QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
- cmdDlg->addCancelConfirmButtons();
- EXPECT_NE(cmdDlg->m_cancelBtn, nullptr);
- EXPECT_NE(cmdDlg->m_confirmBtn, nullptr);
-
- QString confirmText("Add");
- cmdDlg->setConfirmBtnText(confirmText);
- EXPECT_EQ(cmdDlg->m_confirmBtn->text(), confirmText);
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, addCancelConfirmButtonsTest)
-{
- QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
- cmdDlg->addCancelConfirmButtons();
- EXPECT_NE(cmdDlg->m_cancelBtn, nullptr);
- EXPECT_NE(cmdDlg->m_confirmBtn, nullptr);
-
- cmdDlg->m_shortCutLineEdit->setKeySequence(QKeySequence("Ctrl+T"));
- emit cmdDlg->m_cancelBtn->clicked(true);
- emit cmdDlg->m_confirmBtn->clicked(true);
- emit cmdDlg->m_shortCutLineEdit->editingFinished(QKeySequence("Ctrl+T"));
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, slotAddSaveButtonClicked)
-{
- QKeySequence keySeq("Ctrl+T");
- QAction newAction(ShortcutManager::instance());
- newAction.setObjectName("CustomQAction");
- newAction.setText("cmd");
- newAction.setData("ls -al");
- newAction.setShortcut(keySeq);
- ShortcutManager::instance()->addCustomCommand(newAction);
- EXPECT_TRUE(ShortcutManager::instance()->findActionByKey(newAction.text()) != nullptr);
-
- QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
- cmdDlg->m_currItemData = new CustomCommandData;
- cmdDlg->m_currItemData->m_cmdName = "";
- cmdDlg->m_currItemData->m_cmdText = "";
- cmdDlg->m_currItemData->m_cmdShortcut = "";
-
- //add-条件:name="",cammand=""
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(cmdDlg->m_nameLineEdit->text().isEmpty());
-
- //add-条件:name.length>MAX_NAME_LEN,cammand=""
- cmdDlg->m_nameLineEdit->setText(QString('A', MAX_NAME_LEN + 1));
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(cmdDlg->m_nameLineEdit->text().count() > 0);
-
- //add-条件:name="cmd",cammand=""
- cmdDlg->m_nameLineEdit->setText("cmd");
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(cmdDlg->m_nameLineEdit->text().count() > 0);
-
- //add-条件:name="cmd",cammand="ls -al"
- cmdDlg->m_commandLineEdit->setText("ls -al");
- const int cmdDlg_child_count = cmdDlg->children().count();
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(1 == (cmdDlg->children().count() - cmdDlg_child_count));
-
- //modify-调试:m_bRefreshCheck=false,m_currItemData 为空,name<>name_old
- cmdDlg->m_type = CustomCommandOptDlg::CCT_MODIFY;
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(2 == (cmdDlg->children().count() - cmdDlg_child_count));
-
- //modify-调试:m_bRefreshCheck=true,m_currItemData 为空,name<>name_old
- cmdDlg->m_bRefreshCheck = true;
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(2 == (cmdDlg->children().count() - cmdDlg_child_count));
-
- //modify-调试:m_bRefreshCheck=false,m_currItemData 不为空,name<>name_old
- cmdDlg->m_bRefreshCheck = false;
- cmdDlg->m_currItemData->m_cmdName = this->m_validCmdName;
- cmdDlg->m_currItemData->m_cmdText = this->m_validCmdText;
- cmdDlg->m_currItemData->m_cmdShortcut = this->m_validCmdShortcut;
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(2 == (cmdDlg->children().count() - cmdDlg_child_count));
-
- //modify-调试:m_bRefreshCheck=false,m_currItemData 不为空,name<>name_old
- cmdDlg->m_nameLineEdit->setText("cmd_no");
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(2 == (cmdDlg->children().count() - cmdDlg_child_count));
-
- //modify-调试:m_bRefreshCheck=false,m_currItemData not empty,name=name_old
- cmdDlg->m_nameLineEdit->setText(m_validCmdName);
- cmdDlg->m_commandLineEdit->setText(m_validCmdText);
- cmdDlg->m_shortCutLineEdit->setKeySequence(QKeySequence(m_validCmdShortcut));
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(2 == (cmdDlg->children().count() - cmdDlg_child_count));
-
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, slotRefreshData)
-{
- QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
-
- cmdDlg->m_currItemData = new CustomCommandData;
- cmdDlg->m_currItemData->m_cmdName = "";
- cmdDlg->m_currItemData->m_cmdText = "";
- cmdDlg->m_currItemData->m_cmdShortcut = "";
- cmdDlg->m_nameLineEdit->setText(m_validCmdName);
- cmdDlg->m_commandLineEdit->setText(m_validCmdText);
-
- //新增一个窗口
- const int cmdDlg_child_count = cmdDlg->children().count();
- QKeySequence keytmp = cmdDlg->m_shortCutLineEdit->setKeySequence(QKeySequence(m_validCmdShortcut));
- cmdDlg->slotAddSaveButtonClicked();
- EXPECT_TRUE(1 == (cmdDlg->children().count() - cmdDlg_child_count));
-
- //新增的
- cmdDlg->m_type = CustomCommandOptDlg::CCT_ADD;
- cmdDlg->slotRefreshData(m_validCmdName, m_validCmdName + "1");
- EXPECT_TRUE(CustomCommandOptDlg::CCT_ADD == cmdDlg->m_type);
-
- //修改的, old != new
- cmdDlg->m_type = CustomCommandOptDlg::CCT_MODIFY;
- cmdDlg->slotRefreshData(m_validCmdName, m_validCmdName + "1");
- EXPECT_TRUE(CustomCommandOptDlg::CCT_MODIFY == cmdDlg->m_type);
-
- //修改的 old == new, 可以找到new action
- cmdDlg->m_currItemData->m_cmdName = m_validCmdName + "1";
- cmdDlg->m_currItemData->m_cmdText = "";
- cmdDlg->m_currItemData->m_cmdShortcut = "";
- cmdDlg->m_type = CustomCommandOptDlg::CCT_MODIFY;
- cmdDlg->slotRefreshData(m_validCmdName + "1", m_validCmdName);
- EXPECT_TRUE(CustomCommandOptDlg::CCT_MODIFY == cmdDlg->m_type);
-
- //修改的, old = new 没法找到new action
- cmdDlg->slotRefreshData(m_validCmdName, m_validCmdName + "1");
- EXPECT_TRUE(CustomCommandOptDlg::CCT_MODIFY == cmdDlg->m_type);
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, slotShortCutLineEditingFinished)
-{
- Stub stub;
- stub.set(ADDR(ShortcutManager, checkShortcutValid), ut_ShortcutManager_checkShortcutValid);
- QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
- cmdDlg->slotShortCutLineEditingFinished(QKeySequence("Backspace"));
- //Backspace会设置lastCmdShortcut为""
- EXPECT_TRUE(cmdDlg->m_lastCmdShortcut.isEmpty());
-
- cmdDlg->slotShortCutLineEditingFinished(QKeySequence("Esc"));
- //还原最后lastCmdShortcut
- EXPECT_TRUE(cmdDlg->m_shortCutLineEdit->keySequence().toString() == cmdDlg->m_lastCmdShortcut);
-
- cmdDlg->m_type = CustomCommandOptDlg::CCT_MODIFY;
- cmdDlg->slotShortCutLineEditingFinished(QKeySequence());
- //还原最后lastCmdShortcut
- EXPECT_TRUE(cmdDlg->m_shortCutLineEdit->keySequence().toString() == cmdDlg->m_lastCmdShortcut);
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, initCommandFromClipBoardText)
-{
- NormalWindow normal(TermProperties("/"), nullptr);
- CustomCommandOptDlg cmdDlg(CustomCommandOptDlg::CCT_ADD, nullptr, &normal);
- cmdDlg.initCommandFromClipBoardText();
- //会将selectedText赋值到m_commandLineEdit
- EXPECT_TRUE(cmdDlg.m_commandLineEdit->text() == normal.selectedText().trimmed());
-
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, closeRefreshDataConnection)
-{
- QSharedPointer cmdDlg(new CustomCommandOptDlg, doDeleteLater);
- int oldCount = Service::instance()->receivers(SIGNAL(refreshCommandPanel(QString, QString)));
- cmdDlg->closeRefreshDataConnection();
- int newCount = Service::instance()->receivers(SIGNAL(refreshCommandPanel(QString, QString)));
- //关联的槽函数-1
- EXPECT_TRUE(newCount == (oldCount - 1));
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, closeEvent)
-{
- CustomCommandOptDlg cmdDlg;
- cmdDlg.close();
- //关闭时,会done(-1);
- EXPECT_TRUE(-1 == cmdDlg.result());
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, showShortcutConflict)
-{
- CustomCommandOptDlg cmdDlg;
- cmdDlg.showShortcutConflictMsgbox("Return");
- //快捷键显示映射 如:Return 显示成 Enter
- EXPECT_TRUE(cmdDlg.m_shortcutConflictDialog->title().contains("Enter"));
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, checkSequence)
-{
- Stub stub;
- stub.set(ADDR(ShortcutManager, checkShortcutValid), ut_ShortcutManager_checkShortcutValid);
- CustomCommandOptDlg cmdDlg;
-
- //空的sequence返回true
- EXPECT_TRUE(cmdDlg.checkSequence(QKeySequence()));
- //m_validCmdShortcut之前已被设置,故会冲突
- EXPECT_TRUE(!cmdDlg.checkSequence(QKeySequence(m_validCmdShortcut)));
-}
-
-TEST_F(UT_CustomCommandOptDlg_Test, slotCommandLineEditingFinished)
-{
- CustomCommandOptDlg cmdDlg;
- cmdDlg.m_commandLineEdit->setText("");
- cmdDlg.slotCommandLineEditingFinished();
-
- //m_commandLineEdit为空时,placeholderText不为空
- EXPECT_TRUE(cmdDlg.m_commandLineEdit->lineEdit()->placeholderText().count() > 0);
-}
-
-#endif
diff --git a/tests/src/customcommand/ut_customcommandoptdlg_test.h b/tests/src/customcommand/ut_customcommandoptdlg_test.h
deleted file mode 100644
index 45f5d9ab0..000000000
--- a/tests/src/customcommand/ut_customcommandoptdlg_test.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_CUSTOMCOMMANDOPTDLG_TEST_H
-#define UT_CUSTOMCOMMANDOPTDLG_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-#include
-
-class QAction;
-class UT_CustomCommandOptDlg_Test : public ::testing::Test
-{
-public:
- UT_CustomCommandOptDlg_Test();
- ~UT_CustomCommandOptDlg_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
- const QString m_validCmdName = "cmd";
- const QString m_validCmdText = "ls -al";
- const QString m_validCmdShortcut = "Ctrl+Shift+T";
-};
-#endif//UT_CUSTOMCOMMANDOPTDLG_TEST_H
diff --git a/tests/src/customcommand/ut_customcommandpanel_test.cpp b/tests/src/customcommand/ut_customcommandpanel_test.cpp
deleted file mode 100644
index 9226f6d4e..000000000
--- a/tests/src/customcommand/ut_customcommandpanel_test.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "customcommandpanel.h"
-#include "customcommandoptdlg.h"
-#include "ut_defines.h"
-#include "shortcutmanager.h"
-#include "../stub.h"
-#include "ut_stub_defines.h"
-
-#include
-
-//Google GTest 相关头文件
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-
-
-#include
-
-class UT_CustomCommandPanel_Test : public ::testing::Test
-{
-public:
- UT_CustomCommandPanel_Test();
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-private:
- ShortcutManager *m_scManager;
-};
-
-static QAction m_action;
-static QAction *ut_m_pdlg_getCurCustomCmd() {
- return &m_action;
-}
-
-UT_CustomCommandPanel_Test::UT_CustomCommandPanel_Test():m_scManager(nullptr)
-{
-}
-
-void UT_CustomCommandPanel_Test::SetUp()
-{
- //快捷键、自定义命令
- m_scManager = ShortcutManager::instance();
- m_scManager->createCustomCommandsFromConfig();
-}
-
-void UT_CustomCommandPanel_Test::TearDown()
-{
-}
-
-#ifdef UT_CUSTOMCOMMANDPANEL_TEST
-
-TEST_F(UT_CustomCommandPanel_Test, CustomCommandPanelTest)
-{
- QList cmdActionlist = m_scManager->getCustomCommandActionList();
-
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- CustomCommandPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
-
- panel.refreshCmdPanel();
-
- ListView *cmdListWidget = panel.findChild();
- EXPECT_EQ(cmdActionlist.size(), cmdListWidget->count());
-
- panel.refreshCmdSearchState();
-}
-
-TEST_F(UT_CustomCommandPanel_Test, showCurSearchResult)
-{
- CustomCommandPanel panel;
- panel.m_searchEdit->setText("1");
- panel.showCurSearchResult();
- EXPECT_TRUE(panel.m_searchEdit->text().count() > 0);
-}
-
-TEST_F(UT_CustomCommandPanel_Test, showAddCustomCommandDlg)
-{
- QList cmdActionlist = m_scManager->getCustomCommandActionList();
-
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- CustomCommandPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
-
- panel.refreshCmdPanel();
-
- ListView *cmdListWidget = panel.findChild();
- EXPECT_EQ(cmdActionlist.size(), cmdListWidget->count());
-
- panel.refreshCmdSearchState();
- panel.showAddCustomCommandDlg();
- panel.showAddCustomCommandDlg();
- panel.m_bpushButtonHaveFocus = true;
- //打桩
- Stub stub;
- stub.set(ADDR(CustomCommandOptDlg, getCurCustomCmd), ut_m_pdlg_getCurCustomCmd);
-
- panel.onAddCommandResponse(QDialog::Accepted);
- //打桩还原
- stub.reset(ADDR(CustomCommandOptDlg, getCurCustomCmd));
-
- ShortcutManager::instance()->addCustomCommand(QAction("xxx"));
- QAction *action = ShortcutManager::instance()->getCustomCommandActionList().value(0);
- panel.doCustomCommand(action->text());
-}
-
-TEST_F(UT_CustomCommandPanel_Test, onFocusOut)
-{
- UT_STUB_QWIDGET_SETFOCUS_CREATE;
- UT_STUB_QWIDGET_ISVISIBLE_APPEND;
-
- CustomCommandPanel *panel = new CustomCommandPanel;
- UT_STUB_QWIDGET_SETFOCUS_PREPARE
- panel->onFocusOut(Qt::TabFocusReason);
- //会触发setFocus函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-
- panel->m_searchEdit->setFocus();
- UT_STUB_QWIDGET_SETFOCUS_PREPARE
- panel->onFocusOut(Qt::BacktabFocusReason);
- //会触发setFocus函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-
- panel->deleteLater();
-}
-#endif
diff --git a/tests/src/customcommand/ut_customcommandplugin_test.cpp b/tests/src/customcommand/ut_customcommandplugin_test.cpp
deleted file mode 100644
index 1467333fc..000000000
--- a/tests/src/customcommand/ut_customcommandplugin_test.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_customcommandplugin_test.h"
-#include "customcommandplugin.h"
-#include "ut_stub_defines.h"
-#include "mainwindow.h"
-#include "termproperties.h"
-#include "service.h"
-
-//qt
-#include
-#include
-#include
-#include
-
-UT_Customcommandplugin_Test::UT_Customcommandplugin_Test()
-{
-
-}
-
-void UT_Customcommandplugin_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool())
- {
- Service::instance()->setProperty("isServiceInit", true);
- }
- m_cmdPlugin = new CustomCommandPlugin;
-}
-
-void UT_Customcommandplugin_Test::TearDown()
-{
- DELETE_PTR_LATER(m_cmdPlugin->m_mainWindow);
- DELETE_PTR_LATER(m_cmdPlugin);
-}
-
-#ifdef UT_CUSTOMCOMMANDPLUGIN_TEST
-
-TEST_F(UT_Customcommandplugin_Test,initPlugin)
-{
- EXPECT_NE(m_cmdPlugin, nullptr);
-
- NormalWindow* normal = new NormalWindow(TermProperties("/"), nullptr);
-
- m_cmdPlugin->initPlugin(normal);
- EXPECT_NE(m_cmdPlugin->titlebarMenu(normal), nullptr);
- EXPECT_NE(m_cmdPlugin->getCustomCommandTopPanel(), nullptr);
-}
-
-TEST_F(UT_Customcommandplugin_Test,initPlugin001)
-{
- EXPECT_NE(m_cmdPlugin, nullptr);
-
- QuakeWindow *quake = new QuakeWindow(TermProperties({{WorkingDir, "/"},{QuakeMode, true}}));
- m_cmdPlugin->initPlugin(quake);
- EXPECT_NE(m_cmdPlugin->titlebarMenu(quake), nullptr);
- EXPECT_NE(m_cmdPlugin->getCustomCommandTopPanel(), nullptr);
-}
-
-TEST_F(UT_Customcommandplugin_Test,doCustomCommand)
-{
- CustomCommandPlugin *m_cmdPlugin = new CustomCommandPlugin;
- NormalWindow* normal = new NormalWindow(TermProperties("/"), nullptr);
- m_cmdPlugin->initPlugin(normal);
-
- m_cmdPlugin->m_isShow = true;
- m_cmdPlugin->doShowPlugin(MainWindow::PLUGIN_TYPE_NONE, false);
- //会更新m_cmdPlugin的m_isShow
- EXPECT_TRUE(!m_cmdPlugin->m_isShow);
-
- m_cmdPlugin->doCustomCommand("ls");
- //重置m_CurrentShowPlugin为PLUGIN_TYPE_NONE
- EXPECT_TRUE(m_cmdPlugin->m_mainWindow->m_CurrentShowPlugin == MainWindow::PLUGIN_TYPE_NONE);
-
- DELETE_PTR_LATER(m_cmdPlugin->m_mainWindow);
- DELETE_PTR_LATER(m_cmdPlugin);
-}
-
-#endif
-
-
diff --git a/tests/src/customcommand/ut_customcommandplugin_test.h b/tests/src/customcommand/ut_customcommandplugin_test.h
deleted file mode 100644
index 8e3946737..000000000
--- a/tests/src/customcommand/ut_customcommandplugin_test.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_CUSTOMCOMMANDPLUGIN_TEST_H
-#define UT_CUSTOMCOMMANDPLUGIN_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class CustomCommandPlugin;
-class UT_Customcommandplugin_Test : public ::testing::Test
-{
-public:
- UT_Customcommandplugin_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-public:
- CustomCommandPlugin* m_cmdPlugin = nullptr;
-};
-
-#endif//UT_CUSTOMCOMMANDPLUGIN_TEST_H
diff --git a/tests/src/customcommand/ut_customcommandsearchrstpanel_test.cpp b/tests/src/customcommand/ut_customcommandsearchrstpanel_test.cpp
deleted file mode 100644
index 08a492454..000000000
--- a/tests/src/customcommand/ut_customcommandsearchrstpanel_test.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_customcommandsearchrstpanel_test.h"
-#include "customcommandsearchrstpanel.h"
-#include "service.h"
-#include "shortcutmanager.h"
-#include "listview.h"
-#include "../stub.h"
-#include "ut_stub_defines.h"
-
-#include
-#include
-#include
-#include
-#include
-
-UT_CustomCommandSearchRstPanel_Test::UT_CustomCommandSearchRstPanel_Test()
-{
-
-}
-
-void UT_CustomCommandSearchRstPanel_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- DApplicationHelper::instance()->setPaletteType(DApplicationHelper::DarkType);
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_cmdSearchPanel = new CustomCommandSearchRstPanel(m_normalWindow);
-}
-
-void UT_CustomCommandSearchRstPanel_Test::TearDown()
-{
- delete m_cmdSearchPanel;
- delete m_normalWindow;
-
-}
-
-#ifdef UT_CUSTOMCOMMANDSEARCHRSTPANEL_TEST
-
-TEST_F(UT_CustomCommandSearchRstPanel_Test, CustomCommandSearchRstPanelTest)
-{
- m_cmdSearchPanel->handleIconButtonFocusOut(Qt::FocusReason::TabFocusReason);
- EXPECT_TRUE(m_cmdSearchPanel->m_cmdListWidget->count() == 0);
-
- m_cmdSearchPanel->handleListViewFocusOut(Qt::FocusReason::TabFocusReason);
- EXPECT_TRUE(m_cmdSearchPanel->m_cmdListWidget->currentIndex() == -1);
-
- UT_STUB_QWIDGET_SETFOCUS_CREATE;
- m_cmdSearchPanel->handleListViewFocusOut(Qt::NoFocusReason);
- //setFocus被调用过
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-// emit DApplicationHelper::instance()->themeTypeChanged(DApplicationHelper::DarkType);
-// emit DApplicationHelper::instance()->themeTypeChanged(DApplicationHelper::LightType);
-// emit m_cmdSearchPanel->m_rebackButton->focusOut(Qt::FocusReason::TabFocusReason);
-// emit m_cmdSearchPanel->m_cmdListWidget->focusOut(Qt::FocusReason::TabFocusReason);
-// emit m_cmdSearchPanel->m_cmdListWidget->focusOut(Qt::NoFocusReason);
-}
-
-TEST_F(UT_CustomCommandSearchRstPanel_Test, refreshDataTest)
-{
- EXPECT_NE(m_cmdSearchPanel, nullptr);
- m_cmdSearchPanel->show();
-
- m_cmdSearchPanel->refreshData();
-
- m_cmdSearchPanel->refreshData("test");
-}
-
-TEST_F(UT_CustomCommandSearchRstPanel_Test, setSearchFilterTest)
-{
- EXPECT_NE(m_cmdSearchPanel, nullptr);
- m_cmdSearchPanel->show();
-
- m_cmdSearchPanel->setSearchFilter("SearchFilter");
-}
-
-TEST_F(UT_CustomCommandSearchRstPanel_Test, doCustomCommandTest)
-{
- EXPECT_NE(m_cmdSearchPanel, nullptr);
- m_cmdSearchPanel->show();
-
- QKeySequence keySeq("Ctrl+T");
- QAction newAction(ShortcutManager::instance());
- newAction.setObjectName("CustomQAction");
- newAction.setText("myCommand");
- newAction.setData("ls -al");
- newAction.setShortcut(keySeq);
- ShortcutManager::instance()->addCustomCommand(newAction);
-
- m_cmdSearchPanel->doCustomCommand("myCommand");
-}
-
-#endif
diff --git a/tests/src/customcommand/ut_customcommandsearchrstpanel_test.h b/tests/src/customcommand/ut_customcommandsearchrstpanel_test.h
deleted file mode 100644
index 727202abc..000000000
--- a/tests/src/customcommand/ut_customcommandsearchrstpanel_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_CUSTOMCOMMANDSEARCHRSTPANEL_TEST_H
-#define UT_CUSTOMCOMMANDSEARCHRSTPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "mainwindow.h"
-
-#include
-
-class CustomCommandSearchRstPanel;
-class UT_CustomCommandSearchRstPanel_Test : public ::testing::Test
-{
-public:
- UT_CustomCommandSearchRstPanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-public:
- CustomCommandSearchRstPanel* m_cmdSearchPanel = nullptr;
-
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
- TermProperties m_normalTermProperty;
-};
-
-#endif//UT_CUSTOMCOMMANDSEARCHRSTPANEL_TEST_H
-
diff --git a/tests/src/customcommand/ut_customcommandtoppanel_test.cpp b/tests/src/customcommand/ut_customcommandtoppanel_test.cpp
deleted file mode 100644
index e75c3baf0..000000000
--- a/tests/src/customcommand/ut_customcommandtoppanel_test.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_customcommandtoppanel_test.h"
-
-#include "customcommandtoppanel.h"
-#include "mainwindow.h"
-
-#include
-#include
-#include
-#include
-
-UT_CustomCommandTopPanel_Test::UT_CustomCommandTopPanel_Test()
- : m_normalWindow(nullptr)
- , m_cmdTopPanel(nullptr)
-{
-}
-
-void UT_CustomCommandTopPanel_Test::SetUp()
-{
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
-
- m_cmdTopPanel = new CustomCommandTopPanel(m_normalWindow);
-}
-
-void UT_CustomCommandTopPanel_Test::TearDown()
-{
- if (m_cmdTopPanel != nullptr) {
- delete m_cmdTopPanel;
- m_cmdTopPanel = nullptr;
- }
- if (m_normalWindow != nullptr) {
- delete m_normalWindow;
- m_normalWindow = nullptr;
- }
-}
-
-#ifdef UT_CUSTOMCOMMANDTOPPANEL_TEST
-
-TEST_F(UT_CustomCommandTopPanel_Test, showCustomCommandPanel)
-{
- m_cmdTopPanel->show(true);
- EXPECT_EQ(m_cmdTopPanel->isVisible(), true);
-
- m_cmdTopPanel->showCustomCommandPanel();
- EXPECT_EQ(m_cmdTopPanel->m_customCommandPanel->isVisible(), true);
-}
-
-TEST_F(UT_CustomCommandTopPanel_Test, showCustomCommandSearchPanel)
-{
- m_cmdTopPanel->show(true);
- EXPECT_EQ(m_cmdTopPanel->isVisible(), true);
-
- m_cmdTopPanel->showCustomCommandSearchPanel("cmd");
- EXPECT_EQ(m_cmdTopPanel->m_customCommandSearchPanel->isVisible(), true);
-}
-
-TEST_F(UT_CustomCommandTopPanel_Test, slotsRefreshCommandPanel)
-{
- m_cmdTopPanel->show(true);
- EXPECT_EQ(m_cmdTopPanel->isVisible(), true);
-
- m_cmdTopPanel->slotsRefreshCommandPanel();
-}
-
-#endif
diff --git a/tests/src/customcommand/ut_customcommandtoppanel_test.h b/tests/src/customcommand/ut_customcommandtoppanel_test.h
deleted file mode 100644
index a205b0721..000000000
--- a/tests/src/customcommand/ut_customcommandtoppanel_test.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_CUSTOMCOMMANDTOPPANEL_TEST_H
-#define UT_CUSTOMCOMMANDTOPPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class MainWindow;
-class CustomCommandTopPanel;
-class UT_CustomCommandTopPanel_Test : public ::testing::Test
-{
-public:
- UT_CustomCommandTopPanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-private:
- TermProperties m_normalTermProperty;
- MainWindow *m_normalWindow = nullptr;
- CustomCommandTopPanel* m_cmdTopPanel = nullptr;
-};
-
-#endif//UT_CUSTOMCOMMANDTOPPANEL_TEST_H
-
diff --git a/tests/src/encodeplugin/ut_encodelistview_test.cpp b/tests/src/encodeplugin/ut_encodelistview_test.cpp
deleted file mode 100644
index 1143afa3b..000000000
--- a/tests/src/encodeplugin/ut_encodelistview_test.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "encodelistview.h"
-#include "mainwindow.h"
-#include "service.h"
-#include "encodelistmodel.h"
-#include "ut_defines.h"
-#include "termproperties.h"
-#include "../stub.h"
-
-//Google GTest 相关头文件
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-
-class MainWindow;
-class UT_EncodeListView_Test : public ::testing::Test
-{
-public:
- UT_EncodeListView_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- TermProperties m_normalTermProperty;
-};
-
-UT_EncodeListView_Test::UT_EncodeListView_Test()
-{
-}
-
-void UT_EncodeListView_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
-}
-
-void UT_EncodeListView_Test::TearDown()
-{
- delete m_normalWindow;
-}
-static int ut_MouseEvent_source()
-{
- return Qt::MouseEventSynthesizedByQt;
-}
-
-static Qt::FocusReason ut_ListView_getFocusReason()
-{
- return Qt::TabFocusReason;
-}
-
-#ifdef UT_ENCODELISTVIEW_TEST
-
-TEST_F(UT_EncodeListView_Test, initEncodeItems)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
- encodeListView->initEncodeItems();
- EXPECT_GT(encodeListView->count(), 0);
-}
-
-TEST_F(UT_EncodeListView_Test, clickItemTest)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
- if(!encodeListView)
- return;
- encodeListView->show();
-
- int itemCount = encodeListView->count();
- int randomIndex = QRandomGenerator::global()->bounded(0, itemCount);
-
- QAbstractItemModel *model = encodeListView->model();
- if(!model)
- return;
- QModelIndex firstIndex = model->index(0, 0, QModelIndex());
- int itemHeight = encodeListView->visualRect(firstIndex).height();
-
-#ifdef ENABLE_UI_TEST
-
- for (int i = 0; i < itemCount; ++i) {
- if (randomIndex == i) {
- QPoint clickPoint(5, 1 + itemHeight * i);
- QModelIndex index = encodeListView->indexAt(clickPoint);
- if (!index.isValid()) {
- continue;
- }
- QTest::mouseClick(encodeListView->viewport(), Qt::LeftButton, Qt::NoModifier, clickPoint);
- QTest::qWait(2000);
- break;
- }
- }
-
-#endif
-}
-TEST_F(UT_EncodeListView_Test, keyPressEvent)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
- encodeListView->show();
-
- QTest::keyPress(encodeListView, Qt::Key_Space);
- QTest::keyPress(encodeListView, Qt::Key_Escape);
-}
-
-TEST_F(UT_EncodeListView_Test, keyPressEvent2)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
- encodeListView->show();
- encodeListView->addItem("test");
-
- encodeListView->setCurrentIndex(encodeListView->model()->index(0, 0));
- QTest::keyPress(encodeListView, Qt::Key_Up);
-
- int rowcount = encodeListView->m_encodeModel->listData().size();
- while(encodeListView->model()->rowCount() < rowcount) {
- encodeListView->addItem("test");
- }
- encodeListView->setCurrentIndex(encodeListView->model()->index(rowcount - 1, 0));
- QTest::keyPress(encodeListView, Qt::Key_Down);
-
- QTest::keyPress(encodeListView, Qt::Key_A);
-}
-TEST_F(UT_EncodeListView_Test, focusInEvent)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
-
- QFocusEvent event(QEvent::FocusIn, Qt::TabFocusReason);
- encodeListView->focusInEvent(&event);
-}
-
-TEST_F(UT_EncodeListView_Test, mouseMoveEvent)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
-
- //打桩
- Stub stub;
- stub.set(ADDR(QMouseEvent, source), ut_MouseEvent_source);
-
- QMouseEvent event(QEvent::MouseMove, QPoint(1, 1), Qt::NoButton, Qt::NoButton, Qt::KeyboardModifiers());
-
- encodeListView->mouseMoveEvent(&event);
- //打桩还原
- stub.reset(ADDR(QMouseEvent, source));
-}
-
-TEST_F(UT_EncodeListView_Test, paint)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
-
- QPainter painter(encodeListView);
- QStyleOptionViewItem option;
- option.state = QStyle::State_MouseOver
- | QStyle::State_Selected
- ;
- encodeListView->addItem("test");
- QModelIndex index = encodeListView->model()->index(0, 0);
-
- //打桩
- Stub stub;
- stub.set(ADDR(EncodeListView, getFocusReason), ut_ListView_getFocusReason);
-
- encodeListView->itemDelegate()->paint(&painter, option, index);
- //打桩还原
- stub.reset(ADDR(EncodeListView, getFocusReason));
-}
-
-TEST_F(UT_EncodeListView_Test, focusOutEvent)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodeListView *encodeListView = m_normalWindow->findChild("EncodeListView");
-
-
- QFocusEvent event(QEvent::FocusOut);
- encodeListView->focusOutEvent(&event);
-}
-
-#endif
diff --git a/tests/src/encodeplugin/ut_encodepanel_test.cpp b/tests/src/encodeplugin/ut_encodepanel_test.cpp
deleted file mode 100644
index ecf365b6e..000000000
--- a/tests/src/encodeplugin/ut_encodepanel_test.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_encodepanel_test.h"
-
-#include "encodepanel.h"
-#include "service.h"
-
-//Google GTest 相关头文件
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-
-UT_EncodePanel_Test::UT_EncodePanel_Test()
-{
-}
-
-void UT_EncodePanel_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool())
- {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
-}
-
-void UT_EncodePanel_Test::TearDown()
-{
- delete m_normalWindow;
-}
-
-#ifdef UT_ENCODEPANEL_TEST
-TEST_F(UT_EncodePanel_Test, EncodePanelTest)
-{
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_ENCODING);
-
- EncodePanel *panel = m_normalWindow->findChild();
- panel->show();
-}
-#endif
diff --git a/tests/src/encodeplugin/ut_encodepanel_test.h b/tests/src/encodeplugin/ut_encodepanel_test.h
deleted file mode 100644
index 11a062387..000000000
--- a/tests/src/encodeplugin/ut_encodepanel_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_ENCODEPANEL_TEST_H
-#define UT_ENCODEPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class MainWindow;
-class UT_EncodePanel_Test : public ::testing::Test
-{
-public:
- UT_EncodePanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- TermProperties m_normalTermProperty;
-};
-
-#endif // UT_ENCODEPANEL_TEST_H
-
diff --git a/tests/src/main/main.cpp b/tests/src/main/main.cpp
deleted file mode 100644
index cbcf95307..000000000
--- a/tests/src/main/main.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "terminalapplication.h"
-#include "ut_defines.h"
-
-#include
-#include
-
-#include
-#include
-
-#if defined(CMAKE_SAFETYTEST_ARG_ON)
-#include
-#endif
-
-QT_BEGIN_NAMESPACE
-QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
-QT_END_NAMESPACE
-
-int main(int argc, char *argv[])
-{
- qputenv("QT_QPA_PLATFORM", "offscreen");
- TerminalApplication app(argc, argv);
-
- QTEST_DISABLE_KEYPAD_NAVIGATION
- QTEST_ADD_GPU_BLACKLIST_SUPPORT
-
- testing::InitGoogleTest(&argc, argv);
- int ret = RUN_ALL_TESTS();
-
-#if defined(CMAKE_SAFETYTEST_ARG_ON)
- __sanitizer_set_report_path("asan.log");
-#endif
-
- qDebug() << ret;
-
-#ifdef ENABLE_UI_TEST
- QTest::qExec(&app, argc, argv);
-#endif
-
- QTEST_SET_MAIN_SOURCE_PATH
-
- return ret;
-}
diff --git a/tests/src/main/ut_dbusmanager_test.cpp b/tests/src/main/ut_dbusmanager_test.cpp
deleted file mode 100644
index 4ea7d517a..000000000
--- a/tests/src/main/ut_dbusmanager_test.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_dbusmanager_test.h"
-#include "dbusmanager.h"
-#include "ut_stub_defines.h"
-
-UT_Dbusmanager_Test::UT_Dbusmanager_Test()
-{
- m_pDbusManager = new DBusManager();
- m_pDbusManager->initDBus();
-}
-
-UT_Dbusmanager_Test::~UT_Dbusmanager_Test()
-{
- m_pDbusManager->deleteLater();
-}
-
-#ifdef UT_DBUSMANAGER_TEST
-
-//设置桌面索引
-TEST_F(UT_Dbusmanager_Test, callKDECurrentDesktopIndex)
-{
- UT_STUB_QDBUS_CALL_CREATE
- m_pDbusManager->callKDESetCurrentDesktop(1);
- //dbus call被调用过
- EXPECT_TRUE(UT_STUB_QDBUS_CALL_RESULT);
-}
-
-//获取字体 标准字体
-//TEST_F(UT_Dbusmanager_Test, standardfont)
-//{
-// UT_STUB_QDBUS_CALL_CREATE
-// m_pDbusManager->callAppearanceFont("standardfont");
-// //dbus call被调用过
-// EXPECT_TRUE(UT_STUB_QDBUS_CALL_RESULT);
-
-
-//}
-
-//获取字体 等宽字体
-//TEST_F(UT_Dbusmanager_Test, monospacefont)
-//{
-// UT_STUB_QDBUS_CALL_CREATE
-// m_pDbusManager->callAppearanceFont("monospacefont");
-// //dbus call被调用过
-// EXPECT_TRUE(UT_STUB_QDBUS_CALL_RESULT);
-
-//}
-
-//获取字体,其他错误字体
-//TEST_F(UT_Dbusmanager_Test, otherfailfont)
-//{
-// UT_STUB_QDBUS_CALL_CREATE
-// m_pDbusManager->callAppearanceFont("otherfailfont");
-// //dbus call被调用过
-// EXPECT_TRUE(UT_STUB_QDBUS_CALL_RESULT);
-
-//}
-
-//唤醒终端
-TEST_F(UT_Dbusmanager_Test, callTerminal)
-{
- UT_STUB_QDBUS_CALL_CREATE
- m_pDbusManager->callTerminalEntry({"deepin-terminal", "-C", "void_script"});
- //dbus call被调用过
- EXPECT_TRUE(UT_STUB_QDBUS_CALL_RESULT);;
-}
-
-TEST_F(UT_Dbusmanager_Test, listenTouchPadSignal)
-{
- UT_STUB_QDBUS_CONNECT_CREATE
- m_pDbusManager->listenTouchPadSignal();
- //dbus connect被调用过
- EXPECT_TRUE(UT_STUB_QDBUS_CONNECT_RESULT);
-}
-
-TEST_F(UT_Dbusmanager_Test, listenDesktopSwitched)
-{
- UT_STUB_QDBUS_CONNECT_CREATE
- m_pDbusManager->listenDesktopSwitched();
- //dbus connect被调用过
- EXPECT_TRUE(UT_STUB_QDBUS_CONNECT_RESULT);
-}
-
-#endif
-
diff --git a/tests/src/main/ut_dbusmanager_test.h b/tests/src/main/ut_dbusmanager_test.h
deleted file mode 100644
index 88cf9f646..000000000
--- a/tests/src/main/ut_dbusmanager_test.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_DBUSMANAGER_TEST_H
-#define UT_DBUSMANAGER_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class DBusManager;
-class UT_Dbusmanager_Test: public ::testing::Test
-{
-public:
- UT_Dbusmanager_Test();
- ~UT_Dbusmanager_Test();
-private:
- DBusManager *m_pDbusManager;
-};
-
-
-
-#endif//UT_DBUSMANAGER_TEST_H
-
-
-
-
-
diff --git a/tests/src/main/ut_mainwindow_test.cpp b/tests/src/main/ut_mainwindow_test.cpp
deleted file mode 100644
index 79073c561..000000000
--- a/tests/src/main/ut_mainwindow_test.cpp
+++ /dev/null
@@ -1,1579 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_mainwindow_test.h"
-
-#include "service.h"
-#include "mainwindow.h"
-#include "tabbar.h"
-#include "termwidget.h"
-#include "TerminalDisplay.h"
-#include "switchthememenu.h"
-#include "../stub.h"
-#include "settings.h"
-#include "ut_stub_defines.h"
-
-#include
-
-//Google GTest 相关头文件
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-UT_SwitchThemeMenu_Test::UT_SwitchThemeMenu_Test()
-{
-}
-
-void UT_SwitchThemeMenu_Test::SetUp()
-{
- m_themeMenu = new SwitchThemeMenu("Theme", nullptr);
-}
-
-void UT_SwitchThemeMenu_Test::TearDown()
-{
- delete m_themeMenu;
-}
-
-/*******************************************************************************
- 1. @函数: SwitchThemeMenu类的函数
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: SwitchThemeMenu类单元测试
-*******************************************************************************/
-#ifdef UT_SWITCHTHEMEMENU_TEST
-TEST_F(UT_SwitchThemeMenu_Test, SwitchThemeMenuTest)
-{
- EXPECT_NE(m_themeMenu, nullptr);
- m_themeMenu->show();
-
- QEvent e(QEvent::None);
- m_themeMenu->leaveEvent(&e);
-
- QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);
- m_themeMenu->keyPressEvent(&keyPress);
-
- m_themeMenu->enterEvent(&e);
- EXPECT_EQ(m_themeMenu->hoveredThemeStr, "");
-
- QHideEvent he;
- m_themeMenu->hideEvent(&he);
- EXPECT_EQ(m_themeMenu->hoveredThemeStr, "");
-}
-#endif
-
-static QWidget *ut_widget_focusWidget()
-{
- static QWidget w;
- return &w;
-}
-
-UT_MainWindow_Test::UT_MainWindow_Test()
-{
-}
-
-void UT_MainWindow_Test::SetUp()
-{
- m_service = Service::instance();
- //Service的init初始化函数只能执行一次,否则会crash
- if (!m_service->property("isServiceInit").toBool()) {
- m_service->init();
- m_service->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
-
- m_quakeTermProperty[QuakeMode] = true;
- m_quakeWindow = new QuakeWindow(m_quakeTermProperty, nullptr);
-}
-
-void UT_MainWindow_Test::TearDown()
-{
- delete m_normalWindow;
- delete m_quakeWindow;
-}
-
-static QObject *ut_shortcut_sender()
-{
- static QShortcut cut(0);
- return &cut;
-}
-
-static QObject *ut_action_sender()
-{
- static QAction ac(0);
- return ∾
-}
-static bool ut_widget_isActiveWindow()
-{
- return true;
-}
-static void ut_termwidget_onTermIsIdle(bool)
-{
-
-}
-
-#ifdef UT_MAINWINDOW_TEST
-
-/*******************************************************************************
- 1. @函数: QuakeAnimationTest
- 2. @作者: ut001000 任飞翔
- 3. @日期: 2020-11-24
- 4. @说明: 测试雷神窗口动画效果UT
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, QuakeAnimationTest)
-{
- {
- TermProperties property;
- property[QuakeMode] = true;
- QuakeWindow *quakeWindow = new QuakeWindow(property);
- quakeWindow->setAnimationFlag(false);
- quakeWindow->topToBottomAnimation();
- EXPECT_TRUE(quakeWindow->currentPage());
- quakeWindow->deleteLater();
- }
- {
- TermProperties property;
- property[QuakeMode] = true;
- QuakeWindow *quakeWindow = new QuakeWindow(property);
- quakeWindow->setAnimationFlag(false);
- quakeWindow->bottomToTopAnimation();
- EXPECT_TRUE(quakeWindow->currentPage());
- quakeWindow->deleteLater();
- }
-}
-
-int ut_main_runningTerminalCount()
-{
- return 1;
-}
-
-TEST_F(UT_MainWindow_Test, NormalWindowTest)
-{
- EXPECT_EQ(MainWindow::m_MinWidth, WINDOW_MIN_WIDTH);
- EXPECT_EQ(MainWindow::m_MinHeight, WINDOW_MIN_HEIGHT);
-
- EXPECT_NE(m_normalWindow, nullptr);
-
- m_normalWindow->show();
-
- EXPECT_GE(m_normalWindow->width(), MainWindow::m_MinWidth);
- EXPECT_GE(m_normalWindow->height(), MainWindow::m_MinHeight);
-
- m_normalWindow->isQuakeMode();
- m_normalWindow->hasRunningProcesses();
-
-// Stub stub;
-// stub.set(ADDR(TermWidgetPage,runningTerminalCount),ut_main_runningTerminalCount);
-// m_normalWindow->hasRunningProcesses();
-
- const int tabCount = 5;
- for (int i = 0; i < tabCount; i++) {
- m_normalWindow->addTab(m_normalTermProperty);
- }
- TabBar *tabBar = m_normalWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
- //窗口默认启动就自带了1个tab,所以这里加1
- EXPECT_EQ(tabBar->count(), tabCount + 1);
-
- QString firstTabId = tabBar->identifier(0);
- m_normalWindow->closeTab(firstTabId);
-
- EXPECT_EQ(tabBar->count(), tabCount);
-
- TermWidgetPage *currPage = m_normalWindow->currentPage();
- EXPECT_NE(currPage, nullptr);
- TermWidget *currTerm = currPage->currentTerminal();
- EXPECT_NE(currTerm, nullptr);
-
- Service::instance()->showSettingDialog(m_normalWindow);
- m_service->showHideOpacityAndBlurOptions(true);
-
-#ifdef ENABLE_UI_TEST
- //只有在开启UI测试的模式下,才能判断焦点
- currTerm->hasFocus();
-#endif
-}
-
-TEST_F(UT_MainWindow_Test, closeOtherTab)
-{
- TabBar *tabBar = m_normalWindow->m_tabbar;
- QString firstTabId = tabBar->identifier(0);
- m_normalWindow->closeOtherTab(firstTabId);
- EXPECT_EQ(tabBar->count(), 1);
-}
-
-TEST_F(UT_MainWindow_Test, getCurrTabTitle)
-{
- TabBar *tabBar = m_normalWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
- QString firstTabId = tabBar->identifier(0);
-
- QString strTabTitle = "Test Title";
- tabBar->setTabText(firstTabId, strTabTitle);
- QString currTabTitle = m_normalWindow->getCurrTabTitle();
- EXPECT_EQ(currTabTitle, strTabTitle);
-}
-
-TEST_F(UT_MainWindow_Test, isFocusOnList)
-{
- bool isFocusOnList = m_normalWindow->isFocusOnList();
- EXPECT_EQ(isFocusOnList, true);
-}
-
-TEST_F(UT_MainWindow_Test, focusPage)
-{
- TabBar *tabBar = m_normalWindow->m_tabbar;
- QString firstTabId = tabBar->identifier(0);
-
- m_normalWindow->focusPage(firstTabId);
- TermWidgetPage *tabPage = m_normalWindow->getPageByIdentifier(firstTabId);
- EXPECT_NE(tabPage, nullptr);
-
- //#ifdef ENABLE_UI_TEST
- // QTest::qWait(UT_WAIT_TIME);
- // //只有在开启UI测试的模式下,才能判断焦点
- // EXPECT_EQ(tabPage->currentTerminal()->hasFocus(), true);
- //#endif
-}
-
-
-TEST_F(UT_MainWindow_Test, focusCurrentPage)
-{
- TabBar *tabBar = m_normalWindow->m_tabbar;
- m_normalWindow->focusCurrentPage();
- QString firstTabId = tabBar->identifier(0);
-
- m_normalWindow->focusPage(firstTabId);
- TermWidgetPage *tabPage = m_normalWindow->getPageByIdentifier(firstTabId);
- EXPECT_NE(tabPage, nullptr);
-
- //#ifdef ENABLE_UI_TEST
- // QTest::qWait(UT_WAIT_TIME);
- // //只有在开启UI测试的模式下,才能判断焦点
- // EXPECT_EQ(tabPage->currentTerminal()->hasFocus(), true);
- //#endif
-}
-
-TEST_F(UT_MainWindow_Test, showPlugin)
-{
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND);
- EXPECT_EQ(m_normalWindow->m_CurrentShowPlugin, QString(MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND));
-}
-
-
-TEST_F(UT_MainWindow_Test, hidePlugin)
-{
- m_normalWindow->hidePlugin();
- EXPECT_EQ(m_normalWindow->m_CurrentShowPlugin, QString(MainWindow::PLUGIN_TYPE_NONE));
-}
-
-TEST_F(UT_MainWindow_Test, selectedText)
-{
- QString selectedText = m_normalWindow->selectedText();
-
- EXPECT_EQ(selectedText.length(), 0);
-}
-
-TEST_F(UT_MainWindow_Test, createNewTab)
-{
- TabBar *tabBar = m_normalWindow->m_tabbar;
- m_normalWindow->createNewTab();
- EXPECT_EQ(tabBar->count(), 2);
-}
-
-TEST_F(UT_MainWindow_Test, closeAllTab)
-{
- TabBar *tabBar = m_normalWindow->m_tabbar;
- m_normalWindow->closeAllTab();
- EXPECT_EQ(tabBar->count(), 0);
-}
-
-TEST_F(UT_MainWindow_Test, createJsonGroup)
-{
- QJsonArray jsonGroups;
- m_normalWindow->createJsonGroup("terminal", jsonGroups);
- m_normalWindow->createJsonGroup("tab", jsonGroups);
- m_normalWindow->createJsonGroup("advanced", jsonGroups);
-
- ASSERT_TRUE(jsonGroups.size() > 0);
- QJsonArray array = jsonGroups.last().toObject().value("groupItems").toArray();
- EXPECT_TRUE(array.size() > 3);
-
-}
-
-TEST_F(UT_MainWindow_Test, QuakeWindowTest)
-{
- qDebug() << __LINE__ << m_normalWindow->currentPage()->currentTerminal();
- qDebug() << __LINE__ << m_quakeWindow->currentPage()->currentTerminal();
- EXPECT_NE(m_quakeWindow, nullptr);
-
- m_quakeWindow->show();
-
- int desktopWidth = QApplication::desktop()->availableGeometry().width();
- EXPECT_EQ(m_quakeWindow->width(), desktopWidth);
- EXPECT_GE(m_quakeWindow->height(), 0);
-
- EXPECT_EQ(m_quakeWindow->isQuakeMode(), true);
- EXPECT_EQ(m_quakeWindow->hasRunningProcesses(), false);
-
- const int tabCount = 5;
- for (int i = 0; i < tabCount; i++) {
- m_quakeWindow->addTab(m_normalTermProperty);
- }
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
- //窗口默认启动就自带了1个tab,所以这里加1
- EXPECT_EQ(tabBar->count(), tabCount + 1);
-
- QString firstTabId = tabBar->identifier(0);
- m_quakeWindow->closeTab(firstTabId);
-
- QString lastTabId = tabBar->identifier(tabBar->count() - 1);
- m_quakeWindow->closeTab(lastTabId);
-}
-
-TEST_F(UT_MainWindow_Test, quake_closeOtherTab)
-{
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- QString firstTabId = tabBar->identifier(0);
- m_quakeWindow->closeOtherTab(firstTabId);
- EXPECT_EQ(tabBar->count(), 1);
-}
-
-TEST_F(UT_MainWindow_Test, quake_getCurrTabTitle)
-{
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
- QString firstTabId = tabBar->identifier(0);
-
- QString strTabTitle = "Test Title";
- tabBar->setTabText(firstTabId, strTabTitle);
- QString currTabTitle = m_quakeWindow->getCurrTabTitle();
- EXPECT_EQ(currTabTitle, strTabTitle);
-}
-
-TEST_F(UT_MainWindow_Test, quake_isFocusOnList)
-{
- bool isFocusOnList = m_quakeWindow->isFocusOnList();
- EXPECT_EQ(isFocusOnList, true);
-}
-
-TEST_F(UT_MainWindow_Test, quake_focusPage)
-{
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- QString firstTabId = tabBar->identifier(0);
-
- m_quakeWindow->focusPage(firstTabId);
- TermWidgetPage *tabPage = m_quakeWindow->getPageByIdentifier(firstTabId);
- EXPECT_NE(tabPage, nullptr);
-
- //#ifdef ENABLE_UI_TEST
- // QTest::qWait(UT_WAIT_TIME);
- // //只有在开启UI测试的模式下,才能判断焦点
- // EXPECT_EQ(tabPage->currentTerminal()->hasFocus(), true);
- //#endif
-}
-
-TEST_F(UT_MainWindow_Test, quake_focusCurrentPage)
-{
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- m_quakeWindow->focusCurrentPage();
- QString firstTabId = tabBar->identifier(0);
-
- m_quakeWindow->focusPage(firstTabId);
- TermWidgetPage *tabPage = m_quakeWindow->getPageByIdentifier(firstTabId);
- EXPECT_NE(tabPage, nullptr);
-
- //#ifdef ENABLE_UI_TEST
- // QTest::qWait(UT_WAIT_TIME);
- // //只有在开启UI测试的模式下,才能判断焦点
- // EXPECT_EQ(tabPage->currentTerminal()->hasFocus(), true);
- //#endif
-}
-
-TEST_F(UT_MainWindow_Test, quake_showPlugin)
-{
- m_quakeWindow->showPlugin(MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND);
- EXPECT_EQ(m_quakeWindow->m_CurrentShowPlugin, QString(MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND));
-}
-
-
-TEST_F(UT_MainWindow_Test, quake_hidePlugin)
-{
- m_quakeWindow->hidePlugin();
- EXPECT_EQ(m_quakeWindow->m_CurrentShowPlugin, QString(MainWindow::PLUGIN_TYPE_NONE));
-}
-
-TEST_F(UT_MainWindow_Test, quake_selectedText)
-{
- QString selectedText = m_quakeWindow->selectedText();
-
- EXPECT_EQ(selectedText.length(), 0);
-}
-
-TEST_F(UT_MainWindow_Test, quake_createNewTab)
-{
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- m_quakeWindow->createNewTab();
- EXPECT_EQ(tabBar->count(), 2);
-}
-
-TEST_F(UT_MainWindow_Test, quake_closeAllTab)
-{
- TabBar *tabBar = m_quakeWindow->m_tabbar;
- m_quakeWindow->closeAllTab();
- EXPECT_EQ(tabBar->count(), 0);
-}
-
-TEST_F(UT_MainWindow_Test, displayShortcuts)
-{
- UT_STUB_QPROCESS_STARTDETACHED_CREATE;
-
- m_normalWindow->displayShortcuts();
- //startDetched函数被调用过
- EXPECT_TRUE(UT_STUB_QPROCESS_STARTDETACHED_RESULT);
-}
-
-TEST_F(UT_MainWindow_Test, getConfigWindowState)
-{
-// m_normalTermProperty[StartWindowState] = "normal";
-// EXPECT_EQ(m_normalWindow->getConfigWindowState(), "window_normal");
-}
-
-TEST_F(UT_MainWindow_Test, OnHandleCloseType)
-{
- int oldTabCount = m_normalWindow->m_tabbar->count();
- m_normalWindow->createNewTab();
- m_normalWindow->createNewTab();
- m_normalWindow->createNewTab();
-
- //新建了3个tab
- EXPECT_TRUE(3 == (m_normalWindow->m_tabbar->count() - oldTabCount));
-
- //0:不关闭,剩余三个
- int curTabCount = m_normalWindow->m_tabbar->count();
- m_normalWindow->OnHandleCloseType(0, Utils::CloseType::CloseType_Window);
- EXPECT_TRUE(curTabCount == m_normalWindow->m_tabbar->count());
-
- //关闭了一个
- m_normalWindow->OnHandleCloseType(1, Utils::CloseType::CloseType_Tab);
- EXPECT_TRUE(curTabCount - 1 == m_normalWindow->m_tabbar->count());
-
- //关闭了其他,剩余一个
- m_normalWindow->OnHandleCloseType(1, Utils::CloseType::CloseType_OtherTab);
- EXPECT_TRUE(1 == m_normalWindow->m_tabbar->count());
-
- //关闭当前,没有剩余
- m_normalWindow->OnHandleCloseType(1, Utils::CloseType::CloseType_Window);
- EXPECT_TRUE(0 == m_normalWindow->m_tabbar->count());
-}
-
-TEST_F(UT_MainWindow_Test, onWindowSettingChanged)
-{
- //开启或关闭毛玻璃效果
- m_normalWindow->onWindowSettingChanged("advanced.window.blurred_background");
- EXPECT_TRUE(m_normalWindow->enableBlurWindow() == Settings::instance()->backgroundBlur());
-
- //测试时,默认为普通窗口
- m_normalWindow->onWindowSettingChanged("advanced.window.use_on_starting");
- EXPECT_TRUE(m_normalWindow->m_IfUseLastSize);
-
- //normalwindow下的use_on_starting
- m_normalWindow->onWindowSettingChanged("advanced.window.auto_hide_raytheon_window");
- EXPECT_TRUE("window_normal" == Settings::instance()->settings->option("advanced.window.use_on_starting")->value().toString());
-
-}
-
-static bool ut_isTabVisited()
-{
- return true;
-}
-
-TEST_F(UT_MainWindow_Test, onTermIsIdle)
-{
- TermWidgetPage *currPage = m_normalWindow->currentPage();
- ASSERT_TRUE(currPage != nullptr);
-
- Stub stub;
- stub.set(ADDR(MainWindow, isTabVisited), ut_isTabVisited);
-
- //当前id 闲置,故visitMap包含此id
- m_normalWindow->onTermIsIdle(currPage->identifier(), true);
- EXPECT_TRUE(m_normalWindow->m_tabVisitMap.contains(currPage->identifier()));
-
- //当前id繁忙,故颜色会变化
- m_normalWindow->onTermIsIdle(currPage->identifier(), false);
- EXPECT_TRUE(m_normalWindow->m_tabChangeColorMap.contains(currPage->identifier()));
-}
-
-TEST_F(UT_MainWindow_Test, showExitConfirmDialog)
-{
-#ifdef ENABLE_UI_TEST
- //要自己退出,否则对话框窗口会一直阻塞
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
-
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- qApp->exit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- int oldTabCount = m_normalWindow->m_tabbar->count();
- m_normalWindow->createNewTab();
- //新增一个窗口
- EXPECT_TRUE(1 == (m_normalWindow->m_tabbar->count() - oldTabCount));
-
- m_normalWindow->showExitConfirmDialog(Utils::CloseType::CloseType_Tab, 1, m_normalWindow);
-
-#endif
-}
-
-/*******************************************************************************
- 1. @函数: checkThemeItem
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: checkThemeItem函数单元测试
-*******************************************************************************/
-//TEST_F(UT_MainWindow_Test, checkExtendThemeItemTest)
-//{
-// QAction *pAction = nullptr;
-// m_normalWindow->checkExtendThemeItem("Theme1", pAction);
-// EXPECT_EQ(m_normalWindow->themeOneAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme2", pAction);
-// EXPECT_EQ(m_normalWindow->themeTwoAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme3", pAction);
-// EXPECT_EQ(m_normalWindow->themeThreeAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme4", pAction);
-// EXPECT_EQ(m_normalWindow->themeFourAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme5", pAction);
-// EXPECT_EQ(m_normalWindow->themeFiveAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme6", pAction);
-// EXPECT_EQ(m_normalWindow->themeSixAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme7", pAction);
-// EXPECT_EQ(m_normalWindow->themeSevenAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme8", pAction);
-// EXPECT_EQ(m_normalWindow->themeEightAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme9", pAction);
-// EXPECT_EQ(m_normalWindow->themeNineAction, pAction);
-
-// m_normalWindow->checkExtendThemeItem("Theme10", pAction);
-// EXPECT_EQ(m_normalWindow->themeTenAction, pAction);
-//}
-
-/*******************************************************************************
- 1. @函数: checkThemeItem
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: checkThemeItem函数单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, checkThemeItemTest)
-{
- m_normalWindow->checkThemeItem();
- EXPECT_NE(m_normalWindow->currCheckThemeAction, nullptr);
-}
-
-/*******************************************************************************
- 1. @函数: switchThemeAction
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: switchThemeAction函数单元测试
-*******************************************************************************/
-//TEST_F(UT_MainWindow_Test, switchThemeActionTest)
-//{
-// QAction *pAction = m_normalWindow->themeOneAction;
-// QString themeNameStr = MainWindow::THEME_ONE;
-// m_normalWindow->switchThemeAction(pAction, themeNameStr);
-// //修改主题
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_ONE);
-
-// pAction = m_normalWindow->themeNineAction;
-// themeNameStr = MainWindow::THEME_NINE;
-// m_normalWindow->switchThemeAction(pAction, themeNameStr);
-// //修改主题
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_NINE);
-//}
-
-/*******************************************************************************
- 1. @函数: switchThemeAction
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: switchThemeAction函数单元测试
-*******************************************************************************/
-//TEST_F(UT_MainWindow_Test, switchThemeActionTestOne)
-//{
-// QAction *pAction = m_normalWindow->lightThemeAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->colorScheme() == MainWindow::THEME_LIGHT);
-
-// pAction = m_normalWindow->darkThemeAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->colorScheme() == MainWindow::THEME_DARK);
-
-// pAction = m_normalWindow->autoThemeAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_NO);
-
-// pAction = m_normalWindow->themeOneAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_ONE);
-
-// pAction = m_normalWindow->themeTwoAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_TWO);
-
-// pAction = m_normalWindow->themeThreeAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_THREE);
-
-// pAction = m_normalWindow->themeFourAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_FOUR);
-
-// pAction = m_normalWindow->themeFiveAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_FIVE);
-
-// pAction = m_normalWindow->themeSixAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_SIX);
-
-// pAction = m_normalWindow->themeSevenAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_SEVEN);
-
-// pAction = m_normalWindow->themeEightAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_EIGHT);
-
-// pAction = m_normalWindow->themeNineAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_NINE);
-
-// pAction = m_normalWindow->themeTenAction;
-// m_normalWindow->switchThemeAction(pAction);
-// //修改颜色方案
-// EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_TEN);
-//}
-
-/*******************************************************************************
- 1. @函数: setThemeCheckItemSlot
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: setThemeCheckItemSlot函数单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, setThemeCheckItemSlotTest)
-{
- //测试场景,主题列表上下滑动的情况
- Settings::instance()->bSwitchTheme = false;
-
- Settings::instance()->themeStr = "Light";
- Settings::instance()->extendThemeStr = "";
- m_normalWindow->setThemeCheckItemSlot();
- //修改颜色方案
- EXPECT_TRUE(Settings::instance()->colorScheme() == MainWindow::THEME_LIGHT);
-
- Settings::instance()->themeStr = "Dark";
- Settings::instance()->extendThemeStr = "";
- m_normalWindow->setThemeCheckItemSlot();
- //修改颜色方案
- EXPECT_TRUE(Settings::instance()->colorScheme() == MainWindow::THEME_DARK);
-
- m_normalWindow->autoThemeAction->setChecked(true);
- m_normalWindow->setThemeCheckItemSlot();
- //修改颜色方案
- EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_NO);
-
- m_normalWindow->autoThemeAction->setChecked(false);
-
-
- //修改颜色方案
- EXPECT_TRUE(Settings::instance()->extendColorScheme() == MainWindow::THEME_NINE);
-
-}
-
-/*******************************************************************************
- 1. @函数: menuHideSetThemeSlot
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: menuHideSetThemeSlot函数单元测试
-*******************************************************************************/
-
-/*******************************************************************************
- 1. @函数: dragDropTabTest
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-11-20
- 4. @说明: tab标签拖拽单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, clickTabTest)
-{
- EXPECT_NE(m_normalWindow, nullptr);
-
- m_normalWindow->show();
-
- const int tabCount = 5;
- for (int i = 0; i < tabCount; i++) {
- m_normalWindow->addTab(m_normalTermProperty);
- }
- TabBar *tabBar = m_normalWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
-
- QTest::mouseClick(tabBar, Qt::LeftButton, Qt::NoModifier, QPoint(50, 10), UT_WAIT_TIME);
-
- QTest::mouseClick(tabBar, Qt::LeftButton, Qt::NoModifier, QPoint(100, 10), UT_WAIT_TIME);
-
- QTest::mouseClick(tabBar, Qt::LeftButton, Qt::NoModifier, QPoint(200, 10), UT_WAIT_TIME);
-}
-
-/*******************************************************************************
- 1. @函数: hasRunningProcesses
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-13
- 4. @说明: 是否有程序正在运行
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, hasRunningProcesses)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->show();
- // 此时没有正在执行的程序
- EXPECT_EQ(mainWindow->hasRunningProcesses(), false);
-
- // 发送数据
- mainWindow->currentPage()->sendTextToCurrentTerm("ping 127.0.0.1\n");
- bool running = mainWindow->hasRunningProcesses();
- qDebug() << "has running process :" << running;
- // EXPECT_EQ(running, true);
- delete mainWindow;
-}
-
-TEST_F(UT_MainWindow_Test, initPlugins)
-{
- // 新建一个mainWindow
-
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->initTabBar();
- //初始化tab
- EXPECT_TRUE(mainWindow->m_tabbar != nullptr);
-
- emit mainWindow->m_tabbar->tabBarClicked(1, "");
- emit mainWindow->m_tabbar->tabAddRequested();
- emit mainWindow->m_tabbar->tabCloseRequested(1);
- emit mainWindow->m_tabbar->menuCloseTab("");
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutBuiltinCopy单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutBuiltinCopy)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutBuiltinCopy();
- //currentpage 复制内容到剪切板
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutBuiltinPaste单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutBuiltinPaste)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutBuiltinPaste();
- //currentpage 粘贴
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutFocusOut单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutFocusOut)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutFocusOut();
- //currentpage 失去焦点
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutVerticalSplit单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutVerticalSplit)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutVerticalSplit();
- //当前窗口水平分屏
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutHorizonzalSplit单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutHorizonzalSplit)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutHorizonzalSplit();
- //当前窗口垂直分屏
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutNextTab单元测试
-*******************************************************************************/
-
-bool ut_main_hasRunningProcess()
-{
- return false;
-}
-
-bool ut_main_isTabChangeColor()
-{
- return true;
-}
-
-TEST_F(UT_MainWindow_Test, slotShortcutNextTab)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
-
- const int tabCount = 3;
- for (int i = 0; i < tabCount; i++) {
- mainWindow->addTab(m_normalTermProperty);
- }
-
- TabBar *tabBar = mainWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
-
- Stub stub;
- stub.set(ADDR(TermWidget, hasRunningProcess), ut_main_hasRunningProcess);
- stub.set(ADDR(MainWindow, isTabChangeColor), ut_main_isTabChangeColor);
- mainWindow->slotTabBarClicked(0, tabBar->identifier(0));
-
- mainWindow->slotShortcutNextTab();
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutPreviousTab单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutPreviousTab)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
-
- const int tabCount = 3;
- for (int i = 0; i < tabCount; i++) {
- mainWindow->addTab(m_normalTermProperty);
- }
-
- TabBar *tabBar = mainWindow->m_tabbar;
- EXPECT_NE(tabBar, nullptr);
-
- mainWindow->slotTabBarClicked(1, tabBar->identifier(0));
-
- mainWindow->slotShortcutPreviousTab();
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutSwitchFullScreen单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutSwitchFullScreen)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutSwitchFullScreen();
- //全屏
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-TEST_F(UT_MainWindow_Test, slotTabAddRequested)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->m_ReferedAppStartTime = 1;
- //初始化tab,剩余一个
- EXPECT_TRUE(mainWindow->m_tabbar->count() == 1);
-
- mainWindow->slotTabAddRequested();
- //添加一个tab,剩余两个
- EXPECT_TRUE(mainWindow->m_tabbar->count() == 2);
-
- //关闭一个tab,剩余一个
- mainWindow->slotTabCloseRequested(1);
- EXPECT_TRUE(mainWindow->m_tabbar->count() == 1);
-
- //关于其他tab,剩余0个
- mainWindow->slotMenuCloseOtherTab("/");
- EXPECT_TRUE(mainWindow->m_tabbar->count() == 0);
-// mainWindow->slotShowRenameTabDialog("name");
-// mainWindow->slotClickNewWindowTimeout();
- delete mainWindow;
-}
-
-int ut_widgetCount()
-{
- return 200;
-}
-
-TEST_F(UT_MainWindow_Test, slotFileChanged)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotFileChanged();
- mainWindow->singleFlagMove();
-
- Stub stub;
- stub.set(ADDR(WindowsManager, widgetCount), ut_widgetCount);
-
- mainWindow->beginAddTab();
- //当前窗口开始添加tab
- EXPECT_TRUE(mainWindow->currentPage() != nullptr);
-
- delete mainWindow;
-}
-
-bool ut_beginAddTab()
-{
- return true;
-}
-
-TEST_F(UT_MainWindow_Test, addTabWithTermPage)
-{
- // 新建一个mainWindow
- Stub stub;
- stub.set(ADDR(MainWindow, beginAddTab), ut_beginAddTab);
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- int oldTabCount = mainWindow->m_tabbar->count();
- TermWidgetPage *currPage = m_normalWindow->currentPage();
- mainWindow->addTabWithTermPage("name", true, false, currPage, -1);
- //新增了一个tab
- EXPECT_TRUE(1 == (mainWindow->m_tabbar->count() - oldTabCount));
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutCloseOtherTabs单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutCloseOtherTabs)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
-
- //新增了3个后,一个共4个tab
- const int tabCount = 3;
- for (int i = 0; i < tabCount; i++) {
- mainWindow->addTab(m_normalTermProperty);
- }
- EXPECT_TRUE(4 == mainWindow->m_tabbar->count());
-
- //关闭其他后,剩余1个
- mainWindow->slotShortcutCloseOtherTabs();
- EXPECT_TRUE(1 == mainWindow->m_tabbar->count());
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutCloseTab单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutCloseTab)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- EXPECT_TRUE(1 == mainWindow->m_tabbar->count());
-
- //关闭当前
- mainWindow->slotShortcutCloseTab();
- EXPECT_TRUE(0 == mainWindow->m_tabbar->count());
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutNewTab单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutNewTab)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- EXPECT_TRUE(1 == mainWindow->m_tabbar->count());
-
- //新增一个
- mainWindow->slotShortcutNewTab();
- EXPECT_TRUE(2 == mainWindow->m_tabbar->count());
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutPaste单元测试
-*******************************************************************************/
-//TEST_F(UT_MainWindow_Test, slotShortcutPaste)
-//{
-// //默认一个tab
-// MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
-// EXPECT_TRUE(mainWindow->currentPage());
-// EXPECT_TRUE(mainWindow->currentPage()->currentTerminal());
-
-// UT_STUB_QWIDGET_HASFOCUS_CREATE;
-// mainWindow->slotShortcutPaste();
-// //m_terminalDisplay 触发hasFocus函数
-// EXPECT_TRUE(UT_STUB_QWIDGET_HASFOCUS_RESULT);
-// mainWindow->deleteLater();
-//}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutCopy单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutCopy)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- ASSERT_TRUE(mainWindow->currentPage()->currentTerminal());
- TermWidget *w = mainWindow->currentPage()->currentTerminal();
- mainWindow->slotShortcutCopy();
- //
- EXPECT_TRUE(w->selectedText() == qApp->clipboard()->text());
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutZoomIn单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutZoomIn)
-{
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- ASSERT_TRUE(mainWindow->currentPage()->currentTerminal());
- TermWidget *w = mainWindow->currentPage()->currentTerminal();
- TerminalDisplay *display = w->findChild();
-
- int oldFontSize = display->getVTFont().pointSize();
- mainWindow->slotShortcutZoomIn();
- int newFontSize = display->getVTFont().pointSize();
- EXPECT_TRUE((oldFontSize + 1) == newFontSize);
- //
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutZoomOut单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutZoomOut)
-{
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- TermWidget *w = mainWindow->currentPage()->currentTerminal();
- TerminalDisplay *display = w->findChild();
- int oldFontSize = display->getVTFont().pointSize();
- mainWindow->slotShortcutZoomOut();
- int newFontSize = display->getVTFont().pointSize();
- EXPECT_TRUE((oldFontSize - 1) == newFontSize);
- //
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutCloseWorkspace单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutCloseWorkspace)
-{
- //默认一个tab
- NormalWindow mainWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow.currentPage());
- TermWidgetPage *page = mainWindow.currentPage();
- page->split(Qt::Horizontal);
- EXPECT_TRUE(2 == page->getTerminalCount());
- mainWindow.slotShortcutCloseWorkspace();
- EXPECT_TRUE(1 == page->getTerminalCount());
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutSelectLowerWorkspace单元测试
-*******************************************************************************/
-//bool QRect::contains(const QPoint &point, bool proper = false) const
-static bool ut_rect_contain(const QPoint &, bool)
-{
- return true;
-}
-
-TEST_F(UT_MainWindow_Test, slotShortcutSelectLowerWorkspace)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- TermWidgetPage *page = mainWindow->currentPage();
- Stub stub;
- stub.set((bool (QRect::*)(const QPoint &, bool) const)ADDR(QRect, contains), ut_rect_contain);
- UT_STUB_QWIDGET_SETFOCUS_APPEND;
- mainWindow->slotShortcutSelectLowerWorkspace();
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutSelectLeftWorkspace单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutSelectLeftWorkspace)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- TermWidgetPage *page = mainWindow->currentPage();
- Stub stub;
- stub.set((bool (QRect::*)(const QPoint &, bool) const)ADDR(QRect, contains), ut_rect_contain);
- UT_STUB_QWIDGET_SETFOCUS_APPEND;
-
- mainWindow->slotShortcutSelectLeftWorkspace();
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-
- delete mainWindow;
-}
-
-QString ut_getConfigWindowState_window_maximum()
-{
- return "window_maximum";
-}
-
-QString ut_getConfigWindowState_fullscreen()
-{
- return "fullscreen";
-}
-
-QString ut_getConfigWindowState_split_screen()
-{
- return "split_screen";
-}
-
-QString ut_getConfigWindowState_window()
-{
- return "window";
-}
-
-TEST_F(UT_MainWindow_Test, initWindowAttribute)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(MainWindow, getConfigWindowState), ut_getConfigWindowState_window_maximum);
- mainWindow->initWindowAttribute();
- //最大化
- EXPECT_TRUE(mainWindow->windowState() & Qt::WindowMaximized);
-
- stub.reset(ADDR(MainWindow, getConfigWindowState));
- stub.set(ADDR(MainWindow, getConfigWindowState), ut_getConfigWindowState_fullscreen);
- mainWindow->initWindowAttribute();
- //全屏
- EXPECT_TRUE(mainWindow->windowState() & Qt::WindowFullScreen);
-
- stub.reset(ADDR(MainWindow, getConfigWindowState));
- stub.set(ADDR(MainWindow, getConfigWindowState), ut_getConfigWindowState_split_screen);
- mainWindow->initWindowAttribute();
- //普通窗口
- EXPECT_TRUE(mainWindow->windowState() == Qt::WindowNoState);
-
- stub.reset(ADDR(MainWindow, getConfigWindowState));
- stub.set(ADDR(MainWindow, getConfigWindowState), ut_getConfigWindowState_window);
- mainWindow->initWindowAttribute();
- //普通窗口
- EXPECT_TRUE(mainWindow->windowState() == Qt::WindowNoState);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2020-12-25
- 4. @说明: slotShortcutSelectRightWorkspace单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutSelectRightWorkspace)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- TermWidgetPage *page = mainWindow->currentPage();
- Stub stub;
- stub.set((bool (QRect::*)(const QPoint &, bool) const)ADDR(QRect, contains), ut_rect_contain);
- UT_STUB_QWIDGET_SETFOCUS_APPEND;
-
- mainWindow->slotShortcutSelectRightWorkspace();
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-
- delete mainWindow;
-}
-
-bool ut_isTabChangeColor()
-{
- return true;
-}
-
-TEST_F(UT_MainWindow_Test, updateTabStatus)
-{
- // 新建一个mainWindow
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(TermWidget, hasRunningProcess), ut_main_hasRunningProcess);
- stub.set(ADDR(MainWindow, isTabVisited), ut_isTabVisited);
- stub.set(ADDR(MainWindow, isTabChangeColor), ut_isTabChangeColor);
- mainWindow->updateTabStatus();
- //更新窗口的闲置状态,并更新对应的map
- EXPECT_TRUE(mainWindow->m_tabChangeColorMap.count() > 0);
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2021-2-22
- 4. @说明: slotShortcutSelectAll单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutSelectAll)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- ASSERT_TRUE(mainWindow->currentPage()->currentTerminal());
-
- TermWidget *w = mainWindow->currentPage()->currentTerminal();
- ASSERT_TRUE(w);
-
- TerminalDisplay *display = w->findChild();
- ASSERT_TRUE(display);
-
- ScreenWindow *screen = display->_screenWindow;
- ASSERT_TRUE(display);
-
- screen->_bufferNeedsUpdate = false;
-
- mainWindow->slotShortcutSelectAll();
-
- //全选后,需要更新screen,update 为 true
- EXPECT_TRUE(screen->_bufferNeedsUpdate);
-
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2021-2-22
- 4. @说明: slotShortcutCustomCommand单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutCustomCommand)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
-
- QString resultName;
- if (MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND == mainWindow->m_CurrentShowPlugin)
- resultName = MainWindow::PLUGIN_TYPE_NONE;
- else
- resultName = MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND;
-
- mainWindow->slotShortcutCustomCommand();
-
- EXPECT_TRUE(resultName == mainWindow->m_CurrentShowPlugin);
- delete mainWindow;
-}
-
-/*******************************************************************************
- 1. @函数: MainWindow类的函数
- 2. @作者: ut000438 王亮
- 3. @日期: 2021-2-22
- 4. @说明: slotShortcutRemoteManage单元测试
-*******************************************************************************/
-TEST_F(UT_MainWindow_Test, slotShortcutRemoteManage)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
-
- QString resultName;
- if (MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT == mainWindow->m_CurrentShowPlugin)
- resultName = MainWindow::PLUGIN_TYPE_NONE;
- else
- resultName = MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT;
-
- mainWindow->slotShortcutRemoteManage();
-
- EXPECT_TRUE(resultName == mainWindow->m_CurrentShowPlugin);
-
- delete mainWindow;
-}
-
-//MainWindow类的函数
-TEST_F(UT_MainWindow_Test, slotOptionButtonPressed)
-{
- //默认一个tab
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- EXPECT_TRUE(1 == mainWindow->m_tabbar->count());
-
- mainWindow->slotOptionButtonPressed();
-
- EXPECT_TRUE(MainWindow::PLUGIN_TYPE_NONE == mainWindow->m_CurrentShowPlugin);
-
- delete mainWindow;
-}
-
-//MainWindow类的函数
-TEST_F(UT_MainWindow_Test, slotClickNewWindowTimeout)
-{
- UT_STUB_QPROCESS_STARTDETACHED_CREATE;
-
- NormalWindow(TermProperties("/")).slotClickNewWindowTimeout();
-
- EXPECT_TRUE(UT_STUB_QPROCESS_STARTDETACHED_RESULT);
-}
-//MainWindow类的函数
-TEST_F(UT_MainWindow_Test, slotShortcutSwitchActivated)
-{
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(QObject, sender), ut_shortcut_sender);
- mainWindow->slotShortcutSwitchActivated();
- EXPECT_TRUE(0 == mainWindow->m_tabbar->currentIndex());
- mainWindow->deleteLater();
-}
-
-//MainWindow类的函数
-TEST_F(UT_MainWindow_Test, slotShortcutSelectUpperWorkspace)
-{
- //默认一个tab
- MainWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- TermWidgetPage *page = mainWindow->currentPage();
- Stub stub;
- stub.set((bool (QRect::*)(const QPoint &, bool) const)ADDR(QRect, contains), ut_rect_contain);
- UT_STUB_QWIDGET_SETFOCUS_APPEND;
-
- mainWindow->slotShortcutSelectUpperWorkspace();
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-
- delete mainWindow;
-}
-
-//MainWindow类的函数
-TEST_F(UT_MainWindow_Test, slotShortcutFind)
-{
- //默认一个tab
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- mainWindow->slotShortcutFind();
- EXPECT_TRUE(MainWindow::PLUGIN_TYPE_SEARCHBAR == mainWindow->m_CurrentShowPlugin);
- delete mainWindow;
-}
-
-//调用一个新的进程,开启终端
-TEST_F(UT_MainWindow_Test, onCreateNewWindow)
-{
- UT_STUB_QPROCESS_STARTDETACHED_CREATE;
- NormalWindow(TermProperties("/")).onCreateNewWindow("/");
- EXPECT_TRUE(UT_STUB_QPROCESS_STARTDETACHED_RESULT);
-}
-
-//MainWindow类的函数
-TEST_F(UT_MainWindow_Test, onShortcutSettingChanged)
-{
- NormalWindow w(TermProperties("/"));
- w.m_builtInShortcut["shortcuts.terminal.zoom_in"] = new QShortcut(QKeySequence("Ctrl+O"), &w);
- w.onShortcutSettingChanged("shortcuts.terminal.zoom_in");
- EXPECT_TRUE(w.m_builtInShortcut.count() > 0);
-}
-
-TEST_F(UT_MainWindow_Test, onCommandActionTriggered)
-{
- //默认一个tab
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(QObject, sender), ut_action_sender);
- stub.set(ADDR(QWidget, isActiveWindow), ut_widget_isActiveWindow);
-
- mainWindow->onCommandActionTriggered();
- ASSERT_TRUE(mainWindow->currentPage());
- ASSERT_TRUE(mainWindow->currentPage()->currentTerminal());
- EXPECT_TRUE(mainWindow->currentPage()->currentTerminal()->property("isSendByRemoteManage").isValid());
- delete mainWindow;
-}
-
-TEST_F(UT_MainWindow_Test, pressCtrlAt)
-{
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(QWidget, focusWidget), ut_widget_focusWidget);
- UT_STUB_QAPPLICATION_SENDEVENT_APPEND;
- mainWindow->pressCtrlAt();
- //application sendevent被调用
- EXPECT_TRUE(UT_STUB_QAPPLICATION_SENDEVENT_RESULT);
- mainWindow->deleteLater();
-}
-
-TEST_F(UT_MainWindow_Test, pressEnterKey)
-{
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(QWidget, focusWidget), ut_widget_focusWidget);
- UT_STUB_QAPPLICATION_SENDEVENT_APPEND;
- mainWindow->pressEnterKey("");
- //application sendevent被调用
- EXPECT_TRUE(UT_STUB_QAPPLICATION_SENDEVENT_RESULT);
- mainWindow->deleteLater();
-}
-
-TEST_F(UT_MainWindow_Test, pressCtrlU)
-{
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- Stub stub;
- stub.set(ADDR(QWidget, focusWidget), ut_widget_focusWidget);
- UT_STUB_QAPPLICATION_SENDEVENT_APPEND;
- mainWindow->pressCtrlU();
- //application sendevent被调用
- EXPECT_TRUE(UT_STUB_QAPPLICATION_SENDEVENT_RESULT);
- mainWindow->deleteLater();
-}
-
-TEST_F(UT_MainWindow_Test, sleep)
-{
- NormalWindow *mainWindow = new NormalWindow(TermProperties("/"));
- ASSERT_TRUE(mainWindow->currentPage());
- Stub stub;
- stub.set(ADDR(TermWidget, onTermIsIdle), ut_termwidget_onTermIsIdle);
- QElapsedTimer timer;
- timer.start();
- mainWindow->sleep(1000);
- //睡眠1000ms
- qDebug() << timer.elapsed();
- EXPECT_TRUE(qFabs(timer.elapsed() - 1000) < 10);
- mainWindow->deleteLater();
-}
-
-TEST_F(UT_MainWindow_Test, slotWorkAreaResized)
-{
- QuakeWindow *mainWindow = new QuakeWindow(TermProperties({{WorkingDir, "/"}, {QuakeMode, true}}));
-
- mainWindow->slotWorkAreaResized();
- //雷神窗口的宽度为桌面宽度
- EXPECT_TRUE(QApplication::desktop()->availableGeometry().width() == mainWindow->width());
- mainWindow->deleteLater();
-}
-
-
-#endif
diff --git a/tests/src/main/ut_mainwindow_test.h b/tests/src/main/ut_mainwindow_test.h
deleted file mode 100644
index fcac43bd6..000000000
--- a/tests/src/main/ut_mainwindow_test.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_MAINWINDOW_TEST_H
-#define UT_MAINWINDOW_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class Service;
-class MainWindow;
-class SwitchThemeMenu;
-
-/*******************************************************************************
- 1. @类名: SwitchThemeMenu
- 2. @作者: ut000125 sunchengxi
- 3. @日期: 2020-11-05
- 4. @说明: 主题菜单的快捷键项在鼠标离开悬浮时,触发主题还原测试类
-*******************************************************************************/
-class UT_SwitchThemeMenu_Test : public ::testing::Test
-{
-public:
- UT_SwitchThemeMenu_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
- SwitchThemeMenu *m_themeMenu = nullptr;
-};
-
-
-class UT_MainWindow_Test : public ::testing::Test
-{
-public:
- UT_MainWindow_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- Service *m_service = nullptr;
-
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- //雷神窗口
- MainWindow *m_quakeWindow = nullptr;
-
- TermProperties m_normalTermProperty;
- TermProperties m_quakeTermProperty;
-};
-
-#endif // UT_MAINWINDOW_TEST_H
-
diff --git a/tests/src/main/ut_service_test.cpp b/tests/src/main/ut_service_test.cpp
deleted file mode 100644
index 7339bdb7b..000000000
--- a/tests/src/main/ut_service_test.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_service_test.h"
-#include "service.h"
-#include "mainwindow.h"
-#include "windowsmanager.h"
-#include "dbusmanager.h"
-#include "utils.h"
-#include "customthemesettingdialog.h"
-#include "../stub.h"
-#include "ut_stub_defines.h"
-
-//DTK
-#include
-#include
-
-//Qt
-#include
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-UT_Service_Test::UT_Service_Test()
-{
-}
-
-void UT_Service_Test::SetUp()
-{
- m_service = Service::instance();
- m_service->m_settingOwner = new NormalWindow(TermProperties());
- m_service->m_settingShortcutConflictDialog = new DDialog;
- m_service->m_customThemeSettingDialog = new CustomThemeSettingDialog;
- if (!m_service->property("isServiceInit").toBool()) {
- m_service->setProperty("isServiceInit", true);
- }
-}
-
-void UT_Service_Test::TearDown()
-{
-}
-
-static bool ut_dtk_managerhelper_hasComposite()
-{
- return false;
-}
-
-static int ut_dbus_type()
-{
- return QDBusMessage::InvalidMessage;
-}
-
-static void ui_dialog_show()
-{
-
-}
-
-#ifdef UT_SERVICE_TEST
-
-TEST_F(UT_Service_Test, slotCustomThemeSettingDialogFinished)
-{
- m_service->slotCustomThemeSettingDialogFinished(QDialog::Accepted);
- //更新颜色方案
- EXPECT_TRUE(Settings::instance()->extendColorScheme() == Settings::instance()->m_configCustomThemePath);
-
-}
-
-int ut_window_widgetCount()
-{
- return 200;
-}
-
-TEST_F(UT_Service_Test, EntryTerminal)
-{
- Stub stub;
- stub.set(ADDR(WindowsManager,widgetCount),ut_window_widgetCount);
- m_service->EntryTerminal(QStringList() << "1" << "2",true);
- //启动新的终端
- EXPECT_TRUE(ut_window_widgetCount() > MAXWIDGETCOUNT);
-}
-
-TEST_F(UT_Service_Test, isCountEnable)
-{
- bool isCountEnable = m_service->isCountEnable();
- EXPECT_EQ(isCountEnable, true);
-}
-
-TEST_F(UT_Service_Test, getsetIsDialogShow)
-{
- EXPECT_EQ(m_service->getIsDialogShow(), false);
- if(nullptr == WindowsManager::instance()->m_quakeWindow) {
- TermProperties properties;
- Utils::parseCommandLine({"deepin-terminal", "--quake-mode"}, properties);
- WindowsManager::instance()->m_quakeWindow = new QuakeWindow(properties);
- }
-
- m_service->setIsDialogShow(WindowsManager::instance()->getQuakeWindow(), true);
- //运行雷神窗口
- EXPECT_TRUE(!WindowsManager::instance()->getQuakeWindow()->isEnabled());
-}
-
-TEST_F(UT_Service_Test, getEntryTime)
-{
- qint64 entyTime = m_service->getEntryTime();
- EXPECT_GE(entyTime, 0);
-}
-
-TEST_F(UT_Service_Test, showHideOpacityAndBlurOptions)
-{
- m_service->m_settingDialog = new DSettingsDialog();
- m_service->m_settingDialog->widgetFactory()->registerWidget("fontcombobox", Settings::createFontComBoBoxHandle);
- m_service->m_settingDialog->widgetFactory()->registerWidget("slider", Settings::createCustomSliderHandle);
- m_service->m_settingDialog->widgetFactory()->registerWidget("spinbutton", Settings::createSpinButtonHandle);
- m_service->m_settingDialog->widgetFactory()->registerWidget("shortcut", Settings::createShortcutEditOptionHandle);
-
- m_service->m_settingDialog->updateSettings(Settings::instance()->settings);
- m_service->m_settingDialog->setWindowModality(Qt::NonModal);
- m_service->m_settingDialog->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);
-
-
-
- UT_STUB_QWIDGET_SETVISIBLE_CREATE;
- m_service->showHideOpacityAndBlurOptions(true);
- //会调用setvisible函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SETVISIBLE_RESULT);
-
- UT_STUB_QWIDGET_SETVISIBLE_PREPARE;
- m_service->showHideOpacityAndBlurOptions(false);
- //会调用setvisible函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SETVISIBLE_RESULT);
-
-
-
- QWidget *rightFrame = m_service->m_settingDialog->findChild("RightFrame");
- ASSERT_TRUE(rightFrame);
- rightFrame->setObjectName("RightFrame1");
- UT_STUB_QWIDGET_SETVISIBLE_PREPARE;
- m_service->showHideOpacityAndBlurOptions(true);
- //会调用setvisible函数
- EXPECT_TRUE(!UT_STUB_QWIDGET_SETVISIBLE_RESULT);
- rightFrame->setObjectName("RightFrame");
-
-
-}
-
-TEST_F(UT_Service_Test, isSettingDialogVisible)
-{
- m_service->m_settingDialog = new DSettingsDialog();
- m_service->m_settingDialog->widgetFactory()->registerWidget("fontcombobox", Settings::createFontComBoBoxHandle);
- m_service->m_settingDialog->widgetFactory()->registerWidget("slider", Settings::createCustomSliderHandle);
- m_service->m_settingDialog->widgetFactory()->registerWidget("spinbutton", Settings::createSpinButtonHandle);
- m_service->m_settingDialog->widgetFactory()->registerWidget("shortcut", Settings::createShortcutEditOptionHandle);
-
- m_service->m_settingDialog->updateSettings(Settings::instance()->settings);
- m_service->m_settingDialog->setWindowModality(Qt::NonModal);
- m_service->m_settingDialog->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);
-
- m_service->m_settingDialog->show();
- EXPECT_EQ(m_service->isSettingDialogVisible(), true);
-
- m_service->m_settingDialog->close();
-}
-
-/*******************************************************************************
- 1. @函数: init
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-04
- 4. @说明: 初始化设置框
-*******************************************************************************/
-TEST_F(UT_Service_Test, initSetting)
-{
- DELETE_PTR(m_service->m_settingDialog);
- // 初始化设置框
- m_service->initSetting();
-
- DELETE_PTR(m_service->m_settingDialog);
- // 初始化设置框
- Stub stub;
- stub.set(ADDR(DWindowManagerHelper,hasComposite),ut_dtk_managerhelper_hasComposite);
- m_service->initSetting();
-
- // 判断设置框是否被初始化
- EXPECT_NE(m_service->m_settingDialog, nullptr);
- // 获取刚刚生成的dialog
- DSettingsDialog *settingDialog = m_service->m_settingDialog;
- // 再次初始化
- m_service->initSetting();
- // 若已经初始化过,此时指针不变
- EXPECT_NE(m_service->m_settingDialog, nullptr);
- EXPECT_EQ(m_service->m_settingDialog, settingDialog);
-}
-
-/*******************************************************************************
- 1. @函数: getShells
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-04
- 4. @说明: 获取可获取的shell名称和地址
-*******************************************************************************/
-TEST_F(UT_Service_Test, getShells)
-{
- // 获取shell列表
- QMap shellMap = m_service->getShells();
- // 正常情况下若没有shell终端无法打开,所以map不为空
- EXPECT_EQ(shellMap.isEmpty(), false);
- // 且m_shellsMap需要被赋值,内容不为空
- EXPECT_EQ(m_service->m_shellsMap.isEmpty(), false);
-}
-
-/*******************************************************************************
- 1. @函数: shellsMap
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-04
- 4. @说明: 获取当前的shellMap
-*******************************************************************************/
-TEST_F(UT_Service_Test, shellsMap)
-{
- // 清空map
- m_service->m_shellsMap.clear();
- // 获取时候,应该是空的
- EXPECT_EQ(m_service->shellsMap().isEmpty(), true);
- // 获取数据
- m_service->getShells();
- // 内容不为空
- EXPECT_EQ(m_service->shellsMap().isEmpty(), false);
-}
-
-/*******************************************************************************
- 1. @函数: Entry
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-04
- 4. @说明: Service进入接口
-*******************************************************************************/
-TEST_F(UT_Service_Test, Entry)
-{
- // -q进入,启动雷神窗口
- m_service->Entry(QStringList() << "deepin-terminal" << "-q");
- // 雷神窗口不为空
- EXPECT_NE(WindowsManager::instance()->getQuakeWindow(), nullptr);
- // 不带参数进入,启动普通窗口
- // 获取窗口数量
- int widgetCount = WindowsManager::instance()->widgetCount();
- m_service->Entry(QStringList() << "");
- EXPECT_EQ(WindowsManager::instance()->widgetCount(), widgetCount + 1);
-}
-
-/*******************************************************************************
- 1. @函数: isSettingDialogVisible
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-08
- 4. @说明: 设置框是否显示
-*******************************************************************************/
-TEST_F(UT_Service_Test, isSettingDialogVisible2)
-{
- // 此时没有设置窗口新建,应该得到false
- EXPECT_EQ(m_service->isSettingDialogVisible(), false);
-
- // 初始化设置窗口,但是没有show此时应该得到false
- m_service->initSetting();
- EXPECT_EQ(m_service->isSettingDialogVisible(), false);
-
- // 此时显示设置框,应该得到true
- m_service->m_settingDialog->show();
- EXPECT_EQ(m_service->isSettingDialogVisible(), true);
-}
-
-/*******************************************************************************
- 1. @函数: getSettingOwner
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-08
- 4. @说明: 验证获取设置框的所有者是否正确
-*******************************************************************************/
-TEST_F(UT_Service_Test, getSettingOwner)
-{
- // 未设置时是空
- m_service->m_settingOwner = nullptr;
- EXPECT_EQ(m_service->getSettingOwner(), nullptr);
-
- // 显示设置时会有父类
- MainWindow *window = new NormalWindow(TermProperties("/"));
- m_service->showSettingDialog(window);
- EXPECT_EQ(m_service->getSettingOwner(), window);
-
- // 重置设置框所有者
- m_service->resetSettingOwner();
- EXPECT_EQ(m_service->getSettingOwner(), nullptr);
- // 删除临时变量
- delete window;
-}
-
-/*******************************************************************************
- 1. @函数: resetSettingOwner
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-08
- 4. @说明: 重置设置框的所有者
-*******************************************************************************/
-TEST_F(UT_Service_Test, resetSettingOwner)
-{
- // 显示设置
- MainWindow *window = new NormalWindow(TermProperties("/"));
- m_service->m_settingOwner = window;
- EXPECT_EQ(m_service->getSettingOwner(), window);
- // 重置设置框所有者
- m_service->resetSettingOwner();
- EXPECT_EQ(m_service->getSettingOwner(), nullptr);
- // 删除临时变量
- delete window;
-}
-
-/*******************************************************************************
- 1. @函数: onDesktopWorkspaceSwitched
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-08
- 4. @说明: 桌面工作区切换 => 雷神窗口的显隐
-*******************************************************************************/
-TEST_F(UT_Service_Test, onDesktopWorkspaceSwitched)
-{
- // 设置当前窗口1
- DBusManager::callKDESetCurrentDesktop(1);
- // 关闭雷神
- if (WindowsManager::instance()->getQuakeWindow()) {
- WindowsManager::instance()->getQuakeWindow()->closeAllTab();
- }
-
- // 关闭雷神窗口 没有雷神,没有任何影响,程序正常运行
- m_service->onDesktopWorkspaceSwitched(1, 2);
-
- TermProperties properties;
- Utils::parseCommandLine(QStringList() << "deepin-terminal" << "-q", properties);
- // 显示雷神
- WindowsManager::instance()->runQuakeWindow(properties);
-
- // 切换桌面1到桌面2
- m_service->onDesktopWorkspaceSwitched(1, 2);
-
- // 切换桌面雷神影藏
- EXPECT_EQ(WindowsManager::instance()->getQuakeWindow()->isHidden(), true);
- // 切回
- m_service->onDesktopWorkspaceSwitched(2, WindowsManager::instance()->getQuakeWindow()->m_desktopIndex);
-
- // 雷神显示
- EXPECT_EQ(WindowsManager::instance()->getQuakeWindow()->isVisible(), true);
- // 关闭雷神
- WindowsManager::instance()->getQuakeWindow()->closeAllTab();
-}
-
-TEST_F(UT_Service_Test, showShortcutConflictMsgbox)
-{
- Stub sub;
- sub.set(ADDR(DDialog, show), ui_dialog_show);
- QString txt = ShortcutManager::instance()->m_mapReplaceText.keys().value(0);
- //设置中心
- EXPECT_TRUE(m_service->m_settingDialog);
- m_service->showShortcutConflictMsgbox(txt);
- //显示快捷键冲突窗口
- EXPECT_TRUE(m_service->m_settingShortcutConflictDialog->title().count() > 0);
-}
-
-TEST_F(UT_Service_Test, slotSettingShortcutConflictDialogFinished)
-{
- m_service->slotSettingShortcutConflictDialogFinished();
- //关闭快捷键冲突窗口
- EXPECT_TRUE(!m_service->m_settingShortcutConflictDialog);
-}
-
-TEST_F(UT_Service_Test, hideSettingDialog)
-{
- if(nullptr == m_service->m_settingDialog)
- m_service->m_settingDialog = new DSettingsDialog();
-
- UT_STUB_QWIDGET_SETVISIBLE_CREATE;
- m_service->hideSettingDialog();
- //会调用setvisible函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SETVISIBLE_RESULT);
-}
-
-#endif
diff --git a/tests/src/main/ut_service_test.h b/tests/src/main/ut_service_test.h
deleted file mode 100644
index e8592e5cf..000000000
--- a/tests/src/main/ut_service_test.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_SERVICE_TEST_H
-#define UT_SERVICE_TEST_H
-
-#include "ut_defines.h"
-#include "utils.h"
-
-#include
-
-class Service;
-
-class UT_Service_Test : public ::testing::Test
-{
-public:
- UT_Service_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-private:
- Service *m_service = nullptr;
-};
-
-#endif // UT_SERVICE_TEST_H
-
diff --git a/tests/src/main/ut_terminalapplication_test.cpp b/tests/src/main/ut_terminalapplication_test.cpp
deleted file mode 100644
index 979beb581..000000000
--- a/tests/src/main/ut_terminalapplication_test.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_terminalapplication_test.h"
-
-#include "terminalapplication.h"
-#include "../stub.h"
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-#include
-
-UT_TerminalApplication_Test::UT_TerminalApplication_Test()
-{
-}
-
-void UT_TerminalApplication_Test::SetUp()
-{
-}
-
-void UT_TerminalApplication_Test::TearDown()
-{
-}
-
-#ifdef UT_TERMINALAPPLICATION_TEST
-
-int ut_key()
-{
- return Qt::Key_Enter;
-}
-
-TEST_F(UT_TerminalApplication_Test, getsetStartTime)
-{
- int argc = 0;
- char **argv = nullptr;
- TerminalApplication *app = new TerminalApplication(argc, argv);
- Stub stub;
- stub.set(ADDR(QKeyEvent,key),ut_key);
- QtConcurrent::run([ = ]() {
- QTimer timer;
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- app->quit();
- });
-
- timer.start(1000);
- loop->exec();
-
- delete loop;
- });
-
- QTime useTime;
- useTime.start();
- qint64 startTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
-
- app->setStartTime(startTime);
-
- qint64 getStartTime = app->getStartTime();
- EXPECT_EQ(startTime, getStartTime);
-
- app->exec();
-}
-
-TEST_F(UT_TerminalApplication_Test, notify)
-{
- int argc = 0;
- char **argv = nullptr;
- TerminalApplication *app = new TerminalApplication(argc, argv);
-
- QtConcurrent::run([ = ]() {
- QTimer timer;
- DKeySequenceEdit* object = new DKeySequenceEdit();
- QEvent *event = new QEvent(QEvent::FocusOut);
-
- app->notify(object, event);
- if (event) {
- delete event;
- }
- timer.setSingleShot(true);
-
- QEventLoop *loop = new QEventLoop;
- QObject::connect(&timer, &QTimer::timeout, [ = ]() {
- loop->quit();
- app->quit();
- delete object;
- delete loop;
- });
-
- timer.start(2000);
- loop->exec();
- });
-
- QTime useTime;
- useTime.start();
- qint64 startTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
-
- app->setStartTime(startTime);
-
- qint64 getStartTime = app->getStartTime();
- EXPECT_EQ(startTime, getStartTime);
-
- app->exec();
-}
-
-#endif
diff --git a/tests/src/main/ut_terminalapplication_test.h b/tests/src/main/ut_terminalapplication_test.h
deleted file mode 100644
index a4aad829b..000000000
--- a/tests/src/main/ut_terminalapplication_test.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_TerminalApplication_Test_H
-#define UT_TerminalApplication_Test_H
-
-#include "ut_defines.h"
-
-#include
-
-class Service;
-class MainWindow;
-class UT_TerminalApplication_Test : public ::testing::Test
-{
-public:
- UT_TerminalApplication_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-};
-
-#endif // UT_TerminalApplication_Test_H
-
diff --git a/tests/src/main/ut_termproperties_test.cpp b/tests/src/main/ut_termproperties_test.cpp
deleted file mode 100644
index c4b7e830b..000000000
--- a/tests/src/main/ut_termproperties_test.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_termproperties_test.h"
-
-#include "termproperties.h"
-
-//Google GTest 相关头文件
-#include
-
-//Qt单元测试相关头文件
-#include
-
-UT_TermProperties_Test::UT_TermProperties_Test()
-{
-}
-
-void UT_TermProperties_Test::SetUp()
-{
-}
-
-void UT_TermProperties_Test::TearDown()
-{
-}
-
-#ifdef UT_TERMPROPERTIES_TEST
-
-TEST_F(UT_TermProperties_Test, setWorkingDir)
-{
- QString workingDir = "";
- TermProperties tp(workingDir);
- workingDir = "/home/uos";
- tp.setWorkingDir(workingDir);
-
- EXPECT_EQ(tp.m_properties[TermProperty::WorkingDir], workingDir);
-}
-
-TEST_F(UT_TermProperties_Test, contains)
-{
- QString workingDir = "/home/uos";
- QString colorScheme = "someColorScheme";
- TermProperties tp(workingDir, colorScheme);
- EXPECT_EQ(tp.contains(TermProperty::WorkingDir), true);
- EXPECT_EQ(tp.contains(TermProperty::ColorScheme), true);
-}
-
-TEST_F(UT_TermProperties_Test, setTermPropertyMap)
-{
- QMap list;
- TermProperties tp(list);
- QString workingDir = "/home/uos";
- QString colorScheme = "someColorScheme";
-
- list.insert(TermProperty::WorkingDir, workingDir);
- list.insert(TermProperty::ColorScheme, colorScheme);
-
- tp.setTermPropertyMap(list);
-
- EXPECT_EQ(tp.m_properties, list);
-}
-#endif
diff --git a/tests/src/main/ut_termproperties_test.h b/tests/src/main/ut_termproperties_test.h
deleted file mode 100644
index 827aeb846..000000000
--- a/tests/src/main/ut_termproperties_test.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_TERMPROPERTIES_TEST_H
-#define UT_TERMPROPERTIES_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class UT_TermProperties_Test : public ::testing::Test
-{
-public:
- UT_TermProperties_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-};
-
-#endif // UT_TERMPROPERTIES_TEST_H
-
diff --git a/tests/src/main/ut_windowsmanager_test.cpp b/tests/src/main/ut_windowsmanager_test.cpp
deleted file mode 100644
index ea22af558..000000000
--- a/tests/src/main/ut_windowsmanager_test.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_windowsmanager_test.h"
-#include "../stub.h"
-#include "service.h"
-#include "mainwindow.h"
-#include "tabbar.h"
-#include "termwidget.h"
-#include "windowsmanager.h"
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-UI_WindowsManager_Test::UI_WindowsManager_Test()
-{
-}
-
-void UI_WindowsManager_Test::SetUp()
-{
- m_service = Service::instance();
- //Service的init初始化函数只能执行一次,否则会crash
- if (!m_service->property("isServiceInit").toBool()) {
- m_service->init();
- m_service->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
-
- m_quakeTermProperty[QuakeMode] = true;
-}
-
-void UI_WindowsManager_Test::TearDown()
-{
-}
-
-static int ut_quakeWindow_getDesktopIndex()
-{
- return -1;
-}
-
-static bool ut_service_getIsDialogShow()
-{
- return false;
-}
-static bool ut_service_isSettingDialogVisible()
-{
- return true;
-}
-
-static MainWindow* ut_service_getSettingOwner()
-{
- return WindowsManager::instance()->getQuakeWindow();
-}
-
-static bool ut_quakeWindow_isActiveWindow()
-{
- return true;
-}
-
-#ifdef UI_WINDOWSMANAGER_TEST
-
-TEST_F(UI_WindowsManager_Test, runQuakeWindow)
-{
- WindowsManager *winManager = WindowsManager::instance();
- winManager->runQuakeWindow(m_quakeTermProperty);
- EXPECT_EQ((winManager->m_quakeWindow != nullptr), true);
-}
-
-TEST_F(UI_WindowsManager_Test, getQuakeWindow)
-{
- WindowsManager *winManager = WindowsManager::instance();
- MainWindow *mainWin = winManager->getQuakeWindow();
- EXPECT_EQ((mainWin != nullptr), true);
-}
-
-TEST_F(UI_WindowsManager_Test, createNormalWindow)
-{
- WindowsManager *winManager = WindowsManager::instance();
- winManager->createNormalWindow(m_normalTermProperty);
-
- if(!WindowsManager::instance()->getNormalWindowList().isEmpty())
- WindowsManager::instance()->onMainwindowClosed(WindowsManager::instance()->getNormalWindowList().last());
-
- EXPECT_EQ((winManager->m_normalWindowList.size() > 0), true);
-}
-
-TEST_F(UI_WindowsManager_Test, terminalCountIncrease)
-{
- WindowsManager *winManager = WindowsManager::instance();
- int widgetCount = winManager->widgetCount();
- winManager->terminalCountIncrease();
- EXPECT_EQ(winManager->widgetCount(), widgetCount + 1);
-}
-
-TEST_F(UI_WindowsManager_Test, terminalCountReduce)
-{
- WindowsManager *winManager = WindowsManager::instance();
- int widgetCount = winManager->widgetCount();
- winManager->terminalCountReduce();
- EXPECT_EQ(winManager->widgetCount(), widgetCount - 1);
-}
-
-/*******************************************************************************
- 1. @函数: runQuakeWindow
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-09
- 4. @说明: 运行雷神窗口的显隐测试
-*******************************************************************************/
-TEST_F(UI_WindowsManager_Test, runQuakeWindow2)
-{
- // 若雷神还在就关闭
- if (WindowsManager::instance()->getQuakeWindow()) {
- WindowsManager::instance()->getQuakeWindow()->closeAllTab();
- WindowsManager::instance()->m_quakeWindow = nullptr;
- }
-
- // 启动雷神
- WindowsManager::instance()->runQuakeWindow(m_quakeTermProperty);
- WindowsManager::instance()->m_quakeWindow->setAnimationFlag(true);
- // 雷神存在
- EXPECT_NE(WindowsManager::instance()->getQuakeWindow(), nullptr);
- // 相当于再次Alt+F2
- WindowsManager::instance()->runQuakeWindow(m_quakeTermProperty);
-
- // 关闭雷神窗口
- WindowsManager::instance()->getQuakeWindow()->closeAllTab();
- WindowsManager::instance()->m_quakeWindow = nullptr;
-}
-
-/*******************************************************************************
- 1. @函数: onMainwindowClosed
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-09
- 4. @说明: 测试窗口关闭
-*******************************************************************************/
-TEST_F(UI_WindowsManager_Test, onMainwindowClosed)
-{
- // 新建一个窗口
- MainWindow *newWindow = new NormalWindow(m_normalTermProperty);
- // 关闭当前的窗口 => 测试是否正常执行
- WindowsManager::instance()->onMainwindowClosed(newWindow);
-
- // 没有雷神窗口
- if (!WindowsManager::instance()->getQuakeWindow()) {
- // 创建雷神窗口
- WindowsManager::instance()->runQuakeWindow(m_quakeTermProperty);
- }
- // 关闭雷神窗口
- WindowsManager::instance()->getQuakeWindow()->closeAllTab();
- if (WindowsManager::instance()->getQuakeWindow()) {
- WindowsManager::instance()->onMainwindowClosed(WindowsManager::instance()->getQuakeWindow());
- }
- EXPECT_EQ(WindowsManager::instance()->getQuakeWindow(), nullptr);
-}
-
-//TEST_F(UI_WindowsManager_Test, quakeWindowShowOrHide)
-//{
-// // 若雷神还在就关闭
-// if (WindowsManager::instance()->getQuakeWindow()) {
-// WindowsManager::instance()->getQuakeWindow()->closeAllTab();
-// WindowsManager::instance()->m_quakeWindow = nullptr;
-// }
-
-// // 启动雷神
-// WindowsManager::instance()->runQuakeWindow(m_quakeTermProperty);
-// WindowsManager::instance()->m_quakeWindow->setAnimationFlag(true);
-// // 雷神存在
-// EXPECT_NE(WindowsManager::instance()->getQuakeWindow(), nullptr);
-// // 雷神显示
-// EXPECT_EQ(WindowsManager::instance()->getQuakeWindow()->isVisible(), true);
-// WindowsManager::instance()->getQuakeWindow()->setVisible(false);
-// WindowsManager::instance()->m_quakeWindow->hideQuakeWindow();
-// WindowsManager::instance()->quakeWindowShowOrHide();
-
-// {
-// Stub stub;
-// stub.set(ADDR(QuakeWindow, getDesktopIndex), ut_quakeWindow_getDesktopIndex);
-// WindowsManager::instance()->quakeWindowShowOrHide();
-// }
-
-// {
-// Stub stub;
-// stub.set(ADDR(Service, getIsDialogShow), ut_service_getIsDialogShow);
-// stub.set(ADDR(Service, isSettingDialogVisible), ut_service_isSettingDialogVisible);
-// stub.set(ADDR(Service, getSettingOwner), ut_service_getSettingOwner);
-// WindowsManager::instance()->quakeWindowShowOrHide();
-// }
-// {
-
-// Stub stub;
-// stub.set(ADDR(Service, getIsDialogShow), ut_service_getIsDialogShow);
-// stub.set(ADDR(QuakeWindow, isActiveWindow), ut_quakeWindow_isActiveWindow);
-// WindowsManager::instance()->quakeWindowShowOrHide();
-// }
-
-// // 相当于再次Alt+F2
-// WindowsManager::instance()->runQuakeWindow(m_quakeTermProperty);
-// // 雷神隐藏 => 又开始了新一轮的动画
-// EXPECT_EQ(WindowsManager::instance()->getQuakeWindow()->isNotAnimation, false);
-
-// // 关闭雷神窗口
-// WindowsManager::instance()->getQuakeWindow()->closeAllTab();
-// WindowsManager::instance()->m_quakeWindow = nullptr;
-//}
-
-TEST_F(UI_WindowsManager_Test, getNormalWindowList)
-{
- int oldCount = WindowsManager::instance()->getNormalWindowList().size();
- WindowsManager::instance()->createNormalWindow(TermProperties("/"), false);
- //增加一个window
- EXPECT_TRUE(WindowsManager::instance()->getNormalWindowList().size() == (oldCount + 1));
-}
-
-#endif
diff --git a/tests/src/main/ut_windowsmanager_test.h b/tests/src/main/ut_windowsmanager_test.h
deleted file mode 100644
index afad10ad6..000000000
--- a/tests/src/main/ut_windowsmanager_test.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UI_WINDOWSMANAGER_TEST_H
-#define UI_WINDOWSMANAGER_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class Service;
-class MainWindow;
-class UI_WindowsManager_Test : public ::testing::Test
-{
-public:
- UI_WindowsManager_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- Service *m_service = nullptr;
-
- TermProperties m_normalTermProperty;
- TermProperties m_quakeTermProperty;
-};
-
-#endif // UI_WINDOWSMANAGER_TEST_H
-
diff --git a/tests/src/remotemanage/ut_remotemanagementpanel_test.cpp b/tests/src/remotemanage/ut_remotemanagementpanel_test.cpp
deleted file mode 100644
index 2e3f6c782..000000000
--- a/tests/src/remotemanage/ut_remotemanagementpanel_test.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_remotemanagementpanel_test.h"
-#include "remotemanagementpanel.h"
-#include "utils.h"
-#include "../stub.h"
-#include "service.h"
-#include "ut_stub_defines.h"
-
-//Qt
-#include
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-UT_RemoteManagementPanel_Test::UT_RemoteManagementPanel_Test()
-{
-}
-void stub_return()
-{
- return;
-}
-
-void UT_RemoteManagementPanel_Test::SetUp()
-{
- //远程服务器管理
- m_serverConfigManager = ServerConfigManager::instance();
- // 初始化远程管理数据
- m_serverConfigManager->initServerConfig();
-
- prepareData();
-}
-
-int UT_RemoteManagementPanel_Test::getServerConfigCount()
-{
- QList serverConfigList;
- QMap> severConfigs = ServerConfigManager::instance()->getServerConfigs();
- for (QMap>::iterator iter = severConfigs.begin(); iter != severConfigs.end(); ++iter) {
- QList value = iter.value();
- for (int i = 0; i < value.size(); ++i) {
- serverConfigList.append(value.at(i));
- }
- }
-
- qDebug() << serverConfigList.count();
- return serverConfigList.count();
-}
-
-void UT_RemoteManagementPanel_Test::prepareData()
-{
- ServerConfigManager *serverConfigManager = ServerConfigManager::instance();
- serverConfigManager->initServerConfig();
-
- int serverConfigCount = getServerConfigCount();
- qDebug() << serverConfigCount << endl;
-
- QString groupName = QString("group_01");
-
- qsrand(static_cast(time(nullptr)));
- ServerConfig *config = new ServerConfig();
- config->m_serverName = QString("new_server_%1").arg(Utils::getRandString());
- config->m_address = QString("192.168.10.%1").arg(qrand() % 255);
- config->m_userName = QString("zhangsan");
- config->m_password = QString("123");
- config->m_privateKey = QString("");
- config->m_port = QString("");
- config->m_group = groupName;
- config->m_path = QString("");
- config->m_command = QString("");
- config->m_encoding = QString("");
- config->m_backspaceKey = QString("");
- config->m_deleteKey = QString("");
-
- serverConfigManager->saveServerConfig(config);
- EXPECT_EQ(getServerConfigCount(), serverConfigCount + 1);
-
- int serverCount = serverConfigManager->getServerCount(config->m_group);
-
- ServerConfig *currConfig = serverConfigManager->getServerConfig(config->m_serverName);
- EXPECT_NE(currConfig, nullptr);
-
- qsrand(static_cast(time(nullptr)));
- ServerConfig *newConfig = new ServerConfig();
- newConfig->m_serverName = QString("new_server_%1").arg(Utils::getRandString());
- newConfig->m_address = QString("192.168.10.%1").arg(qrand() % 255);
- newConfig->m_userName = QString("uos");
- newConfig->m_password = QString("123456");
- newConfig->m_privateKey = QString("");
- newConfig->m_port = QString("");
- newConfig->m_group = groupName;
- newConfig->m_path = QString("");
- newConfig->m_command = QString("");
- newConfig->m_encoding = QString("");
- newConfig->m_backspaceKey = QString("");
- newConfig->m_deleteKey = QString("");
- serverConfigManager->modifyServerConfig(newConfig, currConfig);
- EXPECT_EQ(newConfig, serverConfigManager->getServerConfig(newConfig->m_serverName));
-
- EXPECT_GE(serverCount, 1);
-
- serverConfigManager->delServerConfig(newConfig);
- EXPECT_EQ(getServerConfigCount(), serverConfigCount);
-
- EXPECT_EQ(serverConfigManager->getServerCount(groupName), serverCount - 1);
-}
-
-void UT_RemoteManagementPanel_Test::TearDown()
-{
-}
-
-#ifdef UT_REMOTEMANAGEMENTPANEL_TEST
-TEST_F(UT_RemoteManagementPanel_Test, refreshPanel)
-{
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- RemoteManagementPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
-
- panel.refreshPanel();
-
-
-}
-
-TEST_F(UT_RemoteManagementPanel_Test, setFocusInPanel)
-{
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- RemoteManagementPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
-
- panel.setFocusInPanel();
- int listIndex = panel.getListIndex();
- qDebug() << "listIndex:" << listIndex << endl;
- EXPECT_EQ(listIndex, -1);
-
- // 最后一种情况
- panel.m_searchEdit->hide();
- panel.m_listWidget->hide();
- panel.setFocusInPanel();
-
-
-}
-
-TEST_F(UT_RemoteManagementPanel_Test, setFocusBack)
-{
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- RemoteManagementPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
-
- // 创建分组
- ServerConfig groupConfig;
- groupConfig.m_serverName = "group_item";
- groupConfig.m_address = "127.0.0.1";
- groupConfig.m_group = "group2020";
- groupConfig.m_userName = "dzw";
- groupConfig.m_port = "22";
- // 分组数据存储结构
- QList list;
- list.append(&groupConfig);
- // 数据存储结构
- ServerConfigManager::instance()->m_serverConfigs.insert("group2020", list);
- // 刷新列表,填充数据
- panel.refreshPanel();
-
- // 要焦点
- panel.m_listWidget->setFocusState(true);
- panel.setFocusBack("group2020");
- int listIndex = panel.getListIndex();
- EXPECT_GE(listIndex, 0);
-
- // 找不到情况
- panel.setFocusBack("group1988");
- listIndex = panel.getListIndex();
- EXPECT_GE(listIndex, 0);
- ServerConfigManager::instance()->m_serverConfigs.clear();
-
-}
-
-TEST_F(UT_RemoteManagementPanel_Test, clearListFocus)
-{
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- RemoteManagementPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
-
- panel.clearListFocus();
- EXPECT_EQ(panel.m_backButton->hasFocus(), false);
- EXPECT_EQ(panel.m_listWidget->hasFocus(), false);
- EXPECT_EQ(panel.m_searchEdit->hasFocus(), false);
- EXPECT_EQ(panel.m_listWidget->currentIndex(), -1);
-}
-
-TEST_F(UT_RemoteManagementPanel_Test, refreshSearchState)
-{
- const int PANEL_WIDTH = 242;
- const int PANEL_HEIGHT = 600;
- RemoteManagementPanel panel;
- panel.resize(PANEL_WIDTH, PANEL_HEIGHT);
- panel.show();
- EXPECT_EQ(panel.size().width(), PANEL_WIDTH);
- EXPECT_EQ(panel.size().height(), PANEL_HEIGHT);
- ServerConfigManager::instance()->m_serverConfigs.clear();
- // 一个也没有,搜索框隐藏
- panel.refreshSearchState();
- //添加数据,显示搜索框
- ServerConfig config;
- config.m_serverName = "test_item";
- config.m_address = "127.0.0.1";
- config.m_userName = "dzw";
- config.m_port = "22";
- ServerConfig config2;
- config2.m_serverName = "test_item2";
- config2.m_address = "127.0.0.1";
- config2.m_userName = "dzw";
- config2.m_port = "22";
- // 分组数据存储结构
- QList list;
- list.append(&config);
- list.append(&config2);
- // 数据存储结构
- ServerConfigManager::instance()->m_serverConfigs.insert("", list);
- // 刷新列表,填充数据
- panel.refreshPanel();
- // 两个数据,搜索框显示
- panel.refreshSearchState();
- // list中数据的数量
- int count = panel.m_listWidget->count();
- EXPECT_EQ(count, 2);
- ServerConfigManager::instance()->m_serverConfigs.clear();
-}
-
-/*******************************************************************************
- 1. @函数: onItemClicked
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-22
- 4. @说明: 当前项被点击
-*******************************************************************************/
-//TEST_F(UT_RemoteManagementPanel_Test, onItemClicked)
-//{
-// // 初始化一个panel
-// RemoteManagementPanel remotePanel;
-// remotePanel.show();
-// // 初始化一个可点击的数据
-// //添加数据,显示搜索框
-// ServerConfig config;
-// config.m_serverName = "test_item";
-// config.m_address = "127.0.0.1";
-// config.m_userName = "dzw";
-// config.m_port = "22";
-// // 添加数据到列表中
-// // 分组数据存储结构
-// QList list;
-// list.append(&config);
-// // 数据存储结构
-// ServerConfigManager::instance()->m_serverConfigs.insert("", list);
-// // 刷新列表,填充数据
-
-// UT_STUB_QWIDGET_SETVISIBLE_CREATE;
-// remotePanel.refreshPanel();
-// EXPECT_TRUE(remotePanel.m_searchEdit->text().isEmpty());
-// EXPECT_TRUE(remotePanel.m_listWidget->count() > 0);
-// //刷新远程控制列表时,会触发setvisible函数
-// EXPECT_TRUE(UT_STUB_QWIDGET_SETVISIBLE_RESULT);
-
-// // 模拟数据被点击
-// // 传来被点击的key值
-// QSignalSpy spy(&remotePanel, &RemoteManagementPanel::doConnectServer);
-// remotePanel.onItemClicked("test_item");
-// ASSERT_TRUE(ServerConfigManager::instance()->getServerConfig("test_item") != nullptr);
-// //会emit doConnectServer
-// EXPECT_TRUE(spy.count() == 1);
-
-// // 传来错误的值
-// remotePanel.onItemClicked("test_item2");
-// ASSERT_TRUE(ServerConfigManager::instance()->getServerConfig("test_item2") == nullptr);
-// //不会 emit doConnectServer
-// EXPECT_TRUE(spy.count() == 1);
-// ServerConfigManager::instance()->m_serverConfigs.clear();
-//}
-
-/*******************************************************************************
- 1. @函数: showCurSearchResult
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-22
- 4. @说明: 测试接口是否可以正常调用
-*******************************************************************************/
-TEST_F(UT_RemoteManagementPanel_Test, showCurSearchResult)
-{
- // 没有搜索内容
- RemoteManagementPanel remotePanel;
- remotePanel.show();
- remotePanel.m_searchEdit->setText("");
- remotePanel.showCurSearchResult();
- EXPECT_TRUE(remotePanel.m_searchEdit->text().isEmpty());
- // 有搜索内容
- remotePanel.m_searchEdit->setText("aaa");
- remotePanel.showCurSearchResult();
- EXPECT_TRUE(remotePanel.m_searchEdit->text() == "aaa");
-}
-
-/*******************************************************************************
- 1. @函数: showAddServerConfigDlg
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-22
- 4. @说明: 弹出添加数据弹窗
-*******************************************************************************/
-TEST_F(UT_RemoteManagementPanel_Test, showAddServerConfigDlg)
-{
- // 没有搜索内容
- RemoteManagementPanel *remotePanel = new RemoteManagementPanel;
- remotePanel->show();
- // 打桩
- Stub s;
- s.set(ADDR(Service, setIsDialogShow), stub_return);
-
- // 显示弹窗
- remotePanel->showAddServerConfigDlg();
- ServerConfigOptDlg *dialog = remotePanel->findChild();
- ASSERT_TRUE(dialog);
- emit dialog->reject();
-
- // 设置添加按钮有焦点
- UT_STUB_QWIDGET_SHOW_CREATE;
- remotePanel->showAddServerConfigDlg();
- dialog = remotePanel->findChild();
- //会触发dialog show函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SHOW_RESULT);
- emit dialog->accept();
-
- remotePanel->deleteLater();
-}
-
-/*******************************************************************************
- 1. @函数: lambda
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 测试部分lambda表达式是否正常响应信号
-*******************************************************************************/
-TEST_F(UT_RemoteManagementPanel_Test, lambda)
-{
- // 初始化界面
- RemoteManagementPanel remotePanel;
- remotePanel.show();
- remotePanel.m_isShow = true;
- // 刷新界面
- emit ServerConfigManager::instance()->refreshList();
-
-
- // 焦点切入切出
- // 切出理由
- emit remotePanel.m_listWidget->focusOut(Qt::TabFocusReason);
-
- // 列表内没有index
- EXPECT_EQ(remotePanel.m_listWidget->m_currentIndex, -1);
- emit remotePanel.m_listWidget->focusOut(Qt::BacktabFocusReason);
-
- EXPECT_EQ(remotePanel.m_listWidget->m_currentIndex, -1);
-
-}
-#endif
diff --git a/tests/src/remotemanage/ut_remotemanagementpanel_test.h b/tests/src/remotemanage/ut_remotemanagementpanel_test.h
deleted file mode 100644
index aa620123d..000000000
--- a/tests/src/remotemanage/ut_remotemanagementpanel_test.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_REMOTEMANAGEMENTPANEL_TEST_H
-#define UT_REMOTEMANAGEMENTPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "serverconfigmanager.h"
-
-#include
-
-class UT_RemoteManagementPanel_Test : public ::testing::Test
-{
-public:
- UT_RemoteManagementPanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
- ServerConfigManager *m_serverConfigManager = nullptr;
-
-private:
- int getServerConfigCount();
-
- void prepareData();
-};
-
-#endif // UT_REMOTEMANAGEMENTPANEL_TEST_H
diff --git a/tests/src/remotemanage/ut_remotemanagementplugn_test.cpp b/tests/src/remotemanage/ut_remotemanagementplugn_test.cpp
deleted file mode 100644
index 3d8674ef3..000000000
--- a/tests/src/remotemanage/ut_remotemanagementplugn_test.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_remotemanagementplugn_test.h"
-
-#include "remotemanagementplugn.h"
-#include "mainwindow.h"
-#include "service.h"
-
-//Google GTest 相关头文件
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-
-class ServerConfigClass : public QObject{
-public:
- explicit ServerConfigClass(QObject *parent);
- virtual ~ServerConfigClass();
- ServerConfig config;
-};
-
-ServerConfigClass::ServerConfigClass(QObject *parent) : QObject(parent)
-{
-
-}
-
-ServerConfigClass::~ServerConfigClass()
-{
-
-}
-
-UT_RemoteManagementPlugin_Test::UT_RemoteManagementPlugin_Test()
-{
-}
-
-void UT_RemoteManagementPlugin_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
-}
-
-void UT_RemoteManagementPlugin_Test::TearDown()
-{
- delete m_normalWindow;
-}
-
-#ifdef UT_REMOTEMANAGEMENTPLUGIN_TEST
-TEST_F(UT_RemoteManagementPlugin_Test, setRemoteEncode)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- remotePlugin->setRemoteEncode(QString("UTF-8"));
-}
-
-TEST_F(UT_RemoteManagementPlugin_Test, setBackspaceKey)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- TermWidget *termWidget = m_normalWindow->currentActivatedTerminal();
- remotePlugin->setBackspaceKey(termWidget, QString("control-h"));
- remotePlugin->setBackspaceKey(termWidget, QString("auto"));
- remotePlugin->setBackspaceKey(termWidget, QString("escape-sequence"));
- remotePlugin->setBackspaceKey(termWidget, QString("ascii-del"));
- remotePlugin->setBackspaceKey(termWidget, QString("tty"));
-}
-
-TEST_F(UT_RemoteManagementPlugin_Test, setDeleteKey)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- TermWidget *termWidget = m_normalWindow->currentActivatedTerminal();
- remotePlugin->setDeleteKey(termWidget, QString("control-h"));
- remotePlugin->setDeleteKey(termWidget, QString("auto"));
- remotePlugin->setDeleteKey(termWidget, QString("escape-sequence"));
- remotePlugin->setDeleteKey(termWidget, QString("ascii-del"));
- remotePlugin->setDeleteKey(termWidget, QString("tty"));
-}
-
-TEST_F(UT_RemoteManagementPlugin_Test, createShellFile)
-{
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- QString groupName = QString("group_01");
-
- qsrand(static_cast(time(nullptr)));
- ServerConfig *config = new ServerConfig();
- config->m_serverName = QString("new_server_%1").arg(Utils::getRandString());
- config->m_address = QString("192.168.10.%1").arg(qrand() % 255);
- config->m_userName = QString("zhangsan");
- config->m_password = QString("123");
- config->m_privateKey = QString("");
- config->m_port = QString("");
- config->m_group = groupName;
- config->m_path = QString("");
- config->m_command = QString("");
- config->m_encoding = QString("");
- config->m_backspaceKey = QString("");
- config->m_deleteKey = QString("");
-
- QString shellFile = remotePlugin->createShellFile(config);
- EXPECT_NE(shellFile.length(), 0);
- delete config;
-}
-
-/*******************************************************************************
- 1. @函数: createShellFile
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-13
- 4. @说明: 测试创建脚本的各种情况
-*******************************************************************************/
-TEST_F(UT_RemoteManagementPlugin_Test, createShellFile2)
-{
- RemoteManagementPlugin *pRemotePlugin = new RemoteManagementPlugin;
- ServerConfig config;
- config.m_userName = "root";
- config.m_address = "127.0.0.1";
- config.m_port = "22";
- // 密钥为空
- config.m_privateKey = "";
- config.m_password = "1";
- config.m_path = "/";
- config.m_command = "ls";
- // 生成配置文件执行位置及其参数
- QString command = pRemotePlugin->createShellFile(&config);
- QStringList strList = command.split(" ");
- QFile file(strList.first());
- // 文件存在
- EXPECT_EQ(file.exists(), true);
-
- // 密钥不为空
- config.m_privateKey = "/";
- command = pRemotePlugin->createShellFile(&config);
- strList.clear();
- strList = command.split(" ");
- file.setFileName(strList.first());
- // 文件存在
- EXPECT_EQ(file.exists(), true);
- // 删除文件
- file.remove();
-
- delete pRemotePlugin;
-}
-
-TEST_F(UT_RemoteManagementPlugin_Test, doCennectServer)
-{
- NormalWindow *normalWindow = new NormalWindow(TermProperties({{WorkingDir, "/"},{QuakeMode, false},{SingleFlag, true}}), nullptr);
- ServerConfigClass *config = new ServerConfigClass(normalWindow);
- RemoteManagementPlugin *pRemotePlugin = new RemoteManagementPlugin(normalWindow);
-
- config->config.m_userName = "root";
- config->config.m_address = "127.0.0.1";
- config->config.m_port = "22";
- // 密钥为空
- config->config.m_privateKey = "";
- config->config.m_password = "1";
- config->config.m_path = "/";
- config->config.m_command = "ls";
- pRemotePlugin->initPlugin(normalWindow);
- pRemotePlugin->doCennectServer(&config->config);
- //代码中有singleShot(100)的调用
- QTest::qWait(1000);
- //连接请求发出后,会showPlugin
- EXPECT_TRUE(normalWindow->m_CurrentShowPlugin == MainWindow::PLUGIN_TYPE_NONE);
- normalWindow->deleteLater();
-}
-
-#endif
diff --git a/tests/src/remotemanage/ut_remotemanagementplugn_test.h b/tests/src/remotemanage/ut_remotemanagementplugn_test.h
deleted file mode 100644
index bc6b03b05..000000000
--- a/tests/src/remotemanage/ut_remotemanagementplugn_test.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_REMOTEMANAGEMENTPLUGIN_TEST_H
-#define UT_REMOTEMANAGEMENTPLUGIN_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class MainWindow;
-class UT_RemoteManagementPlugin_Test : public ::testing::Test
-{
-public:
- UT_RemoteManagementPlugin_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- TermProperties m_normalTermProperty;
-};
-
-#endif // UT_REMOTEMANAGEMENTPLUGIN_TEST_H
diff --git a/tests/src/remotemanage/ut_remotemanagementsearchpanel_test.cpp b/tests/src/remotemanage/ut_remotemanagementsearchpanel_test.cpp
deleted file mode 100644
index d62b6e08d..000000000
--- a/tests/src/remotemanage/ut_remotemanagementsearchpanel_test.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_remotemanagementsearchpanel_test.h"
-#include "remotemanagementsearchpanel.h"
-#include "service.h"
-#include "mainwindow.h"
-#include "../stub.h"
-#include "ut_stub_defines.h"
-
-// DTK
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-void stub_focusCurrentPage()
-{
- return;
-}
-
-UT_RemoteManagementSearchPanel_Test::UT_RemoteManagementSearchPanel_Test()
-{
-}
-
-void UT_RemoteManagementSearchPanel_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-}
-
-void UT_RemoteManagementSearchPanel_Test::TearDown()
-{
- if (m_normalWindow) {
- delete m_normalWindow;
- }
-}
-
-#ifdef UT_REMOTEMANAGEMENTSEARCHPANEL_TEST
-
-/*******************************************************************************
- 1. @函数: refreshDataByGroupAndFilter
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-22
- 4. @说明: 测试组内搜索
-*******************************************************************************/
-TEST_F(UT_RemoteManagementSearchPanel_Test, refreshDataByGroupAndFilter)
-{
- RemoteManagementSearchPanel searchPanel;
- ServerConfig groupConfig;
- groupConfig.m_serverName = "group_item";
- groupConfig.m_address = "127.0.0.1";
- groupConfig.m_group = "group2020";
- groupConfig.m_userName = "dzw";
- groupConfig.m_port = "22";
- //添加数据
- ServerConfig config;
- config.m_serverName = "test_item";
- config.m_address = "127.0.0.1";
- config.m_userName = "dzw";
- config.m_group = "group2020";
- config.m_port = "22";
- ServerConfig config2;
- config2.m_serverName = "test_item2";
- config2.m_address = "127.0.0.1";
- config2.m_userName = "dzw";
- config2.m_port = "22";
- ServerConfigManager::instance()->m_serverConfigs.clear();
- // 分组数据存储结构
- QList list;
- list.append(&groupConfig);
- list.append(&config);
- QList list2;
- list2.append(&config2);
- // 数据存储结构
- ServerConfigManager::instance()->m_serverConfigs.insert("group2020", list);
- ServerConfigManager::instance()->m_serverConfigs.insert("", list2);
- // 刷新列表,填充数据
- searchPanel.refreshDataByGroupAndFilter("group2020", "test_item");
- // 获取当前列表内的数据
- int count = searchPanel.m_listWidget->count();
- EXPECT_EQ(count, 1);
- // 重新搜索 => 找不到的情况
- searchPanel.refreshDataByGroupAndFilter("group2020", "test_item2");
- count = searchPanel.m_listWidget->count();
- EXPECT_EQ(count, 0);
- ServerConfigManager::instance()->m_serverConfigs.clear();
-}
-
-TEST_F(UT_RemoteManagementSearchPanel_Test, refreshDataByFilter)
-{
- RemoteManagementSearchPanel searchPanel;
- ServerConfig groupConfig;
- groupConfig.m_serverName = "group_item";
- groupConfig.m_address = "127.0.0.1";
- groupConfig.m_group = "group2020";
- groupConfig.m_userName = "dzw";
- groupConfig.m_port = "22";
- //添加数据
- ServerConfig config;
- config.m_serverName = "test_item";
- config.m_address = "127.0.0.1";
- config.m_userName = "dzw";
- config.m_group = "group2020";
- config.m_port = "22";
- ServerConfig config2;
- config2.m_serverName = "test_item2";
- config2.m_address = "127.0.0.1";
- config2.m_userName = "dzw";
- config2.m_port = "22";
- ServerConfigManager::instance()->m_serverConfigs.clear();
- // 分组数据存储结构
- QList list;
- list.append(&groupConfig);
- list.append(&config);
- QList list2;
- list2.append(&config2);
- // 数据存储结构
- ServerConfigManager::instance()->m_serverConfigs.insert("group2020", list);
- ServerConfigManager::instance()->m_serverConfigs.insert("", list2);
- // 刷新列表,填充数据
- searchPanel.refreshDataByFilter("item");
- int count = searchPanel.m_listWidget->count();
- EXPECT_EQ(count, 3);
- searchPanel.refreshDataByFilter("group");
- count = searchPanel.m_listWidget->count();
- EXPECT_EQ(count, 2);
- searchPanel.refreshDataByFilter("test_item2");
- count = searchPanel.m_listWidget->count();
- EXPECT_EQ(count, 1);
- searchPanel.refreshDataByFilter("1988");
- count = searchPanel.m_listWidget->count();
- EXPECT_EQ(count, 0);
- ServerConfigManager::instance()->m_serverConfigs.clear();
-}
-
-/*******************************************************************************
- 1. @函数: clearAllFocus
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 清除所有焦点
-*******************************************************************************/
-TEST_F(UT_RemoteManagementSearchPanel_Test, clearAllFocus)
-{
- RemoteManagementSearchPanel searchPanel;
- searchPanel.show();
- searchPanel.clearAllFocus();
- EXPECT_EQ(searchPanel.m_rebackButton->hasFocus(), false);
- EXPECT_EQ(searchPanel.m_listWidget->hasFocus(), false);
- EXPECT_EQ(searchPanel.m_label->hasFocus(), false);
-}
-
-/*******************************************************************************
- 1. @函数: setFocusBack
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 返回设置
-*******************************************************************************/
-TEST_F(UT_RemoteManagementSearchPanel_Test, setFocusBack)
-{
- Stub s;
- s.set(ADDR(MainWindow, focusCurrentPage), stub_focusCurrentPage);
- // 初始化界面
- RemoteManagementSearchPanel searchPanel;
- searchPanel.show();
- // 新增服务器配置数据
- ServerConfig groupConfig;
- groupConfig.m_serverName = "group_item";
- groupConfig.m_address = "127.0.0.1";
- groupConfig.m_group = "group2020";
- groupConfig.m_userName = "dzw";
- groupConfig.m_port = "22";
- // 分组数据存储结构
- QList list;
- list.append(&groupConfig);
- // 数据存储结构
- ServerConfigManager::instance()->m_serverConfigs.insert("group2020", list);
- // 填充数据
- searchPanel.refreshDataByFilter("item");
- //当前检索对象为item
- EXPECT_TRUE("item" == searchPanel.m_strFilter);
-
- // 返回分组,isFocusOn:false,无焦点不做操作
- searchPanel.setFocusBack("group2020", false, 0);
- EXPECT_TRUE(searchPanel.m_listWidget->count() > 0);
-
- // 返回分组2,isFocusOn:false,更新列表,默认选择第一行
- searchPanel.setFocusBack("group2020", true, 0);
- EXPECT_TRUE(searchPanel.m_listWidget->currentIndex() == 0);
-
- // 还原
- ServerConfigManager::instance()->m_serverConfigs.clear();
-}
-
-TEST_F(UT_RemoteManagementSearchPanel_Test, getListIndex)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- RemoteManagementSearchPanel *searchPanel = remoteTopPanel->findChild();
- int listIndex = searchPanel->getListIndex();
- EXPECT_EQ(listIndex, -1);
-}
-
-/*******************************************************************************
- 1. @函数: onItemClicked
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 点击事件
-*******************************************************************************/
-TEST_F(UT_RemoteManagementSearchPanel_Test, onItemClicked)
-{
- // 初始化搜索界面
- RemoteManagementSearchPanel searchPanel;
- searchPanel.show();
-
- // 初始化数据
- ServerConfig config;
- config.m_serverName = "test_item";
- config.m_address = "127.0.0.1";
- config.m_userName = "dzw";
- config.m_port = "22";
- // 添加数据到列表中
- // 分组数据存储结构
- QList list;
- list.append(&config);
- // 数据存储结构
- ServerConfigManager::instance()->m_serverConfigs.insert("", list);
- // 刷新列表,填充数据,更新filter = item
- searchPanel.refreshDataByFilter("item");
- EXPECT_TRUE("item" == searchPanel.m_strFilter);
-
- // 传来被点击的key值,触发emit
- QSignalSpy spy(&searchPanel, &RemoteManagementSearchPanel::doConnectServer);
- searchPanel.onItemClicked("test_item");
- EXPECT_TRUE(1 == spy.count());
- // 清空测试数据
- ServerConfigManager::instance()->m_serverConfigs.clear();
-}
-
-/*******************************************************************************
- 1. @函数: lambda
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 测试lambda表达式
-*******************************************************************************/
-//TEST_F(UT_RemoteManagementSearchPanel_Test, lambda)
-//{
-// // 初始化界面
-// RemoteManagementSearchPanel searchPanel;
-// searchPanel.show();
-
-// //
-// UT_STUB_QAPPLICATION_SENDEVENT_CREATE;
-// searchPanel.handleListViewFocusOut(Qt::TabFocusReason);
-// EXPECT_TRUE(UT_STUB_QAPPLICATION_SENDEVENT_RESULT);
-
-// searchPanel.handleListViewFocusOut(Qt::BacktabFocusReason);
-// EXPECT_TRUE(-1 == searchPanel.m_listWidget->currentIndex());
-
-// // 切换主题
-// searchPanel.handleThemeTypeChanged(DApplicationHelper::DarkType);
-// DPalette p1 = searchPanel.m_label->palette();
-// searchPanel.handleThemeTypeChanged(DApplicationHelper::LightType);
-// DPalette p2 = searchPanel.m_label->palette();
-// //一黑一白两个主题
-// EXPECT_TRUE(p1.brush(QPalette::Text).color() != p2.brush(QPalette::Text).color());
-//}
-#endif
diff --git a/tests/src/remotemanage/ut_remotemanagementsearchpanel_test.h b/tests/src/remotemanage/ut_remotemanagementsearchpanel_test.h
deleted file mode 100644
index e319fa2a6..000000000
--- a/tests/src/remotemanage/ut_remotemanagementsearchpanel_test.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_REMOTEMANAGEMENTSEARCHPANEL_TEST_H
-#define UT_REMOTEMANAGEMENTSEARCHPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class MainWindow;
-class UT_RemoteManagementSearchPanel_Test : public ::testing::Test
-{
-public:
- UT_RemoteManagementSearchPanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- TermProperties m_normalTermProperty;
-};
-
-#endif // UT_REMOTEMANAGEMENTSEARCHPANEL_TEST_H
diff --git a/tests/src/remotemanage/ut_remotemanagementtoppanel_test.cpp b/tests/src/remotemanage/ut_remotemanagementtoppanel_test.cpp
deleted file mode 100644
index b1d127959..000000000
--- a/tests/src/remotemanage/ut_remotemanagementtoppanel_test.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_remotemanagementtoppanel_test.h"
-#include "remotemanagementtoppanel.h"
-#include "service.h"
-#include "mainwindow.h"
-#include "../stub.h"
-#include "ut_stub_defines.h"
-
-//Qt单元测试相关头文件
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-void stub_focusCurrentPage_remote()
-{
- return;
-}
-
-bool stub_isFocusOnList()
-{
- return true;
-}
-
-UT_RemoteManagementTopPanel_Test::UT_RemoteManagementTopPanel_Test()
-{
-}
-
-void UT_RemoteManagementTopPanel_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-}
-
-void UT_RemoteManagementTopPanel_Test::TearDown()
-{
-}
-
-static void doDeleteLater(RemoteManagementTopPanel *obj)
-{
- obj->deleteLater();
-}
-
-#ifdef UT_REMOTEMANAGEMENTTOPPANEL_TEST
-
-TEST_F(UT_RemoteManagementTopPanel_Test, setFocusInPanel)
-{
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- remoteTopPanel->setFocusInPanel();
- m_normalWindow->close();
- delete m_normalWindow;
-}
-
-TEST_F(UT_RemoteManagementTopPanel_Test, showSearchPanel)
-{
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- remoteTopPanel->showSearchPanel("group");
- m_normalWindow->close();
- delete m_normalWindow;
-}
-
-TEST_F(UT_RemoteManagementTopPanel_Test, showGroupPanel)
-{
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- remoteTopPanel->showSearchPanel("group");
-
- //显示前一个界面(返回)
- remoteTopPanel->showPrevPanel();
-
- m_normalWindow->close();
- delete m_normalWindow;
-}
-
-/*******************************************************************************
- 1. @函数: ShowSearchPanel
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 显示搜索面板 => 组内搜索和无法搜索
-*******************************************************************************/
-TEST_F(UT_RemoteManagementTopPanel_Test, ShowSearchPanelTest)
-{
- RemoteManagementTopPanel topPanel;
- // 没数据的情况
- // 显示分组界面的搜索
- topPanel.m_currentPanelType = ServerConfigManager::PanelType_Group;
- topPanel.m_group = "group";
- topPanel.showSearchPanel("1988");
- EXPECT_TRUE(topPanel.m_filterStack.contains("1988"));
-
- // 未知类型
- topPanel.m_currentPanelType = ServerConfigManager::PanelType_Search;
- topPanel.showSearchPanel("1995");
- EXPECT_TRUE(topPanel.m_filterStack.contains("1995"));
-}
-
-/*******************************************************************************
- 1. @函数: showGroupPanel
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 显示分组界面
-*******************************************************************************/
-TEST_F(UT_RemoteManagementTopPanel_Test, showGroupPanelTest)
-{
- Stub s;
- s.set(ADDR(MainWindow, focusCurrentPage), stub_focusCurrentPage_remote);
- RemoteManagementTopPanel topPanel;
- // 没数据的情况
- // 不用界面显示分组界面
- topPanel.m_currentPanelType = ServerConfigManager::PanelType_Manage;
- topPanel.showGroupPanel("1988", false);
- EXPECT_TRUE("1988" == topPanel.m_group);
- EXPECT_TRUE("1988" == topPanel.m_serverConfigGroupPanel->m_groupName);
- //item 1988不获取焦点
- EXPECT_TRUE(false == topPanel.m_prevPanelStack.value(topPanel.m_prevPanelStack.size() - 1).m_isFocusOn);
-
-
- topPanel.m_currentPanelType = ServerConfigManager::PanelType_Manage;
- topPanel.showGroupPanel("1988", true);
- //item 1988获取焦点
- EXPECT_TRUE(true == topPanel.m_prevPanelStack.value(topPanel.m_prevPanelStack.size() - 1).m_isFocusOn);
-
- topPanel.m_currentPanelType = ServerConfigManager::PanelType_Search;
- topPanel.showGroupPanel("1995", true);
- EXPECT_TRUE("1995" == topPanel.m_group);
- EXPECT_TRUE("1995" == topPanel.m_serverConfigGroupPanel->m_groupName);
- //Search/item 1995获取焦点
- EXPECT_TRUE(true == topPanel.m_prevPanelStack.value(topPanel.m_prevPanelStack.size() - 1).m_isFocusOn);
-
- // 未知类型
- topPanel.m_currentPanelType = ServerConfigManager::PanelType_Group;
- topPanel.showGroupPanel("1995", true);
- EXPECT_TRUE("1995" == topPanel.m_group);
- EXPECT_TRUE("1995" == topPanel.m_serverConfigGroupPanel->m_groupName);
- //Group/item 1995获取焦点
- EXPECT_TRUE(true == topPanel.m_prevPanelStack.value(topPanel.m_prevPanelStack.size() - 1).m_isFocusOn);
-
-}
-
-/*******************************************************************************
- 1. @函数: showPrePanel
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-23
- 4. @说明: 显示前一个界面
-*******************************************************************************/
-TEST_F(UT_RemoteManagementTopPanel_Test, showPrePanelTest)
-{
- Stub s;
- s.set(ADDR(MainWindow, isFocusOnList), stub_isFocusOnList);
- // 清空堆栈
- QSharedPointer topPanel(new RemoteManagementTopPanel, doDeleteLater);
- topPanel->m_prevPanelStack.clear();
- // 显示前一个窗口
- UT_STUB_QWIDGET_SHOW_CREATE;
- topPanel->m_prevPanelStack << PanelState();
- topPanel->m_prevPanelStack.last().m_type = ServerConfigManager::PanelType_Manage;
- topPanel->showPrevPanel();
- EXPECT_TRUE(UT_STUB_QWIDGET_SHOW_RESULT);
-
- // 搜索返回
- UT_STUB_QWIDGET_SHOW_PREPARE;
- topPanel->m_prevPanelStack << PanelState();
- topPanel->m_prevPanelStack.last().m_type = ServerConfigManager::PanelType_Search;
- topPanel->m_filterStack.push_back(QString("hello"));
- topPanel->m_filterStack.push_back(QString("world"));
- topPanel->showPrevPanel();
- EXPECT_TRUE(UT_STUB_QWIDGET_SHOW_RESULT);
-
- // 分组返回
- UT_STUB_QWIDGET_SHOW_PREPARE;
- topPanel->m_prevPanelStack << PanelState();
- topPanel->m_prevPanelStack.last().m_type = ServerConfigManager::PanelType_Group;
- topPanel->showPrevPanel();
- EXPECT_TRUE(UT_STUB_QWIDGET_SHOW_RESULT);
-}
-#endif
diff --git a/tests/src/remotemanage/ut_remotemanagementtoppanel_test.h b/tests/src/remotemanage/ut_remotemanagementtoppanel_test.h
deleted file mode 100644
index 14eb4fbff..000000000
--- a/tests/src/remotemanage/ut_remotemanagementtoppanel_test.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_REMOTEMANAGEMENTTOPPANEL_TEST_H
-#define UT_REMOTEMANAGEMENTTOPPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class MainWindow;
-class UT_RemoteManagementTopPanel_Test : public ::testing::Test
-{
-public:
- UT_RemoteManagementTopPanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- TermProperties m_normalTermProperty;
-};
-
-#endif // UT_REMOTEMANAGEMENTTOPPANEL_TEST_H
diff --git a/tests/src/remotemanage/ut_serverconfiggrouppanel_test.cpp b/tests/src/remotemanage/ut_serverconfiggrouppanel_test.cpp
deleted file mode 100644
index 18f3b57fe..000000000
--- a/tests/src/remotemanage/ut_serverconfiggrouppanel_test.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_serverconfiggrouppanel_test.h"
-#include "serverconfiggrouppanel.h"
-#include "service.h"
-#include "mainwindow.h"
-#include "ut_stub_defines.h"
-
-//Qt单元测试相关头文件
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-UT_ServerConfigGroupPanel_Test::UT_ServerConfigGroupPanel_Test()
-{
-}
-
-void UT_ServerConfigGroupPanel_Test::SetUp()
-{
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- m_normalTermProperty[QuakeMode] = false;
- m_normalTermProperty[SingleFlag] = true;
- m_normalWindow = new NormalWindow(m_normalTermProperty, nullptr);
- m_normalWindow->resize(800, 600);
- m_normalWindow->show();
-}
-
-void UT_ServerConfigGroupPanel_Test::TearDown()
-{
- delete m_normalWindow;
-}
-
-#ifdef UT_SERVERCONFIGGROUPPANEL_TEST
-TEST_F(UT_ServerConfigGroupPanel_Test, refreshData)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- ServerConfigGroupPanel *groupPanel = remoteTopPanel->findChild();
- EXPECT_NE(groupPanel, nullptr);
- groupPanel->refreshData("group01");
-}
-
-TEST_F(UT_ServerConfigGroupPanel_Test, setFocusBack)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- ServerConfigGroupPanel *groupPanel = remoteTopPanel->findChild();
- EXPECT_NE(groupPanel, nullptr);
- groupPanel->setFocusBack();
-}
-
-TEST_F(UT_ServerConfigGroupPanel_Test, clearAllFocus)
-{
- EXPECT_EQ(m_normalWindow->isVisible(), true);
-
- m_normalWindow->showPlugin(MainWindow::PLUGIN_TYPE_REMOTEMANAGEMENT);
-
- RemoteManagementPlugin *remotePlugin = m_normalWindow->findChild();
- RemoteManagementTopPanel *remoteTopPanel = remotePlugin->getRemoteManagementTopPanel();
- EXPECT_NE(remoteTopPanel, nullptr);
- EXPECT_EQ(remoteTopPanel->isVisible(), true);
-
- ServerConfigGroupPanel *groupPanel = remoteTopPanel->findChild();
- EXPECT_NE(groupPanel, nullptr);
- groupPanel->clearAllFocus();
-
- EXPECT_EQ(groupPanel->m_rebackButton->hasFocus(), false);
- EXPECT_EQ(groupPanel->m_searchEdit->hasFocus(), false);
- EXPECT_EQ(groupPanel->m_listWidget->hasFocus(), false);
-}
-
-/*******************************************************************************
- 1. @函数: refreshDataTest
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 刷新列表 => 组内数据
-*******************************************************************************/
-TEST_F(UT_ServerConfigGroupPanel_Test, refreshDataTest)
-{
- // 创建分组
- ServerConfig groupConfig;
- groupConfig.m_serverName = "group_item";
- groupConfig.m_address = "127.0.0.1";
- groupConfig.m_group = "group2020";
- groupConfig.m_userName = "dzw";
- groupConfig.m_port = "22";
- // 分组数据存储结构
- QList list;
- list.append(&groupConfig);
- // 数据存储结构
- // 清空数据
- ServerConfigManager::instance()->m_serverConfigs.clear();
- // 装填数据
- ServerConfigManager::instance()->m_serverConfigs.insert("group2020", list);
-
- // 新建界面
- ServerConfigGroupPanel groupPanel;
- // 刷新界面
- groupPanel.refreshData("group2020");
- // 界面下只有一个数据
- int count = groupPanel.m_listWidget->count();
- EXPECT_EQ(count, 1);
-
- // 不存在的组
- groupPanel.refreshData("group1988");
- count = groupPanel.m_listWidget->count();
- EXPECT_EQ(count, 0);
-
- // 清空数据
- ServerConfigManager::instance()->m_serverConfigs.clear();
-}
-
-/*******************************************************************************
- 1. @函数: setFocusBackTest
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 测试界面返回
-*******************************************************************************/
-TEST_F(UT_ServerConfigGroupPanel_Test, setFocusBackTest)
-{
- // 创建分组
- ServerConfig groupConfig;
- groupConfig.m_serverName = "group_item";
- groupConfig.m_address = "127.0.0.1";
- groupConfig.m_group = "group2020";
- groupConfig.m_userName = "dzw";
- groupConfig.m_port = "22";
- ServerConfig groupConfig2;
- groupConfig2.m_serverName = "group_item2";
- groupConfig2.m_address = "127.0.0.1";
- groupConfig2.m_group = "group2020";
- groupConfig2.m_userName = "dzw";
- groupConfig2.m_port = "22";
- // 分组数据存储结构
- QList list;
- list.append(&groupConfig);
- list.append(&groupConfig);
- // 数据存储结构
- // 清空数据
- ServerConfigManager::instance()->m_serverConfigs.clear();
- // 装填数据
- ServerConfigManager::instance()->m_serverConfigs.insert("group2020", list);
- //添加group2020
- EXPECT_TRUE(ServerConfigManager::instance()->m_serverConfigs.contains("group2020"));
-
- // 新建界面
- ServerConfigGroupPanel groupPanel;
- // 刷新界面
- groupPanel.refreshData("group2020");
- //当前group为group2020
- EXPECT_TRUE("group2020" == groupPanel.m_groupName);
- // 刷新搜索框状态
- UT_STUB_QWIDGET_SETVISIBLE_CREATE;
- groupPanel.refreshSearchState();
- //会触发setvisible函数
- EXPECT_TRUE(UT_STUB_QWIDGET_SETVISIBLE_RESULT);
-
- // 两个数据 => 有搜索框
- UT_STUB_QWIDGET_ISVISIBLE_APPEND;
- UT_STUB_QWIDGET_SETFOCUS_APPEND;
- groupPanel.setFocusBack();
- //会触发isvisible喊setFocus函数
- EXPECT_TRUE(UT_STUB_QWIDGET_ISVISIBLE_RESULT);
- EXPECT_TRUE(UT_STUB_QWIDGET_SETFOCUS_RESULT);
-
- // 影藏搜索框
- groupPanel.m_searchEdit->hide();
- groupPanel.setFocusBack();
-
- // 清空数据
- ServerConfigManager::instance()->m_serverConfigs.clear();
- // 刷新界面
- groupPanel.refreshData("group2020");
- groupPanel.setFocusBack();
-}
-
-/*******************************************************************************
- 1. @函数: clearAllFocusTest
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 测试清除焦点是否成功
-*******************************************************************************/
-TEST_F(UT_ServerConfigGroupPanel_Test, clearAllFocusTest)
-{
- ServerConfigGroupPanel groupPanel;
- groupPanel.show();
- groupPanel.refreshData("group2020");
- groupPanel.clearAllFocus();
- EXPECT_EQ(groupPanel.m_rebackButton->hasFocus(), false);
- EXPECT_EQ(groupPanel.m_listWidget->hasFocus(), false);
- EXPECT_EQ(groupPanel.m_searchEdit->hasFocus(), false);
-}
-
-/*******************************************************************************
- 1. @函数: lambda
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 测试lambda表达式,是否会影响进程
-*******************************************************************************/
-TEST_F(UT_ServerConfigGroupPanel_Test, lambda)
-{
- // 初始化界面
- ServerConfigGroupPanel groupPanel;
- groupPanel.show();
- groupPanel.refreshData("group2020");
- groupPanel.m_isShow = true;
-
- groupPanel.onListViewFocusOut(Qt::OtherFocusReason);
- //会选择第一行
- EXPECT_TRUE(groupPanel.m_listWidget->currentIndex() == -1);
-
- UT_STUB_QWIDGET_ISVISIBLE_CREATE;
- groupPanel.onListViewFocusOut(Qt::BacktabFocusReason);
- //会执行isVisible()函数
- EXPECT_TRUE(UT_STUB_QWIDGET_ISVISIBLE_RESULT);
-
- //没有焦点
- groupPanel.onListViewFocusOut(Qt::NoFocusReason);
- EXPECT_TRUE(groupPanel.m_listWidget->currentIndex() == -1);
-
-
- emit ServerConfigManager::instance()->refreshList();
-
-
-}
-#endif
diff --git a/tests/src/remotemanage/ut_serverconfiggrouppanel_test.h b/tests/src/remotemanage/ut_serverconfiggrouppanel_test.h
deleted file mode 100644
index dcf07aac0..000000000
--- a/tests/src/remotemanage/ut_serverconfiggrouppanel_test.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_SERVERCONFIGGROUPPANEL_TEST_H
-#define UT_SERVERCONFIGGROUPPANEL_TEST_H
-
-#include "ut_defines.h"
-#include "termproperties.h"
-
-#include
-
-class MainWindow;
-class UT_ServerConfigGroupPanel_Test : public ::testing::Test
-{
-public:
- UT_ServerConfigGroupPanel_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-public:
- //普通窗口
- MainWindow *m_normalWindow = nullptr;
-
- TermProperties m_normalTermProperty;
-};
-
-#endif // UT_SERVERCONFIGGROUPPANEL_TEST_H
diff --git a/tests/src/remotemanage/ut_serverconfigmanager_test.cpp b/tests/src/remotemanage/ut_serverconfigmanager_test.cpp
deleted file mode 100644
index 333031a40..000000000
--- a/tests/src/remotemanage/ut_serverconfigmanager_test.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_serverconfigmanager_test.h"
-#include "serverconfigmanager.h"
-#include "service.h"
-#include "mainwindow.h"
-#include "serverconfigoptdlg.h"
-#include "utils.h"
-#include "ut_stub_defines.h"
-
-//Qt单元测试相关头文件
-#include
-#include
-
-//Google GTest 相关头文件
-#include
-
-UT_ServerConfigManager_Test::UT_ServerConfigManager_Test()
-{
-}
-
-void UT_ServerConfigManager_Test::SetUp()
-{
-}
-
-void UT_ServerConfigManager_Test::TearDown()
-{
-}
-
-int UT_ServerConfigManager_Test::getServerConfigCount()
-{
- QList serverConfigList;
- QMap> severConfigs = ServerConfigManager::instance()->getServerConfigs();
- for (QMap>::iterator iter = severConfigs.begin(); iter != severConfigs.end(); ++iter) {
- QList value = iter.value();
- for (int i = 0; i < value.size(); ++i) {
- serverConfigList.append(value.at(i));
- }
- }
-
- qDebug() << serverConfigList.count();
- return serverConfigList.count();
-}
-
-#ifdef UT_SERVERCONFIGMANAGER_TEST
-TEST_F(UT_ServerConfigManager_Test, ServerConfigManagerTest)
-{
- ServerConfigManager *serverConfigManager = ServerConfigManager::instance();
- serverConfigManager->initServerConfig();
-
- int serverConfigCount = getServerConfigCount();
- qDebug() << serverConfigCount << endl;
-
- QString groupName = QString("group_01");
-
- qsrand(static_cast(time(nullptr)));
- ServerConfig *config = new ServerConfig();
- config->m_serverName = QString("new_server_%1").arg(Utils::getRandString());
- config->m_address = QString("192.168.10.%1").arg(qrand() % 255);
- config->m_userName = QString("zhangsan");
- config->m_password = QString("123");
- config->m_privateKey = QString("");
- config->m_port = QString("");
- config->m_group = groupName;
- config->m_path = QString("");
- config->m_command = QString("");
- config->m_encoding = QString("");
- config->m_backspaceKey = QString("");
- config->m_deleteKey = QString("");
-
- serverConfigManager->saveServerConfig(config);
- EXPECT_TRUE(serverConfigManager->m_serverConfigs[groupName].contains(config));
-
- serverConfigManager->getServerCount(config->m_group);
-
- ServerConfig *currConfig = serverConfigManager->getServerConfig(config->m_serverName);
-
- //替换conf
- qsrand(static_cast(time(nullptr)));
- ServerConfig *newConfig = new ServerConfig();
- newConfig->m_serverName = QString("new_server_%1").arg(Utils::getRandString());
- newConfig->m_address = QString("192.168.10.%1").arg(qrand() % 255);
- newConfig->m_userName = QString("uos");
- newConfig->m_password = QString("123456");
- newConfig->m_privateKey = QString("");
- newConfig->m_port = QString("");
- newConfig->m_group = groupName;
- newConfig->m_path = QString("");
- newConfig->m_command = QString("");
- newConfig->m_encoding = QString("");
- newConfig->m_backspaceKey = QString("");
- newConfig->m_deleteKey = QString("");
- serverConfigManager->modifyServerConfig(newConfig, currConfig);
- //newConfig替换currConfig
- EXPECT_TRUE(!serverConfigManager->m_serverConfigs[groupName].contains(currConfig));
- EXPECT_TRUE(serverConfigManager->m_serverConfigs[groupName].contains(newConfig));
-
- //删除newConfig
- serverConfigManager->delServerConfig(newConfig);
- EXPECT_TRUE(!serverConfigManager->m_serverConfigs[groupName].contains(newConfig));
-}
-
-/*******************************************************************************
- 1. @函数: initManager
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-25
- 4. @说明: 初始化Manager
-*******************************************************************************/
-TEST_F(UT_ServerConfigManager_Test, initManager)
-{
- // 将现在已有的instance删除
- //delete ServerConfigManager::m_instance;
-// ServerConfigManager::m_instance = nullptr;
-
- // 初始化数据
- // 先将数据存入配置文件
- QString groupName1 = "group2020";
- ServerConfig *config1 = new ServerConfig;
- config1->m_serverName = "group_item";
- config1->m_address = "127.0.0.1";
- config1->m_group = groupName1;
- config1->m_userName = "dzw";
- config1->m_port = "22";
- QString groupName2 = "group2021";
- ServerConfig *config2 = new ServerConfig;
- config2->m_serverName = "1988";
- config2->m_address = "127.0.0.1";
- config2->m_group = groupName2;
- config2->m_userName = "dzw";
- config2->m_port = "22";
- // 保存数据
- ServerConfigManager::instance()->saveServerConfig(config1);
- EXPECT_TRUE(ServerConfigManager::instance()->m_serverConfigs[groupName1].contains(config1));
-
- ServerConfigManager::instance()->saveServerConfig(config2);
- EXPECT_TRUE(ServerConfigManager::instance()->m_serverConfigs[groupName2].contains(config2));
-
- //初始化数据
- ServerConfigManager::instance()->initServerConfig();
- // 删除数据
- ServerConfigManager::instance()->delServerConfig(config1);
- EXPECT_TRUE(!ServerConfigManager::instance()->m_serverConfigs[groupName1].contains(config1));
-
- ServerConfigManager::instance()->delServerConfig(config2);
- EXPECT_TRUE(!ServerConfigManager::instance()->m_serverConfigs[groupName2].contains(config2));
-}
-
-/*******************************************************************************
- 1. @函数: removeDialog
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-25
- 4. @说明: 远程管理弹窗操作
-*******************************************************************************/
-TEST_F(UT_ServerConfigManager_Test, removeDialog)
-{
- // 初始化数据
- ServerConfig config;
- config.m_serverName = "1988";
- config.m_address = "127.0.0.1";
- config.m_group = "";
- config.m_userName = "dzw";
- config.m_port = "22";
-
- //初始化弹窗
- ServerConfigOptDlg *dlg = new ServerConfigOptDlg(ServerConfigOptDlg::SCT_MODIFY, &config, nullptr);
- //构造dialog是会setObjectName
- EXPECT_TRUE(dlg->objectName().count() > 0);
- dlg->show();
-
- // 将弹窗记录
- ServerConfigManager::instance()->setModifyDialog(config.m_serverName, dlg);
- EXPECT_TRUE(ServerConfigManager::instance()->m_serverConfigDialogMap.contains(config.m_serverName));
-
- // 删除弹窗
- ServerConfigManager::instance()->removeDialog(dlg);
- EXPECT_TRUE(!ServerConfigManager::instance()->m_serverConfigDialogMap.contains(config.m_serverName));
-}
-
-/*******************************************************************************
- 1. @函数: closeAllDialog
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-25
- 4. @说明: 关闭同类弹窗
-*******************************************************************************/
-TEST_F(UT_ServerConfigManager_Test, closeAllDialog)
-{
- // 初始化数据
- ServerConfig config;
- config.m_serverName = "1988";
- config.m_address = "127.0.0.1";
- config.m_group = "";
- config.m_userName = "dzw";
- config.m_port = "22";
-
- // 打开多个同一种弹窗
- ServerConfigOptDlg *dlg1 = new ServerConfigOptDlg(ServerConfigOptDlg::SCT_MODIFY, &config, nullptr);
- ServerConfigOptDlg *dlg2 = new ServerConfigOptDlg(ServerConfigOptDlg::SCT_MODIFY, &config, nullptr);
- dlg1->show();
- dlg2->show();
- int oldMapcount = ServerConfigManager::instance()->m_serverConfigDialogMap.count();
-
- // 将弹窗记录
- ServerConfigManager::instance()->setModifyDialog(config.m_serverName, dlg1);
- ServerConfigManager::instance()->setModifyDialog(config.m_serverName, dlg2);
- // 同一类弹窗
- int newMapcount = ServerConfigManager::instance()->m_serverConfigDialogMap.count();
- EXPECT_EQ(oldMapcount + 1, newMapcount);
- // 弹窗数量
- int count = ServerConfigManager::instance()->m_serverConfigDialogMap[config.m_serverName].count();
- EXPECT_EQ(count, 2);
-
- // 将弹窗全部全部拒绝 => 拒绝后信号槽会自动删除弹窗
- ServerConfigManager::instance()->closeAllDialog(config.m_serverName);
-}
-TEST_F(UT_ServerConfigManager_Test, ConvertData)
-{
- UT_STUB_QFILE_REMOVE_CREATE;
- ServerConfigManager::instance()->ConvertData();
- EXPECT_TRUE(UT_STUB_QFILE_REMOVE_RESULT);
-}
-
-#endif
diff --git a/tests/src/remotemanage/ut_serverconfigmanager_test.h b/tests/src/remotemanage/ut_serverconfigmanager_test.h
deleted file mode 100644
index 85f9f917e..000000000
--- a/tests/src/remotemanage/ut_serverconfigmanager_test.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_SERVERCONFIGMANAGER_TEST_H
-#define UT_SERVERCONFIGMANAGER_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class UT_ServerConfigManager_Test : public ::testing::Test
-{
-public:
- UT_ServerConfigManager_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
- int getServerConfigCount();
-};
-
-#endif // UT_SERVERCONFIGMANAGER_TEST_H
diff --git a/tests/src/remotemanage/ut_serverconfigoptdlg_test.cpp b/tests/src/remotemanage/ut_serverconfigoptdlg_test.cpp
deleted file mode 100644
index d66651525..000000000
--- a/tests/src/remotemanage/ut_serverconfigoptdlg_test.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_serverconfigoptdlg_test.h"
-#include "serverconfigoptdlg.h"
-#include "serverconfigmanager.h"
-#include "utils.h"
-
-// DTK
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-
-UT_ServerConfigOptDlg_Test::UT_ServerConfigOptDlg_Test()
-{
-}
-
-void UT_ServerConfigOptDlg_Test::SetUp()
-{
- ServerConfigManager *serverConfigManager = ServerConfigManager::instance();
- serverConfigManager->initServerConfig();
-}
-
-void UT_ServerConfigOptDlg_Test::TearDown()
-{
-}
-
-#ifdef UT_SERVERCONFIGOPTDLG_TEST
-
-TEST_F(UT_ServerConfigOptDlg_Test, getCurServer)
-{
- ServerConfigOptDlg serverCfgDlg;
- serverCfgDlg.show();
- EXPECT_EQ(serverCfgDlg.isVisible(), true);
-
- ServerConfig *serverConfig = serverCfgDlg.getCurServer();
- EXPECT_EQ(serverConfig, nullptr);
-}
-
-TEST_F(UT_ServerConfigOptDlg_Test, setDelServer)
-{
- ServerConfigOptDlg serverCfgDlg;
- serverCfgDlg.show();
- EXPECT_EQ(serverCfgDlg.isVisible(), true);
-
- serverCfgDlg.setDelServer(true);
- EXPECT_EQ(serverCfgDlg.isDelServer(), true);
-
- serverCfgDlg.setDelServer(false);
- EXPECT_EQ(serverCfgDlg.isDelServer(), false);
-}
-
-TEST_F(UT_ServerConfigOptDlg_Test, getServerName)
-{
- ServerConfigOptDlg serverCfgDlg;
- serverCfgDlg.show();
- EXPECT_EQ(serverCfgDlg.isVisible(), true);
-
- QString serverName = serverCfgDlg.getServerName();
- EXPECT_EQ(serverName.isEmpty(), true);
-}
-
-TEST_F(UT_ServerConfigOptDlg_Test, getData)
-{
- ServerConfigOptDlg serverCfgDlg;
-
- ServerConfig serverConfig = serverCfgDlg.getData();
- EXPECT_EQ(serverConfig.m_serverName, serverCfgDlg.getServerName());
-}
-
-TEST_F(UT_ServerConfigOptDlg_Test, resetCurServer)
-{
- ServerConfigOptDlg serverCfgDlg;
-
- ServerConfig serverConfig = serverCfgDlg.getData();
- serverCfgDlg.resetCurServer(&serverConfig);
-
- //替换curServer为serverConfig
- EXPECT_TRUE(serverCfgDlg.m_curServer->m_serverName == serverConfig.m_serverName);
-}
-
-/*******************************************************************************
- 1. @函数: getDataTest
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 测试带值初始化弹窗
-*******************************************************************************/
-TEST_F(UT_ServerConfigOptDlg_Test, getDataTest)
-{
- // 初始化测试数据
- ServerConfig config;
- config.m_serverName = "test_item";
- config.m_address = "127.0.0.1";
- config.m_userName = "dzw";
- config.m_port = "22";
- // 初始化弹窗
- ServerConfigOptDlg serverConfigDialog(ServerConfigOptDlg::SCT_MODIFY, &config);
-
- // 未改变数据前getData
- // 指向的不是同一片空间,所以只能比较里面的值
- ServerConfig curConfig = serverConfigDialog.getData();
- EXPECT_EQ(curConfig.m_serverName, config.m_serverName);
-
- // 修改弹窗内服务器名称
- serverConfigDialog.m_serverName->setText("1988");
- curConfig = serverConfigDialog.getData();
- EXPECT_EQ(curConfig.m_serverName, "1988");
-
- // 函数修改数据 => 还原数据
- serverConfigDialog.updataData(&config);
- curConfig = serverConfigDialog.getData();
- EXPECT_EQ(curConfig.m_serverName, config.m_serverName);
-}
-
-/*******************************************************************************
- 1. @函数: resetCurServerTest
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 尝试重新修改弹窗原数据
-*******************************************************************************/
-TEST_F(UT_ServerConfigOptDlg_Test, resetCurServerTest)
-{
- // 初始化测试数据
- ServerConfig config;
- config.m_serverName = "test_item";
- config.m_address = "127.0.0.1";
- config.m_userName = "dzw";
- config.m_port = "22";
- ServerConfig config2;
- config2.m_serverName = "test_item2";
- config2.m_address = "127.0.0.1";
- config2.m_userName = "dzw";
- config2.m_port = "22";
- // 初始化弹窗
- ServerConfigOptDlg serverConfigDialog(ServerConfigOptDlg::SCT_MODIFY, &config);
-
- // 将数据传入弹窗,获取的指针和原数据指针应该一致
- ServerConfig *curConfig = serverConfigDialog.getCurServer();
- EXPECT_EQ(&config, curConfig);
-
- // 函数修改原数据 => 传入的临时数据不是指针,传入后被拷贝构造,所以还原后指针不一定相同
- // 只能对比数据是否还原
- serverConfigDialog.resetCurServer(&config2);
- curConfig = serverConfigDialog.getCurServer();
- EXPECT_EQ(curConfig->m_serverName, config2.m_serverName);
-}
-
-/*******************************************************************************
- 1. @函数: lambda
- 2. @作者: ut000610 戴正文
- 3. @日期: 2020-12-24
- 4. @说明: 测试lambda表达式
-*******************************************************************************/
-TEST_F(UT_ServerConfigOptDlg_Test, lambda)
-{
- // 初始化弹窗
- ServerConfigOptDlg serverConfigDialog(ServerConfigOptDlg::SCT_ADD, nullptr);
- serverConfigDialog.show();
-
- // 切换主题
- QSignalSpy signalpy1(DApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged);
- EXPECT_TRUE(signalpy1.count() == 0);
-
- emit DApplicationHelper::instance()->themeTypeChanged(DApplicationHelper::DarkType);
- emit DApplicationHelper::instance()->themeTypeChanged(DApplicationHelper::LightType);
- signalpy1.wait(1000);
- EXPECT_TRUE(signalpy1.count() == 2);
-}
-#endif
diff --git a/tests/src/remotemanage/ut_serverconfigoptdlg_test.h b/tests/src/remotemanage/ut_serverconfigoptdlg_test.h
deleted file mode 100644
index e0a1c3aff..000000000
--- a/tests/src/remotemanage/ut_serverconfigoptdlg_test.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_SERVERCONFIGOPTDLG_TEST_H
-#define UT_SERVERCONFIGOPTDLG_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class UT_ServerConfigOptDlg_Test : public ::testing::Test
-{
-public:
- UT_ServerConfigOptDlg_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-};
-
-#endif // UT_SERVERCONFIGOPTDLG_TEST_H
diff --git a/tests/src/settings/ut_newdspinbox_test.cpp b/tests/src/settings/ut_newdspinbox_test.cpp
deleted file mode 100644
index 431eefd0b..000000000
--- a/tests/src/settings/ut_newdspinbox_test.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_newdspinbox_test.h"
-#include "ut_stub_defines.h"
-
-//dtk
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-
-DCORE_USE_NAMESPACE
-
-UT_NewDSpinBox_Test::UT_NewDSpinBox_Test()
-{
-}
-
-void UT_NewDSpinBox_Test::SetUp()
-{
-}
-
-void UT_NewDSpinBox_Test::TearDown()
-{
-}
-
-#ifdef UT_NEWDSPINBOX_TEST
-
-TEST_F(UT_NewDSpinBox_Test, WheelEvent_Increase)
-{
- UT_STUB_QWIDGET_HASFOCUS_CREATE;
- NewDspinBox *spinBox = new NewDspinBox;
- spinBox->setValue(20);
-
- QWheelEvent event(QPointF(63, 29), 120, Qt::NoButton, Qt::NoModifier);
- QApplication::sendEvent(spinBox, &event);
-
- EXPECT_TRUE(spinBox->value() == 21);
- spinBox->deleteLater();
-}
-
-TEST_F(UT_NewDSpinBox_Test, WheelEvent_Reduce)
-{
- UT_STUB_QWIDGET_HASFOCUS_CREATE;
- NewDspinBox *spinBox = new NewDspinBox;
- spinBox->setValue(20);
-
- QWheelEvent event(QPointF(63, 29), -120, Qt::NoButton, Qt::NoModifier);
- QApplication::sendEvent(spinBox, &event);
- EXPECT_TRUE(spinBox->value() == 19);
- spinBox->deleteLater();
-}
-
-TEST_F(UT_NewDSpinBox_Test, eventFilter_Key_Up)
-{
- UT_STUB_QWIDGET_HASFOCUS_CREATE;
- NewDspinBox *spinBox = new NewDspinBox;
- spinBox->setValue(20);
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, QString(""));
- QApplication::sendEvent(spinBox, &event);
- EXPECT_TRUE(spinBox->value() == 21);
- spinBox->deleteLater();
-}
-
-TEST_F(UT_NewDSpinBox_Test, eventFilter_Key_Down)
-{
- UT_STUB_QWIDGET_HASFOCUS_CREATE;
- NewDspinBox *spinBox = new NewDspinBox;
- spinBox->setValue(20);
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, QString(""));
- QApplication::sendEvent(spinBox, &event);
- EXPECT_TRUE(spinBox->value() == 19);
- spinBox->deleteLater();
-}
-
-#endif
diff --git a/tests/src/settings/ut_newdspinbox_test.h b/tests/src/settings/ut_newdspinbox_test.h
deleted file mode 100644
index 3faeaa96a..000000000
--- a/tests/src/settings/ut_newdspinbox_test.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_NEWDSPINBOX_TEST_H
-#define UT_NEWDSPINBOX_TEST_H
-
-#include "ut_defines.h"
-#include "utils.h"
-#include "newdspinbox.h"
-
-#include
-
-class UT_NewDSpinBox_Test : public ::testing::Test
-{
-public:
- UT_NewDSpinBox_Test();
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-};
-
-#endif // UT_NEWDSPINBOX_TEST_H
-
diff --git a/tests/src/settings/ut_settings_test.cpp b/tests/src/settings/ut_settings_test.cpp
deleted file mode 100644
index c7b248686..000000000
--- a/tests/src/settings/ut_settings_test.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright (C) 2019 ~ 2023 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_defines.h"
-#include "settings.h"
-#include "../stub.h"
-#include "ut_stub_defines.h"
-#include "dbusmanager.h"
-
-//dtk
-#include
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-#include
-
-//google test
-#include
-
-DCORE_USE_NAMESPACE
-
-extern void GenerateSettingTranslate();
-
-
-class UT_Settings_Test : public ::testing::Test
-{
-public:
- UT_Settings_Test() {}
-
-public:
- //这里的几个函数都会自动调用
-
- //用于做一些初始化操作
- virtual void SetUp() {}
-
- //用于做一些清理操作
- virtual void TearDown() {}
-};
-
-static bool ut_file_exists()
-{
- return false;
-}
-
-static int ut_combobox_findText(const QString &, Qt::MatchFlags)
-{
- return -1;
-}
-
-static int ut_stringlist_size()
-{
- return 0;
-}
-
-static QString ut_variant_toString()
-{
- return QString();
-}
-
-static void doDeleteLater(DSettingsOption *obj)
-{
- obj->deleteLater();
-}
-
-#ifdef UT_SETTINGS_TEST
-
-TEST_F(UT_Settings_Test, SettingsTest)
-{
- //测试场景:读取的settings的值
-// Settings::instance()->bSwitchTheme = true;
-
- UT_STUB_DSETTINGSOPTION_VALUE_CREATE;
- Settings::instance()->opacity();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->fontName();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->fontSize();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- EXPECT_TRUE(Settings::instance()->encoding() == Settings::instance()->m_EncodeName);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->cursorShape();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->cursorBlink();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->backgroundBlur();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->colorScheme();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->PressingScroll();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-
- UT_STUB_DSETTINGSOPTION_VALUE_PREPARE;
- Settings::instance()->OutputtingScroll();
- EXPECT_TRUE(UT_STUB_DSETTINGSOPTION_VALUE_RESULT);
-}
-
-TEST_F(UT_Settings_Test, GenerateSettingTranslate)
-{
- UT_STUB_QTRANSLATE_TRANSLATE_CREATE;
- GenerateSettingTranslate();
- EXPECT_TRUE(UT_STUB_QTRANSLATE_TRANSLATE_RESULT);
-}
-
-TEST_F(UT_Settings_Test, createSpinButtonHandle)
-{
- DSettingsOption option;
- option.setData("min", QVariant(10));
- option.setData("max", QVariant(90));
- QPair pair = Settings::instance()->createSpinButtonHandle(&option);
- EXPECT_TRUE(pair.second);
-}
-
-TEST_F(UT_Settings_Test, createCustomSliderHandle)
-{
- DSettingsOption option;
- option.setData("min", QVariant(0));
- option.setData("max", QVariant(100));
- QPair pair = Settings::instance()->createCustomSliderHandle(&option);
- EXPECT_TRUE(pair.second);
-}
-
-TEST_F(UT_Settings_Test, createFontComBoBoxHandle)
-{
- Stub stub;
- stub.set((int (QStringList::*)() const)ADDR(QStringList, size), ut_stringlist_size);
- UT_STUB_QDBUS_CALL_APPEND;
-
- DSettingsOption option;
- QPair pair = Settings::instance()->createFontComBoBoxHandle(&option);
- EXPECT_TRUE(pair.second);
-}
-
-TEST_F(UT_Settings_Test, createShortcutEditOptionHandle)
-{
- DSettingsOption option;
- option.setValue(QVariant("Ctrl+Shift+A"));
- QPair pair = Settings::instance()->createShortcutEditOptionHandle(&option);
- ASSERT_TRUE(pair.second);
- DKeySequenceEdit *w = qobject_cast(pair.second);
- ASSERT_TRUE(w);
-
- QSignalSpy spy(w, &DKeySequenceEdit::editingFinished);
- EXPECT_TRUE(spy.count() == 0);
-
- emit w->editingFinished(QKeySequence("Backspace"));
- emit w->editingFinished(QKeySequence("Esc"));
- emit w->editingFinished(QKeySequence("F4"));
- emit w->editingFinished(QKeySequence(""));
-
- spy.wait(1000);
- EXPECT_TRUE(spy.count() == 4);
-}
-
-TEST_F(UT_Settings_Test, createShellConfigComboxOptionHandle)
-{
- Stub stub;
- stub.set((bool (QFile::*)() const)ADDR(QFile, exists), ut_file_exists);
-
- QSharedPointer option(new DSettingsOption, doDeleteLater);
- option->setValue(QVariant("Ctrl+Shift+A"));
- DComboBox *w = qobject_cast(Settings::instance()->createShellConfigComboxOptionHandle(option.data()).second);
- ASSERT_TRUE(w);
-
- QSignalSpy spy(option.get(), &DSettingsOption::valueChanged);
- EXPECT_TRUE(spy.count() == 0);
- const QString DEFAULT_SHELL = "$SHELL";
- emit option->valueChanged(DEFAULT_SHELL);
- emit option->valueChanged("sh");
- spy.wait(1000);
- EXPECT_TRUE(spy.count() == 2);
-
- QSignalSpy spy2(w, &DComboBox::currentTextChanged);
- EXPECT_TRUE(spy2.count() == 0);
- emit w->currentTextChanged("zsh");
- spy2.wait(1000);
- EXPECT_TRUE(spy2.count() >= 1);
-}
-
-TEST_F(UT_Settings_Test, loadDefaultsWhenReinstall)
-{
- UT_STUB_QDIR_EXISTS_CREATE;
- Settings::instance()->loadDefaultsWhenReinstall();
- //会触发dir exists函数
- EXPECT_TRUE(UT_STUB_QDIR_EXISTS_RESULT);
-
- QSignalSpy spy(Settings::instance()->settings, &DSettings::valueChanged);
- EXPECT_TRUE(spy.count() == 0);
- emit Settings::instance()->settings->valueChanged("", "");
- spy.wait(1000);
- EXPECT_TRUE(spy.count() == 1);
-}
-
-static FontDataList ut_DBusManager_callAppearanceFont(QString)
-{
- return FontDataList().appendValues({"Courier 10 Pitch", "DejaVu Sans Mono", "Hack", "Liberation Mono", "Linux Libertine Mono O", "Nimbus Mono L", "Nimbus Mono PS", "Noto Mono", "Noto Sans Mono", "Noto Sans Mono CJK JP", "Noto Sans Mono CJK KR", "Noto Sans Mono CJK SC", "Noto Sans Mono CJK TC", "等距更纱黑体 SC", "文泉驿等宽微米黑"});
-}
-
-TEST_F(UT_Settings_Test, handleWidthFont)
-{
- Stub stub;
- stub.set((int (QComboBox::*)(const QString &, Qt::MatchFlags) const)ADDR(DComboBox, findText), ut_combobox_findText);
-
- //获取等宽字体
- Settings::instance()->handleWidthFont();
- EXPECT_TRUE(Settings::instance()->comboBox->count() > 0);
-}
-
-
-#endif
diff --git a/tests/src/settings/ut_shortcutmanager_test.cpp b/tests/src/settings/ut_shortcutmanager_test.cpp
deleted file mode 100644
index 9b1c3fce1..000000000
--- a/tests/src/settings/ut_shortcutmanager_test.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "ut_shortcutmanager_test.h"
-#include "service.h"
-#include "shortcutmanager.h"
-#include "../stub.h"
-
-//dtk
-#include
-
-//Qt单元测试相关头文件
-#include
-#include
-#include
-#include
-#include
-
-DCORE_USE_NAMESPACE
-
-UT_ShortcutManager_Test::UT_ShortcutManager_Test()
- : m_shortcutManager(nullptr)
- , newAction(nullptr)
-{
-}
-
-void UT_ShortcutManager_Test::SetUp()
-{
-
- //Service中默认已经初始化了ShortcutManager
- if (!Service::instance()->property("isServiceInit").toBool()) {
- Service::instance()->setProperty("isServiceInit", true);
- }
-
- m_shortcutManager = ShortcutManager::instance();
-
- QString key = QString(QChar('A'));
- QString shortcutKey = QString("Ctrl+Shift+%1").arg(key);
- QString cmdName = QString("cmd_001");
- newAction = new QAction;
- newAction->setText(cmdName);
- newAction->setShortcut(QKeySequence(shortcutKey));
-}
-
-void UT_ShortcutManager_Test::TearDown()
-{
- delete newAction;
-}
-
-#ifdef UT_SHORTCUTMANAGER_TEST
-
-TEST_F(UT_ShortcutManager_Test, getCustomCommandActionList)
-{
- EXPECT_TRUE(m_shortcutManager->m_customCommandActionList ==
- m_shortcutManager->getCustomCommandActionList());
-}
-
-
-TEST_F(UT_ShortcutManager_Test, addCustomCommand)
-{
- m_shortcutManager->addCustomCommand(*newAction);
- EXPECT_TRUE(m_shortcutManager->findActionByKey(newAction->text()));
-}
-
-TEST_F(UT_ShortcutManager_Test, checkActionIsExist)
-{
- if(!m_shortcutManager->findActionByKey(newAction->text()))
- m_shortcutManager->addCustomCommand(*newAction);
- EXPECT_TRUE(m_shortcutManager->checkActionIsExist(*newAction));
-}
-
-
-TEST_F(UT_ShortcutManager_Test, checkActionIsExistForModify)
-{
- if(!m_shortcutManager->findActionByKey(newAction->text()))
- m_shortcutManager->addCustomCommand(*newAction);
- EXPECT_TRUE(m_shortcutManager->checkActionIsExistForModify(*newAction));
-}
-
-TEST_F(UT_ShortcutManager_Test, findActionByKey)
-{
- if(!m_shortcutManager->findActionByKey(newAction->text()))
- m_shortcutManager->addCustomCommand(*newAction);
- EXPECT_TRUE(m_shortcutManager->findActionByKey(newAction->text()));
-}
-
-
-TEST_F(UT_ShortcutManager_Test, isShortcutConflictInCustom)
-{
- if(!m_shortcutManager->findActionByKey(newAction->text()))
- m_shortcutManager->addCustomCommand(*newAction);
-
- //名字不相同,快捷键相同,会返回true:快捷键冲突
- EXPECT_TRUE(m_shortcutManager->isShortcutConflictInCustom(newAction->text() + "1", newAction->shortcut().toString()));
-}
-
-bool stub_checkShortcutValid(const QString &Name, const QString &Key, QString &Reason)
-{
- Q_UNUSED(Name)
- Q_UNUSED(Key)
- Q_UNUSED(Reason)
- return false;
-}
-
-bool stub_showShortcutConflictMsgbox(QString txt)
-{
- Q_UNUSED(txt)
- return true;
-}
-
-TEST_F(UT_ShortcutManager_Test, isValidShortcut)
-{
- Stub s;
- s.set(ADDR(ShortcutManager, checkShortcutValid), stub_checkShortcutValid);
- s.set(ADDR(Utils, showShortcutConflictMsgbox), stub_showShortcutConflictMsgbox);
-
- QString newCmdName = QString("cmd_new_%1").arg(Utils::getRandString());
- QString forCheckShortcutKey = QString("Ctrl+Alt+Shift+Tab+T");
- bool isValid = m_shortcutManager->isValidShortcut(newCmdName, forCheckShortcutKey);
- //重复快捷键,无效
- EXPECT_TRUE(isValid == false);
-}
-
-TEST_F(UT_ShortcutManager_Test, checkShortcutValid)
-{
- if(!m_shortcutManager->findActionByKey(newAction->text()))
- m_shortcutManager->addCustomCommand(*newAction);
- //会冲突
- QString reason;
- bool isValid = m_shortcutManager->checkShortcutValid(newAction->text(), newAction->shortcut().toString(), reason);
- EXPECT_TRUE(isValid == false);
-}
-
-#endif
diff --git a/tests/src/settings/ut_shortcutmanager_test.h b/tests/src/settings/ut_shortcutmanager_test.h
deleted file mode 100644
index a6efa7784..000000000
--- a/tests/src/settings/ut_shortcutmanager_test.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef UT_SHORTCUTMANAGER_TEST_H
-#define UT_SHORTCUTMANAGER_TEST_H
-
-#include "ut_defines.h"
-
-#include
-
-class QAction;
-class ShortcutManager;
-class UT_ShortcutManager_Test : public ::testing::Test
-{
-public:
- UT_ShortcutManager_Test();
-
-public:
- //用于做一些初始化操作
- virtual void SetUp();
-
- //用于做一些清理操作
- virtual void TearDown();
-
-private:
- ShortcutManager *m_shortcutManager;
- QAction *newAction;
-};
-
-#endif // UT_SHORTCUTMANAGER_TEST_H
-
diff --git a/tests/src/stub.h b/tests/src/stub.h
deleted file mode 100644
index d5ce4d268..000000000
--- a/tests/src/stub.h
+++ /dev/null
@@ -1,295 +0,0 @@
-// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
-//
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef __STUB_H__
-#define __STUB_H__
-
-
-#ifdef _WIN32
-//windows
-#include
-#include
-#else
-//linux
-#include
-#include
-#include
-#endif
-//c
-#include
-#include
-//c++
-#include