2010-08-22 18:16:05 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tests/controls/windowtest.cpp
|
|
|
|
// Purpose: wxWindow unit test
|
|
|
|
// Author: Steven Lamerton
|
|
|
|
// Created: 2010-07-10
|
|
|
|
// Copyright: (c) 2010 Steven Lamerton
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "testprec.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/window.h"
|
|
|
|
#include "wx/button.h"
|
2018-04-29 17:58:39 -04:00
|
|
|
#include "wx/sizer.h"
|
2010-08-22 18:16:05 -04:00
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
|
|
|
#include "asserthelper.h"
|
|
|
|
#include "testableframe.h"
|
2019-07-17 09:09:34 -04:00
|
|
|
#include "testwindow.h"
|
|
|
|
|
2010-08-22 18:16:05 -04:00
|
|
|
#include "wx/uiaction.h"
|
|
|
|
#include "wx/caret.h"
|
|
|
|
#include "wx/cshelp.h"
|
2019-09-27 10:12:18 -04:00
|
|
|
#include "wx/scopedptr.h"
|
2020-05-06 21:45:17 -04:00
|
|
|
#include "wx/stopwatch.h"
|
2010-08-22 18:16:05 -04:00
|
|
|
#include "wx/tooltip.h"
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
class WindowTestCase
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
public:
|
2019-09-27 09:55:18 -04:00
|
|
|
WindowTestCase()
|
|
|
|
: m_window(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY))
|
|
|
|
{
|
2020-05-06 21:45:17 -04:00
|
|
|
#ifdef __WXGTK3__
|
|
|
|
// Without this, when running this test suite solo it succeeds,
|
|
|
|
// but not when running it together with the other tests !!
|
|
|
|
// Not needed when run under Xvfb display.
|
|
|
|
for ( wxStopWatch sw; sw.Time() < 50; )
|
|
|
|
wxYield();
|
|
|
|
#endif
|
2019-09-27 09:55:18 -04:00
|
|
|
}
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
~WindowTestCase()
|
|
|
|
{
|
|
|
|
wxTheApp->GetTopWindow()->DestroyChildren();
|
|
|
|
}
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
protected:
|
|
|
|
wxWindow* const m_window;
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
wxDECLARE_NO_COPY_CLASS(WindowTestCase);
|
|
|
|
};
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::ShowHideEvent", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2014-05-15 19:56:58 -04:00
|
|
|
#if defined(__WXMSW__)
|
2012-03-11 10:32:24 -04:00
|
|
|
EventCounter show(m_window, wxEVT_SHOW);
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Show(false);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Show();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( show.GetCount() == 2 );
|
2014-05-15 19:56:58 -04:00
|
|
|
#endif // __WXMSW__
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::KeyEvent", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
#if wxUSE_UIACTIONSIMULATOR
|
2019-09-27 09:55:18 -04:00
|
|
|
if ( !EnableUITests() )
|
|
|
|
return;
|
|
|
|
|
2012-03-11 10:32:24 -04:00
|
|
|
EventCounter keydown(m_window, wxEVT_KEY_DOWN);
|
|
|
|
EventCounter keyup(m_window, wxEVT_KEY_UP);
|
|
|
|
EventCounter keychar(m_window, wxEVT_CHAR);
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
wxUIActionSimulator sim;
|
|
|
|
|
|
|
|
m_window->SetFocus();
|
2014-09-23 13:42:51 -04:00
|
|
|
wxYield();
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
sim.Text("text");
|
|
|
|
sim.Char(WXK_SHIFT);
|
|
|
|
wxYield();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( keydown.GetCount() == 5 );
|
|
|
|
CHECK( keyup.GetCount() == 5 );
|
|
|
|
CHECK( keychar.GetCount() == 4 );
|
2010-08-22 18:16:05 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::FocusEvent", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
#ifndef __WXOSX__
|
2017-11-13 20:41:58 -05:00
|
|
|
if ( IsAutomaticTest() )
|
|
|
|
{
|
|
|
|
// Skip this test when running under buildbot, it fails there for
|
|
|
|
// unknown reason and this failure can't be reproduced locally.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-11 10:32:24 -04:00
|
|
|
EventCounter setfocus(m_window, wxEVT_SET_FOCUS);
|
|
|
|
EventCounter killfocus(m_window, wxEVT_KILL_FOCUS);
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->SetFocus();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(setfocus.WaitEvent(500));
|
2019-07-17 09:09:34 -04:00
|
|
|
CHECK_FOCUS_IS( m_window );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY);
|
|
|
|
|
2014-09-23 13:42:58 -04:00
|
|
|
wxYield();
|
2010-08-22 18:16:05 -04:00
|
|
|
button->SetFocus();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( killfocus.GetCount() == 1 );
|
|
|
|
CHECK(!m_window->HasFocus());
|
2010-08-22 18:16:05 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Mouse", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
wxCursor cursor(wxCURSOR_CHAR);
|
|
|
|
m_window->SetCursor(cursor);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->GetCursor().IsOk());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2020-05-08 02:01:56 -04:00
|
|
|
#if wxUSE_CARET
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->GetCaret());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2020-10-17 08:46:41 -04:00
|
|
|
wxCaret* caret = NULL;
|
2020-09-30 20:28:42 -04:00
|
|
|
|
|
|
|
// Try creating the caret in two different, but normally equivalent, ways.
|
|
|
|
SECTION("Caret 1-step")
|
|
|
|
{
|
|
|
|
caret = new wxCaret(m_window, 16, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Caret 2-step")
|
|
|
|
{
|
|
|
|
caret = new wxCaret();
|
|
|
|
caret->Create(m_window, 16, 16);
|
|
|
|
}
|
|
|
|
|
2010-08-22 18:16:05 -04:00
|
|
|
m_window->SetCaret(caret);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->GetCaret()->IsOk());
|
2020-05-08 02:01:56 -04:00
|
|
|
#endif
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->CaptureMouse();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->HasCapture());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->ReleaseMouse();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->HasCapture());
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Properties", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
m_window->SetLabel("label");
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetLabel() == "label" );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->SetName("name");
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetName() == "name" );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
//As we used wxID_ANY we should have a negative id
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->GetId() < 0);
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->SetId(wxID_HIGHEST + 10);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetId() == wxID_HIGHEST + 10 );
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2010-10-04 06:41:39 -04:00
|
|
|
#if wxUSE_TOOLTIPS
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::ToolTip", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->GetToolTip());
|
|
|
|
CHECK( m_window->GetToolTipText() == "" );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->SetToolTip("text tip");
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetToolTipText() == "text tip" );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->UnsetToolTip();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->GetToolTip());
|
|
|
|
CHECK( m_window->GetToolTipText() == "" );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
wxToolTip* tip = new wxToolTip("other tip");
|
|
|
|
|
|
|
|
m_window->SetToolTip(tip);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetToolTip() == tip );
|
|
|
|
CHECK( m_window->GetToolTipText() == "other tip" );
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
2010-10-04 06:41:39 -04:00
|
|
|
#endif // wxUSE_TOOLTIPS
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Help", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2020-05-08 02:01:56 -04:00
|
|
|
#if wxUSE_HELP
|
2010-08-22 18:16:05 -04:00
|
|
|
wxHelpProvider::Set(new wxSimpleHelpProvider());
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetHelpText() == "" );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->SetHelpText("helptext");
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetHelpText() == "helptext" );
|
2020-05-08 02:01:56 -04:00
|
|
|
#endif
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Parent", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetGrandParent() == static_cast<wxWindow*>(NULL) );
|
|
|
|
CHECK( m_window->GetParent() == wxTheApp->GetTopWindow() );
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Siblings", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetNextSibling() == static_cast<wxWindow*>(NULL) );
|
|
|
|
CHECK( m_window->GetPrevSibling() == static_cast<wxWindow*>(NULL) );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
wxWindow* newwin = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetNextSibling() == newwin );
|
|
|
|
CHECK( m_window->GetPrevSibling() == static_cast<wxWindow*>(NULL) );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( newwin->GetNextSibling() == static_cast<wxWindow*>(NULL) );
|
|
|
|
CHECK( newwin->GetPrevSibling() == m_window );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
wxDELETE(newwin);
|
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Children", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetChildren().GetCount() == 0 );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
wxWindow* child1 = new wxWindow(m_window, wxID_ANY);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetChildren().GetCount() == 1 );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->RemoveChild(child1);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetChildren().GetCount() == 0 );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
child1->SetId(wxID_HIGHEST + 1);
|
|
|
|
child1->SetName("child1");
|
|
|
|
|
|
|
|
m_window->AddChild(child1);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetChildren().GetCount() == 1 );
|
|
|
|
CHECK( m_window->FindWindow(wxID_HIGHEST + 1) == child1 );
|
|
|
|
CHECK( m_window->FindWindow("child1") == child1 );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->DestroyChildren();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetChildren().GetCount() == 0 );
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Focus", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
#ifndef __WXOSX__
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->HasFocus());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
if ( m_window->AcceptsFocus() )
|
|
|
|
{
|
|
|
|
m_window->SetFocus();
|
2019-07-17 09:09:34 -04:00
|
|
|
CHECK_FOCUS_IS(m_window);
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//Set the focus back to the main window
|
|
|
|
wxTheApp->GetTopWindow()->SetFocus();
|
|
|
|
|
|
|
|
if ( m_window->AcceptsFocusFromKeyboard() )
|
|
|
|
{
|
|
|
|
m_window->SetFocusFromKbd();
|
2019-07-17 09:09:34 -04:00
|
|
|
CHECK_FOCUS_IS(m_window);
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Positioning", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
//Some basic tests for consistency
|
|
|
|
int x, y;
|
|
|
|
m_window->GetPosition(&x, &y);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetPosition().x == x );
|
|
|
|
CHECK( m_window->GetPosition().y == y );
|
|
|
|
CHECK( m_window->GetRect().GetTopLeft() == m_window->GetPosition() );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->GetScreenPosition(&x, &y);
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( m_window->GetScreenPosition().x == x );
|
|
|
|
CHECK( m_window->GetScreenPosition().y == y );
|
|
|
|
CHECK( m_window->GetScreenRect().GetTopLeft() == m_window->GetScreenPosition() );
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::PositioningBeyondShortLimit", "[window]")
|
2018-04-29 17:58:39 -04:00
|
|
|
{
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
//Positioning under MSW is limited to short relative coordinates
|
|
|
|
|
|
|
|
//
|
|
|
|
//Test window creation beyond SHRT_MAX
|
|
|
|
int commonDim = 10;
|
|
|
|
wxWindow* w = new wxWindow(m_window, wxID_ANY,
|
|
|
|
wxPoint(0, SHRT_MAX + commonDim),
|
|
|
|
wxSize(commonDim, commonDim));
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( w->GetPosition().y == SHRT_MAX + commonDim );
|
2018-04-29 17:58:39 -04:00
|
|
|
|
|
|
|
w->Move(0, 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
//Test window moving beyond SHRT_MAX
|
|
|
|
w->Move(0, SHRT_MAX + commonDim);
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( w->GetPosition().y == SHRT_MAX + commonDim );
|
2018-04-29 17:58:39 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
//Test window moving below SHRT_MIN
|
|
|
|
w->Move(0, SHRT_MIN - commonDim);
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( w->GetPosition().y == SHRT_MIN - commonDim );
|
2018-04-29 17:58:39 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
//Test deferred move beyond SHRT_MAX
|
|
|
|
m_window->SetVirtualSize(-1, SHRT_MAX + 2 * commonDim);
|
|
|
|
wxWindow* bigWin = new wxWindow(m_window, wxID_ANY, wxDefaultPosition,
|
|
|
|
//size is also limited by SHRT_MAX
|
|
|
|
wxSize(commonDim, SHRT_MAX));
|
|
|
|
wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizer->Add(bigWin);
|
|
|
|
sizer->AddSpacer(commonDim); //add some space to go beyond SHRT_MAX
|
|
|
|
sizer->Add(w);
|
|
|
|
m_window->SetSizer(sizer);
|
|
|
|
m_window->Layout();
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( w->GetPosition().y == SHRT_MAX + commonDim );
|
2018-04-29 17:58:39 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Show", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Hide();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Show();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Show(false);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->ShowWithEffect(wxSHOW_EFFECT_BLEND);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->HideWithEffect(wxSHOW_EFFECT_BLEND);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->IsShown());
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::Enable", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsEnabled());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Disable();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->IsEnabled());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Enable();
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(m_window->IsEnabled());
|
2010-08-22 18:16:05 -04:00
|
|
|
|
|
|
|
m_window->Enable(false);
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK(!m_window->IsEnabled());
|
2019-10-26 19:31:21 -04:00
|
|
|
m_window->Enable();
|
|
|
|
|
|
|
|
|
|
|
|
wxWindow* const child = new wxWindow(m_window, wxID_ANY);
|
|
|
|
CHECK(child->IsEnabled());
|
|
|
|
CHECK(child->IsThisEnabled());
|
|
|
|
|
|
|
|
m_window->Disable();
|
|
|
|
CHECK(!child->IsEnabled());
|
|
|
|
CHECK(child->IsThisEnabled());
|
|
|
|
|
|
|
|
child->Disable();
|
|
|
|
CHECK(!child->IsEnabled());
|
|
|
|
CHECK(!child->IsThisEnabled());
|
|
|
|
|
|
|
|
m_window->Enable();
|
|
|
|
CHECK(!child->IsEnabled());
|
|
|
|
CHECK(!child->IsThisEnabled());
|
|
|
|
|
|
|
|
child->Enable();
|
|
|
|
CHECK(child->IsEnabled());
|
|
|
|
CHECK(child->IsThisEnabled());
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
|
|
|
|
2019-09-27 09:55:18 -04:00
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::FindWindowBy", "[window]")
|
2010-08-22 18:16:05 -04:00
|
|
|
{
|
|
|
|
m_window->SetId(wxID_HIGHEST + 1);
|
|
|
|
m_window->SetName("name");
|
|
|
|
m_window->SetLabel("label");
|
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( wxWindow::FindWindowById(wxID_HIGHEST + 1) == m_window );
|
|
|
|
CHECK( wxWindow::FindWindowByName("name") == m_window );
|
|
|
|
CHECK( wxWindow::FindWindowByLabel("label") == m_window );
|
2010-08-22 18:16:05 -04:00
|
|
|
|
2019-09-27 09:58:09 -04:00
|
|
|
CHECK( wxWindow::FindWindowById(wxID_HIGHEST + 3) == NULL );
|
|
|
|
CHECK( wxWindow::FindWindowByName("noname") == NULL );
|
|
|
|
CHECK( wxWindow::FindWindowByLabel("nolabel") == NULL );
|
2010-08-22 18:16:05 -04:00
|
|
|
}
|
2019-09-27 10:12:18 -04:00
|
|
|
|
|
|
|
TEST_CASE_METHOD(WindowTestCase, "Window::SizerErrors", "[window][sizer][error]")
|
|
|
|
{
|
|
|
|
wxWindow* const child = new wxWindow(m_window, wxID_ANY);
|
|
|
|
wxScopedPtr<wxSizer> const sizer1(new wxBoxSizer(wxHORIZONTAL));
|
|
|
|
wxScopedPtr<wxSizer> const sizer2(new wxBoxSizer(wxHORIZONTAL));
|
|
|
|
|
|
|
|
REQUIRE_NOTHROW( sizer1->Add(child) );
|
|
|
|
CHECK_THROWS_AS( sizer1->Add(child), TestAssertFailure );
|
|
|
|
CHECK_THROWS_AS( sizer2->Add(child), TestAssertFailure );
|
|
|
|
|
|
|
|
CHECK_NOTHROW( sizer1->Detach(child) );
|
|
|
|
CHECK_NOTHROW( sizer2->Add(child) );
|
|
|
|
|
|
|
|
REQUIRE_NOTHROW( delete child );
|
|
|
|
}
|