00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifdef __GNUG__
00014 #pragma implementation "TempInteractive.h"
00015 #endif
00016
00017 #include <wxGuiTest/TempInteractive.h>
00018
00019 #include <wx/dialog.h>
00020
00021 #include <wxGuiTest/WxGuiTestHelper.h>
00022 #include "TempInteractiveControl.h"
00023
00024 using namespace wxTst;
00025
00026 void TempInteractive::ShowCurrentGui (const wxString& file, int line)
00027 {
00028 if (WxGuiTestHelper::GetDisableTestInteractivity ()) {
00029
00030 return;
00031 }
00032
00033
00034 bool oldInteractive = WxGuiTestHelper::GetInteractive ();
00035 WxGuiTestHelper::SetInteractive (true);
00036
00037
00038 bool oldShowModalDialogsNonModal = WxGuiTestHelper::GetShowModalDialogsNonModalFlag ();
00039 WxGuiTestHelper::SetShowModalDialogsNonModalFlag (false);
00040 bool oldShowPopupMenus = WxGuiTestHelper::GetShowPopupMenusFlag ();
00041 WxGuiTestHelper::SetShowPopupMenusFlag (true);
00042
00043 wxDialog* dialog = CreateDialog (file, line);
00044 TempInteractiveControl* handler =
00045 new TempInteractiveControl(dialog);
00046 dialog->PushEventHandler (handler);
00047 dialog->Show ();
00048
00049
00050 wxTheApp->MainLoop ();
00051
00052
00053 WxGuiTestHelper::SetInteractive (oldInteractive);
00054
00055 WxGuiTestHelper::SetShowModalDialogsNonModalFlag (oldShowModalDialogsNonModal);
00056 WxGuiTestHelper::SetShowPopupMenusFlag (oldShowPopupMenus);
00057 dialog->PopEventHandler (true);
00058 dialog->Destroy ();
00059 }
00060
00061
00062
00063
00064 wxDialog*
00065 TempInteractive::CreateDialog (const wxString& file, int line)
00066 {
00067 wxDialog* dialog = new wxDialog (wxTheApp->GetTopWindow (), -1,
00068 _("wxGui CppUnit Testing Suspended"), wxDefaultPosition,
00069 wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
00070
00071 wxBoxSizer *sizer = new wxBoxSizer (wxVERTICAL);
00072
00073 wxStaticText *text = new wxStaticText (dialog, -1,
00074 _("Temporary interactive test. -- Continue unit testing?"),
00075 wxDefaultPosition, wxDefaultSize, 0);
00076 sizer->Add (text, 0, wxALIGN_CENTER | wxALL, 10);
00077
00078 if ((file != _T("")) && (line > -1)) {
00079
00080 wxStaticText *fileInfoText =
00081 new wxStaticText (dialog, -1,
00082 wxString::Format (_T("%s: %s\n%s: %d"), _("File"),
00083 file.c_str(), _("Line"), line),
00084 wxDefaultPosition, wxDefaultSize, 0);
00085 sizer->Add (fileInfoText, 0, wxALIGN_CENTER | wxALL, 10);
00086 }
00087
00088 wxButton *okBtn = new wxButton (dialog, -1, _("OK"), wxDefaultPosition,
00089 wxDefaultSize, 0);
00090 sizer->Add (okBtn, 0, wxALIGN_CENTER | wxALL, 10);
00091
00092 dialog->SetSizer (sizer);
00093 sizer->SetSizeHints (dialog);
00094 dialog->Layout ();
00095 return dialog;
00096 }
00097