KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/test_module.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 (C) 2017 CERN
5 * @author Alejandro GarcĂ­a Montoro <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
25#include <boost/test/unit_test.hpp>
26
27#include <wx/app.h>
28#include <wx/init.h>
29
30#include <mock_pgm_base.h>
32#include <qa_utils/file_utils.h>
35
36#include <kiplatform/app.h>
37
38#include <pgm_base.h>
41#include <eeschema_settings.h>
43
44
46{
48 SetPgm( new MOCK_PGM_BASE() );
50 boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";
51
52 wxApp::SetInstance( new wxAppConsole );
53
54 bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
55 boost::unit_test::framework::master_test_suite().argv );
56
57 wxSetAssertHandler( &KI_TEST::wxAssertThrower );
58 delete wxLog::SetActiveTarget( new KI_TEST::QUIET_LOG );
59
60 Pgm().InitPgm( true, true );
66 return ok;
67}
68
69
70int main( int argc, char* argv[] )
71{
72 KI_TEST::SCOPED_PROCESS_TEMP_DIR scopedTempDir( "kicad_qa_eeschema" );
73
74 int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
75
76 Pgm().Destroy();
77
78 // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
79 // but without it, Valgrind notices a lot of leaks from WX
80 wxUninitialize();
81
82 return ret;
83}
A stderr log target that drops informational messages.
Definition wx_log.h:36
Install a temporary directory for the process to use for temporary files, which is (usually) removed ...
Definition file_utils.h:179
void Destroy()
Definition pgm_base.cpp:183
bool InitPgm(bool aHeadless=false, bool aIsUnitTest=false)
Initialize this program.
Definition pgm_base.cpp:340
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Take ownership of the pointer passed in.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
bool init_unit_test()
Main file for the Eeschema tests to be compiled.
bool Init()
Perform application-specific initialization tasks.
Definition unix/app.cpp:40
void wxAssertThrower(const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg)
Definition wx_assert.h:81
void SetMockConfigDir()
void SetPgm(PGM_BASE *pgm)
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
bool init_unit_test()