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
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.
33BOOST_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.
47BOOST_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).
60BOOST_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
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(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
std::vector< std::string > header
BOOST_CHECK_EQUAL(result, "25.4")
BOOST_AUTO_TEST_CASE(CapHeightCapsTallGrid)