wxWidgets/tests/controls/rearrangelisttest.cpp
Vadim Zeitlin 3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00

161 lines
4.7 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: tests/controls/rearrangelisttest.cpp
// Purpose: wxRearrangeList unit test
// Author: Steven Lamerton
// Created: 2010-07-05
// Copyright: (c) 2010 Steven Lamerton
///////////////////////////////////////////////////////////////////////////////
#include "testprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#endif // WX_PRECOMP
#include "wx/rearrangectrl.h"
#include "itemcontainertest.h"
#include "testableframe.h"
class RearrangeListTestCase : public ItemContainerTestCase, public CppUnit::TestCase
{
public:
RearrangeListTestCase() { }
virtual void setUp();
virtual void tearDown();
private:
virtual wxItemContainer *GetContainer() const { return m_rearrange; }
virtual wxWindow *GetContainerWindow() const { return m_rearrange; }
CPPUNIT_TEST_SUITE( RearrangeListTestCase );
wxITEM_CONTAINER_TESTS();
CPPUNIT_TEST( Move );
CPPUNIT_TEST( MoveClientData );
CPPUNIT_TEST_SUITE_END();
void Move();
void MoveClientData();
wxRearrangeList* m_rearrange;
DECLARE_NO_COPY_CLASS(RearrangeListTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( RearrangeListTestCase );
// also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RearrangeListTestCase, "RearrangeListTestCase" );
void RearrangeListTestCase::setUp()
{
//We do not add items here as the wxITEM_CONTAINER_TESTS add their own
wxArrayInt order;
wxArrayString items;
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
wxDefaultPosition, wxDefaultSize, order,
items);
}
void RearrangeListTestCase::tearDown()
{
wxDELETE(m_rearrange);
}
void RearrangeListTestCase::Move()
{
wxArrayInt order;
order.push_back(1);
order.push_back(~2);
order.push_back(0);
wxArrayString items;
items.push_back("first");
items.push_back("second");
items.push_back("third");
wxDELETE(m_rearrange);
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
wxDefaultPosition, wxDefaultSize, order,
items);
//Confusingly setselection sets the physical item rather than the
//item specified in the constructor
m_rearrange->SetSelection(0);
CPPUNIT_ASSERT(!m_rearrange->CanMoveCurrentUp());
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentDown());
m_rearrange->SetSelection(1);
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentUp());
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentDown());
m_rearrange->SetSelection(2);
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentUp());
CPPUNIT_ASSERT(!m_rearrange->CanMoveCurrentDown());
m_rearrange->MoveCurrentUp();
m_rearrange->SetSelection(0);
m_rearrange->MoveCurrentDown();
wxArrayInt neworder = m_rearrange->GetCurrentOrder();
CPPUNIT_ASSERT_EQUAL(neworder[0], 0);
CPPUNIT_ASSERT_EQUAL(neworder[1], 1);
CPPUNIT_ASSERT_EQUAL(neworder[2], ~2);
CPPUNIT_ASSERT_EQUAL("first", m_rearrange->GetString(0));
CPPUNIT_ASSERT_EQUAL("second", m_rearrange->GetString(1));
CPPUNIT_ASSERT_EQUAL("third", m_rearrange->GetString(2));
}
void RearrangeListTestCase::MoveClientData()
{
wxArrayInt order;
order.push_back(0);
order.push_back(1);
order.push_back(2);
wxArrayString items;
items.push_back("first");
items.push_back("second");
items.push_back("third");
wxClientData* item0data = new wxStringClientData("item0data");
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->SetClientObject(0, item0data);
m_rearrange->SetClientObject(1, item1data);
m_rearrange->SetClientObject(2, item2data);
m_rearrange->SetSelection(0);
m_rearrange->MoveCurrentDown();
m_rearrange->SetSelection(2);
m_rearrange->MoveCurrentUp();
CPPUNIT_ASSERT_EQUAL(item1data, m_rearrange->GetClientObject(0));
CPPUNIT_ASSERT_EQUAL(item2data, m_rearrange->GetClientObject(1));
CPPUNIT_ASSERT_EQUAL(item0data, m_rearrange->GetClientObject(2));
CPPUNIT_ASSERT_EQUAL("second", m_rearrange->GetString(0));
CPPUNIT_ASSERT_EQUAL("third", m_rearrange->GetString(1));
CPPUNIT_ASSERT_EQUAL("first", m_rearrange->GetString(2));
}