232fdc630c
Add a lot of tests for many wx GUI classes. Add tests using the new wxUIActionSimulator class but disable them under OS X as too many of them currently fail there. Refactor the test suite to make organizing the existing tests and adding the new ones easier. Improve documentation using the information gathered while testing the classes. Also update the documentation of the testing system itself. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: tests/graphics/colour.cpp
|
|
// Purpose: wxColour unit test
|
|
// Author: Vadim Zeitlin
|
|
// Created: 2009-09-19
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// headers
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#include "testprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#include "wx/colour.h"
|
|
#include "asserthelper.h"
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// test class
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class ColourTestCase : public CppUnit::TestCase
|
|
{
|
|
public:
|
|
ColourTestCase() { }
|
|
|
|
private:
|
|
CPPUNIT_TEST_SUITE( ColourTestCase );
|
|
CPPUNIT_TEST( GetSetRGB );
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
void GetSetRGB();
|
|
|
|
DECLARE_NO_COPY_CLASS(ColourTestCase)
|
|
};
|
|
|
|
// register in the unnamed registry so that these tests are run by default
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( ColourTestCase );
|
|
|
|
// also include in it's own registry so that these tests can be run alone
|
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ColourTestCase, "ColourTestCase" );
|
|
|
|
void ColourTestCase::GetSetRGB()
|
|
{
|
|
wxColour c;
|
|
c.SetRGB(0x123456);
|
|
|
|
CPPUNIT_ASSERT_EQUAL( 0x56, (int)c.Red() );
|
|
CPPUNIT_ASSERT_EQUAL( 0x34, (int)c.Green() );
|
|
CPPUNIT_ASSERT_EQUAL( 0x12, (int)c.Blue() );
|
|
CPPUNIT_ASSERT_EQUAL( wxALPHA_OPAQUE, c.Alpha() );
|
|
|
|
CPPUNIT_ASSERT_EQUAL( wxColour(0x123456), c );
|
|
CPPUNIT_ASSERT_EQUAL( 0x123456, c.GetRGB() );
|
|
|
|
c.SetRGBA(0xaabbccdd);
|
|
|
|
CPPUNIT_ASSERT_EQUAL( 0xdd, (int)c.Red() );
|
|
CPPUNIT_ASSERT_EQUAL( 0xcc, (int)c.Green() );
|
|
CPPUNIT_ASSERT_EQUAL( 0xbb, (int)c.Blue() );
|
|
CPPUNIT_ASSERT_EQUAL( 0xaa, (int)c.Alpha() );
|
|
|
|
// FIXME: at least under wxGTK wxColour ctor doesn't take alpha channel
|
|
// into account: bug or feature?
|
|
//CPPUNIT_ASSERT_EQUAL( wxColour(0xaabbccdd), c );
|
|
CPPUNIT_ASSERT_EQUAL( 0xbbccdd, c.GetRGB() );
|
|
CPPUNIT_ASSERT_EQUAL( 0xaabbccdd, c.GetRGBA() );
|
|
}
|
|
|