KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sch_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>
22#include <sch_commit.h>
23#include <sch_group.h>
24#include <sch_text.h>
25
26BOOST_AUTO_TEST_SUITE( SchCommit )
27
28BOOST_AUTO_TEST_CASE( RecursesThroughGroups )
29{
30 TOOL_MANAGER mgr;
31 SCH_COMMIT commit( &mgr );
32
33 SCH_TEXT t1;
34 SCH_TEXT t2;
36 group.AddItem( &t1 );
37 group.AddItem( &t2 );
38
39 commit.Stage( &group, CHT_MODIFY, nullptr, RECURSE_MODE::RECURSE );
40
41 BOOST_CHECK_EQUAL( commit.GetStatus( &t1 ), CHT_MODIFY );
42 BOOST_CHECK_EQUAL( commit.GetStatus( &t2 ), CHT_MODIFY );
43}
44
45BOOST_AUTO_TEST_CASE( ClearsSelectedByDragFlag )
46{
47 TOOL_MANAGER mgr;
48 SCH_COMMIT commit( &mgr );
49
51 text.SetFlags( SELECTED_BY_DRAG );
52 text.SetSelected();
53
54 commit.Stage( &text, CHT_MODIFY );
55
56 BOOST_CHECK( text.IsSelected() );
58}
59
61
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition: commit.cpp:142
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.
Definition: sch_commit.cpp:70
A set of SCH_ITEMs (i.e., without duplicates).
Definition: sch_group.h:52
Master controller class:
Definition: tool_manager.h:62
@ CHT_MODIFY
Definition: commit.h:45
@ RECURSE
Definition: eda_item.h:51
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
Class to handle a set of SCH_ITEMs.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(RecursesThroughGroups)