qa_common_tools: use common mocks
This commit is contained in:
parent
2583acd1cc
commit
14ded23e97
|
@ -30,7 +30,7 @@ add_executable( qa_common_tools
|
||||||
${CMAKE_SOURCE_DIR}/common/observable.cpp
|
${CMAKE_SOURCE_DIR}/common/observable.cpp
|
||||||
|
|
||||||
# Mock Pgm needed for advanced_config in coroutines
|
# Mock Pgm needed for advanced_config in coroutines
|
||||||
${CMAKE_SOURCE_DIR}/qa/qa_utils/mock_pgm.cpp
|
${CMAKE_SOURCE_DIR}/qa/mocks/kicad/common_mocks.cpp
|
||||||
|
|
||||||
# The main entry point
|
# The main entry point
|
||||||
main.cpp
|
main.cpp
|
||||||
|
@ -45,6 +45,7 @@ add_executable( qa_common_tools
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}
|
${CMAKE_SOURCE_DIR}
|
||||||
${CMAKE_SOURCE_DIR}/include
|
${CMAKE_SOURCE_DIR}/include
|
||||||
|
${CMAKE_SOURCE_DIR}/qa/mocks/include
|
||||||
${INC_AFTER}
|
${INC_AFTER}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,134 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* 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 <pgm_base.h>
|
|
||||||
#include <kiface_base.h>
|
|
||||||
#include <kiway.h>
|
|
||||||
#include <kiway_player.h>
|
|
||||||
|
|
||||||
#include <wx/app.h>
|
|
||||||
|
|
||||||
|
|
||||||
static struct IFACE : public KIFACE_BASE
|
|
||||||
{
|
|
||||||
// Of course all are overloads, implementations of the KIFACE.
|
|
||||||
|
|
||||||
IFACE( const char* aName, KIWAY::FACE_T aType ) :
|
|
||||||
KIFACE_BASE( aName, aType )
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnKifaceEnd() override {}
|
|
||||||
|
|
||||||
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
|
|
||||||
{
|
|
||||||
assert( false );
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function IfaceOrAddress
|
|
||||||
* return a pointer to the requested object. The safest way to use this
|
|
||||||
* is to retrieve a pointer to a static instance of an interface, similar to
|
|
||||||
* how the KIFACE interface is exported. But if you know what you are doing
|
|
||||||
* use it to retrieve anything you want.
|
|
||||||
*
|
|
||||||
* @param aDataId identifies which object you want the address of.
|
|
||||||
*
|
|
||||||
* @return void* - and must be cast into the know type.
|
|
||||||
*/
|
|
||||||
void* IfaceOrAddress( int aDataId ) override
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kiface( "pcb_test_frame", KIWAY::FACE_PCB );
|
|
||||||
|
|
||||||
static struct PGM_TEST_FRAME : public PGM_BASE
|
|
||||||
{
|
|
||||||
bool OnPgmInit();
|
|
||||||
|
|
||||||
void OnPgmExit()
|
|
||||||
{
|
|
||||||
Kiway.OnKiwayEnd();
|
|
||||||
|
|
||||||
// Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
|
|
||||||
// earlier than wxApp and earlier than static destruction would.
|
|
||||||
PGM_BASE::Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacOpenFile( const wxString& aFileName ) override
|
|
||||||
{
|
|
||||||
wxFileName filename( aFileName );
|
|
||||||
|
|
||||||
if( filename.FileExists() )
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
// this pulls in EDA_DRAW_FRAME type info, which we don't want in
|
|
||||||
// the single_top link image.
|
|
||||||
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
|
|
||||||
#else
|
|
||||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( frame )
|
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
program;
|
|
||||||
|
|
||||||
PGM_BASE& Pgm()
|
|
||||||
{
|
|
||||||
return program;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face
|
|
||||||
// is run from a python script, mot from a Kicad application
|
|
||||||
PGM_BASE* PgmOrNull()
|
|
||||||
{
|
|
||||||
return &program;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
KIFACE_BASE& Kiface()
|
|
||||||
{
|
|
||||||
return kiface;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MOCK_PLAYER : public KIWAY_PLAYER
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MOCK_PLAYER( KIWAY *aKiway ) :
|
|
||||||
KIWAY_PLAYER( aKiway, nullptr, FRAME_SCH, wxT( "Mock" ), wxDefaultPosition,
|
|
||||||
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
|
|
||||||
{}
|
|
||||||
|
|
||||||
~MOCK_PLAYER();
|
|
||||||
};
|
|
Loading…
Reference in New Issue