2009-10-30 01:04:47 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tests/toplevel/toplevel.cpp
|
|
|
|
// Purpose: Tests for wxTopLevelWindow
|
|
|
|
// Author: Kevin Ollivier
|
|
|
|
// Created: 2008-05-25
|
|
|
|
// Copyright: (c) 2009 Kevin Ollivier <kevino@theolliviers.com>
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "testprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
2011-05-01 10:58:58 -04:00
|
|
|
#include "wx/dialog.h"
|
|
|
|
#include "wx/frame.h"
|
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#include "wx/toplevel.h"
|
2009-10-30 01:04:47 -04:00
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
|
|
|
#include "wx/evtloop.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// test class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class TopLevelWindowTestCase : public CppUnit::TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TopLevelWindowTestCase() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
CPPUNIT_TEST_SUITE( TopLevelWindowTestCase );
|
|
|
|
CPPUNIT_TEST( DialogShowTest );
|
|
|
|
CPPUNIT_TEST( FrameShowTest );
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
void DialogShowTest();
|
|
|
|
void FrameShowTest();
|
|
|
|
void TopLevelWindowShowTest(wxTopLevelWindow* tlw);
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_NO_COPY_CLASS(TopLevelWindowTestCase);
|
2009-10-30 01:04:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// register in the unnamed registry so that these tests are run by default
|
2011-05-01 10:58:58 -04:00
|
|
|
//CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
|
2009-10-30 01:04:47 -04:00
|
|
|
|
2011-04-30 06:57:04 -04:00
|
|
|
// also include in its own registry so that these tests can be run alone
|
2011-05-01 10:58:58 -04:00
|
|
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase, "fixme" );
|
2009-10-30 01:04:47 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// tests themselves
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void TopLevelWindowTestCase::DialogShowTest()
|
|
|
|
{
|
|
|
|
wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
|
|
|
|
TopLevelWindowShowTest(dialog);
|
|
|
|
dialog->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TopLevelWindowTestCase::FrameShowTest()
|
|
|
|
{
|
|
|
|
wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
|
|
|
|
TopLevelWindowShowTest(frame);
|
|
|
|
frame->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow* tlw)
|
|
|
|
{
|
|
|
|
CPPUNIT_ASSERT(!tlw->IsShown());
|
2012-03-03 19:29:14 -05:00
|
|
|
|
2009-10-30 01:04:47 -04:00
|
|
|
wxTextCtrl* textCtrl = new wxTextCtrl(tlw, -1, "test");
|
|
|
|
textCtrl->SetFocus();
|
2012-03-03 19:29:14 -05:00
|
|
|
|
2009-10-30 01:04:47 -04:00
|
|
|
// only run this test on platforms where ShowWithoutActivating is implemented.
|
2011-05-01 10:58:58 -04:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
2009-10-30 01:04:47 -04:00
|
|
|
tlw->ShowWithoutActivating();
|
|
|
|
CPPUNIT_ASSERT(tlw->IsShown());
|
|
|
|
CPPUNIT_ASSERT(!tlw->IsActive());
|
2012-03-03 19:29:14 -05:00
|
|
|
|
2009-10-30 01:04:47 -04:00
|
|
|
tlw->Hide();
|
|
|
|
CPPUNIT_ASSERT(!tlw->IsShown());
|
|
|
|
CPPUNIT_ASSERT(!tlw->IsActive());
|
|
|
|
#endif
|
2012-03-03 19:29:14 -05:00
|
|
|
|
2009-10-30 01:04:47 -04:00
|
|
|
tlw->Show(true);
|
|
|
|
CPPUNIT_ASSERT(tlw->IsActive());
|
|
|
|
CPPUNIT_ASSERT(tlw->IsShown());
|
2012-03-03 19:29:14 -05:00
|
|
|
|
2009-10-30 01:04:47 -04:00
|
|
|
tlw->Hide();
|
|
|
|
CPPUNIT_ASSERT(!tlw->IsShown());
|
|
|
|
CPPUNIT_ASSERT(tlw->IsActive());
|
|
|
|
}
|