KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_wx_grid.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
#define BOOST_TEST_NO_MAIN
21
#include <boost/test/unit_test.hpp>
22
23
#include <vector>
24
25
#include <
widgets/wx_grid.h
>
26
27
28
BOOST_AUTO_TEST_SUITE
( WxGrid )
29
30
31
// A grid with more rows than the cap must report a height bounded to the cap, so the dialog
32
// hosting it can still be shrunk rather than being forced taller than the screen.
33
BOOST_AUTO_TEST_CASE
( CapHeightCapsTallGrid )
34
{
35
const
int
header
= 24;
36
const
std::vector<int> rows( 20, 25 );
37
const
int
fullHeight =
header
+ 20 * 25;
38
39
int
capped =
WX_GRID::CapHeightToVisibleRows
( fullHeight,
header
, rows, 4 );
40
41
BOOST_CHECK_EQUAL
( capped,
header
+ 4 * 25 );
42
BOOST_CHECK_LT( capped, fullHeight );
43
}
44
45
46
// When the grid has fewer rows than the cap, the cap must not shrink it below its own content.
47
BOOST_AUTO_TEST_CASE
( CapHeightKeepsShortGrid )
48
{
49
const
int
header
= 24;
50
const
std::vector<int> rows( 2, 25 );
51
const
int
fullHeight =
header
+ 2 * 25;
52
53
int
capped =
WX_GRID::CapHeightToVisibleRows
( fullHeight,
header
, rows, 4 );
54
55
BOOST_CHECK_EQUAL
( capped, fullHeight );
56
}
57
58
59
// A negative cap leaves the advertised height untouched (the pre-cap behaviour).
60
BOOST_AUTO_TEST_CASE
( CapHeightDisabled )
61
{
62
const
int
header
= 24;
63
const
std::vector<int> rows( 20, 25 );
64
const
int
fullHeight =
header
+ 20 * 25;
65
66
BOOST_CHECK_EQUAL
(
WX_GRID::CapHeightToVisibleRows
( fullHeight,
header
, rows, -1 ), fullHeight );
67
}
68
69
70
BOOST_AUTO_TEST_SUITE_END
()
WX_GRID::CapHeightToVisibleRows
static int CapHeightToVisibleRows(int aMinHeight, int aHeaderHeight, const std::vector< int > &aRowHeights, int aMaxRows)
Height of aMaxRows data rows plus the column-label header, never more than aMinHeight.
Definition
wx_grid.cpp:90
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()
header
std::vector< std::string > header
Definition
test_pip_benchmark.cpp:864
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(CapHeightCapsTallGrid)
Definition
test_wx_grid.cpp:33
wx_grid.h
src
qa
tests
common
test_wx_grid.cpp
Generated on Tue Jul 7 2026 00:07:26 for KiCad PCB EDA Suite by
1.13.2