KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_lib_tree_model_adapter.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
20
#include <boost/test/unit_test.hpp>
21
22
#include <
lib_tree_model_adapter.h
>
23
#include <
project.h
>
24
#include <
settings/app_settings.h
>
25
26
32
class
TEST_LIB_TREE_MODEL_ADAPTER
:
public
LIB_TREE_MODEL_ADAPTER
33
{
34
public
:
35
TEST_LIB_TREE_MODEL_ADAPTER
(
APP_SETTINGS_BASE::LIB_TREE
& aSettings ) :
36
LIB_TREE_MODEL_ADAPTER
( nullptr, wxT(
"pinned"
), aSettings )
37
{
38
}
39
40
PROJECT::LIB_TYPE_T
getLibType
()
override
{
return
PROJECT::SYMBOL_LIB
; }
41
42
int
LoadedWidth
(
const
wxString& aColumn )
const
43
{
44
auto
it =
m_colWidths
.find( aColumn );
45
return
it !=
m_colWidths
.end() ? it->second : -1;
46
}
47
};
48
49
50
BOOST_AUTO_TEST_SUITE
( LibTreeModelAdapter )
51
52
58
BOOST_AUTO_TEST_CASE
( CorruptPersistedColumnWidthIgnoredOnLoad )
59
{
60
APP_SETTINGS_BASE::LIB_TREE
settings;
61
settings.
column_widths
[ wxT(
"Item"
) ] = 427218649;
62
settings.
column_widths
[ wxT(
"Description"
) ] = 450;
63
64
TEST_LIB_TREE_MODEL_ADAPTER
* adapter =
new
TEST_LIB_TREE_MODEL_ADAPTER
( settings );
65
66
// The corrupt width must not overwrite the default; the legitimate one must be applied.
67
BOOST_CHECK_EQUAL
( adapter->
LoadedWidth
( wxT(
"Item"
) ), 300 );
68
BOOST_CHECK_EQUAL
( adapter->
LoadedWidth
( wxT(
"Description"
) ), 450 );
69
70
adapter->DecRef();
71
}
72
73
BOOST_AUTO_TEST_SUITE_END
()
app_settings.h
LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, const wxString &aPinnedKey, APP_SETTINGS_BASE::LIB_TREE &aSettingsStruct)
Create the adapter.
Definition
lib_tree_model_adapter.cpp:152
LIB_TREE_MODEL_ADAPTER::m_colWidths
std::map< wxString, int > m_colWidths
Definition
lib_tree_model_adapter.h:471
PROJECT::LIB_TYPE_T
LIB_TYPE_T
Definition
project.h:189
PROJECT::SYMBOL_LIB
@ SYMBOL_LIB
Definition
project.h:190
TEST_LIB_TREE_MODEL_ADAPTER
Minimal concrete adapter exposing the loaded column widths.
Definition
test_lib_tree_model_adapter.cpp:33
TEST_LIB_TREE_MODEL_ADAPTER::getLibType
PROJECT::LIB_TYPE_T getLibType() override
Definition
test_lib_tree_model_adapter.cpp:40
TEST_LIB_TREE_MODEL_ADAPTER::TEST_LIB_TREE_MODEL_ADAPTER
TEST_LIB_TREE_MODEL_ADAPTER(APP_SETTINGS_BASE::LIB_TREE &aSettings)
Definition
test_lib_tree_model_adapter.cpp:35
TEST_LIB_TREE_MODEL_ADAPTER::LoadedWidth
int LoadedWidth(const wxString &aColumn) const
Definition
test_lib_tree_model_adapter.cpp:42
lib_tree_model_adapter.h
project.h
APP_SETTINGS_BASE::LIB_TREE
Definition
app_settings.h:157
APP_SETTINGS_BASE::LIB_TREE::column_widths
std::map< wxString, int > column_widths
Column widths, keyed by header name.
Definition
app_settings.h:159
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:71
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_lib_tree_model_adapter.cpp
Generated on Tue Jul 7 2026 00:07:26 for KiCad PCB EDA Suite by
1.13.2