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 along
18 * with this program. If not, see <http://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
32#ifdef KICAD_IPC_API
33BOOST_AUTO_TEST_CASE( QueryWizards )
34{
35 wxFileName qaPath( KI_TEST::GetPcbnewTestDataDir() );
36 qaPath.AppendDir( "wizards" );
37
38 API_PLUGIN_MANAGER& manager = Pgm().GetPluginManager();
39 manager.ReloadPlugins( qaPath.GetFullPath() );
40
41 constexpr int timeoutMs = 10000;
42 constexpr int sleepMs = 100;
43 int elapsed = 0;
44
45 BOOST_TEST_MESSAGE( "Waiting for plugins to load..." );
46
47 while( elapsed < timeoutMs )
48 {
49 wxSafeYield();
50 wxMilliSleep( sleepMs );
51 elapsed += sleepMs;
52
53 if( !manager.Busy() )
54 break;
55 }
56
57 BOOST_TEST_WARN( elapsed < timeoutMs, "Timed out waiting for manager to finish loading plugins" );
58
59 std::vector<const PLUGIN_ACTION*> actions = manager.GetActionsForScope( PLUGIN_ACTION_SCOPE::FOOTPRINT_WIZARD );
60
61 BOOST_TEST_WARN( !actions.empty(), "No available wizards to test with (maybe Python or kicad-python unavailable?); skipping tests" );
62
63 if( actions.empty() )
64 return;
65
66 for( auto& action : actions )
67 {
68 BOOST_TEST_CONTEXT( action->identifier )
69 {
70 // QA test actions should have real metadata
71 BOOST_TEST_REQUIRE( !action->description.IsEmpty() );
72 BOOST_TEST_REQUIRE( !action->entrypoint.IsEmpty() );
73 BOOST_TEST_REQUIRE( action->scopes.contains( PLUGIN_ACTION_SCOPE::FOOTPRINT_WIZARD ) );
74
75 FOOTPRINT_WIZARD wizard;
76 wizard.SetIdentifier( action->identifier );
77 BOOST_TEST_REQUIRE( FOOTPRINT_WIZARD_MANAGER::RefreshInfo( &wizard ) );
78
79 BOOST_TEST_REQUIRE( wizard.Info().meta.identifier.Matches( action->identifier ) );
80 }
81 }
82}
83#endif
84
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...
std::vector< const PLUGIN_ACTION * > GetActionsForScope(PLUGIN_ACTION_SCOPE aScope)
void ReloadPlugins(std::optional< wxString > aDirectoryToScan=std::nullopt)
Clears the loaded plugins and actions and re-scans the filesystem to register new ones.
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)
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")