KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_api_wizards.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 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <boost/test/unit_test.hpp>
22#include <wx/filename.h>
23
25#include <footprint_wizard.h>
26#include <mock_pgm_base.h>
28
29BOOST_AUTO_TEST_SUITE( ApiWizards )
30
31
32BOOST_AUTO_TEST_CASE( QueryWizards )
33{
34 wxFileName qaPath( KI_TEST::GetPcbnewTestDataDir() );
35 qaPath.AppendDir( "wizards" );
36
38 manager.ReloadPlugins( qaPath.GetFullPath() );
39
40 constexpr int timeoutMs = 10000;
41 constexpr int sleepMs = 100;
42 int elapsed = 0;
43
44 BOOST_TEST_MESSAGE( "Waiting for plugins to load..." );
45
46 while( elapsed < timeoutMs )
47 {
48 wxSafeYield();
49 wxMilliSleep( sleepMs );
50 elapsed += sleepMs;
51
52 if( !manager.Busy() )
53 break;
54 }
55
56 BOOST_TEST_WARN( elapsed < timeoutMs, "Timed out waiting for manager to finish loading plugins" );
57
58 std::vector<const PLUGIN_ACTION*> actions = manager.GetActionsForScope( PLUGIN_ACTION_SCOPE::FOOTPRINT_WIZARD );
59
60 BOOST_TEST_WARN( !actions.empty(), "No available wizards to test with (maybe Python or kicad-python unavailable?); skipping tests" );
61
62 if( actions.empty() )
63 return;
64
65 for( auto& action : actions )
66 {
67 BOOST_TEST_CONTEXT( action->identifier )
68 {
69 // QA test actions should have real metadata
70 BOOST_TEST_REQUIRE( !action->description.IsEmpty() );
71 BOOST_TEST_REQUIRE( !action->entrypoint.IsEmpty() );
72 BOOST_TEST_REQUIRE( action->scopes.contains( PLUGIN_ACTION_SCOPE::FOOTPRINT_WIZARD ) );
73
74 FOOTPRINT_WIZARD wizard;
75 wizard.SetIdentifier( action->identifier );
76 BOOST_TEST_REQUIRE( FOOTPRINT_WIZARD_MANAGER::RefreshInfo( &wizard ) );
77
78 BOOST_TEST_REQUIRE( wizard.Info().meta.identifier.Matches( action->identifier ) );
79 }
80 }
81}
82
General utilities for PCB file IO for QA programs.
Responsible for loading plugin definitions for API-based plugins (ones that do not run inside KiCad i...
void ReloadPlugins(std::optional< wxString > aDirectoryToScan=std::nullopt, std::shared_ptr< REPORTER > aReporter=nullptr)
Clears the loaded plugins and actions and re-scans the filesystem to register new ones.
std::vector< const PLUGIN_ACTION * > GetActionsForScope(PLUGIN_ACTION_SCOPE aScope)
static bool RefreshInfo(FOOTPRINT_WIZARD *aWizard)
Runs a wizard plugin with the –get-info argument, which should result in the plugin dumping a WizardI...
WIZARD_INFO & Info()
void SetIdentifier(const wxString &aId)
virtual API_PLUGIN_MANAGER & GetPluginManager() const
Definition pgm_base.h:140
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
PGM_BASE & Pgm()
The global program "get" accessor.
WIZARD_META_INFO meta
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_TEST_CONTEXT("Test Clearance")