KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_notifications_manager.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 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
22#include <ui_events.h>
23#include <build_version.h>
24#include <paths.h>
25#include <wx/filename.h>
26#include <wx/string.h>
27
29
30BOOST_AUTO_TEST_SUITE( Notifications )
31
32BOOST_AUTO_TEST_CASE( CreateAndPersist )
33{
34 wxFileName tmpDir( wxFileName::GetTempDir(), "" );
35 wxString envPath = tmpDir.GetFullPath();
36
37 wxSetEnv( wxS("KICAD_CACHE_HOME"), envPath );
38 wxFileName::Mkdir( PATHS::GetUserCachePath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
39
41 mgr.CreateOrUpdate( wxS("key"), wxS("Title"), wxS("Desc") );
42 mgr.Save();
43
44 wxFileName fn( PATHS::GetUserCachePath(), wxS("notifications.json") );
45 BOOST_CHECK( fn.FileExists() );
46}
47
48class TEST_HANDLER : public wxEvtHandler
49{
50public:
51 bool triggered = false;
52 void OnEvent( wxCommandEvent& ) { triggered = true; }
53};
54
55BOOST_AUTO_TEST_CASE( EventDispatch )
56{
57 TEST_HANDLER handler;
58 handler.Bind( EDA_EVT_UNITS_CHANGED, &TEST_HANDLER::OnEvent, &handler );
59 wxCommandEvent evt( EDA_EVT_UNITS_CHANGED );
60 handler.ProcessEvent( evt );
61 BOOST_CHECK( handler.triggered );
62}
63
65
void Save()
Save notifications to disk.
void CreateOrUpdate(const wxString &aKey, const wxString &aTitle, const wxString &aDescription, const wxString &aHref=wxEmptyString)
Create a notification with the given parameters or updates an existing one with the same key.
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
Definition: paths.cpp:419
void OnEvent(wxCommandEvent &)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(CreateAndPersist)