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 ( TestSheetListPageProperties  )

Definition at line 118 of file test_sch_sheet_list.cpp.

119 {
120  loadSchematic( "complex_hierarchy/complex_hierarchy" );
121 
122  SCH_SHEET_LIST sheets = m_schematic.GetSheets();
123 
125 
126  sheets.SetInitialPageNumbers();
127 
128  // The root sheet should now be page 1.
129  BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "1" );
130  BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "2" );
131  BOOST_CHECK_EQUAL( sheets.at( 2 ).Last()->GetPageNumber(), "3" );
132 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
BOOST_CHECK(v2.Cross(v1)==1)
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
void SetInitialPageNumbers()
Set initial sheet page numbers.

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

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( TestEditPageNumbersInSharedDesign  )

Definition at line 135 of file test_sch_sheet_list.cpp.

136 {
137  BOOST_TEST_CONTEXT( "Read Sub-Sheet, prior to modification" )
138  {
139  // Check the Sub Sheet has the expected page numbers
140  loadSchematic( "complex_hierarchy_shared/ampli_ht/ampli_ht" );
141 
142  SCH_SHEET_LIST sheets = m_schematic.GetSheets();
143 
144  BOOST_CHECK_EQUAL( sheets.size(), 2 );
145  BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "i" );
146  BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "ii" );
147  }
148 
149  BOOST_TEST_CONTEXT( "Read Root Sheet, prior to modification" )
150  {
151  // Check the parent sheet has the expected page numbers
152  loadSchematic( "complex_hierarchy_shared/complex_hierarchy" );
153 
154  SCH_SHEET_LIST sheets = m_schematic.GetSheets();
155 
156  BOOST_CHECK_EQUAL( sheets.size(), 5 );
157  BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "1" );
158  BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "2" );
159  // BOOST_CHECK_EQUAL( sheets.at( 2 ).Last()->GetPageNumber(), "3" );
160  // BOOST_CHECK_EQUAL( sheets.at( 3 ).Last()->GetPageNumber(), "4" );
161  BOOST_CHECK_EQUAL( sheets.at( 4 ).Last()->GetPageNumber(), "5" );
162  }
163 
164  BOOST_TEST_CONTEXT( "Modify page numbers in root sheet" )
165  {
166  SCH_SHEET_LIST sheets = m_schematic.GetSheets();
167 
168  // Amend Page numbers
169  sheets.at( 0 ).Last()->SetPageNumber( "A" );
170  sheets.at( 1 ).Last()->SetPageNumber( "B" );
171  sheets.at( 2 ).Last()->SetPageNumber( "C" );
172  sheets.at( 3 ).Last()->SetPageNumber( "D" );
173  sheets.at( 4 ).Last()->SetPageNumber( "E" );
174 
175  // Save and reload
176  wxString tempName = "complex_hierarchy_shared/complex_hierarchy_modified";
177  wxFileName tempFn = buildFullPath( tempName );
178  m_pi->Save( tempFn.GetFullPath(), &m_schematic.Root(), &m_schematic );
179  loadSchematic( tempName );
180 
181  sheets = m_schematic.GetSheets();
182 
183  BOOST_CHECK_EQUAL( sheets.size(), 5 );
184  BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "A" );
185  BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "B" );
186  BOOST_CHECK_EQUAL( sheets.at( 2 ).Last()->GetPageNumber(), "C" );
187  // BOOST_CHECK_EQUAL( sheets.at( 3 ).Last()->GetPageNumber(), "D" );
188  BOOST_CHECK_EQUAL( sheets.at( 4 ).Last()->GetPageNumber(), "E" );
189 
190  // Cleanup
191  wxRemoveFile( tempFn.GetFullPath() );
192  }
193 
194  BOOST_TEST_CONTEXT( "Read Sub-Sheet, after modification" )
195  {
196  // Check the Sub Sheet has the expected page numbers
197  // (This should not have been modified after editing the root sheet)
198  loadSchematic( "complex_hierarchy_shared/ampli_ht/ampli_ht" );
199 
200  SCH_SHEET_LIST sheets = m_schematic.GetSheets();
201 
202  BOOST_CHECK_EQUAL( sheets.size(), 2 );
203  BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "i" );
204  BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "ii" );
205  }
206 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
#define BOOST_TEST_CONTEXT(A)

References BOOST_TEST_CONTEXT.