KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_board_commit.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 along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21#include <tool/tool_manager.h>
23#include <board.h>
24#include <board_commit.h>
25#include <pcb_shape.h>
26#include <pcb_group.h>
27
28BOOST_AUTO_TEST_SUITE( BoardCommit )
29
30BOOST_AUTO_TEST_CASE( RecursesThroughGroups )
31{
32 BOARD board;
33 TOOL_MANAGER mgr;
34 mgr.SetEnvironment( &board, nullptr, nullptr, nullptr, nullptr );
36 mgr.RegisterTool( dummyTool );
37 BOARD_COMMIT commit( dummyTool );
38
39 PCB_SHAPE s1( nullptr, SHAPE_T::SEGMENT );
40 PCB_SHAPE s2( nullptr, SHAPE_T::SEGMENT );
41 PCB_GROUP group( nullptr );
42 group.AddItem( &s1 );
43 group.AddItem( &s2 );
44
45 commit.Stage( &group, CHT_MODIFY, nullptr, RECURSE_MODE::RECURSE );
46
47 BOOST_CHECK_EQUAL( commit.GetStatus( &s1 ), CHT_MODIFY );
48 BOOST_CHECK_EQUAL( commit.GetStatus( &s2 ), CHT_MODIFY );
49}
50
51BOOST_AUTO_TEST_CASE( MakeImageCreatesTransientCopy )
52{
53 PCB_SHAPE shape( nullptr, SHAPE_T::SEGMENT );
55
57 BOOST_CHECK( copy != &shape );
58 BOOST_CHECK( copy->HasFlag( UR_TRANSIENT ) );
59
60 delete copy;
61}
62
63BOOST_AUTO_TEST_CASE( ReturnsBoardFromManager )
64{
65 BOARD board;
66 TOOL_MANAGER mgr;
67 mgr.SetEnvironment( &board, nullptr, nullptr, nullptr, nullptr );
69 mgr.RegisterTool( dummyTool );
70
71 BOARD_COMMIT commit( dummyTool );
72
73 BOOST_CHECK_EQUAL( commit.GetBoard(), &board );
74}
75
77
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
BOARD * GetBoard() const
static EDA_ITEM * MakeImage(EDA_ITEM *aItem)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition: commit.cpp:142
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:53
Master controller class:
Definition: tool_manager.h:62
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
@ CHT_MODIFY
Definition: commit.h:45
@ RECURSE
Definition: eda_item.h:51
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Class to handle a set of BOARD_ITEMs.
BOOST_AUTO_TEST_CASE(RecursesThroughGroups)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()