Replace wxScopedPtr with std::unique_ptr in the tests

Just use the standard class instead of the wx one, as they can be used
in exactly the same way.
This commit is contained in:
Vadim Zeitlin 2023-03-06 23:34:44 +01:00
parent 29a97bb52d
commit 363f0988cf
34 changed files with 185 additions and 152 deletions

View file

@ -19,6 +19,7 @@
#include <string>
#include <list>
#include <map>
#include <memory>
#include <sys/stat.h>
using std::string;
@ -537,7 +538,7 @@ TestEntry& ArchiveTestCase<ClassFactoryT>::Add(const char *name,
template <class ClassFactoryT>
void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out)
{
wxScopedPtr<OutputStreamT> arc(m_factory->NewStream(out));
std::unique_ptr<OutputStreamT> arc(m_factory->NewStream(out));
TestEntries::iterator it;
OnCreateArchive(*arc);
@ -565,7 +566,7 @@ void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out)
if ((choices & 2) || testEntry.IsText()) {
// try PutNextEntry(EntryT *pEntry)
wxScopedPtr<EntryT> entry(m_factory->NewEntry());
std::unique_ptr<EntryT> entry(m_factory->NewEntry());
entry->SetName(name, wxPATH_UNIX);
if (setIsDir)
entry->SetIsDir();
@ -681,8 +682,8 @@ template <class ClassFactoryT>
void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in,
wxOutputStream& out)
{
wxScopedPtr<InputStreamT> arcIn(m_factory->NewStream(in));
wxScopedPtr<OutputStreamT> arcOut(m_factory->NewStream(out));
std::unique_ptr<InputStreamT> arcIn(m_factory->NewStream(in));
std::unique_ptr<OutputStreamT> arcOut(m_factory->NewStream(out));
EntryT *pEntry;
const wxString deleteName = wxT("bin/bin1000");
@ -694,7 +695,7 @@ void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in,
arcOut->CopyArchiveMetaData(*arcIn);
while ((pEntry = arcIn->GetNextEntry()) != nullptr) {
wxScopedPtr<EntryT> entry(pEntry);
std::unique_ptr<EntryT> entry(pEntry);
OnSetNotifier(*entry);
wxString name = entry->GetName(wxPATH_UNIX);
@ -739,7 +740,7 @@ void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in,
// try adding a new entry
TestEntry& testEntry = Add(newName.mb_str(), newData);
wxScopedPtr<EntryT> newentry(m_factory->NewEntry());
std::unique_ptr<EntryT> newentry(m_factory->NewEntry());
newentry->SetName(newName);
newentry->SetDateTime(testEntry.GetDateTime());
newentry->SetSize(testEntry.GetLength());
@ -762,7 +763,7 @@ void ArchiveTestCase<ClassFactoryT>::ExtractArchive(wxInputStream& in)
typedef std::list<EntryPtr> Entries;
typedef typename Entries::iterator EntryIter;
wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
std::unique_ptr<InputStreamT> arc(m_factory->NewStream(in));
int expectedTotal = m_testEntries.size();
EntryPtr entry;
Entries entries;
@ -973,13 +974,13 @@ void ArchiveTestCase<ClassFactoryT>::TestIterator(wxInputStream& in)
typedef std::list<EntryT*> ArchiveCatalog;
typedef typename ArchiveCatalog::iterator CatalogIter;
wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
std::unique_ptr<InputStreamT> arc(m_factory->NewStream(in));
size_t count = 0;
ArchiveCatalog cat((IterT)*arc, IterT());
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
wxScopedPtr<EntryT> entry(*it);
std::unique_ptr<EntryT> entry(*it);
count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
}
@ -996,13 +997,13 @@ void ArchiveTestCase<ClassFactoryT>::TestPairIterator(wxInputStream& in)
typedef std::map<wxString, EntryT*> ArchiveCatalog;
typedef typename ArchiveCatalog::iterator CatalogIter;
wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
std::unique_ptr<InputStreamT> arc(m_factory->NewStream(in));
size_t count = 0;
ArchiveCatalog cat((PairIterT)*arc, PairIterT());
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
wxScopedPtr<EntryT> entry(it->second);
std::unique_ptr<EntryT> entry(it->second);
count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
}
@ -1019,7 +1020,7 @@ void ArchiveTestCase<ClassFactoryT>::TestSmartIterator(wxInputStream& in)
typedef typename ArchiveCatalog::iterator CatalogIter;
typedef wxArchiveIterator<InputStreamT, Ptr<EntryT> > Iter;
wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
std::unique_ptr<InputStreamT> arc(m_factory->NewStream(in));
ArchiveCatalog cat((Iter)*arc, Iter());
@ -1039,7 +1040,7 @@ void ArchiveTestCase<ClassFactoryT>::TestSmartPairIterator(wxInputStream& in)
typedef wxArchiveIterator<InputStreamT,
std::pair<wxString, Ptr<EntryT> > > PairIter;
wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
std::unique_ptr<InputStreamT> arc(m_factory->NewStream(in));
ArchiveCatalog cat((PairIter)*arc, PairIter());
@ -1060,8 +1061,8 @@ void ArchiveTestCase<ClassFactoryT>::ReadSimultaneous(TestInputStream& in)
// create two archive input streams
TestInputStream in2(in);
wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
wxScopedPtr<InputStreamT> arc2(m_factory->NewStream(in2));
std::unique_ptr<InputStreamT> arc(m_factory->NewStream(in));
std::unique_ptr<InputStreamT> arc2(m_factory->NewStream(in2));
// load the catalog
ArchiveCatalog cat((PairIter)*arc, PairIter());
@ -1147,7 +1148,7 @@ protected:
void CreateArchive(wxOutputStream& out);
void ExtractArchive(wxInputStream& in);
wxScopedPtr<wxArchiveClassFactory> m_factory; // factory to make classes
std::unique_ptr<wxArchiveClassFactory> m_factory; // factory to make classes
int m_options; // test options
};
@ -1187,7 +1188,7 @@ void CorruptionTestCase::runTest()
void CorruptionTestCase::CreateArchive(wxOutputStream& out)
{
wxScopedPtr<wxArchiveOutputStream> arc(m_factory->NewStream(out));
std::unique_ptr<wxArchiveOutputStream> arc(m_factory->NewStream(out));
arc->PutNextDirEntry(wxT("dir"));
arc->PutNextEntry(wxT("file"));
@ -1196,8 +1197,8 @@ void CorruptionTestCase::CreateArchive(wxOutputStream& out)
void CorruptionTestCase::ExtractArchive(wxInputStream& in)
{
wxScopedPtr<wxArchiveInputStream> arc(m_factory->NewStream(in));
wxScopedPtr<wxArchiveEntry> entry(arc->GetNextEntry());
std::unique_ptr<wxArchiveInputStream> arc(m_factory->NewStream(in));
std::unique_ptr<wxArchiveEntry> entry(arc->GetNextEntry());
while (entry.get() != nullptr) {
char buf[1024];

View file

@ -12,7 +12,6 @@
#define WX_TEST_ARCHIVE_ITERATOR
#include "wx/archive.h"
#include "wx/scopedptr.h"
#include "wx/wfstream.h"
#include <map>
@ -220,7 +219,7 @@ protected:
typedef std::map<wxString, TestEntry*> TestEntries;
TestEntries m_testEntries; // test data
wxScopedPtr<ClassFactoryT> m_factory; // factory to make classes
std::unique_ptr<ClassFactoryT> m_factory; // factory to make classes
int m_options; // test options
wxDateTime m_timeStamp; // timestamp to give test entries
int m_id; // select between the possibilites

View file

@ -17,6 +17,8 @@
#include "archivetest.h"
#include "wx/zipstrm.h"
#include <memory>
using std::string;
@ -183,7 +185,7 @@ void ZipPipeTestCase::runTest()
TestInputStream in(out, m_id % ((m_options & PipeIn) ? 4 : 3));
wxZipInputStream zip(in);
wxScopedPtr<wxZipEntry> entry(zip.GetNextEntry());
std::unique_ptr<wxZipEntry> entry(zip.GetNextEntry());
CPPUNIT_ASSERT(entry.get() != nullptr);
if ((m_options & PipeIn) == 0)

View file

@ -19,11 +19,12 @@
#include "wx/checkbox.h"
#include "wx/control.h"
#include "wx/scopedptr.h"
#include "wx/stattext.h"
#include "wx/generic/stattextg.h"
#include <memory>
namespace
{
@ -90,14 +91,14 @@ TEST_CASE("wxControl::Label", "[wxControl][label]")
{
SECTION("wxStaticText")
{
const wxScopedPtr<wxStaticText>
const std::unique_ptr<wxStaticText>
st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
DoTestLabel(st.get());
}
SECTION("wxStaticText/ellipsized")
{
const wxScopedPtr<wxStaticText>
const std::unique_ptr<wxStaticText>
st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL,
wxDefaultPosition, wxDefaultSize,
wxST_ELLIPSIZE_START));
@ -106,14 +107,14 @@ TEST_CASE("wxControl::Label", "[wxControl][label]")
SECTION("wxGenericStaticText")
{
const wxScopedPtr<wxGenericStaticText>
const std::unique_ptr<wxGenericStaticText>
gst(new wxGenericStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
DoTestLabel(gst.get());
}
SECTION("wxCheckBox")
{
const wxScopedPtr<wxCheckBox>
const std::unique_ptr<wxCheckBox>
cb(new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
DoTestLabel(cb.get());
}

View file

@ -17,12 +17,13 @@
#endif // WX_PRECOMP
#include "wx/notebook.h"
#include "wx/scopedptr.h"
#include "asserthelper.h"
#include "bookctrlbasetest.h"
#include "testableframe.h"
#include <memory>
class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
{
public:
@ -128,7 +129,7 @@ TEST_CASE("wxNotebook::AddPageEvents", "[wxNotebook][AddPage][event]")
wxNotebook* const
notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
wxDefaultPosition, wxSize(400, 200));
wxScopedPtr<wxNotebook> cleanup(notebook);
std::unique_ptr<wxNotebook> cleanup(notebook);
CHECK( notebook->GetSelection() == wxNOT_FOUND );
@ -172,7 +173,7 @@ void NotebookTestCase::GetTabRect()
{
wxNotebook *notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
wxDefaultPosition, wxSize(400, 200));
wxScopedPtr<wxNotebook> cleanup(notebook);
std::unique_ptr<wxNotebook> cleanup(notebook);
notebook->AddPage(new wxPanel(notebook), "Page");
@ -217,7 +218,7 @@ void NotebookTestCase::GetTabRect()
void NotebookTestCase::HitTestFlags()
{
wxScopedPtr<wxNotebook> notebook;
std::unique_ptr<wxNotebook> notebook;
#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
long style = 0;

View file

@ -16,9 +16,10 @@
#include "wx/radiobox.h"
#endif // WX_PRECOMP
#include "wx/scopedptr.h"
#include "wx/tooltip.h"
#include <memory>
class RadioBoxTestCase
{
protected:
@ -195,7 +196,7 @@ TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::SetString", "[radiobox]")
TEST_CASE("RadioBox::NoItems", "[radiobox]")
{
wxScopedPtr<wxRadioBox>
std::unique_ptr<wxRadioBox>
radio(new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "Empty",
wxDefaultPosition, wxDefaultSize,
0, nullptr,

View file

@ -24,6 +24,8 @@
#include "testableframe.h"
#include "testwindow.h"
#include <memory>
class RadioButtonTestCase
{
public:
@ -89,22 +91,22 @@ TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Group", "[radiobutton]")
wxWindow* const parent = wxTheApp->GetTopWindow();
// Create two different radio groups.
wxScopedPtr<wxRadioButton> g1radio0(new wxRadioButton(parent, wxID_ANY, "radio 1.0",
std::unique_ptr<wxRadioButton> g1radio0(new wxRadioButton(parent, wxID_ANY, "radio 1.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP));
wxScopedPtr<wxRadioButton> g1radio1(new wxRadioButton(parent, wxID_ANY, "radio 1.1"));
std::unique_ptr<wxRadioButton> g1radio1(new wxRadioButton(parent, wxID_ANY, "radio 1.1"));
wxScopedPtr<wxRadioButton> g2radio0(new wxRadioButton(parent, wxID_ANY, "radio 2.0",
std::unique_ptr<wxRadioButton> g2radio0(new wxRadioButton(parent, wxID_ANY, "radio 2.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP));
wxScopedPtr<wxRadioButton> g2radio1(new wxRadioButton(parent, wxID_ANY, "radio 2.1"));
std::unique_ptr<wxRadioButton> g2radio1(new wxRadioButton(parent, wxID_ANY, "radio 2.1"));
// Check that having another control between radio buttons doesn't break
// grouping.
wxScopedPtr<wxStaticText> text(new wxStaticText(parent, wxID_ANY, "Label"));
wxScopedPtr<wxRadioButton> g2radio2(new wxRadioButton(parent, wxID_ANY, "radio 2.2"));
std::unique_ptr<wxStaticText> text(new wxStaticText(parent, wxID_ANY, "Label"));
std::unique_ptr<wxRadioButton> g2radio2(new wxRadioButton(parent, wxID_ANY, "radio 2.2"));
g1radio0->SetValue(true);
g2radio0->SetValue(true);
@ -174,24 +176,24 @@ TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Group", "[radiobutton]")
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Single", "[radiobutton]")
{
//Create a group of 2 buttons, having second button selected
wxScopedPtr<wxRadioButton> gradio0(new wxRadioButton(wxTheApp->GetTopWindow(),
std::unique_ptr<wxRadioButton> gradio0(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_GROUP));
wxScopedPtr<wxRadioButton> gradio1(new wxRadioButton(wxTheApp->GetTopWindow(),
std::unique_ptr<wxRadioButton> gradio1(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton"));
gradio1->SetValue(true);
//Create a "single" button (by default it will not be selected)
wxScopedPtr<wxRadioButton> sradio(new wxRadioButton(wxTheApp->GetTopWindow(),
std::unique_ptr<wxRadioButton> sradio(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_SINGLE));
//Create a non-grouped button and select it
wxScopedPtr<wxRadioButton> ngradio(new wxRadioButton(wxTheApp->GetTopWindow(),
std::unique_ptr<wxRadioButton> ngradio(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton"));
ngradio->SetValue(true);
@ -214,7 +216,7 @@ TEST_CASE("RadioButton::Focus", "[radiobutton][focus]")
// Create a container panel just to be able to destroy all the windows
// created here at once by simply destroying it.
wxWindow* const tlw = wxTheApp->GetTopWindow();
wxScopedPtr<wxPanel> parentPanel(new wxPanel(tlw));
std::unique_ptr<wxPanel> parentPanel(new wxPanel(tlw));
// Create a panel containing 2 radio buttons and another control outside
// this panel, so that we could give focus to something different and then

View file

@ -17,9 +17,10 @@
#include "testableframe.h"
#include "wx/uiaction.h"
#include "wx/scopedptr.h"
#include "wx/spinctrl.h"
#include <memory>
class SpinCtrlDoubleTestCase
{
public:
@ -55,7 +56,7 @@ TEST_CASE("SpinCtrlDouble::NoEventsInCtor", "[spinctrl][spinctrldouble]")
{
// Verify that creating the control does not generate any events. This is
// unexpected and shouldn't happen.
wxScopedPtr<wxSpinCtrlDouble> m_spin(new wxSpinCtrlDouble);
std::unique_ptr<wxSpinCtrlDouble> m_spin(new wxSpinCtrlDouble);
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRLDOUBLE);
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
@ -246,7 +247,7 @@ TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
static inline unsigned int GetInitialDigits(double inc)
{
wxScopedPtr<wxSpinCtrlDouble> sc(new wxSpinCtrlDouble
std::unique_ptr<wxSpinCtrlDouble> sc(new wxSpinCtrlDouble
(
wxTheApp->GetTopWindow(),
wxID_ANY,

View file

@ -21,7 +21,6 @@
#endif // WX_PRECOMP
#include "wx/platinfo.h"
#include "wx/scopedptr.h"
#include "wx/uiaction.h"
#if wxUSE_CLIPBOARD
@ -39,6 +38,8 @@
#include "testableframe.h"
#include "asserthelper.h"
#include <memory>
static const int TEXT_HEIGHT = 200;
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
@ -1319,7 +1320,7 @@ TEST_CASE("wxTextCtrl::GetBestSize", "[wxTextCtrl][best-size]")
{
wxSize operator()(const wxString& text) const
{
wxScopedPtr<wxTextCtrl>
std::unique_ptr<wxTextCtrl>
t(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, text,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE));
@ -1388,7 +1389,7 @@ TEST_CASE("wxTextCtrl::LongPaste", "[wxTextCtrl][clipboard][paste]")
return;
}
wxScopedPtr<wxTextCtrl>
std::unique_ptr<wxTextCtrl>
text(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, wxString(),
wxDefaultPosition, wxDefaultSize, style));
@ -1431,7 +1432,7 @@ TEST_CASE("wxTextCtrl::EventsOnCreate", "[wxTextCtrl][event]")
EventCounter updated(parent, wxEVT_TEXT);
wxScopedPtr<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "Hello"));
std::unique_ptr<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "Hello"));
// Creating the control shouldn't result in any wxEVT_TEXT events.
CHECK( updated.GetCount() == 0 );
@ -1471,7 +1472,7 @@ TEST_CASE("wxTextCtrl::InitialCanUndo", "[wxTextCtrl][undo]")
INFO("wxTextCtrl with style " << style);
wxWindow* const parent = wxTheApp->GetTopWindow();
wxScopedPtr<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "",
std::unique_ptr<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,
style));
@ -1494,7 +1495,7 @@ TEST_CASE("wxTextCtrl::EmptyUndoBuffer", "[wxTextCtrl][undo]")
return;
}
wxScopedPtr<wxTextCtrl> text(new wxTextCtrl(wxTheApp->GetTopWindow(),
std::unique_ptr<wxTextCtrl> text(new wxTextCtrl(wxTheApp->GetTopWindow(),
wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,

View file

@ -22,9 +22,10 @@
#include "textentrytest.h"
#include "testableframe.h"
#include "wx/scopedptr.h"
#include "wx/uiaction.h"
#include <memory>
void TextEntryTestCase::SetValue()
{
wxTextEntry * const entry = GetTestEntry();
@ -532,7 +533,7 @@ void TestProcessEnter(const TextLikeControlCreator& controlCreator)
SECTION("Without wxTE_PROCESS_ENTER but with wxTE_MULTILINE")
{
wxScopedPtr<TextLikeControlCreator>
std::unique_ptr<TextLikeControlCreator>
multiLineCreator(controlCreator.CloneAsMultiLine());
if ( !multiLineCreator )
return;
@ -544,7 +545,7 @@ void TestProcessEnter(const TextLikeControlCreator& controlCreator)
SECTION("With wxTE_PROCESS_ENTER and wxTE_MULTILINE but skipping")
{
wxScopedPtr<TextLikeControlCreator>
std::unique_ptr<TextLikeControlCreator>
multiLineCreator(controlCreator.CloneAsMultiLine());
if ( !multiLineCreator )
return;
@ -556,7 +557,7 @@ void TestProcessEnter(const TextLikeControlCreator& controlCreator)
SECTION("With wxTE_PROCESS_ENTER and wxTE_MULTILINE without skipping")
{
wxScopedPtr<TextLikeControlCreator>
std::unique_ptr<TextLikeControlCreator>
multiLineCreator(controlCreator.CloneAsMultiLine());
if ( !multiLineCreator )
return;

View file

@ -24,11 +24,12 @@
#include "wx/caret.h"
#include "wx/cshelp.h"
#include "wx/dcclient.h"
#include "wx/scopedptr.h"
#include "wx/stopwatch.h"
#include "wx/tooltip.h"
#include "wx/wupdlock.h"
#include <memory>
class WindowTestCase
{
public:
@ -443,8 +444,8 @@ TEST_CASE_METHOD(WindowTestCase, "Window::FindWindowBy", "[window]")
TEST_CASE_METHOD(WindowTestCase, "Window::SizerErrors", "[window][sizer][error]")
{
wxWindow* const child = new wxWindow(m_window, wxID_ANY);
wxScopedPtr<wxSizer> const sizer1(new wxBoxSizer(wxHORIZONTAL));
wxScopedPtr<wxSizer> const sizer2(new wxBoxSizer(wxHORIZONTAL));
std::unique_ptr<wxSizer> const sizer1(new wxBoxSizer(wxHORIZONTAL));
std::unique_ptr<wxSizer> const sizer2(new wxBoxSizer(wxHORIZONTAL));
REQUIRE_NOTHROW( sizer1->Add(child) );
#ifdef __WXDEBUG__

View file

@ -23,12 +23,13 @@
#include "wx/docmdi.h"
#include "wx/frame.h"
#include "wx/menu.h"
#include "wx/scopedptr.h"
#include "wx/scopeguard.h"
#include "wx/toolbar.h"
#include "wx/uiaction.h"
#include "wx/stopwatch.h"
#include <memory>
// FIXME: Currently under OS X testing paint event doesn't work because neither
// calling Refresh()+Update() nor even sending wxPaintEvent directly to
// the window doesn't result in calls to its event handlers, so disable
@ -464,7 +465,7 @@ void EventPropagationTestCase::MenuEvent()
wxMenu* const menu = CreateTestMenu(frame);
#if wxUSE_MENUBAR
wxMenuBar* const mb = menu->GetMenuBar();
wxScopedPtr<wxMenuBar> ensureMenuBarDestruction(mb);
std::unique_ptr<wxMenuBar> ensureMenuBarDestruction(mb);
wxON_BLOCK_EXIT_OBJ1( *frame, wxFrame::SetMenuBar, (wxMenuBar*)nullptr );
#endif
// Check that wxApp gets the event exactly once.
@ -537,7 +538,7 @@ void EventPropagationTestCase::DocView()
// Set up the parent frame and its menu bar.
wxDocManager docManager;
wxScopedPtr<wxDocMDIParentFrame>
std::unique_ptr<wxDocMDIParentFrame>
parent(new wxDocMDIParentFrame(&docManager, nullptr, wxID_ANY, "Parent"));
wxMenu* const menu = CreateTestMenu(parent.get());
@ -565,7 +566,7 @@ void EventPropagationTestCase::DocView()
wxDocument* const doc = docTemplate.CreateDocument("");
wxView* const view = doc->GetFirstView();
wxScopedPtr<wxMDIChildFrame>
std::unique_ptr<wxMDIChildFrame>
child(new wxDocMDIChildFrame(doc, view, parent.get(), wxID_ANY, "Child"));
wxMenu* const menuChild = CreateTestMenu(child.get());

View file

@ -22,7 +22,8 @@
#if wxUSE_FILESYSTEM
#include "wx/fs_mem.h"
#include "wx/scopedptr.h"
#include <memory>
// ----------------------------------------------------------------------------
// helpers
@ -196,7 +197,7 @@ TEST_CASE("wxFileSystem::MemoryFSHandler", "[filesys][memoryfshandler][find]")
}
private:
wxScopedPtr<wxMemoryFSHandler> const m_handler;
std::unique_ptr<wxMemoryFSHandler> const m_handler;
} autoMemoryFSHandler;
wxMemoryFSHandler::AddFile("foo.txt", "foo contents");

View file

@ -24,12 +24,13 @@
#include "wx/filefn.h"
#include "wx/fswatcher.h"
#include "wx/log.h"
#include "wx/scopedptr.h"
#include "wx/stdpaths.h"
#include "wx/vector.h"
#include "testfile.h"
#include <memory>
// ----------------------------------------------------------------------------
// local functions
// ----------------------------------------------------------------------------
@ -347,7 +348,7 @@ protected:
EventGenerator& eg;
wxEventLoop m_loop; // loop reference
wxScopedPtr<wxFileSystemWatcher> m_watcher;
std::unique_ptr<wxFileSystemWatcher> m_watcher;
int m_eventTypes; // Which event-types to watch. Normally all of them

View file

@ -20,11 +20,12 @@
#include "wx/app.h"
#include "wx/window.h"
#include "wx/dcclient.h"
#include "wx/scopedptr.h"
#include "testfile.h"
#include "waitforpaint.h"
#include <memory>
static const wxSize s_dcSize(260, 300);
static const wxColour s_bgColour(*wxWHITE); // colour to draw outside clipping box
static const wxColour s_fgColour(*wxGREEN); // colour to draw inside clipping box
@ -3978,9 +3979,9 @@ TEST_CASE("ClippingBoxTestCase::wxPaintDC", "[clip][dc][paintdc]")
#if defined(__WXGTK__)
// Under wxGTK we need to have two children (at least) because if there
// is one child its paint area is set to fill the whole parent frame.
wxScopedPtr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
std::unique_ptr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
#endif // wxGTK
wxScopedPtr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)));
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)));
win->SetClientSize(s_dcSize);
// Wait for the first paint event to be sure
@ -4337,7 +4338,7 @@ TEST_CASE("ClippingBoxTestCase::wxPaintDC", "[clip][dc][paintdc]")
// Helper functions
static inline void FlushGC(wxScopedPtr<wxGraphicsContext>& gc)
static inline void FlushGC(std::unique_ptr<wxGraphicsContext>& gc)
{
gc->Flush();
#if defined(__WXMSW__) && wxUSE_GRAPHICS_DIRECT2D
@ -4364,7 +4365,7 @@ static void CheckClipPos(wxGraphicsContext* gc,
x, y, width, height, posTolerance);
}
static void CheckClipBox(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp,
static void CheckClipBox(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp,
int x, int y, int w, int h,
int xPh, int yPh, int wPh, int hPh)
{
@ -4381,7 +4382,7 @@ static void CheckClipBox(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp
}
}
static void CheckClipShape(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxBitmap& bmpRef, int posTolerance)
static void CheckClipShape(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxBitmap& bmpRef, int posTolerance)
{
// Update wxGraphicsContext contents.
FlushGC(gc);
@ -4407,7 +4408,7 @@ void ClearGC(wxGraphicsContext* gc)
// Actual tests
static void InitialState(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void InitialState(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Initial clipping box should be the same as the entire GC surface.
ClearGC(gc.get());
@ -4415,7 +4416,7 @@ static void InitialState(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp
0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight());
}
static void InitialStateWithTransformedGC(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void InitialStateWithTransformedGC(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Initial clipping box with transformed GC.
wxGraphicsMatrix m = gc->CreateMatrix();
@ -4436,7 +4437,7 @@ static void InitialStateWithTransformedGC(wxScopedPtr<wxGraphicsContext>& gc, co
0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight());
}
static void OneRegion(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void OneRegion(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region inside DC area.
const int x = 10;
@ -4450,7 +4451,7 @@ static void OneRegion(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, c
x + parentDcOrigin.x, y + parentDcOrigin.y, w, h);
}
static void OneLargeRegion(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void OneLargeRegion(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region larger then GC surface.
// Final clipping box should be limited to the GC extents.
@ -4461,7 +4462,7 @@ static void OneLargeRegion(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& b
0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight());
}
static void OneOuterRegion(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp)
static void OneOuterRegion(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp)
{
// Setting one clipping region entirely outside GC surface.
// Final clipping box should be empty.
@ -4471,7 +4472,7 @@ static void OneOuterRegion(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& b
0, 0, 0, 0);
}
static void OneRegionNegDim(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void OneRegionNegDim(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region with negative sizes values.
// Final clipping box should have standard positive size values.
@ -4490,7 +4491,7 @@ static void OneRegionNegDim(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap&
r.GetLeft() + parentDcOrigin.x, r.GetTop() + parentDcOrigin.y, r.GetWidth(), r.GetHeight());
}
static void OneRegionAndReset(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void OneRegionAndReset(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region and next destroy it.
// Final clipping box should be the same as GC surface.
@ -4501,7 +4502,7 @@ static void OneRegionAndReset(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap
0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight());
}
static void OneRegionAndEmpty(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp)
static void OneRegionAndEmpty(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp)
{
// Setting one clipping region and next an empty box.
// Final clipping box should empty.
@ -4512,7 +4513,7 @@ static void OneRegionAndEmpty(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap
0, 0, 0, 0);
}
static void OneRegionWithTransformedGC(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void OneRegionWithTransformedGC(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region inside GC area
// with applied some transformations.
@ -4546,7 +4547,7 @@ static void OneRegionWithTransformedGC(wxScopedPtr<wxGraphicsContext>& gc, const
wxRound(xd + parentDcOrigin.x), wxRound(yd + parentDcOrigin.y), wxRound(wd), wxRound(hd));
}
static void OneRegionWithRotatedGC(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void OneRegionWithRotatedGC(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one rectangular clipping region for rotated graphics context.
const double rotAngle = wxDegToRad(1.0);
@ -4570,7 +4571,7 @@ static void OneRegionWithRotatedGC(wxScopedPtr<wxGraphicsContext>& gc, const wxB
memDC.Clear();
memDC.SetDeviceOrigin(parentDcOrigin.x, parentDcOrigin.y);
wxGraphicsRenderer* rend = gc->GetRenderer();
wxScopedPtr<wxGraphicsContext> gcRef(rend->CreateContext(memDC));
std::unique_ptr<wxGraphicsContext> gcRef(rend->CreateContext(memDC));
gcRef->SetAntialiasMode(wxANTIALIAS_NONE);
gcRef->DisableOffset();
gcRef->SetBrush(wxBrush(s_bgColour, wxBRUSHSTYLE_SOLID));
@ -4591,7 +4592,7 @@ static void OneRegionWithRotatedGC(wxScopedPtr<wxGraphicsContext>& gc, const wxB
CheckClipShape(gc, bmp, bmpRef, 1);
}
static void TwoRegionsOverlapping(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void TwoRegionsOverlapping(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region and next another region (partially overlapping).
// Final clipping box should be an intersection of these two boxes.
@ -4607,7 +4608,7 @@ static void TwoRegionsOverlapping(wxScopedPtr<wxGraphicsContext>& gc, const wxBi
r.GetLeft() + parentDcOrigin.x, r.GetTop() + parentDcOrigin.y, r.GetWidth(), r.GetHeight());
}
static void TwoRegionsOverlappingNegDim(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
static void TwoRegionsOverlappingNegDim(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxPoint& parentDcOrigin)
{
// Setting one clipping region with negative size values
// and next another region (partially overlapping).
@ -4633,7 +4634,7 @@ static void TwoRegionsOverlappingNegDim(wxScopedPtr<wxGraphicsContext>& gc, cons
r.GetLeft() + parentDcOrigin.x, r.GetTop() + parentDcOrigin.y, r.GetWidth(), r.GetHeight());
}
static void TwoRegionsNonOverlapping(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp)
static void TwoRegionsNonOverlapping(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp)
{
// Setting one clipping region and next another region (non-overlapping).
// Final clipping box should be empty.
@ -4648,7 +4649,7 @@ static void TwoRegionsNonOverlapping(wxScopedPtr<wxGraphicsContext>& gc, const w
0, 0, 0, 0);
}
static void TwoRegionsNonOverlappingNegDim(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp)
static void TwoRegionsNonOverlappingNegDim(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp)
{
// Setting one clipping region with negative size values
// and next another region (non-overlapping).
@ -4673,7 +4674,7 @@ static void TwoRegionsNonOverlappingNegDim(wxScopedPtr<wxGraphicsContext>& gc, c
0, 0, 0, 0);
}
static void RegionsAndPushPopState(wxScopedPtr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxDC& parentDc)
static void RegionsAndPushPopState(std::unique_ptr<wxGraphicsContext>& gc, const wxBitmap& bmp, const wxDC& parentDc)
{
// Setting muliple rectangular clipping regions
// for transformed wxGC and store/restore them.
@ -4745,7 +4746,7 @@ static void RegionsAndPushPopState(wxScopedPtr<wxGraphicsContext>& gc, const wxB
memDC.SetLogicalOrigin(org.x, org.y);
wxGraphicsRenderer* rend = gc->GetRenderer();
wxScopedPtr<wxGraphicsContext> gcRef(rend->CreateContext(memDC));
std::unique_ptr<wxGraphicsContext> gcRef(rend->CreateContext(memDC));
gcRef->SetAntialiasMode(wxANTIALIAS_NONE);
gcRef->DisableOffset();
@ -4798,7 +4799,7 @@ TEST_CASE("ClippingBoxTestCaseGC::DefaultRenderer", "[clip][gc][default]")
wxPoint dcOrigin = -dc.DeviceToLogical(0, 0);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetDefaultRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
gc->SetAntialiasMode(wxANTIALIAS_NONE);
gc->DisableOffset();
@ -4903,7 +4904,7 @@ TEST_CASE("ClippingBoxTestCaseGC::GDI+Renderer", "[clip][gc][gdiplus]")
wxPoint dcOrigin = -dc.DeviceToLogical(0, 0);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetGDIPlusRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
gc->SetAntialiasMode(wxANTIALIAS_NONE);
gc->DisableOffset();
@ -5008,7 +5009,7 @@ TEST_CASE("ClippingBoxTestCaseGC::Direct2DRenderer", "[clip][gc][direct2d]")
wxPoint dcOrigin = -dc.DeviceToLogical(0, 0);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetDirect2DRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
gc->SetAntialiasMode(wxANTIALIAS_NONE);
gc->DisableOffset();
@ -5118,7 +5119,7 @@ TEST_CASE("ClippingBoxTestCaseGC::CairoRenderer", "[clip][gc][cairo]")
wxPoint dcOrigin = -dc.DeviceToLogical(0, 0);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetCairoRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
gc->SetAntialiasMode(wxANTIALIAS_NONE);
gc->DisableOffset();

View file

@ -14,6 +14,8 @@
#include "wx/graphics.h"
#include "wx/dcmemory.h"
#include <memory>
static void InitState(wxGraphicsContext* gc);
static void InvertMatrix(wxGraphicsContext* gc);
static void Concat1(wxGraphicsContext* gc);
@ -26,7 +28,7 @@ TEST_CASE("GraphicsMatrixTestCase::DefaultRenderer", "[graphmatrix][default]")
wxMemoryDC dc(bmp);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetDefaultRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
SECTION("InitState")
@ -64,7 +66,7 @@ TEST_CASE("GraphicsMatrixTestCase::GDIPlusRenderer", "[graphmatrix][gdiplus]")
wxMemoryDC dc(bmp);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetGDIPlusRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
SECTION("InitState")
@ -101,7 +103,7 @@ TEST_CASE("GraphicsMatrixTestCase::Direct2DRenderer", "[graphmatrix][direct2d]")
wxMemoryDC dc(bmp);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetDirect2DRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
SECTION("InitState")
@ -140,7 +142,7 @@ TEST_CASE("GraphicsMatrixTestCase::CairoRenderer", "[graphmatrix][cairo]")
wxMemoryDC dc(bmp);
wxGraphicsRenderer* rend = wxGraphicsRenderer::GetCairoRenderer();
REQUIRE(rend);
wxScopedPtr<wxGraphicsContext> gc(rend->CreateContext(dc));
std::unique_ptr<wxGraphicsContext> gc(rend->CreateContext(dc));
REQUIRE(gc.get());
SECTION("InitState")

View file

@ -18,7 +18,8 @@
#include "wx/bitmap.h"
#include "wx/dcmemory.h"
#include "wx/dcgraph.h"
#include "wx/scopedptr.h"
#include <memory>
static void DoAllTests(wxGraphicsContext* gc);
@ -30,7 +31,7 @@ TEST_CASE("GraphicsPathTestCase", "[path]")
{
wxBitmap bmp(500, 500);
wxMemoryDC mdc(bmp);
wxScopedPtr<wxGraphicsContext> gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(mdc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(mdc));
REQUIRE(gc);
DoAllTests(gc.get());
}
@ -42,7 +43,7 @@ TEST_CASE("GraphicsPathTestCaseGDIPlus", "[path][gdi+]")
{
wxBitmap bmp(500, 500);
wxMemoryDC mdc(bmp);
wxScopedPtr<wxGraphicsContext> gc(wxGraphicsRenderer::GetGDIPlusRenderer()->CreateContext(mdc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsRenderer::GetGDIPlusRenderer()->CreateContext(mdc));
REQUIRE(gc);
DoAllTests(gc.get());
}
@ -56,7 +57,7 @@ TEST_CASE("GraphicsPathTestCaseDirect2D", "[path][d2d]")
wxBitmap bmp(500, 500);
wxMemoryDC mdc(bmp);
wxScopedPtr<wxGraphicsContext> gc(wxGraphicsRenderer::GetDirect2DRenderer()->CreateContext(mdc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsRenderer::GetDirect2DRenderer()->CreateContext(mdc));
REQUIRE(gc);
DoAllTests(gc.get());
}
@ -69,7 +70,7 @@ TEST_CASE("GraphicsPathTestCaseCairo", "[path][cairo]")
{
wxBitmap bmp(500, 500);
wxMemoryDC mdc(bmp);
wxScopedPtr<wxGraphicsContext> gc(wxGraphicsRenderer::GetCairoRenderer()->CreateContext(mdc));
std::unique_ptr<wxGraphicsContext> gc(wxGraphicsRenderer::GetCairoRenderer()->CreateContext(mdc));
REQUIRE(gc);
DoAllTests(gc.get());
}

View file

@ -20,7 +20,8 @@
#endif // WX_PRECOMP
#include "wx/html/winpars.h"
#include "wx/scopedptr.h"
#include <memory>
// Test that parsing invalid HTML simply fails but doesn't crash for example.
TEST_CASE("wxHtmlParser::ParseInvalid", "[html][parser][error]")
@ -45,7 +46,7 @@ TEST_CASE("wxHtmlCell::Detach", "[html][cell]")
{
wxMemoryDC dc;
wxScopedPtr<wxHtmlContainerCell> const top(new wxHtmlContainerCell(nullptr));
std::unique_ptr<wxHtmlContainerCell> const top(new wxHtmlContainerCell(nullptr));
wxHtmlContainerCell* const cont = new wxHtmlContainerCell(nullptr);
wxHtmlCell* const cell1 = new wxHtmlWordCell("Hello", dc);
wxHtmlCell* const cell2 = new wxHtmlColourCell(*wxRED);

View file

@ -31,10 +31,10 @@
#include "wx/wfstream.h"
#include "wx/clipbrd.h"
#include "wx/dataobj.h"
#include "wx/scopedptr.h"
#include "testimage.h"
#include <memory>
#define CHECK_EQUAL_COLOUR_RGB(c1, c2) \
CHECK( (int)c1.Red() == (int)c2.Red() ); \
@ -180,7 +180,7 @@ void ImageTestCase::LoadFromSocketStream()
wxURL url(urlStr);
REQUIRE( url.GetError() == wxURL_NOERR );
wxScopedPtr<wxInputStream> in_stream(url.GetInputStream());
std::unique_ptr<wxInputStream> in_stream(url.GetInputStream());
REQUIRE( in_stream );
REQUIRE( in_stream->IsOk() );

View file

@ -18,7 +18,8 @@
#endif // WX_PRECOMP
#include "wx/list.h"
#include "wx/scopedptr.h"
#include <memory>
// --------------------------------------------------------------------------
// test class
@ -243,7 +244,7 @@ void ElementsListNode::DeleteData()
TEST_CASE("wxWindowList::Find", "[list]")
{
ListElement* const el = new ListElement(17);
wxScopedPtr<ListElementBase> elb(el);
std::unique_ptr<ListElementBase> elb(el);
ElementsList l;
l.Append(el);

View file

@ -17,7 +17,8 @@
#endif // WX_PRECOMP
#include "wx/accel.h"
#include "wx/scopedptr.h"
#include <memory>
namespace
{
@ -36,7 +37,7 @@ void CheckAccelEntry(const wxAcceleratorEntry& accel, int keycode, int flags)
*/
TEST_CASE( "wxAcceleratorEntry::Create", "[accelentry]" )
{
wxScopedPtr<wxAcceleratorEntry> pa;
std::unique_ptr<wxAcceleratorEntry> pa;
SECTION( "Correct behavior" )
{

View file

@ -20,12 +20,13 @@
#endif // WX_PRECOMP
#include "wx/menu.h"
#include "wx/scopedptr.h"
#include "wx/translation.h"
#include "wx/uiaction.h"
#include <stdarg.h>
#include <memory>
// ----------------------------------------------------------------------------
// helper
// ----------------------------------------------------------------------------
@ -668,7 +669,7 @@ namespace
void VerifyAccelAssigned( wxString labelText, int keycode )
{
const wxScopedPtr<wxAcceleratorEntry> entry(
const std::unique_ptr<wxAcceleratorEntry> entry(
wxAcceleratorEntry::Create( labelText )
);

View file

@ -25,10 +25,11 @@
#include "wx/clipbrd.h"
#include "wx/dataobj.h"
#include "wx/panel.h"
#include "wx/scopedptr.h"
#include "asserthelper.h"
#include <memory>
// ----------------------------------------------------------------------------
// the tests
// ----------------------------------------------------------------------------
@ -142,9 +143,9 @@ TEST_CASE("GUI::ClientToScreen", "[guifuncs]")
wxWindow* const tlw = wxTheApp->GetTopWindow();
REQUIRE( tlw );
wxScopedPtr<wxPanel> const
std::unique_ptr<wxPanel> const
p1(new wxPanel(tlw, wxID_ANY, wxPoint(0, 0), wxSize(100, 50)));
wxScopedPtr<wxPanel> const
std::unique_ptr<wxPanel> const
p2(new wxPanel(tlw, wxID_ANY, wxPoint(0, 50), wxSize(100, 50)));
wxWindow* const
b = new wxWindow(p2.get(), wxID_ANY, wxPoint(10, 10), wxSize(30, 10));
@ -194,10 +195,10 @@ TEST_CASE("GUI::FindWindowAtPoint", "[guifuncs]")
// assertion messages.
parent->SetLabel("parent");
wxScopedPtr<wxWindow> btn1(new TestButton(parent, "1", wxPoint(10, 10)));
wxScopedPtr<wxWindow> btn2(new TestButton(parent, "2", wxPoint(10, 90)));
std::unique_ptr<wxWindow> btn1(new TestButton(parent, "1", wxPoint(10, 10)));
std::unique_ptr<wxWindow> btn2(new TestButton(parent, "2", wxPoint(10, 90)));
// No need to use wxScopedPtr<> for this one, it will be deleted by btn2.
// No need to use std::unique_ptr<> for this one, it will be deleted by btn2.
wxWindow* btn3 = new TestButton(btn2.get(), "3", wxPoint(20, 20));
// We need this to realize the windows created above under wxGTK.
@ -233,7 +234,7 @@ TEST_CASE("wxWindow::Dump", "[window]")
{
CHECK_NOTHROW( wxDumpWindow(nullptr) );
wxScopedPtr<wxButton>
std::unique_ptr<wxButton>
button(new wxButton(wxTheApp->GetTopWindow(), wxID_ANY, "bloordyblop"));
const std::string s = wxDumpWindow(button.get()).utf8_string();

View file

@ -23,12 +23,13 @@
#include "wx/socket.h"
#include "wx/url.h"
#include "wx/scopedptr.h"
#include "wx/sstream.h"
#include "wx/evtloop.h"
typedef wxScopedPtr<wxSockAddress> wxSockAddressPtr;
typedef wxScopedPtr<wxSocketClient> wxSocketClientPtr;
#include <memory>
typedef std::unique_ptr<wxSockAddress> wxSockAddressPtr;
typedef std::unique_ptr<wxSocketClient> wxSocketClientPtr;
static wxString gs_serverHost(wxGetenv("WX_TEST_SERVER"));
@ -294,7 +295,7 @@ void SocketTestCase::UrlTest()
wxURL url("http://" + gs_serverHost);
const wxScopedPtr<wxInputStream> in(url.GetInputStream());
const std::unique_ptr<wxInputStream> in(url.GetInputStream());
CPPUNIT_ASSERT( in.get() );
wxStringOutputStream out;

View file

@ -23,6 +23,8 @@
#include "wx/filename.h"
#include "wx/wfstream.h"
#include <memory>
// This test uses httpbin service and by default uses the mirror at the
// location below, which seems to be more reliable than the main site at
// https://httpbin.org. Any other mirror, including a local one, which can be
@ -394,7 +396,7 @@ TEST_CASE_METHOD(RequestFixture,
return;
Create("/put");
wxScopedPtr<wxInputStream> is(new wxFileInputStream("horse.png"));
std::unique_ptr<wxInputStream> is(new wxFileInputStream("horse.png"));
REQUIRE( is->IsOk() );
request.SetData(is.release(), "image/png");

View file

@ -21,7 +21,7 @@
#include "asserthelper.h"
#include "wx/scopedptr.h"
#include <memory>
// ----------------------------------------------------------------------------
// test fixture
@ -366,7 +366,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::IncompatibleFlags", "[sizer]")
#define ASSERT_SIZER_INVALID_FLAGS(f, msg) \
WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE( \
"Expected assertion not generated for " msg, \
wxScopedPtr<wxSizerItem> item(new wxSizerItem(10, 10, 0, f)); \
std::unique_ptr<wxSizerItem> item(new wxSizerItem(10, 10, 0, f)); \
sizer->Add(item.get()); \
item.release() \
)

View file

@ -21,9 +21,11 @@
#include "asserthelper.h"
#include <memory>
TEST_CASE("wxWrapSizer::CalcMin", "[wxWrapSizer]")
{
wxScopedPtr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
win->SetClientSize(180, 240);
wxSizer *sizer = new wxWrapSizer(wxHORIZONTAL);
@ -74,7 +76,7 @@ TEST_CASE("wxWrapSizer::CalcMin", "[wxWrapSizer]")
TEST_CASE("wxWrapSizer::CalcMinFromMinor", "[wxWrapSizer]")
{
wxScopedPtr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
win->SetClientSize(180, 240);
wxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);

View file

@ -29,9 +29,10 @@
#endif
#include "wx/filename.h"
#include "wx/scopedptr.h"
#include "wx/wfstream.h"
#include <memory>
#ifdef __WINDOWS__
#include "wx/msw/wrapwin.h"
#ifdef __VISUALC__
@ -116,7 +117,7 @@ void LargeFileTest::runTest()
// write a large file
{
wxScopedPtr<wxOutputStream> out(MakeOutStream(tmpfile.m_name));
std::unique_ptr<wxOutputStream> out(MakeOutStream(tmpfile.m_name));
// write 'A's at [ 0x7fffffbf, 0x7fffffff [
pos = 0x7fffffff - size;
@ -150,7 +151,7 @@ void LargeFileTest::runTest()
// read the large file back
{
wxScopedPtr<wxInputStream> in(MakeInStream(tmpfile.m_name));
std::unique_ptr<wxInputStream> in(MakeInStream(tmpfile.m_name));
char buf[size];
if (haveLFS) {
@ -214,7 +215,7 @@ protected:
wxInputStream *LargeFileTest_wxFile::MakeInStream(const wxString& name) const
{
wxScopedPtr<wxFileInputStream> in(new wxFileInputStream(name));
std::unique_ptr<wxFileInputStream> in(new wxFileInputStream(name));
CPPUNIT_ASSERT(in->IsOk());
return in.release();
}
@ -246,7 +247,7 @@ protected:
wxInputStream *LargeFileTest_wxFFile::MakeInStream(const wxString& name) const
{
wxScopedPtr<wxFFileInputStream> in(new wxFFileInputStream(name));
std::unique_ptr<wxFFileInputStream> in(new wxFFileInputStream(name));
CPPUNIT_ASSERT(in->IsOk());
return in.release();
}

View file

@ -9,9 +9,10 @@
#ifndef _WX_TESTS_TESTWINDOW_H_
#define _WX_TESTS_TESTWINDOW_H_
#include "wx/scopedptr.h"
#include "wx/window.h"
#include <memory>
// We need to wrap wxWindow* in a class as specializing StringMaker for
// wxWindow* doesn't seem to work.
class wxWindowPtr
@ -19,7 +20,7 @@ class wxWindowPtr
public:
explicit wxWindowPtr(wxWindow* win) : m_win(win) {}
template <typename W>
explicit wxWindowPtr(const wxScopedPtr<W>& win) : m_win(win.get()) {}
explicit wxWindowPtr(const std::unique_ptr<W>& win) : m_win(win.get()) {}
wxString Dump() const
{

View file

@ -19,9 +19,10 @@
#include "wx/url.h"
#include "wx/mstream.h"
#include "wx/scopedptr.h"
#include "wx/utils.h"
#include <memory>
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
@ -76,7 +77,7 @@ void URLTestCase::GetInputStream()
wxURL url("http://detectportal.firefox.com/");
CPPUNIT_ASSERT_EQUAL(wxURL_NOERR, url.GetError());
wxScopedPtr<wxInputStream> in_stream(url.GetInputStream());
std::unique_ptr<wxInputStream> in_stream(url.GetInputStream());
if ( !in_stream && IsAutomaticTest() )
{
// Sometimes the connection fails during CI runs, don't consider this

View file

@ -18,7 +18,7 @@
#include "wx/window.h"
#endif // WX_PRECOMP
#include "wx/scopedptr.h"
#include <memory>
#include "asserthelper.h"
#include "waitforpaint.h"
@ -44,7 +44,7 @@ TEST_CASE("wxWindow::ClientWindowSizeRoundTrip", "[window][client-size]")
TEST_CASE("wxWindow::MinClientSize", "[window][client-size]")
{
wxScopedPtr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY,
std::unique_ptr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxBORDER_THEME));
w->SetSize(wxSize(1,1));
@ -59,9 +59,9 @@ TEST_CASE("wxWindow::SetClientSize", "[window][client-size]")
// Under wxGTK2 we need to have two children (at least) because if there
// is exactly one child its size is set to fill the whole parent frame
// and the window cannot be resized - see wxTopLevelWindowBase::Layout().
wxScopedPtr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
std::unique_ptr<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
#endif // wxGTK 2
wxScopedPtr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
std::unique_ptr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
wxRect reqSize = wxTheApp->GetTopWindow()->GetClientRect();
reqSize.Deflate(25);

View file

@ -19,7 +19,7 @@
#include "wx/window.h"
#endif // WX_PRECOMP
#include "wx/scopedptr.h"
#include <memory>
#include "asserthelper.h"
#include "waitforpaint.h"
@ -52,7 +52,7 @@ protected:
TEST_CASE("wxWindow::SetSize", "[window][size]")
{
wxScopedPtr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
std::unique_ptr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
SECTION("Simple")
{
@ -73,7 +73,7 @@ TEST_CASE("wxWindow::SetSize", "[window][size]")
TEST_CASE("wxWindow::GetBestSize", "[window][size][best-size]")
{
wxScopedPtr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
std::unique_ptr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
CHECK( wxSize(50, 250) == w->GetBestSize() );
@ -86,7 +86,7 @@ TEST_CASE("wxWindow::GetBestSize", "[window][size][best-size]")
TEST_CASE("wxWindow::MovePreservesSize", "[window][size][move]")
{
wxScopedPtr<wxWindow>
std::unique_ptr<wxWindow>
w(new wxFrame(wxTheApp->GetTopWindow(), wxID_ANY, "Test child frame"));
// Unfortunately showing the window is asynchronous, at least when using

View file

@ -18,11 +18,12 @@
#endif // WX_PRECOMP
#include "wx/xml/xml.h"
#include "wx/scopedptr.h"
#include "wx/sstream.h"
#include <stdarg.h>
#include <memory>
// ----------------------------------------------------------------------------
// helpers for testing XML tree
// ----------------------------------------------------------------------------
@ -107,7 +108,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( XmlTestCase, "XmlTestCase" );
void XmlTestCase::InsertChild()
{
wxScopedPtr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
std::unique_ptr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
root->AddChild(new wxXmlNode(wxXML_ELEMENT_NODE, "1"));
wxXmlNode *two = new wxXmlNode(wxXML_ELEMENT_NODE, "2");
root->AddChild(two);
@ -127,7 +128,7 @@ void XmlTestCase::InsertChild()
void XmlTestCase::InsertChildAfter()
{
wxScopedPtr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
std::unique_ptr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
root->InsertChildAfter(new wxXmlNode(wxXML_ELEMENT_NODE, "1"), nullptr);
CheckXml(root.get(), "1", nullptr);

View file

@ -22,7 +22,6 @@
#include "wx/fs_inet.h"
#include "wx/imagxpm.h"
#include "wx/xml/xml.h"
#include "wx/scopedptr.h"
#include "wx/sstream.h"
#include "wx/wfstream.h"
#include "wx/xrc/xmlres.h"
@ -30,6 +29,8 @@
#include <stdarg.h>
#include <memory>
#include "testfile.h"
// ----------------------------------------------------------------------------
@ -44,7 +45,7 @@ static const char *TEST_XRC_FILE = "test.xrc";
void LoadXrcFrom(const wxString& xrcText)
{
wxStringInputStream sis(xrcText);
wxScopedPtr<wxXmlDocument> xmlDoc(new wxXmlDocument(sis, "UTF-8"));
std::unique_ptr<wxXmlDocument> xmlDoc(new wxXmlDocument(sis, "UTF-8"));
REQUIRE( xmlDoc->IsOk() );
// Load the xrc we've just created