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
40
41/*
42 * Simple function to handle a WX assertion and throw a real exception.
43 *
44 * This is useful when you want to check assertions fire in unit tests.
45 */
46void wxAssertThrower( const wxString& aFile, int aLine, const wxString& aFunc,
47 const wxString& aCond, const wxString& aMsg )
48{
49 throw KI_TEST::WX_ASSERT_ERROR( aFile, aLine, aFunc, aCond, aMsg );
50}
51
52
54{
56 boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests";
57
58 wxApp::SetInstance( new wxAppConsole );
59
60 bool ok = wxInitialize( boost::unit_test::framework::master_test_suite().argc,
61 boost::unit_test::framework::master_test_suite().argv );
62
63 wxSetAssertHandler( &wxAssertThrower );
64
65 Pgm().InitPgm( true, true, true );
66 Pgm().GetSettingsManager().RegisterSettings( new EESCHEMA_SETTINGS, false );
67 Pgm().GetSettingsManager().RegisterSettings( new SYMBOL_EDITOR_SETTINGS, false );
68 Pgm().GetSettingsManager().Load();
69 return ok;
70}
71
72
73int main( int argc, char* argv[] )
74{
75 int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
76
77 Pgm().Destroy();
78
79 // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
80 // but without it, Valgrind notices a lot of leaks from WX
81 wxUninitialize();
82
83 return ret;
84}
An exception class to represent a WX assertion.
Definition: wx_assert.h:47
main()
bool init_unit_test()
void wxAssertThrower(const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg)
Main file for the Eeschema tests to be compiled.
bool Init()
Perform application-specific initialization tasks.
Definition: gtk/app.cpp:40
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115