]> git.saurik.com Git - wxWidgets.git/blame - tests/graphics/measuring.cpp
Removed redundant DoEnable
[wxWidgets.git] / tests / graphics / measuring.cpp
CommitLineData
f806b2b4 1///////////////////////////////////////////////////////////////////////////////
2fc9c1ea
KO
2// Name: tests/graphics/measuring.cpp
3// Purpose: Tests for wxGraphicsRenderer::CreateMeasuringContext
4// Author: Kevin Ollivier
f806b2b4 5// Created: 2008-02-12
b5b208a1 6// RCS-ID: $Id$
2fc9c1ea 7// Copyright: (c) 2008 Kevin Ollivier <kevino@theolliviers.com>
f806b2b4
KO
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
bb1b20f1
VZ
16// wxCairoRenderer::CreateMeasuringContext() is not implement for wxX11
17#if wxUSE_GRAPHICS_CONTEXT && !defined(__WXX11__)
f806b2b4
KO
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24 #include "wx/app.h"
25 #include "wx/font.h"
26 #include "wx/window.h"
27#endif // WX_PRECOMP
28
29#include "wx/graphics.h"
30// ----------------------------------------------------------------------------
31// test class
32// ----------------------------------------------------------------------------
33
34class MeasuringContextTestCase : public CppUnit::TestCase
35{
36public:
37 MeasuringContextTestCase() { }
38
39 virtual void setUp();
40 virtual void tearDown();
41
42private:
43 CPPUNIT_TEST_SUITE( MeasuringContextTestCase );
44 CPPUNIT_TEST( GetTextExtent );
45 CPPUNIT_TEST_SUITE_END();
46
47 void GetTextExtent();
48
49 wxWindow *m_win;
50
51 DECLARE_NO_COPY_CLASS(MeasuringContextTestCase)
52};
53
54// register in the unnamed registry so that these tests are run by default
55CPPUNIT_TEST_SUITE_REGISTRATION( MeasuringContextTestCase );
56
e3778b4d 57// also include in its own registry so that these tests can be run alone
f806b2b4
KO
58CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MeasuringContextTestCase, "MeasuringContextTestCase" );
59
60// ----------------------------------------------------------------------------
61// test initialization
62// ----------------------------------------------------------------------------
63
64void MeasuringContextTestCase::setUp()
65{
66 m_win = wxTheApp->GetTopWindow();
67}
68
69void MeasuringContextTestCase::tearDown()
70{
71 m_win = NULL;
72}
73
74// ----------------------------------------------------------------------------
75// tests themselves
76// ----------------------------------------------------------------------------
77
78void MeasuringContextTestCase::GetTextExtent()
79{
80 wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
81 CPPUNIT_ASSERT(renderer);
82 wxGraphicsContext* context = renderer->CreateMeasuringContext();
83 CPPUNIT_ASSERT(context);
84 wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
85 CPPUNIT_ASSERT(font.IsOk());
86 context->SetFont(font, *wxBLACK);
87 double width, height, descent, externalLeading = 0.0;
88 context->GetTextExtent("x", &width, &height, &descent, &externalLeading);
89
90 // TODO: Determine a way to make these tests more robust.
91 CPPUNIT_ASSERT(width > 0.0);
92 CPPUNIT_ASSERT(height > 0.0);
93
94}
95
96#endif