2021-08-12 16:58:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-03-27 10:04:03 +00:00
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-08-12 16:58:30 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qa_utils/wx_utils/unit_test_utils.h>
|
2022-03-18 20:05:15 +00:00
|
|
|
#include <pcbnew_utils/board_test_utils.h>
|
2021-08-12 16:58:30 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <pcb_marker.h>
|
|
|
|
#include <drc/drc_item.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
|
|
|
|
|
2023-06-30 10:56:36 +00:00
|
|
|
struct DRC_SOLDER_MASK_BRIDGING_TEST_FIXTURE
|
2021-08-12 16:58:30 +00:00
|
|
|
{
|
2023-06-30 10:56:36 +00:00
|
|
|
DRC_SOLDER_MASK_BRIDGING_TEST_FIXTURE() :
|
2021-08-12 16:58:30 +00:00
|
|
|
m_settingsManager( true /* headless */ )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
SETTINGS_MANAGER m_settingsManager;
|
|
|
|
std::unique_ptr<BOARD> m_board;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-06-30 10:56:36 +00:00
|
|
|
BOOST_FIXTURE_TEST_CASE( DRCSolderMaskBridgingTest, DRC_SOLDER_MASK_BRIDGING_TEST_FIXTURE )
|
2021-08-12 16:58:30 +00:00
|
|
|
{
|
2022-03-09 16:18:54 +00:00
|
|
|
wxString brd_name( wxT( "solder_mask_bridge_test" ) );
|
|
|
|
KI_TEST::LoadBoard( m_settingsManager, brd_name, m_board );
|
2022-02-11 12:42:09 +00:00
|
|
|
KI_TEST::FillZones( m_board.get() );
|
2021-08-12 16:58:30 +00:00
|
|
|
|
|
|
|
std::vector<DRC_ITEM> violations;
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
|
|
|
|
2022-01-12 13:41:11 +00:00
|
|
|
// Disable some DRC tests not useful in this testcase (and time consuming)
|
|
|
|
bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_ISSUES ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_LIB_FOOTPRINT_MISMATCH ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_COPPER_SLIVER ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
|
|
|
bds.m_DRCSeverities[ DRCE_STARVED_THERMAL ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
2023-03-27 10:04:03 +00:00
|
|
|
bds.m_DRCSeverities[ DRCE_SILK_CLEARANCE ] = SEVERITY::RPT_SEVERITY_IGNORE;
|
2022-01-12 13:41:11 +00:00
|
|
|
|
2021-08-12 16:58:30 +00:00
|
|
|
bds.m_DRCEngine->SetViolationHandler(
|
2022-08-15 16:59:34 +00:00
|
|
|
[&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
|
2021-08-12 16:58:30 +00:00
|
|
|
{
|
|
|
|
PCB_MARKER temp( aItem, aPos );
|
|
|
|
|
2023-01-29 18:06:05 +00:00
|
|
|
if( bds.m_DrcExclusions.find( temp.SerializeToString() ) == bds.m_DrcExclusions.end() )
|
2021-08-12 16:58:30 +00:00
|
|
|
violations.push_back( *aItem );
|
|
|
|
} );
|
|
|
|
|
|
|
|
bds.m_DRCEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false );
|
|
|
|
|
2022-03-09 16:18:54 +00:00
|
|
|
const int expected_err_cnt = 5;
|
|
|
|
|
|
|
|
if( violations.size() == expected_err_cnt )
|
2021-08-12 16:58:30 +00:00
|
|
|
{
|
|
|
|
BOOST_CHECK_EQUAL( 1, 1 ); // quiet "did not check any assertions" warning
|
|
|
|
BOOST_TEST_MESSAGE( "DRC solder mask bridge test passed" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-09 16:18:54 +00:00
|
|
|
BOOST_CHECK_EQUAL( violations.size(), expected_err_cnt );
|
2021-08-12 16:58:30 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES );
|
|
|
|
|
2021-08-12 16:58:30 +00:00
|
|
|
std::map<KIID, EDA_ITEM*> itemMap;
|
|
|
|
m_board->FillItemMap( itemMap );
|
|
|
|
|
|
|
|
for( const DRC_ITEM& item : violations )
|
2022-09-19 16:09:59 +00:00
|
|
|
BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR, itemMap ) );
|
2021-08-12 16:58:30 +00:00
|
|
|
|
2022-03-09 16:18:54 +00:00
|
|
|
BOOST_ERROR( wxString::Format( "DRC solder mask bridge test failed board <%s>", brd_name ) );
|
2021-08-12 16:58:30 +00:00
|
|
|
}
|
|
|
|
}
|