KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_desktop_app_id.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
#define BOOST_TEST_NO_MAIN
20
#include <boost/test/unit_test.hpp>
21
22
#include <
pgm_base.h
>
23
24
// PGM_BASE::DesktopAppIdForProgram maps argv[0] to the freedesktop launcher id used for the
25
// X11 WM_CLASS and the Wayland application id. A wrong or empty mapping is what let window
26
// managers mis-group KiCad windows under an unrelated application (issue 70216).
27
28
BOOST_AUTO_TEST_SUITE
( DesktopAppId )
29
30
BOOST_AUTO_TEST_CASE
( NonGuiProgramsHaveNoId )
31
{
32
// Executables without an installed .desktop launcher must not claim an application id.
33
BOOST_CHECK(
PGM_BASE::DesktopAppIdForProgram
( wxT(
"pl_editor"
) ).IsEmpty() );
34
BOOST_CHECK(
PGM_BASE::DesktopAppIdForProgram
( wxT(
"kicad-cli"
) ).IsEmpty() );
35
BOOST_CHECK(
PGM_BASE::DesktopAppIdForProgram
( wxT(
"something-else"
) ).IsEmpty() );
36
}
37
38
// On GTK/Linux, pgm_base.cpp is compiled with the desktop-id macros, so the GUI programs
39
// resolve to real launcher ids. Elsewhere the mapping is intentionally empty.
40
#if defined( __WXGTK__ )
41
42
BOOST_AUTO_TEST_CASE
( GuiProgramsGetDistinctIds )
43
{
44
const
wxString kicad =
PGM_BASE::DesktopAppIdForProgram
( wxT(
"kicad"
) );
45
const
wxString
eeschema
=
PGM_BASE::DesktopAppIdForProgram
( wxT(
"eeschema"
) );
46
const
wxString
pcbnew
=
PGM_BASE::DesktopAppIdForProgram
( wxT(
"pcbnew"
) );
47
48
// Every GUI app resolves to an id, and the ids are distinct so each groups on its own
49
// launcher rather than collapsing together.
50
BOOST_CHECK( !kicad.IsEmpty() );
51
BOOST_CHECK( !
eeschema
.IsEmpty() );
52
BOOST_CHECK( !
pcbnew
.IsEmpty() );
53
54
BOOST_CHECK_NE( kicad,
eeschema
);
55
BOOST_CHECK_NE(
eeschema
,
pcbnew
);
56
57
#if defined( KICAD_DESKTOP_APP_NAME )
58
// The ids must equal the launcher basenames that carry the matching StartupWMClass, for both
59
// the regular (org.kicad) and Flatpak (org.kicad.KiCad) prefixes.
60
const
wxString prefix( wxT( KICAD_DESKTOP_APP_PREFIX ) );
61
62
BOOST_CHECK_EQUAL
( kicad, wxString( wxT( KICAD_DESKTOP_APP_NAME ) ) );
63
BOOST_CHECK_EQUAL
(
eeschema
, prefix + wxT(
".eeschema"
) );
64
BOOST_CHECK_EQUAL
(
pcbnew
, prefix + wxT(
".pcbnew"
) );
65
#endif
66
}
67
68
BOOST_AUTO_TEST_CASE
( PcbCalculatorUsesFreedesktopName )
69
{
70
// pcb_calculator installs as pcbcalculator; the id must follow the launcher, not argv[0].
71
const
wxString
id
=
PGM_BASE::DesktopAppIdForProgram
( wxT(
"pcb_calculator"
) );
72
73
BOOST_CHECK(
id
.EndsWith( wxT(
".pcbcalculator"
) ) );
74
BOOST_CHECK( !
id
.EndsWith( wxT(
".pcb_calculator"
) ) );
75
76
#if defined( KICAD_DESKTOP_APP_NAME )
77
BOOST_CHECK_EQUAL
(
id
, wxString( wxT( KICAD_DESKTOP_APP_PREFIX ) ) + wxT(
".pcbcalculator"
) );
78
#endif
79
}
80
81
#endif
82
83
BOOST_AUTO_TEST_SUITE_END
()
BITMAPS::pcbnew
@ pcbnew
Definition
bitmaps_list.h:432
BITMAPS::eeschema
@ eeschema
Definition
bitmaps_list.h:185
PGM_BASE::DesktopAppIdForProgram
static wxString DesktopAppIdForProgram(const wxString &aPgmName)
Map a program name (argv[0] basename, lowercased) to the freedesktop application id of its installed ...
Definition
pgm_base.cpp:321
pgm_base.h
see class PGM_BASE
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:72
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(NonGuiProgramsHaveNoId)
Definition
test_desktop_app_id.cpp:30
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_desktop_app_id.cpp
Generated on Fri Jul 31 2026 00:08:01 for KiCad PCB EDA Suite by
1.13.2