KiCad PCB EDA Suite
test_sch_sheet_list.cpp File Reference

Go to the source code of this file.

Classes

class  TEST_SCH_SHEET_LIST_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (TestSheetListPageProperties)
 
 BOOST_AUTO_TEST_CASE (TestEditPageNumbersInSharedDesign)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( TestEditPageNumbersInSharedDesign  )

Definition at line 65 of file test_sch_sheet_list.cpp.

66{
67 BOOST_TEST_CONTEXT( "Read Sub-Sheet, prior to modification" )
68 {
69 // Check the Sub Sheet has the expected page numbers
70 LoadSchematic( "complex_hierarchy_shared/ampli_ht/ampli_ht" );
71
72 SCH_SHEET_LIST sheets = m_schematic.GetSheets();
73
74 BOOST_CHECK_EQUAL( sheets.size(), 2 );
75 BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "i" );
76 BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "ii" );
77 }
78
79 BOOST_TEST_CONTEXT( "Read Root Sheet, prior to modification" )
80 {
81 // Check the parent sheet has the expected page numbers
82 LoadSchematic( "complex_hierarchy_shared/complex_hierarchy" );
83
84 SCH_SHEET_LIST sheets = m_schematic.GetSheets();
85
86 BOOST_CHECK_EQUAL( sheets.size(), 5 );
87 BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "1" );
88 BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "2" );
89 BOOST_CHECK_EQUAL( sheets.at( 2 ).GetPageNumber(), "3" );
90 BOOST_CHECK_EQUAL( sheets.at( 3 ).GetPageNumber(), "4" );
91 BOOST_CHECK_EQUAL( sheets.at( 4 ).GetPageNumber(), "5" );
92 }
93
94 BOOST_TEST_CONTEXT( "Modify page numbers in root sheet" )
95 {
96 SCH_SHEET_LIST sheets = m_schematic.GetSheets();
97
98 // Amend Page numbers
99 sheets.at( 0 ).SetPageNumber( "A" );
100 sheets.at( 1 ).SetPageNumber( "B" );
101 sheets.at( 2 ).SetPageNumber( "C" );
102 sheets.at( 3 ).SetPageNumber( "D" );
103 sheets.at( 4 ).SetPageNumber( "E" );
104
105 // Save and reload
106 wxString tempName = "complex_hierarchy_shared/complex_hierarchy_modified";
107 wxFileName tempFn = GetSchematicPath( tempName );
108 m_pi->Save( tempFn.GetFullPath(), &m_schematic.Root(), &m_schematic );
109 LoadSchematic( tempName );
110
111 sheets = m_schematic.GetSheets();
112
113 BOOST_CHECK_EQUAL( sheets.size(), 5 );
114 BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "A" );
115 BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "B" );
116 BOOST_CHECK_EQUAL( sheets.at( 2 ).GetPageNumber(), "C" );
117 BOOST_CHECK_EQUAL( sheets.at( 3 ).GetPageNumber(), "D" );
118 BOOST_CHECK_EQUAL( sheets.at( 4 ).GetPageNumber(), "E" );
119
120 // Cleanup
121 wxRemoveFile( tempFn.GetFullPath() );
122 }
123
124 BOOST_TEST_CONTEXT( "Read Sub-Sheet, after modification" )
125 {
126 // Check the Sub Sheet has the expected page numbers
127 // (This should not have been modified after editing the root sheet)
128 LoadSchematic( "complex_hierarchy_shared/ampli_ht/ampli_ht" );
129
130 SCH_SHEET_LIST sheets = m_schematic.GetSheets();
131
132 BOOST_CHECK_EQUAL( sheets.size(), 2 );
133 BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "i" );
134 BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "ii" );
135 }
136}
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
#define BOOST_TEST_CONTEXT(A)

References BOOST_TEST_CONTEXT.

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( TestSheetListPageProperties  )

Definition at line 48 of file test_sch_sheet_list.cpp.

49{
50 LoadSchematic( "complex_hierarchy/complex_hierarchy" );
51
52 SCH_SHEET_LIST sheets = m_schematic.GetSheets();
53
55
56 sheets.SetInitialPageNumbers();
57
58 // The root sheet should now be page 1.
59 BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "1" );
60 BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "2" );
61 BOOST_CHECK_EQUAL( sheets.at( 2 ).GetPageNumber(), "3" );
62}
void SetInitialPageNumbers()
Set initial sheet page numbers.
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
BOOST_CHECK(v2.Cross(v1)==1)

References SCH_SHEET_LIST::AllSheetPageNumbersEmpty(), BOOST_CHECK(), and SCH_SHEET_LIST::SetInitialPageNumbers().