]> git.saurik.com Git - wxWidgets.git/blob - tests/graphics/bitmap.cpp
Fix compilation after r72375 - LC_CTYPE requires locale.h.
[wxWidgets.git] / tests / graphics / bitmap.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/graphics/bitmap.cpp
3 // Purpose: wxBitmap unit test
4 // Author: Vadim Zeitlin
5 // Created: 2010-03-29
6 // RCS-ID: $Id$
7 // Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #include "wx/bitmap.h"
21 #include "wx/dcmemory.h"
22
23 // ----------------------------------------------------------------------------
24 // test class
25 // ----------------------------------------------------------------------------
26
27 class BitmapTestCase : public CppUnit::TestCase
28 {
29 public:
30 BitmapTestCase() { }
31
32 virtual void setUp();
33 virtual void tearDown();
34
35 private:
36 CPPUNIT_TEST_SUITE( BitmapTestCase );
37 CPPUNIT_TEST( Mask );
38 CPPUNIT_TEST_SUITE_END();
39
40 void Mask();
41
42 wxBitmap m_bmp;
43
44 DECLARE_NO_COPY_CLASS(BitmapTestCase)
45 };
46
47 // register in the unnamed registry so that these tests are run by default
48 CPPUNIT_TEST_SUITE_REGISTRATION( BitmapTestCase );
49
50 // also include in its own registry so that these tests can be run alone
51 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapTestCase, "BitmapTestCase" );
52
53 void BitmapTestCase::setUp()
54 {
55 m_bmp.Create(10, 10);
56
57 wxMemoryDC dc(m_bmp);;
58 dc.SetBackground(*wxWHITE);
59 dc.Clear();
60
61 dc.SetBrush(*wxBLACK_BRUSH);
62 dc.DrawRectangle(4, 4, 2, 2);
63
64 dc.SetPen(*wxRED_PEN);
65 dc.DrawLine(0, 0, 10, 10);
66 dc.DrawLine(10, 0, 0, 10);
67 }
68
69 void BitmapTestCase::tearDown()
70 {
71 m_bmp = wxNullBitmap;
72 }
73
74 void BitmapTestCase::Mask()
75 {
76 wxMask *mask = new wxMask(m_bmp, *wxBLACK);
77 m_bmp.SetMask(mask);
78
79 // copying masks should work
80 wxMask *mask2 = new wxMask(*mask);
81 m_bmp.SetMask(mask2);
82 }
83