Add wxTEST_DIALOG for testing of modal dialogs.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72837 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2012-11-01 16:45:11 +00:00
parent a4d982a7cf
commit 643e9cf9f6
58 changed files with 632 additions and 48 deletions

396
include/wx/testing.h Normal file
View File

@@ -0,0 +1,396 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/testing.h
// Purpose: helpers for GUI testing
// Author: Vaclav Slavik
// Created: 2012-08-28
// RCS-ID: $Id$
// Copyright: (c) 2012 Vaclav Slavik
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TESTING_H_
#define _WX_TESTING_H_
#include "wx/debug.h"
#include "wx/string.h"
class WXDLLIMPEXP_FWD_CORE wxDialog;
class WXDLLIMPEXP_FWD_CORE wxMessageDialogBase;
class WXDLLIMPEXP_FWD_CORE wxFileDialogBase;
// ----------------------------------------------------------------------------
// implementation helpers
// ----------------------------------------------------------------------------
// Helper hook class used to redirect ShowModal() to testing code.
// Instead of showing a dialog modally, hook code is called to simulate what
// the user would do and return appropriate ID from ShowModal().
class WXDLLIMPEXP_CORE wxModalDialogHook
{
public:
wxModalDialogHook() {}
virtual ~wxModalDialogHook() {}
/// Returns currently active hook object or NULL.
static wxModalDialogHook *Get() { return ms_instance; }
/// Set the hook and returns the previously set one.
static wxModalDialogHook *Set(wxModalDialogHook *hook)
{
wxModalDialogHook *old = ms_instance;
ms_instance = hook;
return old;
}
/// Entry point that is called from ShowModal().
virtual int Invoke(wxDialog *dlg) = 0;
private:
static wxModalDialogHook *ms_instance;
wxDECLARE_NO_COPY_CLASS(wxModalDialogHook);
};
// This macro needs to be used at the top of every implementation of
// ShowModal() in order for the above modal dialogs testing code to work.
#define WX_TESTING_SHOW_MODAL_HOOK() \
if ( wxModalDialogHook::Get() ) \
{ \
int rc = wxModalDialogHook::Get()->Invoke(this); \
if ( rc != wxID_NONE ) \
return rc; \
} \
struct wxDummyTestingStruct /* just to force a semicolon */
// ----------------------------------------------------------------------------
// testing API
// ----------------------------------------------------------------------------
// Don't include this code when building the library itself
#ifndef WXBUILDING
#include "wx/beforestd.h"
#include <algorithm>
#include <iterator>
#include <queue>
#include "wx/afterstd.h"
#include "wx/cpp.h"
class wxTestingModalHook;
// Non-template base class for wxExpectModal<T> (via wxExpectModalBase).
// Only used internally.
class wxModalExpectation
{
public:
wxModalExpectation() : m_isOptional(false) {}
virtual ~wxModalExpectation() {}
bool IsOptional() const { return m_isOptional; }
virtual int Invoke(wxDialog *dlg) const = 0;
virtual wxString GetDescription() const = 0;
protected:
// Is this dialog optional, i.e. not required to be shown?
bool m_isOptional;
};
// This must be specialized for each type. The specialization MUST be derived
// from wxExpectModalBase<T>.
template<class T> class wxExpectModal {};
/**
Base class for wxExpectModal<T> specializations.
Every such specialization must be derived from wxExpectModalBase; there's
no other use for this class than to serve as wxExpectModal<T>'s base class.
T must be a class derived from wxDialog.
*/
template<class T>
class wxExpectModalBase : public wxModalExpectation
{
public:
typedef T DialogType;
typedef wxExpectModal<DialogType> ExpectationType;
/**
Returns a copy of the expectation where the expected dialog is marked
as optional.
Optional dialogs aren't required to appear, it's not an error if they
don't.
*/
ExpectationType Optional() const
{
ExpectationType e(*static_cast<const ExpectationType*>(this));
e.m_isOptional = true;
return e;
}
protected:
virtual int Invoke(wxDialog *dlg) const
{
DialogType *t = dynamic_cast<DialogType*>(dlg);
if ( t )
return OnInvoked(t);
else
return wxID_NONE; // not handled
}
/// Returns description of the expected dialog (by default, its class).
virtual wxString GetDescription() const
{
return wxCLASSINFO(T)->GetClassName();
}
/**
This method is called when ShowModal() was invoked on a dialog of type T.
@return Return value is used as ShowModal()'s return value.
*/
virtual int OnInvoked(DialogType *dlg) const = 0;
};
// wxExpectModal<T> specializations for common dialogs:
template<>
class wxExpectModal<wxMessageDialog> : public wxExpectModalBase<wxMessageDialog>
{
public:
wxExpectModal(int id)
{
switch ( id )
{
case wxYES:
m_id = wxID_YES;
break;
case wxNO:
m_id = wxID_NO;
break;
case wxCANCEL:
m_id = wxID_CANCEL;
break;
case wxOK:
m_id = wxID_OK;
break;
case wxHELP:
m_id = wxID_HELP;
break;
default:
m_id = id;
break;
}
}
protected:
virtual int OnInvoked(wxMessageDialog *WXUNUSED(dlg)) const
{
return m_id;
}
int m_id;
};
template<>
class wxExpectModal<wxFileDialog> : public wxExpectModalBase<wxFileDialog>
{
public:
wxExpectModal(const wxString& path, int id = wxID_OK)
: m_path(path), m_id(id)
{
}
protected:
virtual int OnInvoked(wxFileDialog *dlg) const
{
dlg->SetPath(m_path);
return m_id;
}
wxString m_path;
int m_id;
};
// Implementation of wxModalDialogHook for use in testing, with
// wxExpectModal<T> and the wxTEST_DIALOG() macro. It is not intended for
// direct use, use the macro instead.
class wxTestingModalHook : public wxModalDialogHook
{
public:
wxTestingModalHook()
{
m_prevHook = wxModalDialogHook::Set(this);
}
virtual ~wxTestingModalHook()
{
wxModalDialogHook::Set(m_prevHook);
}
virtual int Invoke(wxDialog *dlg)
{
while ( !m_expectations.empty() )
{
const wxModalExpectation *expect = m_expectations.front();
m_expectations.pop();
int ret = expect->Invoke(dlg);
if ( ret != wxID_NONE )
return ret; // dialog shown as expected
// not showing an optional dialog is OK, but showing an unexpected
// one definitely isn't:
if ( !expect->IsOptional() )
{
ReportFailure
(
wxString::Format
(
"A %s dialog was shown unexpectedly, expected %s.",
dlg->GetClassInfo()->GetClassName(),
expect->GetDescription()
)
);
return wxID_NONE;
}
// else: try the next expectation in the chain
}
ReportFailure
(
wxString::Format
(
"A dialog (%s) was shown unexpectedly.",
dlg->GetClassInfo()->GetClassName()
)
);
return wxID_NONE;
}
// Called to verify that all expectations were met. This cannot be done in
// the destructor, because ReportFailure() may throw (either because it's
// overriden or because wx's assertions handling is, globally). And
// throwing from the destructor would introduce all sort of problems,
// including messing up the order of errors in some cases.
void CheckUnmetExpectations()
{
while ( !m_expectations.empty() )
{
const wxModalExpectation *expect = m_expectations.front();
m_expectations.pop();
if ( expect->IsOptional() )
continue;
ReportFailure
(
wxString::Format
(
"Expected %s dialog was not shown.",
expect->GetDescription()
)
);
break;
}
}
void AddExpectation(const wxModalExpectation& e)
{
m_expectations.push(&e);
}
protected:
virtual void ReportFailure(const wxString& msg)
{
wxFAIL_MSG( msg );
}
private:
wxModalDialogHook *m_prevHook;
std::queue<const wxModalExpectation*> m_expectations;
wxDECLARE_NO_COPY_CLASS(wxTestingModalHook);
};
// Redefining this value makes it possible to customize the hook class,
// including e.g. its error reporting.
#define wxTEST_DIALOG_HOOK_CLASS wxTestingModalHook
#define WX_TEST_IMPL_ADD_EXPECTATION(pos, expect) \
const wxModalExpectation& wx_exp##pos = expect; \
wx_hook.AddExpectation(wx_exp##pos);
/**
Runs given code with all modal dialogs redirected to wxExpectModal<T>
hooks, instead of being shown to the user.
The first argument is any valid expression, typically a function call. The
remaining arguments are wxExpectModal<T> instances defining the dialogs
that are expected to be shown, in order of appearance.
Some typical examples:
@code
wxTEST_DIALOG
(
rc = dlg.ShowModal(),
wxExpectModal<wxFileDialog>(wxGetCwd() + "/test.txt")
);
@endcode
Sometimes, the code may show more than one dialog:
@code
wxTEST_DIALOG
(
RunSomeFunction(),
wxExpectModal<wxMessageDialog>(wxNO),
wxExpectModal<MyConfirmationDialog>(wxYES),
wxExpectModal<wxFileDialog>(wxGetCwd() + "/test.txt")
);
@endcode
Notice that wxExpectModal<T> has some convenience methods for further
tweaking the expectations. For example, it's possible to mark an expected
dialog as @em optional for situations when a dialog may be shown, but isn't
required to, by calling the Optional() method:
@code
wxTEST_DIALOG
(
RunSomeFunction(),
wxExpectModal<wxMessageDialog>(wxNO),
wxExpectModal<wxFileDialog>(wxGetCwd() + "/test.txt").Optional()
);
@endcode
@note By default, errors are reported with wxFAIL_MSG(). You may customize this by
implementing a class derived from wxTestingModalHook, overriding its
ReportFailure() method and redefining the wxTEST_DIALOG_HOOK_CLASS
macro to be the name of this class.
@note Custom dialogs are supported too. All you have to do is to specialize
wxExpectModal<> for your dialog type and implement its OnInvoked()
method.
*/
#define wxTEST_DIALOG(codeToRun, ...) \
{ \
wxTEST_DIALOG_HOOK_CLASS wx_hook; \
wxCALL_FOR_EACH(WX_TEST_IMPL_ADD_EXPECTATION, __VA_ARGS__) \
codeToRun; \
wx_hook.CheckUnmetExpectations(); \
}
#endif // !WXBUILDING
#endif // _WX_TESTING_H_

View File

@@ -19,6 +19,7 @@
#include "wx/settings.h"
#endif //WX_PRECOMP
#include "wx/testing.h"
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
@@ -127,6 +128,8 @@ bool wxDialog::Show(bool show)
// is stopped (via EndModal()) it returns the exit code.
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxCHECK_MSG(!IsModal(),GetReturnCode(),wxT("wxDialog::ShowModal called within its own modal loop"));
// Show(true) will set m_isShown = true

View File

@@ -31,6 +31,7 @@
#endif
#include "wx/filename.h"
#include "wx/testing.h"
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
@@ -104,6 +105,8 @@ wxDirDialog::~wxDirDialog()
int wxDirDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxAutoNSAutoreleasePool thePool;
m_fileNames.Empty();

View File

@@ -33,6 +33,7 @@
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
#include "wx/testing.h"
#import <AppKit/NSOpenPanel.h>
#import <AppKit/NSSavePanel.h>
@@ -196,6 +197,8 @@ void wxFileDialog::SetPath(const wxString& path)
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxAutoNSAutoreleasePool thePool;
m_fileNames.Empty();

View File

@@ -31,6 +31,7 @@
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
#include "wx/testing.h"
#import <AppKit/NSAlert.h>
// ============================================================================
@@ -72,6 +73,8 @@ void wxCocoaMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& va
int wxCocoaMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxAutoNSAutoreleasePool thePool;
NSAlert *alert = [[[NSAlert alloc] init] autorelease];

View File

@@ -43,6 +43,7 @@
#include "wx/bookctrl.h"
#include "wx/scrolwin.h"
#include "wx/textwrapper.h"
#include "wx/testing.h"
#if wxUSE_DISPLAY
#include "wx/display.h"
@@ -50,6 +51,8 @@
extern WXDLLEXPORT_DATA(const char) wxDialogNameStr[] = "dialog";
wxModalDialogHook *wxModalDialogHook::ms_instance = NULL;
// ----------------------------------------------------------------------------
// XTI
// ----------------------------------------------------------------------------

View File

@@ -49,6 +49,7 @@
#include "wx/filectrl.h"
#include "wx/generic/filedlgg.h"
#include "wx/debug.h"
#include "wx/testing.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
@@ -308,6 +309,8 @@ wxBitmapButton* wxGenericFileDialog::AddBitmapButton( wxWindowID winId,
int wxGenericFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
if (CreateExtraControl())
{
wxSizer *sizer = GetSizer();

View File

@@ -39,6 +39,7 @@
#include "wx/msgdlg.h"
#include "wx/artprov.h"
#include "wx/textwrapper.h"
#include "wx/testing.h"
#if wxUSE_STATLINE
#include "wx/statline.h"
@@ -268,6 +269,8 @@ void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
int wxGenericMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
if ( !m_created )
{
m_created = true;

View File

@@ -19,6 +19,7 @@
#if wxUSE_COLOURDLG
#include "wx/colordlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
@@ -82,6 +83,8 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
int wxColourDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
ColourDataToDialog();
gint result = gtk_dialog_run(GTK_DIALOG(m_widget));

View File

@@ -19,6 +19,7 @@
#include "wx/evtloop.h"
#include "wx/scopedptr.h"
#include "wx/testing.h"
#include <gtk/gtk.h>
@@ -100,6 +101,8 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxASSERT_MSG( !IsModal(), "ShowModal() can't be called twice" );
// release the mouse if it's currently captured as the window having it

View File

@@ -29,6 +29,7 @@
#include "wx/filename.h" // wxFilename
#include "wx/tokenzr.h" // wxStringTokenizer
#include "wx/filefn.h" // ::wxGetCwd
#include "wx/testing.h"
//-----------------------------------------------------------------------------
// "clicked" for OK-button
@@ -342,6 +343,8 @@ void wxFileDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
CreateExtraControl();
return wxDialog::ShowModal();

View File

@@ -34,6 +34,7 @@
#include "wx/dynlib.h"
#include "wx/paper.h"
#include "wx/dcprint.h"
#include "wx/testing.h"
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-pango.h>
@@ -591,6 +592,8 @@ wxGnomePrintDialog::~wxGnomePrintDialog()
int wxGnomePrintDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
int response = gtk_dialog_run (GTK_DIALOG (m_widget));
if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL)
@@ -736,6 +739,8 @@ wxPageSetupDialogData& wxGnomePageSetupDialog::GetPageSetupDialogData()
int wxGnomePageSetupDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxGnomePrintNativeData *native =
(wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData();

View File

@@ -24,6 +24,8 @@
#include "wx/intl.h"
#endif
#include "wx/testing.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/messagetype.h"
@@ -273,6 +275,8 @@ void wxMessageDialog::GTKCreateMsgDialog()
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
// break the mouse capture as it would interfere with modal dialog (see
// wxDialog::ShowModal)
wxWindow * const win = wxWindow::GetCapture();

View File

@@ -34,6 +34,7 @@
#include "wx/dynlib.h"
#include "wx/paper.h"
#include "wx/scopeguard.h"
#include "wx/testing.h"
#include <gtk/gtk.h>
@@ -623,6 +624,8 @@ wxGtkPrintDialog::~wxGtkPrintDialog()
// This is called even if we actually don't want the dialog to appear.
int wxGtkPrintDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
// We need to restore the settings given in the constructor.
wxPrintData data = m_printDialogData.GetPrintData();
wxGtkPrintNativeData *native =
@@ -747,6 +750,8 @@ wxGtkPageSetupDialog::~wxGtkPageSetupDialog()
int wxGtkPageSetupDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
// Get the config.
m_pageDialogData.GetPrintData().ConvertToNative();
wxGtkPrintNativeData *native = (wxGtkPrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData();

View File

@@ -19,6 +19,7 @@
#endif // WX_PRECOMP
#include "wx/evtloop.h"
#include "wx/testing.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
@@ -182,6 +183,8 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
if (IsModal())
{
wxFAIL_MSG( wxT("wxDialog:ShowModal called twice") );

View File

@@ -13,6 +13,7 @@
#if wxUSE_FILEDLG
#include "wx/filedlg.h"
#include "wx/testing.h"
//-----------------------------------------------------------------------------
@@ -49,6 +50,8 @@ void wxFileDialog::OnFakeOk( wxCommandEvent &event )
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
return wxGenericFileDialog::ShowModal();
}

View File

@@ -21,6 +21,7 @@
#endif
#include "wx/evtloop.h"
#include "wx/testing.h"
#ifdef __VMS__
#pragma message disable nosimpint
@@ -288,6 +289,8 @@ bool wxDialog::Show( bool show )
// Shows a dialog modally, returning a return code
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
Show(true);
// after the event loop ran, the widget might already have been destroyed

View File

@@ -23,6 +23,7 @@
#include "wx/tokenzr.h"
#include "wx/stockitem.h"
#include "wx/testing.h"
#ifdef __VMS__
#pragma message disable nosimpint
@@ -151,6 +152,8 @@ static void wxChangeListBoxColours(wxWindow* WXUNUSED(win), Widget widget)
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxBeginBusyCursor();
// static char fileBuf[512];

View File

@@ -40,6 +40,7 @@
#include "wx/settings.h"
#endif
#include "wx/testing.h"
#include "wx/motif/private.h"
// ----------------------------------------------------------------------------
@@ -105,6 +106,8 @@ extern "C"
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
const long style = GetMessageDialogStyle();
DialogCreateFunction dialogCreateFunction;

View File

@@ -27,6 +27,7 @@
#if wxUSE_COLOURDLG && !(defined(__SMARTPHONE__) && defined(__WXWINCE__))
#include "wx/colordlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/msw/wrapcdlg.h"
@@ -114,6 +115,8 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
int wxColourDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
// initialize the struct used by Windows
CHOOSECOLOR chooseColorStruct;
memset(&chooseColorStruct, 0, sizeof(CHOOSECOLOR));

View File

@@ -25,6 +25,7 @@
#endif
#include "wx/dialog.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/msw/wrapcdlg.h"
@@ -197,6 +198,8 @@ bool wxDialog::Show(bool show)
// show dialog modally
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxASSERT_MSG( !IsModal(), wxT("ShowModal() can't be called twice") );
Show();

View File

@@ -30,6 +30,7 @@
(defined(__HANDHELDPC__) && (_WIN32_WCE >= 500)))
#include "wx/dirdlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/utils.h"
@@ -220,6 +221,8 @@ void wxDirDialog::SetPath(const wxString& path)
int wxDirDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxWindow* const parent = GetParent();
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;

View File

@@ -47,6 +47,7 @@
#include "wx/filename.h"
#include "wx/scopeguard.h"
#include "wx/tokenzr.h"
#include "wx/testing.h"
// ----------------------------------------------------------------------------
// constants
@@ -449,6 +450,8 @@ void wxFileDialog::MSWOnInitDialogHook(WXHWND hwnd)
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
HWND hWnd = 0;
if (m_parent) hWnd = (HWND) m_parent->GetHWND();
if (!hWnd && wxTheApp->GetTopWindow())

View File

@@ -27,6 +27,7 @@
#if wxUSE_FONTDLG
#include "wx/fontdlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/msw/wrapcdlg.h"
@@ -55,6 +56,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
int wxFontDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
// It should be OK to always use GDI simulations
DWORD flags = CF_SCREENFONTS /* | CF_NOSIMULATIONS */ ;

View File

@@ -42,6 +42,7 @@
#include "wx/msw/private/button.h"
#include "wx/msw/private/metrics.h"
#include "wx/msw/private/msgdlg.h"
#include "wx/testing.h"
#if wxUSE_MSGBOX_HOOK
#include "wx/fontutil.h"
@@ -591,6 +592,8 @@ int wxMessageDialog::ShowMessageBox()
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
#ifdef wxHAS_MSW_TASKDIALOG
if ( HasNativeTaskDialog() )
{

View File

@@ -39,6 +39,7 @@
#include "wx/msw/printdlg.h"
#include "wx/msw/dcprint.h"
#include "wx/paper.h"
#include "wx/testing.h"
#include <stdlib.h>
@@ -738,6 +739,8 @@ wxWindowsPrintDialog::~wxWindowsPrintDialog()
int wxWindowsPrintDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
ConvertToNative( m_printDialogData );
PRINTDLG *pd = (PRINTDLG*) m_printDlg;
@@ -957,6 +960,8 @@ wxWindowsPageSetupDialog::~wxWindowsPageSetupDialog()
int wxWindowsPageSetupDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
ConvertToNative( m_pageSetupData );
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageDlg;

View File

@@ -18,6 +18,7 @@
#if wxUSE_RICHMSGDLG
#include "wx/richmsgdlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/msw/private.h"
@@ -33,6 +34,8 @@
int wxRichMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
#ifdef wxHAS_MSW_TASKDIALOG
using namespace wxMSWMessageDialog;

View File

@@ -47,6 +47,7 @@
#include <string.h>
#include "wx/filename.h"
#include "wx/testing.h"
// ============================================================================
// implementation
@@ -112,6 +113,8 @@ void wxFileDialog::SetPath(const wxString& path)
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxWindow* parentWindow = GetParent();
if (!parentWindow)
parentWindow = wxTheApp->GetTopWindow();

View File

@@ -26,6 +26,7 @@
#include "wx/os2/private.h"
#include "wx/evtloop.h"
#include "wx/scopedptr.h"
#include "wx/testing.h"
#define wxDIALOG_DEFAULT_X 300
#define wxDIALOG_DEFAULT_Y 300
@@ -219,6 +220,8 @@ bool wxDialog::Show( bool bShow )
//
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxASSERT_MSG( !IsModal(), wxT("wxDialog::ShowModal() reentered?") );
m_endModalCalled = false;

View File

@@ -13,6 +13,7 @@
#include "wx/wxprec.h"
#include "wx/dirdlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include <stdio.h>
@@ -42,6 +43,8 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
int wxDirDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
// TODO
return wxID_CANCEL;
}

View File

@@ -39,6 +39,7 @@
#include <string.h>
#include "wx/tokenzr.h"
#include "wx/testing.h"
#define wxMAXPATH 1024
#define wxMAXFILE 1024
@@ -104,6 +105,8 @@ void wxFileDialog::GetPaths (
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxString sTheFilter;
wxString sFilterBuffer;
wxChar* pzFilterBuffer;

View File

@@ -23,6 +23,7 @@
#endif
#include "wx/fontutil.h"
#include "wx/testing.h"
#define INCL_PM
#include <os2.h>
@@ -36,6 +37,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
int wxFontDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
FONTDLG vFontDlg;
char zCurrentFont[FACESIZE];
HWND hWndFontDlg;

View File

@@ -22,6 +22,7 @@
#include "wx/math.h"
#endif
#include "wx/testing.h"
#include "wx/os2/private.h"
#include <stdlib.h>
@@ -34,6 +35,8 @@ IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
HWND hWnd = 0;
ULONG ulStyle = MB_OK;
int nAns = wxOK;

View File

@@ -14,6 +14,7 @@
#include "wx/colordlg.h"
#include "wx/fontdlg.h"
#include "wx/testing.h"
#if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
@@ -47,6 +48,8 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
int wxColourDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
RGBColor currentColor ;
m_colourData.m_dataColour.GetRGBColor( &currentColor );

View File

@@ -22,6 +22,7 @@
#include "wx/colordlg.h"
#include "wx/fontdlg.h"
#include "wx/testing.h"
// ============================================================================
// implementation
@@ -122,6 +123,8 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
}
int wxColourDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
//Start the pool. Required for carbon interaction
//(For those curious, the only thing that happens
//if you don't do this is a bunch of error

View File

@@ -21,6 +21,7 @@
#endif // WX_PRECOMP
#include "wx/filename.h"
#include "wx/testing.h"
#include "wx/osx/private.h"
@@ -72,6 +73,8 @@ wxDirDialog::wxDirDialog(wxWindow *parent,
int wxDirDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
NavDialogRef dialog = NULL;
NavDialogCreationOptions options;
NavReplyRecord reply ;

View File

@@ -26,6 +26,7 @@
#include "wx/filename.h"
#include "wx/osx/private.h"
#include "wx/testing.h"
#ifndef __DARWIN__
#include <Navigation.h>
@@ -476,6 +477,8 @@ void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
m_paths.Empty();
m_fileNames.Empty();

View File

@@ -42,6 +42,7 @@
#include "wx/fontdlg.h"
#include "wx/fontutil.h"
#include "wx/testing.h"
#if wxOSX_USE_EXPERIMENTAL_FONTDIALOG
@@ -229,6 +230,8 @@ bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
int wxFontDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
#if wxOSX_USE_CARBON
OSStatus err ;

View File

@@ -28,6 +28,7 @@
#endif
#include "wx/fontutil.h"
#include "wx/testing.h"
// ============================================================================
// implementation
@@ -434,6 +435,8 @@ bool wxFontDialog::Create(wxWindow *parent)
int wxFontDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
//Start the pool. Required for carbon interaction
//(For those curious, the only thing that happens
//if you don't do this is a bunch of error

View File

@@ -19,6 +19,7 @@
#endif
#include "wx/thread.h"
#include "wx/testing.h"
#include "wx/osx/uma.h"
@@ -36,6 +37,8 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
int resultbutton = wxID_CANCEL;
const long style = GetMessageDialogStyle();

View File

@@ -28,9 +28,12 @@
#include "wx/osx/private/print.h"
#include "wx/osx/private.h"
#include "wx/statline.h"
#include "wx/testing.h"
int wxMacPrintDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
m_printDialogData.GetPrintData().ConvertToNative();
((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData );
@@ -74,6 +77,8 @@ int wxMacPrintDialog::ShowModal()
int wxMacPageSetupDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
m_pageSetupData.GetPrintData().ConvertToNative();
wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
nativeData->TransferFrom( &m_pageSetupData );

View File

@@ -32,6 +32,7 @@
#include "wx/filename.h"
#include "wx/evtloop.h"
#include "wx/testing.h"
#include "wx/osx/private.h"
@@ -94,6 +95,8 @@ void wxDirDialog::ShowWindowModal()
int wxDirDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxCFEventLoopPauseIdleEvents pause;
NSOpenPanel *oPanel = OSXCreatePanel();

View File

@@ -38,6 +38,7 @@
#include "wx/osx/private.h"
#include "wx/sysopt.h"
#include "wx/testing.h"
#include <mach-o/dyld.h>
@@ -495,6 +496,8 @@ void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
int wxFileDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxCFEventLoopPauseIdleEvents pause;
wxMacAutoreleasePool autoreleasepool;

View File

@@ -21,6 +21,7 @@
#include "wx/control.h"
#include "wx/thread.h"
#include "wx/evtloop.h"
#include "wx/testing.h"
#include "wx/osx/private.h"
@@ -62,6 +63,8 @@ wxMessageDialog::~wxMessageDialog()
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
wxCFEventLoopPauseIdleEvents pause;
int resultbutton = wxID_CANCEL;

View File

@@ -14,6 +14,7 @@
#if wxUSE_PRINTING_ARCHITECTURE
#include "wx/printdlg.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/object.h"
@@ -59,6 +60,8 @@ void wxOSXCocoaPrintData::UpdateToPMState()
int wxMacPrintDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
m_printDialogData.GetPrintData().ConvertToNative();
int result = wxID_CANCEL;
@@ -82,6 +85,8 @@ int wxMacPrintDialog::ShowModal()
int wxMacPageSetupDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
m_pageSetupData.GetPrintData().ConvertToNative();
((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData );

View File

@@ -13,6 +13,7 @@
#include "wx/dialog.h"
#include "wx/evtloop.h"
#include "wx/testing.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
@@ -137,6 +138,8 @@ bool wxDialog::Show(bool show)
// Replacement for Show(true) for modal dialogs - returns return code
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
m_modality = wxDIALOG_MODALITY_APP_MODAL;
Show();

View File

@@ -20,6 +20,7 @@
#include "wx/thread.h"
#include "wx/osx/private.h"
#include "wx/testing.h"
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
@@ -36,6 +37,8 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
int wxMessageDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
int resultbutton = wxID_CANCEL;
const long style = GetMessageDialogStyle();

View File

@@ -29,6 +29,7 @@
#endif
#include "wx/evtloop.h"
#include "wx/testing.h"
//-----------------------------------------------------------------------------
// wxDialog
@@ -165,6 +166,8 @@ bool wxDialog::IsModal() const
int wxDialog::ShowModal()
{
WX_TESTING_SHOW_MODAL_HOOK();
if ( IsModal() )
{
wxFAIL_MSG( wxT("wxDialog:ShowModal called twice") );

View File

@@ -204,6 +204,7 @@ TEST_GUI_OBJECTS = \
test_gui_virtlistctrltest.o \
test_gui_webtest.o \
test_gui_windowtest.o \
test_gui_dialogtest.o \
test_gui_clone.o \
test_gui_propagation.o \
test_gui_keyboard.o \
@@ -866,6 +867,9 @@ test_gui_webtest.o: $(srcdir)/controls/webtest.cpp $(TEST_GUI_ODEP)
test_gui_windowtest.o: $(srcdir)/controls/windowtest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/windowtest.cpp
test_gui_dialogtest.o: $(srcdir)/controls/dialogtest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/dialogtest.cpp
test_gui_clone.o: $(srcdir)/events/clone.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/events/clone.cpp

View File

@@ -190,6 +190,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_virtlistctrltest.obj \
$(OBJS)\test_gui_webtest.obj \
$(OBJS)\test_gui_windowtest.obj \
$(OBJS)\test_gui_dialogtest.obj \
$(OBJS)\test_gui_clone.obj \
$(OBJS)\test_gui_propagation.obj \
$(OBJS)\test_gui_keyboard.obj \
@@ -910,6 +911,9 @@ $(OBJS)\test_gui_webtest.obj: .\controls\webtest.cpp
$(OBJS)\test_gui_windowtest.obj: .\controls\windowtest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\windowtest.cpp
$(OBJS)\test_gui_dialogtest.obj: .\controls\dialogtest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\dialogtest.cpp
$(OBJS)\test_gui_clone.obj: .\events\clone.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\events\clone.cpp

View File

@@ -183,6 +183,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_virtlistctrltest.o \
$(OBJS)\test_gui_webtest.o \
$(OBJS)\test_gui_windowtest.o \
$(OBJS)\test_gui_dialogtest.o \
$(OBJS)\test_gui_clone.o \
$(OBJS)\test_gui_propagation.o \
$(OBJS)\test_gui_keyboard.o \
@@ -893,6 +894,9 @@ $(OBJS)\test_gui_webtest.o: ./controls/webtest.cpp
$(OBJS)\test_gui_windowtest.o: ./controls/windowtest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_dialogtest.o: ./controls/dialogtest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_clone.o: ./events/clone.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<

View File

@@ -187,6 +187,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_virtlistctrltest.obj \
$(OBJS)\test_gui_webtest.obj \
$(OBJS)\test_gui_windowtest.obj \
$(OBJS)\test_gui_dialogtest.obj \
$(OBJS)\test_gui_clone.obj \
$(OBJS)\test_gui_propagation.obj \
$(OBJS)\test_gui_keyboard.obj \
@@ -1050,6 +1051,9 @@ $(OBJS)\test_gui_webtest.obj: .\controls\webtest.cpp
$(OBJS)\test_gui_windowtest.obj: .\controls\windowtest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\windowtest.cpp
$(OBJS)\test_gui_dialogtest.obj: .\controls\dialogtest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\dialogtest.cpp
$(OBJS)\test_gui_clone.obj: .\events\clone.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\events\clone.cpp

View File

@@ -440,6 +440,7 @@ TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_virtlistctrltest.obj &
$(OBJS)\test_gui_webtest.obj &
$(OBJS)\test_gui_windowtest.obj &
$(OBJS)\test_gui_dialogtest.obj &
$(OBJS)\test_gui_clone.obj &
$(OBJS)\test_gui_propagation.obj &
$(OBJS)\test_gui_keyboard.obj &
@@ -954,6 +955,9 @@ $(OBJS)\test_gui_webtest.obj : .AUTODEPEND .\controls\webtest.cpp
$(OBJS)\test_gui_windowtest.obj : .AUTODEPEND .\controls\windowtest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_dialogtest.obj : .AUTODEPEND .\controls\dialogtest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_clone.obj : .AUTODEPEND .\events\clone.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<

View File

@@ -185,6 +185,7 @@
controls/virtlistctrltest.cpp
controls/webtest.cpp
controls/windowtest.cpp
controls/dialogtest.cpp
events/clone.cpp
events/propagation.cpp
events/keyboard.cpp

View File

@@ -315,6 +315,10 @@ SOURCE=.\controls\datepickerctrltest.cpp
# End Source File
# Begin Source File
SOURCE=.\controls\dialogtest.cpp
# End Source File
# Begin Source File
SOURCE=.\dummy.cpp
# ADD BASE CPP /Yc"testprec.h"
# ADD CPP /Yc"testprec.h"

View File

@@ -625,6 +625,9 @@
<File
RelativePath=".\controls\datepickerctrltest.cpp">
</File>
<File
RelativePath=".\controls\dialogtest.cpp">
</File>
<File
RelativePath=".\dummy.cpp">
<FileConfiguration

View File

@@ -907,6 +907,10 @@
RelativePath=".\controls\datepickerctrltest.cpp"
>
</File>
<File
RelativePath=".\controls\dialogtest.cpp"
>
</File>
<File
RelativePath=".\dummy.cpp"
>

View File

@@ -879,6 +879,10 @@
RelativePath=".\controls\datepickerctrltest.cpp"
>
</File>
<File
RelativePath=".\controls\dialogtest.cpp"
>
</File>
<File
RelativePath=".\dummy.cpp"
>