Update of /cvsroot/wgui/wgui/includes/unit_tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3448/includes/unit_tests
Modified Files:
Makefile.am
Added Files:
wg_radiobutton_unittests.h
Log Message:
Integrated a number of changes from Jurgen De Backer including the new CRadioButton class
--- NEW FILE: wg_radiobutton_unittests.h ---
// wg_radiobutton_unittests.h
//
// CRadioButton class unit tests
//
//
// Copyright (c) 2005-2006 Rob Wiskow
// ro...@bo...
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifdef UNIT_TESTS
#include "unit_tests/tut.h"
#include "wg_test_message_client.h"
namespace tut
{
struct UnitTestStruct_CRadioButton {};
typedef test_group<UnitTestStruct_CRadioButton> TestGroup_CRadioButton;
typedef TestGroup_CRadioButton::object TestObject_CRadioButton;
}
namespace
{
tut::TestGroup_CRadioButton UnitTestGroup_CRadioButton("CRadioButton");
}
namespace tut
{
void TestObject_CRadioButton::test()
{
wGui::CApplication App(0, 0);
App.Init();
wGui::CView View(wGui::CRect(0, 0, 100, 100), "UnitTest");
CTestMessageWindow Client1(wGui::CRect(0, 0, 90, 90), &View);
wGui::CMessageServer& Server = wGui::CMessageServer::Instance();
Server.IgnoreAllNewMessages(false);
Server.RegisterMessageClient(&Client1, wGui::CMessage::CTRL_SINGLELCLICK);
Server.RegisterMessageClient(&Client1, wGui::CMessage::CTRL_SINGLEMCLICK);
Server.RegisterMessageClient(&Client1, wGui::CMessage::CTRL_SINGLERCLICK);
wGui::CRadioButton* pRadioButton1 = new wGui::CRadioButton(wGui::CRect(1, 1, 5, 5), &Client1);
ensure_equals("CRadioButton Constructor - GetState", pRadioButton1->GetState(), wGui::CRadioButton::UNCHECKED);
pRadioButton1->SetState(wGui::CRadioButton::CHECKED);
ensure_equals("CRadioButton - SetState", pRadioButton1->GetState(), wGui::CRadioButton::CHECKED);
pRadioButton1->SetState(wGui::CRadioButton::UNCHECKED);
ensure_equals("CRadioButton - SetState", pRadioButton1->GetState(), wGui::CRadioButton::UNCHECKED);
ensure("CRadioButton - OnMouseButtonDown (outside bounds)", !pRadioButton1->OnMouseButtonDown(wGui::CPoint(0, 0), wGui::CMouseMessage::LEFT));
ensure("CRadioButton - OnMouseButtonDown (in bounds)", pRadioButton1->OnMouseButtonDown(
View.ClientToView(pRadioButton1->GetWindowRect().TopLeft()) + wGui::CPoint(1, 1), wGui::CMouseMessage::LEFT));
ensure_equals("CRadioButton - OnMouseButtonDown (RadioButton State)", pRadioButton1->GetState(), wGui::CRadioButton::UNCHECKED);
ensure(! Client1.bNewMessage);
ensure("CRadioButton - OnMouseButtonUp (in bounds)", pRadioButton1->OnMouseButtonUp(
View.ClientToView(pRadioButton1->GetWindowRect().TopLeft()) + wGui::CPoint(1, 1), wGui::CMouseMessage::LEFT));
while (Server.MessageAvailable())
{
Server.DeliverMessage();
}
ensure_equals("CRadioButton - OnMouseButtonUp (RadioButton State)", pRadioButton1->GetState(), wGui::CRadioButton::CHECKED);
ensure("CRadioButton - OnMouseButtonUp (message)", Client1.bNewMessage && (Client1.eLastMessage == wGui::CMessage::CTRL_SINGLELCLICK));
ensure("CRadioButton - OnMouseButtonDown (middle CRadioButton)", pRadioButton1->OnMouseButtonDown(
View.ClientToView(pRadioButton1->GetWindowRect().TopLeft()) + wGui::CPoint(1, 1), wGui::CMouseMessage::MIDDLE));
ensure("CRadioButton - OnMouseButtonUp (middle CRadioButton)", pRadioButton1->OnMouseButtonUp(
View.ClientToView(pRadioButton1->GetWindowRect().TopLeft()) + wGui::CPoint(1, 1), wGui::CMouseMessage::MIDDLE));
while (Server.MessageAvailable())
{
Server.DeliverMessage();
}
ensure("CRadioButton - OnMouseButtonUp (message)", Client1.bNewMessage && (Client1.eLastMessage == wGui::CMessage::CTRL_SINGLEMCLICK));
}
void RegisterUnitTests_CRadioButton(void)
{
UnitTestGroup_CRadioButton.reg(1, &TestObject_CRadioButton::test);
}
}
#endif // UNIT_TESTS
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wgui/wgui/includes/unit_tests/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.am 31 Mar 2004 15:31:32 -0000 1.3
--- Makefile.am 29 Dec 2005 13:46:18 -0000 1.4
***************
*** 19,22 ****
--- 19,23 ----
wg_point_unittests.h \
wg_progress_unittests.h \
+ wg_radiobutton_unittests.h \
wg_rect_unittests.h \
wg_scrollbar_unittests.h \
|