mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-25 17:15:45 +08:00
Replace raw pointers in tests fixtures with std::unique_ptr<>
Now that we have fixtures, with ctors and dtors, instead of setUp() and tearDown(), we can use std::unique_ptr<> instead of manual memory management. No real changes.
This commit is contained in:
+22
-25
@@ -41,13 +41,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~AuiNotebookTestCase()
|
||||
{
|
||||
delete nb;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxAuiNotebook* const nb;
|
||||
const std::unique_ptr<wxAuiNotebook> nb;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -56,7 +52,7 @@ protected:
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
{
|
||||
wxPanel *p = new wxPanel(nb);
|
||||
wxPanel *p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(100, 100));
|
||||
REQUIRE( nb->AddPage(p, "Center Pane") );
|
||||
|
||||
@@ -64,11 +60,11 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
|
||||
SECTION( "Single pane with multiple tabs" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(300, 100));
|
||||
nb->AddPage(p, "Center Tab 2");
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(100, 200));
|
||||
nb->AddPage(p, "Center Tab 3");
|
||||
|
||||
@@ -77,21 +73,21 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
|
||||
SECTION( "Horizontal split" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(25, 0));
|
||||
nb->AddPage(p, "Left Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxLEFT);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(125, 100 + tabHeight) );
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(50, 0));
|
||||
nb->AddPage(p, "Right Pane 1");
|
||||
nb->Split(nb->GetPageCount()-1, wxRIGHT);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(175, 100 + tabHeight) );
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(100, 0));
|
||||
nb->AddPage(p, "Right Pane 2");
|
||||
nb->Split(nb->GetPageCount()-1, wxRIGHT);
|
||||
@@ -101,19 +97,19 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
|
||||
SECTION( "Vertical split" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(0, 100));
|
||||
nb->AddPage(p, "Top Pane 1");
|
||||
nb->Split(nb->GetPageCount()-1, wxTOP);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(0, 50));
|
||||
nb->AddPage(p, "Top Pane 2");
|
||||
nb->Split(nb->GetPageCount()-1, wxTOP);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(100, 250 + 3*tabHeight) );
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(0, 25));
|
||||
nb->AddPage(p, "Bottom Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxBOTTOM);
|
||||
@@ -123,22 +119,22 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
|
||||
SECTION( "Surrounding panes" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(50, 25));
|
||||
nb->AddPage(p, "Bottom Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxBOTTOM);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(50, 120));
|
||||
nb->AddPage(p, "Right Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxRIGHT);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(225, 50));
|
||||
nb->AddPage(p, "Top Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxTOP);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p = new wxPanel(nb.get());
|
||||
p->SetMinSize(wxSize(25, 105));
|
||||
nb->AddPage(p, "Left Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxLEFT);
|
||||
@@ -149,17 +145,17 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::RTTI", "[aui][rtti]")
|
||||
{
|
||||
wxBookCtrlBase* const book = nb;
|
||||
CHECK( wxDynamicCast(book, wxAuiNotebook) == nb );
|
||||
wxBookCtrlBase* const book = nb.get();
|
||||
CHECK( wxDynamicCast(book, wxAuiNotebook) == nb.get() );
|
||||
|
||||
CHECK( wxDynamicCast(nb, wxBookCtrlBase) == book );
|
||||
CHECK( wxDynamicCast(nb.get(), wxBookCtrlBase) == book );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::FindPage", "[aui]")
|
||||
{
|
||||
wxPanel *p1 = new wxPanel(nb);
|
||||
wxPanel *p2 = new wxPanel(nb);
|
||||
wxPanel *p3 = new wxPanel(nb);
|
||||
wxPanel *p1 = new wxPanel(nb.get());
|
||||
wxPanel *p2 = new wxPanel(nb.get());
|
||||
wxPanel *p3 = new wxPanel(nb.get());
|
||||
REQUIRE( nb->AddPage(p1, "Page 1") );
|
||||
REQUIRE( nb->AddPage(p2, "Page 2") );
|
||||
|
||||
@@ -173,7 +169,8 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::Layout", "[aui]")
|
||||
{
|
||||
const auto addPage = [this](int n)
|
||||
{
|
||||
return nb->AddPage(new wxPanel(nb), wxString::Format("Page %d", n + 1));
|
||||
return nb->AddPage(new wxPanel(nb.get()),
|
||||
wxString::Format("Page %d", n + 1));
|
||||
};
|
||||
|
||||
for ( int n = 0; n < 5; n++ )
|
||||
|
||||
@@ -21,19 +21,23 @@
|
||||
#include "itemcontainertest.h"
|
||||
#include "asserthelper.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class BitmapComboBoxTestCase : public TextEntryTestCase,
|
||||
public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
BitmapComboBoxTestCase();
|
||||
~BitmapComboBoxTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo; }
|
||||
virtual wxTextEntry *GetTestEntry() const override
|
||||
{ return m_combo.get(); }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo.get(); }
|
||||
|
||||
virtual wxItemContainer *GetContainer() const override { return m_combo; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_combo; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_combo.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_combo.get(); }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel)) override
|
||||
{
|
||||
@@ -42,7 +46,7 @@ protected:
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
wxBitmapComboBox *m_combo;
|
||||
std::unique_ptr<wxBitmapComboBox> m_combo;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(BitmapComboBoxTestCase);
|
||||
};
|
||||
@@ -55,13 +59,10 @@ wxITEM_CONTAINER_TESTS(BitmapComboBoxTestCase, "BitmapComboBox",
|
||||
|
||||
BitmapComboBoxTestCase::BitmapComboBoxTestCase()
|
||||
{
|
||||
m_combo = new wxBitmapComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_combo = make_unique<wxBitmapComboBox>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY);
|
||||
}
|
||||
|
||||
BitmapComboBoxTestCase::~BitmapComboBoxTestCase()
|
||||
{
|
||||
wxDELETE(m_combo);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BitmapComboBoxTestCase, "BitmapComboBox::Bitmap",
|
||||
"[bitmapcombobox]")
|
||||
|
||||
@@ -23,32 +23,29 @@
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/artprov.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class BitmapToggleButtonTestCase
|
||||
{
|
||||
public:
|
||||
BitmapToggleButtonTestCase();
|
||||
~BitmapToggleButtonTestCase();
|
||||
|
||||
protected:
|
||||
wxBitmapToggleButton* m_button;
|
||||
std::unique_ptr<wxBitmapToggleButton> m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(BitmapToggleButtonTestCase);
|
||||
};
|
||||
|
||||
BitmapToggleButtonTestCase::BitmapToggleButtonTestCase()
|
||||
{
|
||||
m_button = new wxBitmapToggleButton(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxArtProvider::GetIcon(wxART_INFORMATION,
|
||||
wxART_OTHER,
|
||||
wxSize(32, 32)));
|
||||
m_button = make_unique<wxBitmapToggleButton>(
|
||||
wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER,
|
||||
wxSize(32, 32)));
|
||||
m_button->Update();
|
||||
m_button->Refresh();
|
||||
}
|
||||
|
||||
BitmapToggleButtonTestCase::~BitmapToggleButtonTestCase()
|
||||
{
|
||||
wxDELETE(m_button);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BitmapToggleButtonTestCase, "BitmapToggleButton::Click", "[bitmaptogglebutton]")
|
||||
{
|
||||
@@ -56,7 +53,7 @@ TEST_CASE_METHOD(BitmapToggleButtonTestCase, "BitmapToggleButton::Click", "[bitm
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter clicked(m_button, wxEVT_TOGGLEBUTTON);
|
||||
EventCounter clicked(m_button.get(), wxEVT_TOGGLEBUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -89,7 +86,7 @@ TEST_CASE_METHOD(BitmapToggleButtonTestCase, "BitmapToggleButton::Click", "[bitm
|
||||
|
||||
TEST_CASE_METHOD(BitmapToggleButtonTestCase, "BitmapToggleButton::Value", "[bitmaptogglebutton]")
|
||||
{
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
EventCounter clicked(m_button.get(), wxEVT_BUTTON);
|
||||
|
||||
m_button->SetValue(true);
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_BUTTON
|
||||
|
||||
|
||||
@@ -29,10 +31,9 @@ class ButtonTestCase
|
||||
{
|
||||
public:
|
||||
ButtonTestCase();
|
||||
~ButtonTestCase();
|
||||
|
||||
protected:
|
||||
wxButton* m_button;
|
||||
std::unique_ptr<wxButton> m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ButtonTestCase);
|
||||
};
|
||||
@@ -41,13 +42,10 @@ ButtonTestCase::ButtonTestCase()
|
||||
{
|
||||
//We use wxTheApp->GetTopWindow() as there is only a single testable frame
|
||||
//so it will always be returned
|
||||
m_button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY, "wxButton");
|
||||
m_button = make_unique<wxButton>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxButton");
|
||||
}
|
||||
|
||||
ButtonTestCase::~ButtonTestCase()
|
||||
{
|
||||
delete m_button;
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
@@ -55,7 +53,7 @@ TEST_CASE_METHOD(ButtonTestCase, "Button::Click", "[button]")
|
||||
{
|
||||
//We use the internal class EventCounter which handles connecting and
|
||||
//disconnecting the control to the wxTestableFrame
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
EventCounter clicked(m_button.get(), wxEVT_BUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -87,13 +85,12 @@ TEST_CASE_METHOD(ButtonTestCase, "Button::Disabled", "[button]")
|
||||
|
||||
SECTION("Create disabled")
|
||||
{
|
||||
delete m_button;
|
||||
m_button = new wxButton();
|
||||
m_button = make_unique<wxButton>();
|
||||
m_button->Disable();
|
||||
m_button->Create(wxTheApp->GetTopWindow(), wxID_ANY, "wxButton");
|
||||
}
|
||||
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
EventCounter clicked(m_button.get(), wxEVT_BUTTON);
|
||||
|
||||
sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10));
|
||||
wxYield();
|
||||
|
||||
@@ -18,45 +18,44 @@
|
||||
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class CheckBoxTestCase
|
||||
{
|
||||
public:
|
||||
CheckBoxTestCase();
|
||||
~CheckBoxTestCase();
|
||||
|
||||
protected:
|
||||
// Initialize m_check with a new checkbox with the specified style
|
||||
// Initialize m_check.get() with a new checkbox with the specified style
|
||||
//
|
||||
// This function always returns false just to make it more convenient to
|
||||
// use inside WX_ASSERT_FAILS_WITH_ASSERT(), its return value doesn't have
|
||||
// any meaning otherwise.
|
||||
bool CreateCheckBox(long style)
|
||||
{
|
||||
wxDELETE( m_check );
|
||||
m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box",
|
||||
wxDefaultPosition, wxDefaultSize, style);
|
||||
m_check = make_unique<wxCheckBox>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"Check box",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
wxCheckBox* m_check;
|
||||
std::unique_ptr<wxCheckBox> m_check;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(CheckBoxTestCase);
|
||||
};
|
||||
|
||||
CheckBoxTestCase::CheckBoxTestCase()
|
||||
{
|
||||
m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box");
|
||||
m_check = make_unique<wxCheckBox>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"Check box");
|
||||
}
|
||||
|
||||
CheckBoxTestCase::~CheckBoxTestCase()
|
||||
{
|
||||
delete m_check;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(CheckBoxTestCase, "CheckBox::Check", "[checkbox]")
|
||||
{
|
||||
EventCounter clicked(m_check, wxEVT_CHECKBOX);
|
||||
EventCounter clicked(m_check.get(), wxEVT_CHECKBOX);
|
||||
|
||||
//We should be unchecked by default
|
||||
CHECK(!m_check->IsChecked());
|
||||
|
||||
@@ -19,17 +19,20 @@
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class CheckListBoxTestCase : public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
CheckListBoxTestCase();
|
||||
~CheckListBoxTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_check; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_check; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_check.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_check.get(); }
|
||||
|
||||
wxCheckListBox* m_check;
|
||||
std::unique_ptr<wxCheckListBox> m_check;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(CheckListBoxTestCase);
|
||||
};
|
||||
@@ -39,17 +42,13 @@ wxITEM_CONTAINER_TESTS(CheckListBoxTestCase, "CheckListBox",
|
||||
|
||||
CheckListBoxTestCase::CheckListBoxTestCase()
|
||||
{
|
||||
m_check = new wxCheckListBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_check = make_unique<wxCheckListBox>(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
CheckListBoxTestCase::~CheckListBoxTestCase()
|
||||
{
|
||||
wxDELETE(m_check);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(CheckListBoxTestCase, "CheckListBox::Check", "[checklistbox]")
|
||||
{
|
||||
EventCounter toggled(m_check, wxEVT_CHECKLISTBOX);
|
||||
EventCounter toggled(m_check.get(), wxEVT_CHECKLISTBOX);
|
||||
|
||||
wxArrayInt checkedItems;
|
||||
wxArrayString testitems;
|
||||
|
||||
@@ -19,14 +19,16 @@
|
||||
#include "wx/choicebk.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ChoicebookTestCase : public BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
ChoicebookTestCase();
|
||||
~ChoicebookTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_choicebook; }
|
||||
virtual wxBookCtrlBase *GetBase() const override
|
||||
{ return m_choicebook.get(); }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_CHOICEBOOK_PAGE_CHANGED; }
|
||||
@@ -36,7 +38,7 @@ protected:
|
||||
|
||||
virtual bool HasBrokenMnemonics() const override { return true; }
|
||||
|
||||
wxChoicebook *m_choicebook;
|
||||
std::unique_ptr<wxChoicebook> m_choicebook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ChoicebookTestCase);
|
||||
};
|
||||
@@ -46,14 +48,11 @@ wxBOOK_CTRL_BASE_TESTS(ChoicebookTestCase, "Choicebook",
|
||||
|
||||
ChoicebookTestCase::ChoicebookTestCase()
|
||||
{
|
||||
m_choicebook = new wxChoicebook(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_choicebook = make_unique<wxChoicebook>(
|
||||
wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
ChoicebookTestCase::~ChoicebookTestCase()
|
||||
{
|
||||
wxDELETE(m_choicebook);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ChoicebookTestCase, "Choicebook::Choice", "[choicebook]")
|
||||
{
|
||||
|
||||
@@ -18,17 +18,20 @@
|
||||
|
||||
#include "itemcontainertest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ChoiceTestCase : public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
ChoiceTestCase();
|
||||
~ChoiceTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_choice; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_choice; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_choice.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_choice.get(); }
|
||||
|
||||
wxChoice* m_choice;
|
||||
std::unique_ptr<wxChoice> m_choice;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ChoiceTestCase);
|
||||
};
|
||||
@@ -38,21 +41,16 @@ wxITEM_CONTAINER_TESTS(ChoiceTestCase, "Choice",
|
||||
|
||||
ChoiceTestCase::ChoiceTestCase()
|
||||
{
|
||||
m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_choice = make_unique<wxChoice>(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
ChoiceTestCase::~ChoiceTestCase()
|
||||
{
|
||||
wxDELETE(m_choice);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ChoiceTestCase, "Choice::Sort", "[choice]")
|
||||
{
|
||||
#if !defined(__WXOSX__)
|
||||
wxDELETE(m_choice);
|
||||
m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxCB_SORT);
|
||||
m_choice = make_unique<wxChoice>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
nullptr, wxCB_SORT);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("aaa");
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -32,14 +34,16 @@ class ComboBoxTestCase : public TextEntryTestCase, public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
ComboBoxTestCase();
|
||||
~ComboBoxTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo; }
|
||||
virtual wxTextEntry *GetTestEntry() const override
|
||||
{ return m_combo.get(); }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo.get(); }
|
||||
|
||||
virtual wxItemContainer *GetContainer() const override { return m_combo; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_combo; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_combo.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_combo.get(); }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel)) override
|
||||
{
|
||||
@@ -48,7 +52,7 @@ protected:
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
wxComboBox *m_combo;
|
||||
std::unique_ptr<wxComboBox> m_combo;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ComboBoxTestCase);
|
||||
};
|
||||
@@ -88,14 +92,9 @@ wxTEXT_ENTRY_TESTS(ComboBoxTestCase, "ComboBox",
|
||||
|
||||
ComboBoxTestCase::ComboBoxTestCase()
|
||||
{
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_combo = make_unique<wxComboBox>(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
ComboBoxTestCase::~ComboBoxTestCase()
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
@@ -129,8 +128,8 @@ TEST_CASE_METHOD(ComboBoxTestCase, "ComboBox::Size", "[combobox]")
|
||||
TEST_CASE_METHOD(ComboBoxTestCase, "ComboBox::PopDismiss", "[combobox]")
|
||||
{
|
||||
#if defined(__WXMSW__) || defined(__WXGTK210__) || defined(__WXQT__)
|
||||
EventCounter drop(m_combo, wxEVT_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
|
||||
EventCounter drop(m_combo.get(), wxEVT_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo.get(), wxEVT_COMBOBOX_CLOSEUP);
|
||||
|
||||
m_combo->Popup();
|
||||
CHECK(drop.GetCount() == 1);
|
||||
@@ -150,10 +149,9 @@ TEST_CASE_METHOD(ComboBoxTestCase, "ComboBox::PopDismiss", "[combobox]")
|
||||
TEST_CASE_METHOD(ComboBoxTestCase, "ComboBox::Sort", "[combobox]")
|
||||
{
|
||||
#if !defined(__WXOSX__)
|
||||
delete m_combo;
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxCB_SORT);
|
||||
m_combo = make_unique<wxComboBox>(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
nullptr, wxCB_SORT);
|
||||
|
||||
m_combo->Append("aaa");
|
||||
m_combo->Append("Aaa");
|
||||
@@ -181,10 +179,9 @@ TEST_CASE_METHOD(ComboBoxTestCase, "ComboBox::ReadOnly", "[combobox]")
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
delete m_combo;
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, testitems,
|
||||
wxCB_READONLY);
|
||||
m_combo = make_unique<wxComboBox>(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
testitems, wxCB_READONLY);
|
||||
|
||||
m_combo->SetValue("item 1");
|
||||
|
||||
@@ -230,7 +227,7 @@ TEST_CASE_METHOD(ComboBoxTestCase, "ComboBox::SetStringSelection",
|
||||
m_combo->Append("bar");
|
||||
m_combo->Append("baz");
|
||||
|
||||
EventCounter events(m_combo, wxEVT_COMBOBOX);
|
||||
EventCounter events(m_combo.get(), wxEVT_COMBOBOX);
|
||||
m_combo->SetStringSelection("bar");
|
||||
CHECK( events.GetCount() == 0 );
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_DATAVIEWCTRL
|
||||
|
||||
|
||||
@@ -34,13 +36,12 @@ class DataViewCtrlTestCase
|
||||
{
|
||||
public:
|
||||
explicit DataViewCtrlTestCase(long style);
|
||||
~DataViewCtrlTestCase();
|
||||
|
||||
protected:
|
||||
void TestSelectionFor0and1();
|
||||
|
||||
// the dataview control itself
|
||||
wxDataViewTreeCtrl *m_dvc;
|
||||
std::unique_ptr<wxDataViewTreeCtrl> m_dvc;
|
||||
|
||||
// and some of its items
|
||||
wxDataViewItem m_root,
|
||||
@@ -73,11 +74,10 @@ class MultiColumnsDataViewCtrlTestCase
|
||||
{
|
||||
public:
|
||||
MultiColumnsDataViewCtrlTestCase();
|
||||
~MultiColumnsDataViewCtrlTestCase();
|
||||
|
||||
protected:
|
||||
// the dataview control itself
|
||||
wxDataViewListCtrl *m_dvc;
|
||||
std::unique_ptr<wxDataViewListCtrl> m_dvc;
|
||||
|
||||
// constants
|
||||
const wxSize m_size;
|
||||
@@ -349,7 +349,6 @@ class DataViewCtrlWithCustomModelTestCase
|
||||
{
|
||||
public:
|
||||
DataViewCtrlWithCustomModelTestCase();
|
||||
~DataViewCtrlWithCustomModelTestCase();
|
||||
|
||||
protected:
|
||||
enum wxItemExistence
|
||||
@@ -390,7 +389,7 @@ protected:
|
||||
}
|
||||
|
||||
// The dataview control.
|
||||
wxDataViewCtrl *m_dvc;
|
||||
std::unique_ptr<wxDataViewCtrl> m_dvc;
|
||||
|
||||
// The dataview model.
|
||||
DataViewCtrlTestModel *m_model;
|
||||
@@ -412,11 +411,11 @@ protected:
|
||||
|
||||
DataViewCtrlTestCase::DataViewCtrlTestCase(long style)
|
||||
{
|
||||
m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
style);
|
||||
m_dvc = make_unique<wxDataViewTreeCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
style);
|
||||
|
||||
m_root = m_dvc->AppendContainer(wxDataViewItem(), "The root");
|
||||
m_child1 = m_dvc->AppendContainer(m_root, "child1");
|
||||
@@ -429,16 +428,13 @@ DataViewCtrlTestCase::DataViewCtrlTestCase(long style)
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
DataViewCtrlTestCase::~DataViewCtrlTestCase()
|
||||
{
|
||||
delete m_dvc;
|
||||
}
|
||||
|
||||
MultiColumnsDataViewCtrlTestCase::MultiColumnsDataViewCtrlTestCase()
|
||||
: m_size(200, 100),
|
||||
m_firstColumnWidth(50)
|
||||
{
|
||||
m_dvc = new wxDataViewListCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_dvc = make_unique<wxDataViewListCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY);
|
||||
|
||||
m_firstColumn =
|
||||
m_dvc->AppendTextColumn(wxString(), wxDATAVIEW_CELL_INERT, m_firstColumnWidth);
|
||||
@@ -452,18 +448,14 @@ MultiColumnsDataViewCtrlTestCase::MultiColumnsDataViewCtrlTestCase()
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
MultiColumnsDataViewCtrlTestCase::~MultiColumnsDataViewCtrlTestCase()
|
||||
{
|
||||
delete m_dvc;
|
||||
}
|
||||
|
||||
DataViewCtrlWithCustomModelTestCase::DataViewCtrlWithCustomModelTestCase()
|
||||
{
|
||||
m_dvc = new wxDataViewCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
wxDV_SINGLE);
|
||||
m_dvc = make_unique<wxDataViewCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
wxDV_SINGLE);
|
||||
|
||||
m_model = new DataViewCtrlTestModel();
|
||||
m_dvc->AssociateModel(m_model);
|
||||
@@ -495,10 +487,6 @@ DataViewCtrlWithCustomModelTestCase::DataViewCtrlWithCustomModelTestCase()
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
DataViewCtrlWithCustomModelTestCase::~DataViewCtrlWithCustomModelTestCase()
|
||||
{
|
||||
delete m_dvc;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
@@ -870,7 +858,7 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter keyEvents(m_dvc, wxEVT_KEY_DOWN);
|
||||
EventCounter keyEvents(m_dvc.get(), wxEVT_KEY_DOWN);
|
||||
|
||||
m_dvc->SetFocus();
|
||||
wxYield();
|
||||
|
||||
@@ -21,29 +21,24 @@
|
||||
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class DatePickerCtrlTestCase
|
||||
{
|
||||
public:
|
||||
DatePickerCtrlTestCase();
|
||||
~DatePickerCtrlTestCase();
|
||||
|
||||
protected:
|
||||
wxDatePickerCtrl* m_datepicker;
|
||||
wxButton* m_button;
|
||||
std::unique_ptr<wxDatePickerCtrl> m_datepicker;
|
||||
std::unique_ptr<wxButton> m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(DatePickerCtrlTestCase);
|
||||
};
|
||||
|
||||
DatePickerCtrlTestCase::DatePickerCtrlTestCase()
|
||||
{
|
||||
m_datepicker = new wxDatePickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_button = nullptr;
|
||||
}
|
||||
|
||||
DatePickerCtrlTestCase::~DatePickerCtrlTestCase()
|
||||
{
|
||||
delete m_button;
|
||||
delete m_datepicker;
|
||||
m_datepicker = make_unique<wxDatePickerCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(DatePickerCtrlTestCase, "DatePickerCtrl::Value", "[datepicker]")
|
||||
@@ -118,15 +113,15 @@ TEST_CASE_METHOD(DatePickerCtrlTestCase, "DatePickerCtrl::Focus", "[datepicker]"
|
||||
return;
|
||||
|
||||
// Create another control just to give focus to it initially.
|
||||
m_button = new wxButton(wxTheApp->GetTopWindow(), wxID_OK);
|
||||
m_button = make_unique<wxButton>(wxTheApp->GetTopWindow(), wxID_OK);
|
||||
m_button->Move(0, m_datepicker->GetSize().y * 3);
|
||||
m_button->SetFocus();
|
||||
wxYield();
|
||||
|
||||
CHECK( !m_datepicker->HasFocus() );
|
||||
|
||||
EventCounter setFocus(m_datepicker, wxEVT_SET_FOCUS);
|
||||
EventCounter killFocus(m_datepicker, wxEVT_KILL_FOCUS);
|
||||
EventCounter setFocus(m_datepicker.get(), wxEVT_SET_FOCUS);
|
||||
EventCounter killFocus(m_datepicker.get(), wxEVT_KILL_FOCUS);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
|
||||
@@ -16,26 +16,22 @@
|
||||
#include "wx/gauge.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include <memory>
|
||||
|
||||
class GaugeTestCase
|
||||
{
|
||||
public:
|
||||
GaugeTestCase();
|
||||
~GaugeTestCase();
|
||||
|
||||
protected:
|
||||
wxGauge* m_gauge;
|
||||
std::unique_ptr<wxGauge> m_gauge;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(GaugeTestCase);
|
||||
};
|
||||
|
||||
GaugeTestCase::GaugeTestCase()
|
||||
{
|
||||
m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100);
|
||||
}
|
||||
|
||||
GaugeTestCase::~GaugeTestCase()
|
||||
{
|
||||
wxTheApp->GetTopWindow()->DestroyChildren();
|
||||
m_gauge = make_unique<wxGauge>(wxTheApp->GetTopWindow(), wxID_ANY, 100);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(GaugeTestCase, "Gauge::Direction", "[gauge]")
|
||||
@@ -43,15 +39,15 @@ TEST_CASE_METHOD(GaugeTestCase, "Gauge::Direction", "[gauge]")
|
||||
//We should default to a horizontal gauge
|
||||
CHECK(!m_gauge->IsVertical());
|
||||
|
||||
wxDELETE(m_gauge);
|
||||
m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100,
|
||||
wxDefaultPosition, wxDefaultSize, wxGA_VERTICAL);
|
||||
m_gauge = make_unique<wxGauge>(wxTheApp->GetTopWindow(), wxID_ANY, 100,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxGA_VERTICAL);
|
||||
|
||||
CHECK(m_gauge->IsVertical());
|
||||
|
||||
wxDELETE(m_gauge);
|
||||
m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100,
|
||||
wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
|
||||
m_gauge = make_unique<wxGauge>(wxTheApp->GetTopWindow(), wxID_ANY, 100,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxGA_HORIZONTAL);
|
||||
|
||||
CHECK(!m_gauge->IsVertical());
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "wx/headerctrl.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -27,10 +29,9 @@ class HeaderCtrlTestCase
|
||||
{
|
||||
public:
|
||||
HeaderCtrlTestCase();
|
||||
~HeaderCtrlTestCase();
|
||||
|
||||
protected:
|
||||
wxHeaderCtrlSimple *m_header;
|
||||
std::unique_ptr<wxHeaderCtrlSimple> m_header;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(HeaderCtrlTestCase);
|
||||
};
|
||||
@@ -41,14 +42,9 @@ protected:
|
||||
|
||||
HeaderCtrlTestCase::HeaderCtrlTestCase()
|
||||
{
|
||||
m_header = new wxHeaderCtrlSimple(wxTheApp->GetTopWindow());
|
||||
m_header = make_unique<wxHeaderCtrlSimple>(wxTheApp->GetTopWindow());
|
||||
}
|
||||
|
||||
HeaderCtrlTestCase::~HeaderCtrlTestCase()
|
||||
{
|
||||
delete m_header;
|
||||
m_header = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
|
||||
@@ -18,17 +18,20 @@
|
||||
#include "wx/htmllbox.h"
|
||||
#include "itemcontainertest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class HtmlListBoxTestCase : public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
HtmlListBoxTestCase();
|
||||
~HtmlListBoxTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_htmllbox; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_htmllbox; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_htmllbox.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_htmllbox.get(); }
|
||||
|
||||
wxSimpleHtmlListBox* m_htmllbox;
|
||||
std::unique_ptr<wxSimpleHtmlListBox> m_htmllbox;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(HtmlListBoxTestCase);
|
||||
};
|
||||
@@ -38,12 +41,9 @@ wxITEM_CONTAINER_TESTS(HtmlListBoxTestCase, "HtmlListBox",
|
||||
|
||||
HtmlListBoxTestCase::HtmlListBoxTestCase()
|
||||
{
|
||||
m_htmllbox = new wxSimpleHtmlListBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_htmllbox = make_unique<wxSimpleHtmlListBox>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY);
|
||||
}
|
||||
|
||||
HtmlListBoxTestCase::~HtmlListBoxTestCase()
|
||||
{
|
||||
wxDELETE(m_htmllbox);
|
||||
}
|
||||
|
||||
#endif //wxUSE_HTML
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_HYPERLINKCTRL
|
||||
|
||||
|
||||
@@ -25,17 +27,14 @@ class HyperlinkCtrlTestCase
|
||||
public:
|
||||
HyperlinkCtrlTestCase()
|
||||
{
|
||||
m_hyperlink = new wxHyperlinkCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxWidgets", "http://wxwidgets.org");
|
||||
m_hyperlink = make_unique<wxHyperlinkCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxWidgets",
|
||||
"http://wxwidgets.org");
|
||||
}
|
||||
|
||||
~HyperlinkCtrlTestCase()
|
||||
{
|
||||
delete m_hyperlink;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxHyperlinkCtrl* m_hyperlink;
|
||||
std::unique_ptr<wxHyperlinkCtrl> m_hyperlink;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(HyperlinkCtrlTestCase);
|
||||
};
|
||||
@@ -86,7 +85,7 @@ TEST_CASE_METHOD(HyperlinkCtrlTestCase, "wxHyperlinkCtrl::Click",
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter hyperlink(m_hyperlink, wxEVT_HYPERLINK);
|
||||
EventCounter hyperlink(m_hyperlink.get(), wxEVT_HYPERLINK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@
|
||||
#include "wx/listctrl.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ListbookTestCase : public BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
ListbookTestCase();
|
||||
~ListbookTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_listbook; }
|
||||
virtual wxBookCtrlBase *GetBase() const override
|
||||
{ return m_listbook.get(); }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_LISTBOOK_PAGE_CHANGED; }
|
||||
@@ -37,7 +39,7 @@ protected:
|
||||
|
||||
virtual bool HasBrokenMnemonics() const override { return true; }
|
||||
|
||||
wxListbook *m_listbook;
|
||||
std::unique_ptr<wxListbook> m_listbook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListbookTestCase);
|
||||
};
|
||||
@@ -47,15 +49,11 @@ wxBOOK_CTRL_BASE_TESTS(ListbookTestCase, "Listbook",
|
||||
|
||||
ListbookTestCase::ListbookTestCase()
|
||||
{
|
||||
m_listbook = new wxListbook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 300));
|
||||
m_listbook = make_unique<wxListbook>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 300));
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
ListbookTestCase::~ListbookTestCase()
|
||||
{
|
||||
wxDELETE(m_listbook);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListbookTestCase, "Listbook::ListView", "[listbook]")
|
||||
{
|
||||
|
||||
@@ -20,27 +20,28 @@
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ListBoxTestCase : public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
ListBoxTestCase();
|
||||
~ListBoxTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_list; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_list; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_list.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_list.get(); }
|
||||
|
||||
// Recreate the list box as an owner-drawn one, only used under MSW.
|
||||
void MakeOwnerDrawn()
|
||||
{
|
||||
wxDELETE(m_list);
|
||||
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(300, 200), 0, nullptr,
|
||||
wxLB_OWNERDRAW);
|
||||
m_list = make_unique<wxListBox>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(300, 200),
|
||||
0, nullptr, wxLB_OWNERDRAW);
|
||||
}
|
||||
|
||||
wxListBox* m_list;
|
||||
std::unique_ptr<wxListBox> m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListBoxTestCase);
|
||||
};
|
||||
@@ -63,24 +64,19 @@ wxITEM_CONTAINER_TESTS(ListBoxTestCase, "ListBox",
|
||||
|
||||
ListBoxTestCase::ListBoxTestCase()
|
||||
{
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(300, 200));
|
||||
m_list = make_unique<wxListBox>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(300, 200));
|
||||
}
|
||||
|
||||
ListBoxTestCase::~ListBoxTestCase()
|
||||
{
|
||||
wxDELETE(m_list);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListBoxTestCase, "ListBox::Sort", "[listbox]")
|
||||
{
|
||||
wxLISTBOX_TEST_OWNERDRAWN();
|
||||
|
||||
#ifndef __WXOSX__
|
||||
wxDELETE(m_list);
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxLB_SORT);
|
||||
m_list = make_unique<wxListBox>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
nullptr, wxLB_SORT);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("aaa");
|
||||
@@ -119,10 +115,9 @@ TEST_CASE_METHOD(ListBoxTestCase, "ListBox::MultipleSelect", "[listbox]")
|
||||
{
|
||||
wxLISTBOX_TEST_OWNERDRAWN();
|
||||
|
||||
wxDELETE(m_list);
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxLB_MULTIPLE);
|
||||
m_list = make_unique<wxListBox>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
nullptr, wxLB_MULTIPLE);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
|
||||
@@ -28,12 +28,12 @@ class NotebookTestCase : public BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
NotebookTestCase();
|
||||
~NotebookTestCase();
|
||||
|
||||
void OnPageChanged(wxNotebookEvent&) { m_numPageChanges++; }
|
||||
|
||||
protected:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_notebook; }
|
||||
virtual wxBookCtrlBase *GetBase() const override
|
||||
{ return m_notebook.get(); }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_NOTEBOOK_PAGE_CHANGED; }
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_NOTEBOOK_PAGE_CHANGING; }
|
||||
|
||||
wxNotebook *m_notebook = nullptr;
|
||||
std::unique_ptr<wxNotebook> m_notebook;
|
||||
|
||||
int m_numPageChanges = 0;
|
||||
|
||||
@@ -57,29 +57,24 @@ wxBOOK_CTRL_BASE_TEST_CASE(NotebookTestCase, "Notebook", Image,
|
||||
|
||||
NotebookTestCase::NotebookTestCase()
|
||||
{
|
||||
m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
m_notebook = make_unique<wxNotebook>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
NotebookTestCase::~NotebookTestCase()
|
||||
{
|
||||
wxDELETE(m_notebook);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(NotebookTestCase, "Notebook::RowCount", "[notebook]")
|
||||
{
|
||||
CHECK(m_notebook->GetRowCount() == 1);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxDELETE(m_notebook);
|
||||
m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200),
|
||||
wxNB_MULTILINE);
|
||||
m_notebook = make_unique<wxNotebook>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200),
|
||||
wxNB_MULTILINE);
|
||||
|
||||
for( unsigned int i = 0; i < 10; i++ )
|
||||
{
|
||||
m_notebook->AddPage(new wxPanel(m_notebook), "Panel", false, 0);
|
||||
m_notebook->AddPage(new wxPanel(m_notebook.get()), "Panel", false, 0);
|
||||
}
|
||||
|
||||
CHECK( m_notebook->GetRowCount() != 1 );
|
||||
@@ -104,8 +99,7 @@ TEST_CASE_METHOD(NotebookTestCase, "Notebook::NoEventsOnDestruction",
|
||||
// used to do under GTK+ 3 when a page different from the first one was
|
||||
// selected.
|
||||
m_notebook->ChangeSelection(1);
|
||||
m_notebook->Destroy();
|
||||
m_notebook = nullptr;
|
||||
m_notebook.release()->Destroy();
|
||||
CHECK( m_numPageChanges == 1 );
|
||||
}
|
||||
|
||||
@@ -223,9 +217,9 @@ TEST_CASE_METHOD(NotebookTestCase, "Notebook::HitTestFlags", "[notebook]")
|
||||
if ( isVertical && wxIsRunningUnderWine() )
|
||||
return;
|
||||
|
||||
notebook.reset(new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxPoint(0, 0), wxSize(400, 200),
|
||||
style));
|
||||
notebook = make_unique<wxNotebook>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxPoint(0, 0), wxSize(400, 200),
|
||||
style);
|
||||
|
||||
// Simulate an icon of standard size, its contents doesn't matter.
|
||||
const wxSize imageSize(16, 16);
|
||||
@@ -278,8 +272,8 @@ TEST_CASE_METHOD(NotebookTestCase, "Notebook::HitTestFlags", "[notebook]")
|
||||
CHECK(onLabel);
|
||||
CHECK(onItem);
|
||||
#else // !(__WXMSW__ || __WXUNIVERSAL__)
|
||||
notebook.reset(new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200)));
|
||||
notebook = make_unique<wxNotebook>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
notebook->AddPage(new wxPanel(notebook.get()), "First Page");
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(notebook->GetTabRect(0));
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -34,14 +36,16 @@ class OwnerDrawnComboBoxTestCase : public TextEntryTestCase,
|
||||
{
|
||||
public:
|
||||
OwnerDrawnComboBoxTestCase();
|
||||
~OwnerDrawnComboBoxTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo; }
|
||||
virtual wxTextEntry *GetTestEntry() const override
|
||||
{ return m_combo.get(); }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo.get(); }
|
||||
|
||||
virtual wxItemContainer *GetContainer() const override { return m_combo; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_combo; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_combo.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_combo.get(); }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel)) override
|
||||
{
|
||||
@@ -50,7 +54,7 @@ protected:
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
wxOwnerDrawnComboBox *m_combo;
|
||||
std::unique_ptr<wxOwnerDrawnComboBox> m_combo;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(OwnerDrawnComboBoxTestCase);
|
||||
};
|
||||
@@ -67,14 +71,10 @@ wxITEM_CONTAINER_TESTS(OwnerDrawnComboBoxTestCase, "OwnerDrawnComboBox",
|
||||
|
||||
OwnerDrawnComboBoxTestCase::OwnerDrawnComboBoxTestCase()
|
||||
{
|
||||
m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_combo = make_unique<wxOwnerDrawnComboBox>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY);
|
||||
}
|
||||
|
||||
OwnerDrawnComboBoxTestCase::~OwnerDrawnComboBoxTestCase()
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
@@ -109,8 +109,8 @@ TEST_CASE_METHOD(OwnerDrawnComboBoxTestCase, "OwnerDrawnComboBox::Size",
|
||||
TEST_CASE_METHOD(OwnerDrawnComboBoxTestCase, "OwnerDrawnComboBox::PopDismiss",
|
||||
"[ownerdrawncombobox]")
|
||||
{
|
||||
EventCounter drop(m_combo, wxEVT_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
|
||||
EventCounter drop(m_combo.get(), wxEVT_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo.get(), wxEVT_COMBOBOX_CLOSEUP);
|
||||
|
||||
m_combo->Popup();
|
||||
m_combo->Dismiss();
|
||||
@@ -122,12 +122,11 @@ TEST_CASE_METHOD(OwnerDrawnComboBoxTestCase, "OwnerDrawnComboBox::PopDismiss",
|
||||
TEST_CASE_METHOD(OwnerDrawnComboBoxTestCase, "OwnerDrawnComboBox::Sort",
|
||||
"[ownerdrawncombobox]")
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
0, nullptr,
|
||||
wxCB_SORT);
|
||||
m_combo = make_unique<wxOwnerDrawnComboBox>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, 0, nullptr,
|
||||
wxCB_SORT);
|
||||
|
||||
m_combo->Append("aaa");
|
||||
m_combo->Append("Aaa");
|
||||
@@ -155,11 +154,11 @@ TEST_CASE_METHOD(OwnerDrawnComboBoxTestCase, "OwnerDrawnComboBox::ReadOnly",
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
delete m_combo;
|
||||
m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
testitems,
|
||||
wxCB_READONLY);
|
||||
m_combo = make_unique<wxOwnerDrawnComboBox>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, testitems,
|
||||
wxCB_READONLY);
|
||||
|
||||
m_combo->SetValue("item 1");
|
||||
|
||||
|
||||
@@ -24,18 +24,19 @@
|
||||
#include "pickerbasetest.h"
|
||||
#include "asserthelper.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_COLOURPICKERCTRL
|
||||
|
||||
class ColourPickerCtrlTestCase : public PickerBaseTestCase
|
||||
{
|
||||
public:
|
||||
ColourPickerCtrlTestCase();
|
||||
~ColourPickerCtrlTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxPickerBase *GetBase() const override { return m_colour; }
|
||||
virtual wxPickerBase *GetBase() const override { return m_colour.get(); }
|
||||
|
||||
wxColourPickerCtrl *m_colour;
|
||||
std::unique_ptr<wxColourPickerCtrl> m_colour;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ColourPickerCtrlTestCase);
|
||||
};
|
||||
@@ -45,15 +46,13 @@ wxPICKER_BASE_TESTS(ColourPickerCtrlTestCase, "ColourPickerCtrl",
|
||||
|
||||
ColourPickerCtrlTestCase::ColourPickerCtrlTestCase()
|
||||
{
|
||||
m_colour = new wxColourPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
*wxBLACK, wxDefaultPosition,
|
||||
wxDefaultSize, wxCLRP_USE_TEXTCTRL);
|
||||
m_colour = make_unique<wxColourPickerCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, *wxBLACK,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxCLRP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
ColourPickerCtrlTestCase::~ColourPickerCtrlTestCase()
|
||||
{
|
||||
wxDELETE(m_colour);
|
||||
}
|
||||
|
||||
#endif //wxUSE_COLOURPICKERCTRL
|
||||
|
||||
@@ -63,12 +62,11 @@ class DirPickerCtrlTestCase : public PickerBaseTestCase
|
||||
{
|
||||
public:
|
||||
DirPickerCtrlTestCase();
|
||||
~DirPickerCtrlTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxPickerBase *GetBase() const override { return m_dir; }
|
||||
virtual wxPickerBase *GetBase() const override { return m_dir.get(); }
|
||||
|
||||
wxDirPickerCtrl *m_dir;
|
||||
std::unique_ptr<wxDirPickerCtrl> m_dir;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(DirPickerCtrlTestCase);
|
||||
};
|
||||
@@ -78,16 +76,12 @@ wxPICKER_BASE_TESTS(DirPickerCtrlTestCase, "DirPickerCtrl",
|
||||
|
||||
DirPickerCtrlTestCase::DirPickerCtrlTestCase()
|
||||
{
|
||||
m_dir = new wxDirPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxEmptyString, wxDirSelectorPromptStr,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDIRP_USE_TEXTCTRL);
|
||||
m_dir = make_unique<wxDirPickerCtrl>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxEmptyString, wxDirSelectorPromptStr,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDIRP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
DirPickerCtrlTestCase::~DirPickerCtrlTestCase()
|
||||
{
|
||||
wxDELETE(m_dir);
|
||||
}
|
||||
|
||||
#endif //wxUSE_DIRPICKERCTRL
|
||||
|
||||
@@ -97,12 +91,11 @@ class FilePickerCtrlTestCase : public PickerBaseTestCase
|
||||
{
|
||||
public:
|
||||
FilePickerCtrlTestCase();
|
||||
~FilePickerCtrlTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxPickerBase *GetBase() const override { return m_file; }
|
||||
virtual wxPickerBase *GetBase() const override { return m_file.get(); }
|
||||
|
||||
wxFilePickerCtrl *m_file;
|
||||
std::unique_ptr<wxFilePickerCtrl> m_file;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(FilePickerCtrlTestCase);
|
||||
};
|
||||
@@ -112,17 +105,14 @@ wxPICKER_BASE_TESTS(FilePickerCtrlTestCase, "FilePickerCtrl",
|
||||
|
||||
FilePickerCtrlTestCase::FilePickerCtrlTestCase()
|
||||
{
|
||||
m_file = new wxFilePickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxEmptyString, wxFileSelectorPromptStr,
|
||||
wxFileSelectorDefaultWildcardStr,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxFLP_USE_TEXTCTRL);
|
||||
m_file = make_unique<wxFilePickerCtrl>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxEmptyString,
|
||||
wxFileSelectorPromptStr,
|
||||
wxFileSelectorDefaultWildcardStr,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxFLP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
FilePickerCtrlTestCase::~FilePickerCtrlTestCase()
|
||||
{
|
||||
wxDELETE(m_file);
|
||||
}
|
||||
|
||||
#endif //wxUSE_FILEPICKERCTRL
|
||||
|
||||
@@ -132,12 +122,11 @@ class FontPickerCtrlTestCase : public PickerBaseTestCase
|
||||
{
|
||||
public:
|
||||
FontPickerCtrlTestCase();
|
||||
~FontPickerCtrlTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxPickerBase *GetBase() const override { return m_font; }
|
||||
virtual wxPickerBase *GetBase() const override { return m_font.get(); }
|
||||
|
||||
wxFontPickerCtrl *m_font;
|
||||
std::unique_ptr<wxFontPickerCtrl> m_font;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(FontPickerCtrlTestCase);
|
||||
};
|
||||
@@ -147,15 +136,12 @@ wxPICKER_BASE_TESTS(FontPickerCtrlTestCase, "FontPickerCtrl",
|
||||
|
||||
FontPickerCtrlTestCase::FontPickerCtrlTestCase()
|
||||
{
|
||||
m_font = new wxFontPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxNullFont, wxDefaultPosition, wxDefaultSize,
|
||||
wxFNTP_USE_TEXTCTRL);
|
||||
m_font = make_unique<wxFontPickerCtrl>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxNullFont,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxFNTP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
FontPickerCtrlTestCase::~FontPickerCtrlTestCase()
|
||||
{
|
||||
wxDELETE(m_font);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(FontPickerCtrlTestCase, "FontPickerCtrl::ColourSelection",
|
||||
"[fontpicker]")
|
||||
|
||||
@@ -30,32 +30,27 @@ class RadioButtonTestCase
|
||||
{
|
||||
public:
|
||||
RadioButtonTestCase();
|
||||
~RadioButtonTestCase();
|
||||
|
||||
protected:
|
||||
wxRadioButton* m_radio;
|
||||
std::unique_ptr<wxRadioButton> m_radio;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RadioButtonTestCase);
|
||||
};
|
||||
|
||||
RadioButtonTestCase::RadioButtonTestCase()
|
||||
{
|
||||
m_radio = new wxRadioButton(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxRadioButton");
|
||||
m_radio = make_unique<wxRadioButton>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxRadioButton");
|
||||
m_radio->Update();
|
||||
m_radio->Refresh();
|
||||
}
|
||||
|
||||
RadioButtonTestCase::~RadioButtonTestCase()
|
||||
{
|
||||
delete m_radio;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Click", "[radiobutton]")
|
||||
{
|
||||
// OS X doesn't support selecting a single radio button
|
||||
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__)
|
||||
EventCounter selected(m_radio, wxEVT_RADIOBUTTON);
|
||||
EventCounter selected(m_radio.get(), wxEVT_RADIOBUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
wxYield();
|
||||
@@ -72,7 +67,7 @@ TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Click", "[radiobutton]")
|
||||
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Value", "[radiobutton]")
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
EventCounter selected(m_radio, wxEVT_RADIOBUTTON);
|
||||
EventCounter selected(m_radio.get(), wxEVT_RADIOBUTTON);
|
||||
|
||||
m_radio->SetValue(true);
|
||||
|
||||
|
||||
@@ -19,17 +19,20 @@
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RearrangeListTestCase : public ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
RearrangeListTestCase();
|
||||
~RearrangeListTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_rearrange; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_rearrange; }
|
||||
virtual wxItemContainer *GetContainer() const override
|
||||
{ return m_rearrange.get(); }
|
||||
virtual wxWindow *GetContainerWindow() const override
|
||||
{ return m_rearrange.get(); }
|
||||
|
||||
wxRearrangeList* m_rearrange;
|
||||
std::unique_ptr<wxRearrangeList> m_rearrange;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RearrangeListTestCase);
|
||||
};
|
||||
@@ -43,15 +46,11 @@ RearrangeListTestCase::RearrangeListTestCase()
|
||||
wxArrayInt order;
|
||||
wxArrayString items;
|
||||
|
||||
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, order,
|
||||
items);
|
||||
m_rearrange = make_unique<wxRearrangeList>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, order, items);
|
||||
}
|
||||
|
||||
RearrangeListTestCase::~RearrangeListTestCase()
|
||||
{
|
||||
wxDELETE(m_rearrange);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RearrangeListTestCase, "RearrangeList::Move",
|
||||
"[rearrangelist]")
|
||||
@@ -66,11 +65,9 @@ TEST_CASE_METHOD(RearrangeListTestCase, "RearrangeList::Move",
|
||||
items.push_back("second");
|
||||
items.push_back("third");
|
||||
|
||||
wxDELETE(m_rearrange);
|
||||
|
||||
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, order,
|
||||
items);
|
||||
m_rearrange = make_unique<wxRearrangeList>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, order, items);
|
||||
|
||||
//Confusingly setselection sets the physical item rather than the
|
||||
//item specified in the constructor
|
||||
@@ -121,11 +118,9 @@ TEST_CASE_METHOD(RearrangeListTestCase, "RearrangeList::MoveClientData",
|
||||
wxClientData* item1data = new wxStringClientData("item1data");
|
||||
wxClientData* item2data = new wxStringClientData("item2data");
|
||||
|
||||
wxDELETE(m_rearrange);
|
||||
|
||||
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, order,
|
||||
items);
|
||||
m_rearrange = make_unique<wxRearrangeList>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, order, items);
|
||||
|
||||
m_rearrange->SetClientObject(0, item0data);
|
||||
m_rearrange->SetClientObject(1, item1data);
|
||||
|
||||
@@ -28,14 +28,15 @@
|
||||
#include "asserthelper.h"
|
||||
#include "waitfor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RichTextCtrlTestCase
|
||||
{
|
||||
public:
|
||||
RichTextCtrlTestCase();
|
||||
~RichTextCtrlTestCase();
|
||||
|
||||
protected:
|
||||
wxRichTextCtrl* m_rich;
|
||||
std::unique_ptr<wxRichTextCtrl> m_rich;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RichTextCtrlTestCase);
|
||||
};
|
||||
@@ -73,14 +74,11 @@ bool ClipboardContainsText(const wxString &text)
|
||||
|
||||
RichTextCtrlTestCase::RichTextCtrlTestCase()
|
||||
{
|
||||
m_rich = new wxRichTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxSize(400, 200), wxWANTS_CHARS);
|
||||
m_rich = make_unique<wxRichTextCtrl>(
|
||||
wxTheApp->GetTopWindow(), wxID_ANY, "", wxDefaultPosition, wxSize(400,
|
||||
200), wxWANTS_CHARS);
|
||||
}
|
||||
|
||||
RichTextCtrlTestCase::~RichTextCtrlTestCase()
|
||||
{
|
||||
wxDELETE(m_rich);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::IsModified",
|
||||
"[richtextctrl]")
|
||||
@@ -98,8 +96,8 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::CharacterEvent",
|
||||
return;
|
||||
|
||||
|
||||
EventCounter character(m_rich, wxEVT_RICHTEXT_CHARACTER);
|
||||
EventCounter content(m_rich, wxEVT_RICHTEXT_CONTENT_INSERTED);
|
||||
EventCounter character(m_rich.get(), wxEVT_RICHTEXT_CHARACTER);
|
||||
EventCounter content(m_rich.get(), wxEVT_RICHTEXT_CONTENT_INSERTED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@@ -131,8 +129,8 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::DeleteEvent",
|
||||
return;
|
||||
|
||||
|
||||
EventCounter deleteevent(m_rich, wxEVT_RICHTEXT_DELETE);
|
||||
EventCounter contentdelete(m_rich, wxEVT_RICHTEXT_CONTENT_DELETED);
|
||||
EventCounter deleteevent(m_rich.get(), wxEVT_RICHTEXT_DELETE);
|
||||
EventCounter contentdelete(m_rich.get(), wxEVT_RICHTEXT_CONTENT_DELETED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@@ -156,7 +154,7 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::ReturnEvent",
|
||||
return;
|
||||
|
||||
|
||||
EventCounter returnevent(m_rich, wxEVT_RICHTEXT_RETURN);
|
||||
EventCounter returnevent(m_rich.get(), wxEVT_RICHTEXT_RETURN);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@@ -171,7 +169,7 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::ReturnEvent",
|
||||
TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::StyleEvent",
|
||||
"[richtextctrl]")
|
||||
{
|
||||
EventCounter stylechanged(m_rich, wxEVT_RICHTEXT_STYLE_CHANGED);
|
||||
EventCounter stylechanged(m_rich.get(), wxEVT_RICHTEXT_STYLE_CHANGED);
|
||||
|
||||
m_rich->SetValue("Sometext");
|
||||
m_rich->SetStyle(0, 8, wxTextAttr(*wxRED, *wxWHITE));
|
||||
@@ -182,7 +180,7 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::StyleEvent",
|
||||
TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::BufferResetEvent",
|
||||
"[richtextctrl]")
|
||||
{
|
||||
EventCounter reset(m_rich, wxEVT_RICHTEXT_BUFFER_RESET);
|
||||
EventCounter reset(m_rich.get(), wxEVT_RICHTEXT_BUFFER_RESET);
|
||||
|
||||
m_rich->AppendText("more text!");
|
||||
m_rich->SetValue("");
|
||||
@@ -210,7 +208,7 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::UrlEvent",
|
||||
return;
|
||||
|
||||
|
||||
EventCounter url(m_rich, wxEVT_TEXT_URL);
|
||||
EventCounter url(m_rich.get(), wxEVT_TEXT_URL);
|
||||
|
||||
m_rich->BeginURL("http://www.wxwidgets.org");
|
||||
m_rich->WriteText("http://www.wxwidgets.org");
|
||||
@@ -234,7 +232,7 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::TextEvent",
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter updated(m_rich, wxEVT_TEXT);
|
||||
EventCounter updated(m_rich.get(), wxEVT_TEXT);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@@ -429,7 +427,7 @@ TEST_CASE_METHOD(RichTextCtrlTestCase, "RichTextCtrl::Editable",
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter updated(m_rich, wxEVT_TEXT);
|
||||
EventCounter updated(m_rich.get(), wxEVT_TEXT);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_SEARCHCTRL
|
||||
|
||||
|
||||
@@ -27,20 +29,16 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~SearchCtrlTestCase()
|
||||
{
|
||||
delete m_search;
|
||||
}
|
||||
|
||||
void CheckStringSelection(const char *sel)
|
||||
{
|
||||
wxTextEntry * const entry = m_search;
|
||||
wxTextEntry * const entry = m_search.get();
|
||||
CHECK( sel == entry->GetStringSelection() );
|
||||
}
|
||||
|
||||
void AssertSelection(int from, int to, const char *sel)
|
||||
{
|
||||
wxTextEntry * const entry = m_search;
|
||||
wxTextEntry * const entry = m_search.get();
|
||||
|
||||
CHECK( entry->HasSelection() );
|
||||
|
||||
@@ -56,7 +54,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSearchCtrl* const m_search;
|
||||
const std::unique_ptr<wxSearchCtrl> m_search;
|
||||
};
|
||||
|
||||
#define SEARCH_CTRL_TEST_CASE(name, tags) \
|
||||
@@ -67,7 +65,7 @@ protected:
|
||||
SEARCH_CTRL_TEST_CASE("wxSearchCtrl::Focus", "[wxSearchCtrl][focus]")
|
||||
{
|
||||
m_search->SetFocus();
|
||||
CHECK_FOCUS_IS( m_search );
|
||||
CHECK_FOCUS_IS( m_search.get() );
|
||||
}
|
||||
#endif // !__WXOSX__
|
||||
|
||||
@@ -105,7 +103,7 @@ SEARCH_CTRL_TEST_CASE("wxSearchCtrl::SetValue", "[wxSearchCtrl][set_value]")
|
||||
|
||||
SEARCH_CTRL_TEST_CASE("wxSearchCtrl::Selection", "[wxSearchCtrl][selection]")
|
||||
{
|
||||
wxTextEntry * const entry = m_search;
|
||||
wxTextEntry * const entry = m_search.get();
|
||||
|
||||
entry->SetValue("0123456789");
|
||||
|
||||
|
||||
@@ -19,22 +19,24 @@
|
||||
#include "wx/simplebook.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SimplebookTestCase : public BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
SimplebookTestCase();
|
||||
~SimplebookTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_simplebook; }
|
||||
virtual wxBookCtrlBase *GetBase() const override
|
||||
{ return m_simplebook.get(); }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_BOOKCTRL_PAGE_CHANGED; }
|
||||
{ return wxEVT_BOOKCTRL_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_BOOKCTRL_PAGE_CHANGING; }
|
||||
{ return wxEVT_BOOKCTRL_PAGE_CHANGING; }
|
||||
|
||||
wxSimplebook *m_simplebook;
|
||||
std::unique_ptr<wxSimplebook> m_simplebook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(SimplebookTestCase);
|
||||
};
|
||||
@@ -44,14 +46,11 @@ wxBOOK_CTRL_BASE_TESTS(SimplebookTestCase, "Simplebook",
|
||||
|
||||
SimplebookTestCase::SimplebookTestCase()
|
||||
{
|
||||
m_simplebook = new wxSimplebook(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_simplebook = make_unique<wxSimplebook>(
|
||||
wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
SimplebookTestCase::~SimplebookTestCase()
|
||||
{
|
||||
wxDELETE(m_simplebook);
|
||||
}
|
||||
|
||||
#endif // wxUSE_BOOKCTRL
|
||||
|
||||
|
||||
@@ -23,24 +23,24 @@
|
||||
#include "wx/uiaction.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SliderTestCase
|
||||
{
|
||||
public:
|
||||
SliderTestCase() { Create(wxSL_HORIZONTAL); }
|
||||
~SliderTestCase() { wxDELETE(m_slider); }
|
||||
|
||||
protected:
|
||||
// Recreate the slider using the given style instead of the default one.
|
||||
void Create(long style)
|
||||
{
|
||||
wxDELETE(m_slider);
|
||||
|
||||
m_slider = new wxSlider(wxTheApp->GetTopWindow(), wxID_ANY, 50, 0, 100,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
m_slider = make_unique<wxSlider>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
50, 0, 100,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
wxSlider* m_slider = nullptr;
|
||||
std::unique_ptr<wxSlider> m_slider;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(SliderTestCase);
|
||||
};
|
||||
@@ -54,8 +54,8 @@ TEST_CASE_METHOD(SliderTestCase, "Slider::PageUpDown", "[slider]")
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter pageup(m_slider, wxEVT_SCROLL_PAGEUP);
|
||||
EventCounter pagedown(m_slider, wxEVT_SCROLL_PAGEDOWN);
|
||||
EventCounter pageup(m_slider.get(), wxEVT_SCROLL_PAGEUP);
|
||||
EventCounter pagedown(m_slider.get(), wxEVT_SCROLL_PAGEDOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -78,8 +78,8 @@ TEST_CASE_METHOD(SliderTestCase, "Slider::LineUpDown", "[slider]")
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter lineup(m_slider, wxEVT_SCROLL_LINEUP);
|
||||
EventCounter linedown(m_slider, wxEVT_SCROLL_LINEDOWN);
|
||||
EventCounter lineup(m_slider.get(), wxEVT_SCROLL_LINEUP);
|
||||
EventCounter linedown(m_slider.get(), wxEVT_SCROLL_LINEDOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -102,7 +102,7 @@ TEST_CASE_METHOD(SliderTestCase, "Slider::EvtSlider", "[slider]")
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter slider(m_slider, wxEVT_SLIDER);
|
||||
EventCounter slider(m_slider.get(), wxEVT_SLIDER);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -203,9 +203,9 @@ TEST_CASE_METHOD(SliderTestCase, "Slider::Thumb", "[slider]")
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter track(m_slider, wxEVT_SCROLL_THUMBTRACK);
|
||||
EventCounter release(m_slider, wxEVT_SCROLL_THUMBRELEASE);
|
||||
EventCounter changed(m_slider, wxEVT_SCROLL_CHANGED);
|
||||
EventCounter track(m_slider.get(), wxEVT_SCROLL_THUMBTRACK);
|
||||
EventCounter release(m_slider.get(), wxEVT_SCROLL_THUMBRELEASE);
|
||||
EventCounter changed(m_slider.get(), wxEVT_SCROLL_CHANGED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
|
||||
@@ -31,13 +31,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~SpinCtrlDoubleTestCase()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrlDouble* const m_spin;
|
||||
const std::unique_ptr<wxSpinCtrlDouble> m_spin;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(SpinCtrlDoubleTestCase);
|
||||
};
|
||||
@@ -74,7 +70,7 @@ TEST_CASE("SpinCtrlDouble::NoEventsInCtor", "[spinctrl][spinctrldouble]")
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Arrows", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
EventCounter updated(m_spin, wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updated(m_spin.get(), wxEVT_SPINCTRLDOUBLE);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -127,8 +123,8 @@ TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
// that this doesn't result in any events (as this is not something done by
|
||||
// the user).
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
|
||||
|
||||
m_spin->SetRange(1., 10.);
|
||||
CHECK( m_spin->GetValue() == 1. );
|
||||
@@ -155,8 +151,8 @@ TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Value", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
|
||||
|
||||
m_spin->SetDigits(2);
|
||||
m_spin->SetIncrement(0.1);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_SPINCTRL
|
||||
|
||||
|
||||
@@ -28,13 +30,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~SpinCtrlTestCase1()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrl* m_spin;
|
||||
std::unique_ptr<wxSpinCtrl> m_spin;
|
||||
};
|
||||
|
||||
class SpinCtrlTestCase2
|
||||
@@ -45,13 +43,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~SpinCtrlTestCase2()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrl* m_spin;
|
||||
std::unique_ptr<wxSpinCtrl> m_spin;
|
||||
};
|
||||
|
||||
class SpinCtrlTestCase3
|
||||
@@ -63,10 +57,6 @@ public:
|
||||
m_spin->Bind(wxEVT_SPINCTRL, &SpinCtrlTestCase3::OnSpinSetValue, this);
|
||||
}
|
||||
|
||||
~SpinCtrlTestCase3()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnSpinSetValue(wxSpinEvent &e)
|
||||
@@ -81,7 +71,7 @@ private:
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrl* m_spin;
|
||||
std::unique_ptr<wxSpinCtrl> m_spin;
|
||||
};
|
||||
|
||||
|
||||
@@ -139,8 +129,8 @@ TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::NoEventsInCtor", "[spinctrl]")
|
||||
{
|
||||
// Verify that creating the control does not generate any events. This is
|
||||
// unexpected and shouldn't happen.
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
|
||||
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
@@ -153,7 +143,7 @@ TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::NoEventsInCtor", "[spinctrl]")
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Arrows", "[spinctrl]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter updated(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updated(m_spin.get(), wxEVT_SPINCTRL);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -213,8 +203,8 @@ TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Range", "[spinctrl]")
|
||||
// that this doesn't result in any events (as this is not something done by
|
||||
// the user).
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
|
||||
|
||||
m_spin->SetRange(1, 10);
|
||||
CHECK(m_spin->GetValue() == 1);
|
||||
@@ -264,8 +254,8 @@ TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Range", "[spinctrl]")
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Value", "[spinctrl]")
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
|
||||
|
||||
CHECK(m_spin->GetValue() == 0);
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_STC
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
@@ -37,10 +39,6 @@ public:
|
||||
&StcPopupWindowsTestCase::OnCallTipClick, this);
|
||||
}
|
||||
|
||||
~StcPopupWindowsTestCase()
|
||||
{
|
||||
delete m_stc;
|
||||
}
|
||||
|
||||
void OnKillSTCFocus(wxFocusEvent& WXUNUSED(event))
|
||||
{
|
||||
@@ -53,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
wxStyledTextCtrl* const m_stc;
|
||||
const std::unique_ptr<wxStyledTextCtrl> m_stc;
|
||||
bool m_focusAlwaysRetained;
|
||||
bool m_calltipClickReceived;
|
||||
};
|
||||
@@ -95,7 +93,7 @@ TEST_CASE_METHOD(StcPopupWindowsTestCase,
|
||||
if ( m_stc->AutoCompActive() )
|
||||
m_stc->AutoCompCancel();
|
||||
|
||||
CHECK_FOCUS_IS( m_stc );
|
||||
CHECK_FOCUS_IS( m_stc.get() );
|
||||
|
||||
// Unfortunately under GTK we do get focus loss events, at least sometimes
|
||||
// (and actually more often than not, especially with GTK2, but this
|
||||
@@ -149,7 +147,7 @@ TEST_CASE_METHOD(StcPopupWindowsTestCase,
|
||||
// Unfortunately this test fails for unknown reasons under Xvfb (but only
|
||||
// there).
|
||||
if ( !IsRunningUnderXVFB() )
|
||||
CHECK_FOCUS_IS( m_stc );
|
||||
CHECK_FOCUS_IS( m_stc.get() );
|
||||
|
||||
// With wxGTK there is the same problem here as in the test above.
|
||||
#ifndef __WXGTK__
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#endif
|
||||
|
||||
#include "wx/private/localeset.h"
|
||||
#include "wx/private/make_unique.h"
|
||||
|
||||
#include "textentrytest.h"
|
||||
#include "testableframe.h"
|
||||
@@ -67,14 +66,10 @@ public:
|
||||
CreateText(0);
|
||||
}
|
||||
|
||||
~TextCtrlTestCase()
|
||||
{
|
||||
wxDELETE(m_text);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_text; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_text; }
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_text.get(); }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_text.get(); }
|
||||
|
||||
// These tests are run for both single and multi-line controls.
|
||||
void ReadOnly();
|
||||
@@ -121,7 +116,7 @@ protected:
|
||||
// Return a string pattern of length _len_ used as text lines in multi-line control
|
||||
static wxString MakeLinePattern(int len = 100);
|
||||
|
||||
wxTextCtrl *m_text;
|
||||
std::unique_ptr<wxTextCtrl> m_text;
|
||||
|
||||
const long m_style;
|
||||
|
||||
@@ -202,9 +197,9 @@ void TextCtrlTestCase::CreateText(long extraStyles)
|
||||
{
|
||||
const long style = m_style | extraStyles;
|
||||
const int h = (style & wxTE_MULTILINE) ? TEXT_HEIGHT : -1;
|
||||
m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxSize(400, h),
|
||||
style);
|
||||
m_text = make_unique<wxTextCtrl>(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxSize(400, h),
|
||||
style);
|
||||
}
|
||||
|
||||
wxString TextCtrlTestCase::MakeLinePattern(int len)
|
||||
@@ -245,10 +240,9 @@ void TextCtrlTestCase::ReadOnly()
|
||||
return;
|
||||
|
||||
// we need a read only control for this test so recreate it
|
||||
delete m_text;
|
||||
CreateText(wxTE_READONLY);
|
||||
|
||||
EventCounter updated(m_text, wxEVT_TEXT);
|
||||
EventCounter updated(m_text.get(), wxEVT_TEXT);
|
||||
|
||||
m_text->SetFocus();
|
||||
|
||||
@@ -290,9 +284,8 @@ void TextCtrlTestCase::MaxLength()
|
||||
if ( m_style == wxTE_MULTILINE )
|
||||
{
|
||||
#if defined(__WXMSW__) || defined(__WXGTK3__) || defined(__WXQT__)
|
||||
delete m_text;
|
||||
CreateText(wxTE_DONTWRAP);
|
||||
EventCounter maxlen(m_text, wxEVT_TEXT_MAXLEN);
|
||||
EventCounter maxlen(m_text.get(), wxEVT_TEXT_MAXLEN);
|
||||
|
||||
m_text->SetMaxLength(250);
|
||||
m_text->SetFocus();
|
||||
@@ -374,8 +367,8 @@ void TextCtrlTestCase::MaxLength()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EventCounter updated(m_text, wxEVT_TEXT);
|
||||
EventCounter maxlen(m_text, wxEVT_TEXT_MAXLEN);
|
||||
EventCounter updated(m_text.get(), wxEVT_TEXT);
|
||||
EventCounter maxlen(m_text.get(), wxEVT_TEXT_MAXLEN);
|
||||
|
||||
m_text->SetMaxLength(10);
|
||||
m_text->SetFocus();
|
||||
@@ -422,7 +415,7 @@ void TextCtrlTestCase::StreamInput()
|
||||
// Ensure we use decimal point and not a comma.
|
||||
wxCLocaleSetter setCLocale;
|
||||
|
||||
*m_text << "stringinput"
|
||||
*m_text.get() << "stringinput"
|
||||
<< 10
|
||||
<< 1000L
|
||||
<< 3.14f
|
||||
@@ -437,7 +430,7 @@ void TextCtrlTestCase::StreamInput()
|
||||
|
||||
#if wxHAS_TEXT_WINDOW_STREAM
|
||||
|
||||
std::ostream stream(m_text);
|
||||
std::ostream stream(m_text.get());
|
||||
|
||||
// We don't test a wide character as this is not a wide stream
|
||||
stream << "stringinput"
|
||||
@@ -459,7 +452,7 @@ void TextCtrlTestCase::Redirector()
|
||||
{
|
||||
#if wxHAS_TEXT_WINDOW_STREAM
|
||||
|
||||
wxStreamToTextRedirector redirect(m_text);
|
||||
wxStreamToTextRedirector redirect(m_text.get());
|
||||
|
||||
std::cout << "stringinput"
|
||||
<< 10
|
||||
@@ -555,7 +548,7 @@ void TextCtrlTestCase::ProcessEnter()
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_text, wxEVT_TEXT_ENTER);
|
||||
EventCounter count(m_text.get(), wxEVT_TEXT_ENTER);
|
||||
|
||||
m_text->SetFocus();
|
||||
|
||||
@@ -566,7 +559,6 @@ void TextCtrlTestCase::ProcessEnter()
|
||||
CHECK(frame->GetEventCount(wxEVT_TEXT_ENTER) == 0);
|
||||
|
||||
// we need a text control with wxTE_PROCESS_ENTER for this test
|
||||
delete m_text;
|
||||
CreateText(wxTE_PROCESS_ENTER);
|
||||
|
||||
m_text->SetFocus();
|
||||
@@ -590,7 +582,6 @@ void TextCtrlTestCase::Url()
|
||||
if ( IsAutomaticTest() )
|
||||
return;
|
||||
|
||||
delete m_text;
|
||||
CreateText(wxTE_RICH | wxTE_AUTO_URL);
|
||||
|
||||
m_text->AppendText("http://www.wxwidgets.org");
|
||||
@@ -598,7 +589,7 @@ void TextCtrlTestCase::Url()
|
||||
wxUIActionSimulator sim;
|
||||
sim.MouseMove(m_text->ClientToScreen(wxPoint(5, 5)));
|
||||
|
||||
EventCounter url(m_text, wxEVT_TEXT_URL);
|
||||
EventCounter url(m_text.get(), wxEVT_TEXT_URL);
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
@@ -610,7 +601,6 @@ void TextCtrlTestCase::Url()
|
||||
void TextCtrlTestCase::Style()
|
||||
{
|
||||
#if !defined(__WXOSX__) && !defined(__WXQT__)
|
||||
delete m_text;
|
||||
// We need wxTE_RICH under windows for style support
|
||||
CreateText(wxTE_MULTILINE|wxTE_RICH);
|
||||
|
||||
@@ -667,7 +657,6 @@ void TextCtrlTestCase::FontStyle()
|
||||
{
|
||||
// We need wxTE_RICH under MSW and wxTE_MULTILINE under GTK for style
|
||||
// support so recreate the control with these styles.
|
||||
delete m_text;
|
||||
CreateText(wxTE_RICH);
|
||||
|
||||
// Check that we get back the same font from GetStyle() after setting it
|
||||
@@ -757,7 +746,7 @@ void TextCtrlTestCase::LogTextCtrl()
|
||||
{
|
||||
CHECK(m_text->IsEmpty());
|
||||
|
||||
wxLogTextCtrl* logtext = new wxLogTextCtrl(m_text);
|
||||
wxLogTextCtrl* logtext = new wxLogTextCtrl(m_text.get());
|
||||
|
||||
wxLog* old = wxLog::SetActiveTarget(logtext);
|
||||
|
||||
@@ -771,7 +760,6 @@ void TextCtrlTestCase::LogTextCtrl()
|
||||
|
||||
void TextCtrlTestCase::LongText()
|
||||
{
|
||||
delete m_text;
|
||||
CreateText(wxTE_MULTILINE|wxTE_DONTWRAP);
|
||||
|
||||
const int numLines = 1000;
|
||||
@@ -815,7 +803,6 @@ void TextCtrlTestCase::PositionToCoordsRich2()
|
||||
|
||||
void TextCtrlTestCase::DoPositionToCoordsTestWithStyle(long style)
|
||||
{
|
||||
delete m_text;
|
||||
CreateText(style|wxTE_MULTILINE);
|
||||
|
||||
// Asking for invalid index should fail.
|
||||
@@ -915,7 +902,6 @@ void TextCtrlTestCase::PositionToXYMultiLineRich2()
|
||||
|
||||
void TextCtrlTestCase::DoPositionToXYMultiLine(long style)
|
||||
{
|
||||
delete m_text;
|
||||
CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP);
|
||||
|
||||
#if wxHAS_2CHAR_NEWLINES
|
||||
@@ -1137,7 +1123,6 @@ void TextCtrlTestCase::XYToPositionMultiLineRich2()
|
||||
|
||||
void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
|
||||
{
|
||||
delete m_text;
|
||||
CreateText(style|wxTE_MULTILINE|wxTE_DONTWRAP);
|
||||
|
||||
#if wxHAS_2CHAR_NEWLINES
|
||||
@@ -1294,7 +1279,6 @@ void TextCtrlTestCase::DoXYToPositionMultiLine(long style)
|
||||
|
||||
void TextCtrlTestCase::PositionToXYSingleLine()
|
||||
{
|
||||
delete m_text;
|
||||
CreateText(wxTE_DONTWRAP);
|
||||
|
||||
bool ok;
|
||||
@@ -1349,7 +1333,6 @@ void TextCtrlTestCase::PositionToXYSingleLine()
|
||||
|
||||
void TextCtrlTestCase::XYToPositionSingleLine()
|
||||
{
|
||||
delete m_text;
|
||||
CreateText(wxTE_DONTWRAP);
|
||||
|
||||
wxString text;
|
||||
@@ -1419,9 +1402,7 @@ TEST_CASE("wxTextCtrl::ProcessEnter", "[wxTextCtrl][enter]")
|
||||
}
|
||||
|
||||
virtual TextLikeControlCreator* CloneAsMultiLine() const override
|
||||
{
|
||||
return new TextCtrlCreator(wxTE_MULTILINE);
|
||||
}
|
||||
{ return new TextCtrlCreator(wxTE_MULTILINE); }
|
||||
|
||||
private:
|
||||
int m_styleToAdd;
|
||||
@@ -1811,7 +1792,7 @@ TEST_CASE("wxTextCtrl::RichWithHint", "[wxTextCtrl][hint][rich]")
|
||||
richStyle = wxTE_RICH2;
|
||||
}
|
||||
|
||||
auto text = std::make_unique<wxTextCtrl>
|
||||
auto text = make_unique<wxTextCtrl>
|
||||
(
|
||||
wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxSize(400, 200),
|
||||
|
||||
@@ -19,27 +19,25 @@
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/tglbtn.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ToggleButtonTestCase
|
||||
{
|
||||
public:
|
||||
ToggleButtonTestCase();
|
||||
~ToggleButtonTestCase();
|
||||
|
||||
protected:
|
||||
wxToggleButton* m_button;
|
||||
std::unique_ptr<wxToggleButton> m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ToggleButtonTestCase);
|
||||
};
|
||||
|
||||
ToggleButtonTestCase::ToggleButtonTestCase()
|
||||
{
|
||||
m_button = new wxToggleButton(wxTheApp->GetTopWindow(), wxID_ANY, "wxToggleButton");
|
||||
m_button = make_unique<wxToggleButton>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxToggleButton");
|
||||
}
|
||||
|
||||
ToggleButtonTestCase::~ToggleButtonTestCase()
|
||||
{
|
||||
wxDELETE(m_button);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ToggleButtonTestCase, "ToggleButton::Click", "[togglebutton]")
|
||||
{
|
||||
@@ -47,7 +45,7 @@ TEST_CASE_METHOD(ToggleButtonTestCase, "ToggleButton::Click", "[togglebutton]")
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter clicked(m_button, wxEVT_TOGGLEBUTTON);
|
||||
EventCounter clicked(m_button.get(), wxEVT_TOGGLEBUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -72,7 +70,7 @@ TEST_CASE_METHOD(ToggleButtonTestCase, "ToggleButton::Click", "[togglebutton]")
|
||||
|
||||
TEST_CASE_METHOD(ToggleButtonTestCase, "ToggleButton::Value", "[togglebutton]")
|
||||
{
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
EventCounter clicked(m_button.get(), wxEVT_BUTTON);
|
||||
|
||||
m_button->SetValue(true);
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@
|
||||
#include "wx/toolbar.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ToolbookTestCase : public BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
ToolbookTestCase();
|
||||
~ToolbookTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_toolbook; }
|
||||
virtual wxBookCtrlBase *GetBase() const override
|
||||
{ return m_toolbook.get(); }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_TOOLBOOK_PAGE_CHANGED; }
|
||||
@@ -37,7 +39,7 @@ protected:
|
||||
|
||||
virtual void Realize() override { m_toolbook->GetToolBar()->Realize(); }
|
||||
|
||||
wxToolbook *m_toolbook;
|
||||
std::unique_ptr<wxToolbook> m_toolbook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ToolbookTestCase);
|
||||
};
|
||||
@@ -47,14 +49,11 @@ wxBOOK_CTRL_BASE_TESTS(ToolbookTestCase, "Toolbook",
|
||||
|
||||
ToolbookTestCase::ToolbookTestCase()
|
||||
{
|
||||
m_toolbook = new wxToolbook(wxTheApp->GetTopWindow(), wxID_ANY, wxDefaultPosition, wxSize(400, 200));
|
||||
m_toolbook = make_unique<wxToolbook>(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
ToolbookTestCase::~ToolbookTestCase()
|
||||
{
|
||||
wxDELETE(m_toolbook);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ToolbookTestCase, "Toolbook::ToolBar", "[toolbook]")
|
||||
{
|
||||
|
||||
@@ -19,22 +19,24 @@
|
||||
#include "wx/treebook.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class TreebookTestCase : public BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
TreebookTestCase();
|
||||
~TreebookTestCase();
|
||||
|
||||
protected:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_treebook; }
|
||||
virtual wxBookCtrlBase *GetBase() const override
|
||||
{ return m_treebook.get(); }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_TREEBOOK_PAGE_CHANGED; }
|
||||
{ return wxEVT_TREEBOOK_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_TREEBOOK_PAGE_CHANGING; }
|
||||
{ return wxEVT_TREEBOOK_PAGE_CHANGING; }
|
||||
|
||||
wxTreebook *m_treebook;
|
||||
std::unique_ptr<wxTreebook> m_treebook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TreebookTestCase);
|
||||
};
|
||||
@@ -48,20 +50,16 @@ wxBOOK_CTRL_BASE_TEST_CASE(TreebookTestCase, "Treebook", Image,
|
||||
|
||||
TreebookTestCase::TreebookTestCase()
|
||||
{
|
||||
m_treebook = new wxTreebook(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_treebook = make_unique<wxTreebook>(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
TreebookTestCase::~TreebookTestCase()
|
||||
{
|
||||
wxDELETE(m_treebook);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreebookTestCase, "Treebook::SubPages", "[treebook]")
|
||||
{
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook.get());
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook.get());
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook.get());
|
||||
|
||||
m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0);
|
||||
|
||||
@@ -86,15 +84,15 @@ TEST_CASE_METHOD(TreebookTestCase, "Treebook::ContainerPage", "[treebook]")
|
||||
REQUIRE_NOTHROW( m_treebook->AddPage(nullptr, "Container page") );
|
||||
CHECK( m_treebook->GetPageParent(0) == -1 );
|
||||
|
||||
m_treebook->AddSubPage(new wxPanel(m_treebook), "Child page");
|
||||
m_treebook->AddSubPage(new wxPanel(m_treebook.get()), "Child page");
|
||||
CHECK( m_treebook->GetPageParent(1) == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreebookTestCase, "Treebook::Expand", "[treebook]")
|
||||
{
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook.get());
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook.get());
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook.get());
|
||||
|
||||
m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0);
|
||||
m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1);
|
||||
@@ -118,9 +116,9 @@ TEST_CASE_METHOD(TreebookTestCase, "Treebook::Expand", "[treebook]")
|
||||
|
||||
TEST_CASE_METHOD(TreebookTestCase, "Treebook::Delete", "[treebook]")
|
||||
{
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook.get());
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook.get());
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook.get());
|
||||
|
||||
m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0);
|
||||
m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_TREECTRL
|
||||
|
||||
|
||||
@@ -36,11 +38,9 @@ class TreeCtrlTestCase
|
||||
public:
|
||||
explicit TreeCtrlTestCase(int exStyle = 0)
|
||||
{
|
||||
m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
wxTR_DEFAULT_STYLE | wxTR_EDIT_LABELS | exStyle);
|
||||
m_tree = make_unique<wxTreeCtrl>(
|
||||
wxTheApp->GetTopWindow(), wxID_ANY, wxDefaultPosition, wxSize(400,
|
||||
200), wxTR_DEFAULT_STYLE | wxTR_EDIT_LABELS | exStyle);
|
||||
|
||||
m_root = m_tree->AddRoot("root");
|
||||
m_child1 = m_tree->AppendItem(m_root, "child1");
|
||||
@@ -53,15 +53,11 @@ public:
|
||||
m_tree->Update();
|
||||
}
|
||||
|
||||
~TreeCtrlTestCase()
|
||||
{
|
||||
delete m_tree;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// the tree control itself
|
||||
wxTreeCtrl *m_tree = nullptr;
|
||||
std::unique_ptr<wxTreeCtrl> m_tree;
|
||||
|
||||
// and some of its items
|
||||
wxTreeItemId m_root,
|
||||
@@ -176,7 +172,7 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectItemMulti", "[treectrl]")
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteItem", "[treectrl]")
|
||||
{
|
||||
EventCounter deleteitem(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
EventCounter deleteitem(m_tree.get(), wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
|
||||
m_tree->AppendItem(todelete, "deleteme2");
|
||||
@@ -187,7 +183,7 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteItem", "[treectrl]")
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteChildren", "[treectrl]")
|
||||
{
|
||||
EventCounter deletechildren(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
EventCounter deletechildren(m_tree.get(), wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
m_tree->AppendItem(m_child1, "another grandchild");
|
||||
m_tree->DeleteChildren(m_child1);
|
||||
@@ -197,7 +193,7 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteChildren", "[treectrl]")
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteAllItems", "[treectrl]")
|
||||
{
|
||||
EventCounter deleteall(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
EventCounter deleteall(m_tree.get(), wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
m_tree->DeleteAllItems();
|
||||
|
||||
@@ -208,8 +204,8 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteAllItems", "[treectrl]")
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::ItemClick", "[treectrl]")
|
||||
{
|
||||
EventCounter activated(m_tree, wxEVT_TREE_ITEM_ACTIVATED);
|
||||
EventCounter rclick(m_tree, wxEVT_TREE_ITEM_RIGHT_CLICK);
|
||||
EventCounter activated(m_tree.get(), wxEVT_TREE_ITEM_ACTIVATED);
|
||||
EventCounter rclick(m_tree.get(), wxEVT_TREE_ITEM_RIGHT_CLICK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -234,8 +230,8 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::ItemClick", "[treectrl]")
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::LabelEdit", "[treectrl]")
|
||||
{
|
||||
EventCounter beginedit(m_tree, wxEVT_TREE_BEGIN_LABEL_EDIT);
|
||||
EventCounter endedit(m_tree, wxEVT_TREE_END_LABEL_EDIT);
|
||||
EventCounter beginedit(m_tree.get(), wxEVT_TREE_BEGIN_LABEL_EDIT);
|
||||
EventCounter endedit(m_tree.get(), wxEVT_TREE_END_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -260,7 +256,7 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::LabelEdit", "[treectrl]")
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::KeyDown", "[treectrl]")
|
||||
{
|
||||
EventCounter keydown(m_tree, wxEVT_TREE_KEY_DOWN);
|
||||
EventCounter keydown(m_tree.get(), wxEVT_TREE_KEY_DOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -282,10 +278,10 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::CollapseExpandEvents", "[treectr
|
||||
|
||||
m_tree->CollapseAll();
|
||||
|
||||
EventCounter collapsed(m_tree, wxEVT_TREE_ITEM_COLLAPSED);
|
||||
EventCounter collapsing(m_tree, wxEVT_TREE_ITEM_COLLAPSING);
|
||||
EventCounter expanded(m_tree, wxEVT_TREE_ITEM_EXPANDED);
|
||||
EventCounter expanding(m_tree, wxEVT_TREE_ITEM_EXPANDING);
|
||||
EventCounter collapsed(m_tree.get(), wxEVT_TREE_ITEM_COLLAPSED);
|
||||
EventCounter collapsing(m_tree.get(), wxEVT_TREE_ITEM_COLLAPSING);
|
||||
EventCounter expanded(m_tree.get(), wxEVT_TREE_ITEM_EXPANDED);
|
||||
EventCounter expanding(m_tree.get(), wxEVT_TREE_ITEM_EXPANDING);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -424,7 +420,7 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectItemMultiInteractive", "[t
|
||||
// problem in the test.
|
||||
m_tree->SetFocus();
|
||||
|
||||
EventCounter beginedit(m_tree, wxEVT_TREE_BEGIN_LABEL_EDIT);
|
||||
EventCounter beginedit(m_tree.get(), wxEVT_TREE_BEGIN_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -479,7 +475,7 @@ TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectItemMultiInteractive", "[t
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Menu", "[treectrl]")
|
||||
{
|
||||
EventCounter menu(m_tree, wxEVT_TREE_ITEM_MENU);
|
||||
EventCounter menu(m_tree.get(), wxEVT_TREE_ITEM_MENU);
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "wx/app.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -27,7 +29,6 @@ class TreeListCtrlTestCase
|
||||
{
|
||||
public:
|
||||
TreeListCtrlTestCase();
|
||||
~TreeListCtrlTestCase();
|
||||
|
||||
protected:
|
||||
// Create the control with the given style.
|
||||
@@ -43,7 +44,7 @@ protected:
|
||||
// Tests:
|
||||
|
||||
// The control itself.
|
||||
wxTreeListCtrl *m_treelist;
|
||||
std::unique_ptr<wxTreeListCtrl> m_treelist;
|
||||
|
||||
// And some of its items.
|
||||
wxTreeListItem m_code,
|
||||
@@ -80,11 +81,11 @@ TreeListCtrlTestCase::AddItem(const char *label,
|
||||
|
||||
void TreeListCtrlTestCase::Create(long style)
|
||||
{
|
||||
m_treelist = new wxTreeListCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
style);
|
||||
m_treelist = make_unique<wxTreeListCtrl>(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
style);
|
||||
|
||||
m_treelist->AppendColumn("Component");
|
||||
m_treelist->AppendColumn("# Files");
|
||||
@@ -118,11 +119,6 @@ TreeListCtrlTestCase::TreeListCtrlTestCase()
|
||||
Create(wxTL_MULTIPLE | wxTL_3STATE);
|
||||
}
|
||||
|
||||
TreeListCtrlTestCase::~TreeListCtrlTestCase()
|
||||
{
|
||||
delete m_treelist;
|
||||
m_treelist = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -31,10 +33,9 @@ class VirtListCtrlTestCase
|
||||
{
|
||||
public:
|
||||
VirtListCtrlTestCase();
|
||||
~VirtListCtrlTestCase();
|
||||
|
||||
protected:
|
||||
wxListCtrl *m_list;
|
||||
std::unique_ptr<wxListCtrl> m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(VirtListCtrlTestCase);
|
||||
};
|
||||
@@ -59,20 +60,13 @@ VirtListCtrlTestCase::VirtListCtrlTestCase()
|
||||
|
||||
protected:
|
||||
virtual wxString OnGetItemText(long item, long column) const override
|
||||
{
|
||||
return wxString::Format("Row %ld, col %ld", item, column);
|
||||
}
|
||||
{ return wxString::Format("Row %ld, col %ld", item, column); }
|
||||
};
|
||||
|
||||
m_list = new VirtListCtrl;
|
||||
m_list = make_unique<VirtListCtrl>();
|
||||
m_list->AppendColumn("Col0");
|
||||
}
|
||||
|
||||
VirtListCtrlTestCase::~VirtListCtrlTestCase()
|
||||
{
|
||||
delete m_list;
|
||||
m_list = nullptr;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(VirtListCtrlTestCase, "VirtListCtrl::UpdateSelection", "[listctrl][virtual]")
|
||||
{
|
||||
@@ -103,7 +97,7 @@ TEST_CASE_METHOD(VirtListCtrlTestCase, "VirtListCtrl::DeselectedEvent", "[listct
|
||||
return;
|
||||
|
||||
m_list->SetItemCount(1);
|
||||
wxListCtrl* const list = m_list;
|
||||
wxListCtrl* const list = m_list.get();
|
||||
|
||||
EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED);
|
||||
EventCounter deselected(list, wxEVT_LIST_ITEM_DESELECTED);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_WEBVIEW && (wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_WEBKIT2 || wxUSE_WEBVIEW_IE)
|
||||
|
||||
|
||||
@@ -33,7 +35,7 @@ class WebViewTestCase
|
||||
public:
|
||||
WebViewTestCase()
|
||||
: m_browser(wxWebView::New()),
|
||||
m_loaded(new EventCounter(m_browser, wxEVT_WEBVIEW_LOADED))
|
||||
m_loaded(new EventCounter(m_browser.get(), wxEVT_WEBVIEW_LOADED))
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
if (wxWebView::IsBackendAvailable(wxWebViewBackendEdge))
|
||||
@@ -52,11 +54,6 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
~WebViewTestCase()
|
||||
{
|
||||
delete m_loaded;
|
||||
delete m_browser;
|
||||
}
|
||||
|
||||
protected:
|
||||
void LoadUrl(int times = 1)
|
||||
@@ -89,8 +86,8 @@ protected:
|
||||
m_browser->Unbind(wxEVT_WEBVIEW_SCRIPT_RESULT, &WebViewTestCase::OnScriptResult, this);
|
||||
}
|
||||
|
||||
wxWebView* const m_browser;
|
||||
EventCounter* const m_loaded;
|
||||
const std::unique_ptr<wxWebView> m_browser;
|
||||
const std::unique_ptr<EventCounter> m_loaded;
|
||||
wxString m_blankTitle;
|
||||
wxString m_alternateHistoryURL;
|
||||
int m_asyncScriptResult;
|
||||
@@ -109,7 +106,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]")
|
||||
}
|
||||
#endif
|
||||
|
||||
m_browser -> Create(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_browser->Create(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
ENSURE_LOADED;
|
||||
|
||||
SECTION("Title")
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "wx/tooltip.h"
|
||||
#include "wx/wupdlock.h"
|
||||
|
||||
#include "wx/private/make_unique.h"
|
||||
|
||||
class WindowTestCase
|
||||
{
|
||||
@@ -269,7 +268,7 @@ TEST_CASE_METHOD(WindowTestCase, "Window::ContextHelpCaptureLost",
|
||||
#endif // __WXOSX__
|
||||
|
||||
auto const winPtr =
|
||||
std::make_unique<ContextHelpCaptureLostTester>(wxTheApp->GetTopWindow());
|
||||
make_unique<ContextHelpCaptureLostTester>(wxTheApp->GetTopWindow());
|
||||
auto* const win = winPtr.get();
|
||||
|
||||
ContextHelpCaptureLostState state(win);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include "wx/private/glibc.h"
|
||||
#include "wx/private/make_unique.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -55,7 +54,7 @@ public:
|
||||
|
||||
wxLocale::AddCatalogLookupPathPrefix("./intl");
|
||||
|
||||
auto locale = std::make_unique<wxLocale>();
|
||||
auto locale = make_unique<wxLocale>();
|
||||
|
||||
// don't load default catalog, it may be unavailable:
|
||||
REQUIRE( locale->Init(wxLANGUAGE_FRENCH, wxLOCALE_DONT_LOAD_DEFAULT) );
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "wx/filename.h"
|
||||
#include "wx/stdpaths.h"
|
||||
|
||||
#include "wx/private/make_unique.h"
|
||||
|
||||
#ifdef __UNIX__
|
||||
#include <unistd.h>
|
||||
@@ -497,7 +496,7 @@ class IPCServerContext
|
||||
{
|
||||
public:
|
||||
IPCServerContext()
|
||||
: m_server(std::make_unique<IPCServerTestServer>())
|
||||
: m_server(make_unique<IPCServerTestServer>())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -581,7 +580,7 @@ struct IPCServerLaunchState
|
||||
wxString command;
|
||||
long pid = 0;
|
||||
|
||||
IPCServerLaunchState() : process(std::make_unique<IPCServerProcess>()) {}
|
||||
IPCServerLaunchState() : process(make_unique<IPCServerProcess>()) {}
|
||||
};
|
||||
|
||||
// Pump the real event loop so async wxExecute() can deliver its process-exit
|
||||
@@ -690,7 +689,7 @@ struct IPCServerThread::Private
|
||||
};
|
||||
|
||||
IPCServerThread::IPCServerThread()
|
||||
: m_priv(std::make_unique<Private>())
|
||||
: m_priv(make_unique<Private>())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "wx/uri.h"
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
#include "wx/private/make_unique.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -269,7 +268,7 @@ protected:
|
||||
};
|
||||
|
||||
if ( debug == "1" )
|
||||
GetSession().SetDebugLogger(std::make_unique<DebugLogger>());
|
||||
GetSession().SetDebugLogger(make_unique<DebugLogger>());
|
||||
else
|
||||
WARN("Unknown WX_TEST_WEBREQUEST_DEBUG value: " << debug);
|
||||
}
|
||||
|
||||
+16
-19
@@ -38,13 +38,9 @@ public:
|
||||
m_win->SetSizer(m_sizer);
|
||||
}
|
||||
|
||||
~BoxSizerTestCase()
|
||||
{
|
||||
delete m_win;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxWindow* const m_win;
|
||||
const std::unique_ptr<wxWindow> m_win;
|
||||
wxSizer* const m_sizer;
|
||||
};
|
||||
|
||||
@@ -58,7 +54,8 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::Size1", "[sizer]")
|
||||
const wxSize sizeChild = sizeTotal / 2;
|
||||
|
||||
wxWindow * const
|
||||
child = new wxWindow(m_win, wxID_ANY, wxDefaultPosition, sizeChild);
|
||||
child = new wxWindow(m_win.get(), wxID_ANY,
|
||||
wxDefaultPosition, sizeChild);
|
||||
m_sizer->Add(child);
|
||||
m_win->Layout();
|
||||
CHECK(child->GetSize() == sizeChild);
|
||||
@@ -152,9 +149,9 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::Size3", "[sizer]")
|
||||
wxGCC_WARNING_RESTORE(missing-field-initializers)
|
||||
|
||||
wxWindow *child[3];
|
||||
child[0] = new wxWindow(m_win, wxID_ANY);
|
||||
child[1] = new wxWindow(m_win, wxID_ANY);
|
||||
child[2] = new wxWindow(m_win, wxID_ANY);
|
||||
child[0] = new wxWindow(m_win.get(), wxID_ANY);
|
||||
child[1] = new wxWindow(m_win.get(), wxID_ANY);
|
||||
child[2] = new wxWindow(m_win.get(), wxID_ANY);
|
||||
|
||||
for ( unsigned i = 0; i < WXSIZEOF(layoutTestData); i++ )
|
||||
{
|
||||
@@ -247,7 +244,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::CalcMin", "[sizer]")
|
||||
unsigned n;
|
||||
wxWindow *child[NUM_TEST_ITEM];
|
||||
for ( n = 0; n < NUM_TEST_ITEM; n++ )
|
||||
child[n] = new wxWindow(m_win, wxID_ANY);
|
||||
child[n] = new wxWindow(m_win.get(), wxID_ANY);
|
||||
|
||||
for ( unsigned i = 0; i < WXSIZEOF(calcMinTestData); i++ )
|
||||
{
|
||||
@@ -273,7 +270,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::CalcMin", "[sizer]")
|
||||
|
||||
TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::SetMinSize", "[sizer]")
|
||||
{
|
||||
wxWindow* const child = new wxWindow(m_win, wxID_ANY);
|
||||
wxWindow* const child = new wxWindow(m_win.get(), wxID_ANY);
|
||||
child->SetInitialSize(wxSize(10, -1));
|
||||
m_sizer->Add(child);
|
||||
|
||||
@@ -294,7 +291,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::BestSizeRespectsMaxSize", "[sizer]
|
||||
const int maxWidth = 100;
|
||||
|
||||
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
wxListBox* listbox = new wxListBox(m_win, wxID_ANY);
|
||||
wxListBox* listbox = new wxListBox(m_win.get(), wxID_ANY);
|
||||
listbox->Append("some very very very very very very very very very very very long string");
|
||||
listbox->SetMaxSize(wxSize(maxWidth, -1));
|
||||
sizer->Add(listbox);
|
||||
@@ -316,14 +313,14 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::RecalcSizesRespectsMaxSize1", "[si
|
||||
wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer->Add(sizer1);
|
||||
|
||||
wxListBox* listbox1 = new wxListBox(m_win, wxID_ANY);
|
||||
wxListBox* listbox1 = new wxListBox(m_win.get(), wxID_ANY);
|
||||
listbox1->Append("some very very very very very very very very very very very long string");
|
||||
sizer1->Add(listbox1);
|
||||
|
||||
wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer1->Add(sizer2, wxSizerFlags().Expand());
|
||||
|
||||
wxListBox* listbox2 = new wxListBox(m_win, wxID_ANY);
|
||||
wxListBox* listbox2 = new wxListBox(m_win.get(), wxID_ANY);
|
||||
listbox2->Append("some string");
|
||||
listbox2->SetMaxSize(wxSize(100, -1));
|
||||
sizer2->Add(listbox2, wxSizerFlags().Proportion(1));
|
||||
@@ -343,14 +340,14 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::RecalcSizesRespectsMaxSize2", "[si
|
||||
wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer->Add(sizer1, wxSizerFlags().Expand());
|
||||
|
||||
wxWindow* child1 = new wxWindow(m_win, wxID_ANY);
|
||||
wxWindow* child1 = new wxWindow(m_win.get(), wxID_ANY);
|
||||
sizer1->Add(child1, wxSizerFlags().Proportion(1));
|
||||
|
||||
wxWindow* child2 = new wxWindow(m_win, wxID_ANY);
|
||||
wxWindow* child2 = new wxWindow(m_win.get(), wxID_ANY);
|
||||
child2->SetMaxSize(wxSize(-1, 50));
|
||||
sizer1->Add(child2, wxSizerFlags().Proportion(1));
|
||||
|
||||
wxWindow* child3 = new wxWindow(m_win, wxID_ANY);
|
||||
wxWindow* child3 = new wxWindow(m_win.get(), wxID_ANY);
|
||||
sizer1->Add(child3, wxSizerFlags().Proportion(1));
|
||||
|
||||
m_win->Layout();
|
||||
@@ -445,7 +442,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::IncompatibleFlags", "[sizer]")
|
||||
TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::Replace", "[sizer]")
|
||||
{
|
||||
m_sizer->AddSpacer(1);
|
||||
m_sizer->Replace(0, new wxSizerItem(new wxWindow(m_win, wxID_ANY)));
|
||||
m_sizer->Replace(0, new wxSizerItem(new wxWindow(m_win.get(), wxID_ANY)));
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BoxSizerTestCase, "Sizer::DetachItem", "[sizer]")
|
||||
@@ -464,7 +461,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "Sizer::DetachItem", "[sizer]")
|
||||
|
||||
SECTION("Window")
|
||||
{
|
||||
item = new wxSizerItem(new wxWindow(m_win, wxID_ANY));
|
||||
item = new wxSizerItem(new wxWindow(m_win.get(), wxID_ANY));
|
||||
}
|
||||
|
||||
m_sizer->Add(item);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
@@ -32,13 +34,12 @@ class GridSizerTestCaseBase
|
||||
{
|
||||
protected:
|
||||
explicit GridSizerTestCaseBase(wxGridSizer* sizer);
|
||||
~GridSizerTestCaseBase();
|
||||
// Clear the current sizer contents and add the specified windows to it,
|
||||
// using the same flags for all of them.
|
||||
void SetChildren(const wxVector<wxWindow*>& children,
|
||||
const wxSizerFlags& flags);
|
||||
|
||||
wxWindow *m_win;
|
||||
std::unique_ptr<wxWindow> m_win;
|
||||
wxGridSizer* const m_sizerBase;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(GridSizerTestCaseBase);
|
||||
@@ -73,16 +74,12 @@ protected:
|
||||
GridSizerTestCaseBase::GridSizerTestCaseBase(wxGridSizer* sizer)
|
||||
: m_sizerBase(sizer)
|
||||
{
|
||||
m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_win = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_win->SetClientSize(127, 35);
|
||||
|
||||
m_win->SetSizer(m_sizerBase);
|
||||
}
|
||||
|
||||
GridSizerTestCaseBase::~GridSizerTestCaseBase()
|
||||
{
|
||||
delete m_win;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helpers
|
||||
@@ -116,7 +113,7 @@ TEST_CASE_METHOD(GridSizerTestCase,
|
||||
wxVector<wxWindow*> children;
|
||||
for ( int n = 0; n < 3; n++ )
|
||||
{
|
||||
children.push_back(new wxWindow(m_win, wxID_ANY));
|
||||
children.push_back(new wxWindow(m_win.get(), wxID_ANY));
|
||||
}
|
||||
|
||||
SetChildren(children, wxSizerFlags().Expand());
|
||||
@@ -137,7 +134,8 @@ TEST_CASE_METHOD(FlexGridSizerTestCase,
|
||||
wxVector<wxWindow*> children;
|
||||
for ( int n = 0; n < 4; n++ )
|
||||
{
|
||||
children.push_back(new wxWindow(m_win, wxID_ANY, wxDefaultPosition,
|
||||
children.push_back(new wxWindow(m_win.get(), wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
sizeChild));
|
||||
}
|
||||
|
||||
@@ -228,7 +226,7 @@ TEST_CASE_METHOD(FlexGridSizerTestCase,
|
||||
wxVector<wxWindow*> children;
|
||||
for ( int n = 0; n < 4; n++ )
|
||||
{
|
||||
children.push_back(new wxWindow(m_win, wxID_ANY));
|
||||
children.push_back(new wxWindow(m_win.get(), wxID_ANY));
|
||||
}
|
||||
|
||||
// Proportions of growable columns should be respected.
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
// This provides std::make_unique() even when using C++11 compilers.
|
||||
#include "wx/private/make_unique.h"
|
||||
|
||||
// It is used often enough in the tests to make it worth avoiding the need to
|
||||
// qualify it with "std::" every time.
|
||||
using std::make_unique;
|
||||
|
||||
// This header must be included before catch.hpp to be taken into account.
|
||||
#include "asserthelper.h"
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
@@ -30,10 +32,9 @@ class NumValidatorTestCase
|
||||
{
|
||||
public:
|
||||
NumValidatorTestCase();
|
||||
~NumValidatorTestCase();
|
||||
|
||||
protected:
|
||||
wxTextCtrl* const m_text;
|
||||
const std::unique_ptr<wxTextCtrl> m_text;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(NumValidatorTestCase);
|
||||
};
|
||||
@@ -43,16 +44,12 @@ NumValidatorTestCase::NumValidatorTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
NumValidatorTestCase::~NumValidatorTestCase()
|
||||
{
|
||||
delete m_text;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::TransferInt", "[valnum]")
|
||||
{
|
||||
int value = 0;
|
||||
wxIntegerValidator<int> valInt(&value);
|
||||
valInt.SetWindow(m_text);
|
||||
valInt.SetWindow(m_text.get());
|
||||
|
||||
CHECK( valInt.TransferToWindow() );
|
||||
CHECK( m_text->GetValue() == "0" );
|
||||
@@ -80,7 +77,7 @@ TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::TransferUnsigned", "[valnum]")
|
||||
{
|
||||
unsigned value = 0;
|
||||
wxIntegerValidator<unsigned> valUnsigned(&value);
|
||||
valUnsigned.SetWindow(m_text);
|
||||
valUnsigned.SetWindow(m_text.get());
|
||||
|
||||
CHECK( valUnsigned.TransferToWindow() );
|
||||
CHECK( m_text->GetValue() == "0" );
|
||||
@@ -120,7 +117,7 @@ TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::TransferUnsignedRange", "[valnum
|
||||
{
|
||||
unsigned value = 1;
|
||||
wxIntegerValidator<unsigned> valUnsigned(&value, 1, 20);
|
||||
valUnsigned.SetWindow(m_text);
|
||||
valUnsigned.SetWindow(m_text.get());
|
||||
|
||||
CHECK( valUnsigned.TransferToWindow() );
|
||||
CHECK( m_text->GetValue() == "1" );
|
||||
@@ -154,7 +151,7 @@ TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::TransferULL", "[valnum]")
|
||||
{
|
||||
unsigned long long value = 0;
|
||||
wxIntegerValidator<unsigned long long> valULL(&value);
|
||||
valULL.SetWindow(m_text);
|
||||
valULL.SetWindow(m_text.get());
|
||||
|
||||
SECTION("LLONG_MAX")
|
||||
{
|
||||
@@ -200,7 +197,7 @@ TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::TransferFloat", "[valnum]")
|
||||
|
||||
float value = 0;
|
||||
wxFloatingPointValidator<float> valFloat(3, &value);
|
||||
valFloat.SetWindow(m_text);
|
||||
valFloat.SetWindow(m_text.get());
|
||||
|
||||
CHECK( valFloat.TransferToWindow() );
|
||||
CHECK( m_text->GetValue() == "0.000" );
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if wxUSE_VALIDATORS && wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
|
||||
@@ -26,13 +28,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~TextValidatorTestCase()
|
||||
{
|
||||
delete m_text;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxTextCtrl* const m_text;
|
||||
const std::unique_ptr<wxTextCtrl> m_text;
|
||||
};
|
||||
|
||||
#define TEXT_VALIDATOR_TEST_CASE(name, tags) \
|
||||
|
||||
Reference in New Issue
Block a user