KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_reset_print_to_file.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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
22#include <printing.h>
23
24#include <wx/print.h>
25#include <wx/cmndata.h>
26
27#if defined( __WXGTK__ ) && wxUSE_GTKPRINT
28#include <wx/gtk/print.h>
29#include <gtk/gtk.h>
30#endif
31
32
33BOOST_AUTO_TEST_SUITE( ResetPrintToFile )
34
35
36// The wx-level filename is always cleared, on every platform.
37BOOST_AUTO_TEST_CASE( ClearsWxFilename )
38{
39 wxPrintData data;
40 data.SetFilename( wxT( "/tmp/gtkprintXXXXXX" ) );
41
43
44 BOOST_CHECK( data.GetFilename().IsEmpty() );
45}
46
47
48#if defined( __WXGTK__ ) && wxUSE_GTKPRINT
49
50// The reported bug is that GTK stores the print-to-file destination in the native
51// GtkPrintSettings output URI, which the wx-level filename does not track. Seed the URI the
52// way a completed print-to-file operation would and confirm the reset clears it.
53BOOST_AUTO_TEST_CASE( ClearsGtkOutputUri )
54{
55 wxPrintData data;
56
57 wxGtkPrintNativeData* nativeData = dynamic_cast<wxGtkPrintNativeData*>( data.GetNativeData() );
58 BOOST_REQUIRE( nativeData );
59 BOOST_REQUIRE( nativeData->GetPrintConfig() );
60
61 gtk_print_settings_set( nativeData->GetPrintConfig(), GTK_PRINT_SETTINGS_OUTPUT_URI,
62 "file:///tmp/gtkprintXXXXXX" );
63
64 BOOST_REQUIRE( gtk_print_settings_get( nativeData->GetPrintConfig(),
65 GTK_PRINT_SETTINGS_OUTPUT_URI ) != nullptr );
66
68
69 BOOST_CHECK( gtk_print_settings_get( nativeData->GetPrintConfig(),
70 GTK_PRINT_SETTINGS_OUTPUT_URI ) == nullptr );
71}
72
73#endif
74
75
void ResetPrintToFilePath(wxPrintData &aData)
Clear any leftover "print to file" destination from aData.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ClearsWxFilename)