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 (C) 2019-2020 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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
29#include <boost/test/unit_test.hpp>
30#include <kiplatform/app.h>
31
32#include <pgm_base.h>
34#include <eeschema_settings.h>
36#include <wx/app.h>
37#include <wx/init.h>
38#include <mock_pgm_base.h>
39
41
42
44{
45 SetPgm( new MOCK_PGM_BASE() );
47 boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";
48
49 wxApp::SetInstance( new wxAppConsole );
50
51 bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
52 boost::unit_test::framework::master_test_suite().argv );
53
54 wxSetAssertHandler( &KI_TEST::wxAssertThrower );
55
56 Pgm().InitPgm( true, true, true );
60 return ok;
61}
62
63
64int main( int argc, char* argv[] )
65{
66 int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
67
68 Pgm().Destroy();
69
70 // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
71 // but without it, Valgrind notices a lot of leaks from WX
72 wxUninitialize();
73
74 return ret;
75}
void Destroy()
Definition: pgm_base.cpp:170
bool InitPgm(bool aHeadless=false, bool aSkipPyInit=false, bool aIsUnitTest=false)
Initialize this program.
Definition: pgm_base.cpp:457
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
main()
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:71
void SetPgm(PGM_BASE *pgm)
Definition: pgm_base.cpp:1072
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE