>From 0ac20fdf4c15164c6c7869d9f1eedb17773ab41c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Mar 2015 17:09:12 +0100 Subject: [PATCH 3/4] Add a unit test verifying that wxLog errors are shown to the user. Check that wxLogWarning() or wxLogError() calls from wxWidgets itself are shown to the user to ensure that the bug fixed by the previous commit is not reintroduced in the future. --- Makefile.am | 1 + objects.make | 1 + wx_test_log_errors.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 wx_test_log_errors.cpp diff --git a/Makefile.am b/Makefile.am index 5ed0773..2f0a1fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -266,6 +266,7 @@ wx_test_SOURCES = \ wx_test_expiry_dates.cpp \ wx_test_input_sequences.cpp \ wx_test_input_validation.cpp \ + wx_test_log_errors.cpp \ wx_test_paste_census.cpp \ wx_test_pdf_create.cpp \ wx_test_validate_output.cpp diff --git a/objects.make b/objects.make index bf9e18b..4d8eb57 100644 --- a/objects.make +++ b/objects.make @@ -367,6 +367,7 @@ wx_test_objects := \ wx_test_expiry_dates.o \ wx_test_input_sequences.o \ wx_test_input_validation.o \ + wx_test_log_errors.o \ wx_test_paste_census.o \ wx_test_pdf_create.o \ wx_test_validate_output.o \ diff --git a/wx_test_log_errors.cpp b/wx_test_log_errors.cpp new file mode 100644 index 0000000..631e2b3 --- /dev/null +++ b/wx_test_log_errors.cpp @@ -0,0 +1,52 @@ +// Test that wxLog error messages are shown to the user. +// +// Copyright (C) 2015 Gregory W. Chicares. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +// +// http://savannah.nongnu.org/projects/lmi +// email: +// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA + +// $Id$ + +#ifdef __BORLANDC__ +# include "pchfile.hpp" +# pragma hdrstop +#endif + +#include "assert_lmi.hpp" +#include "wx_test_case.hpp" + +#include +#include +#include +#include + +LMI_WX_TEST_CASE(log_error) +{ + wxDocManager* const doc_manager = wxDocManager::GetDocumentManager(); + LMI_ASSERT(doc_manager); + + // Silently opening a file without extension must fail as the doc/view + // framework has no way to find the template associated with it. + doc_manager->CreateDocument("file_without_extension", wxDOC_SILENT); + + wxTEST_DIALOG + (wxLog::FlushActive() + ,wxExpectModal(wxOK). + Describe("warning about being unable to determine file format") + ); +} + -- 2.1.0