]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/hyperlinkctrltest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/hyperlinkctrltest.cpp
3 // Purpose: wxHyperlinkCtrl unit test
4 // Author: Steven Lamerton
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
11 #if wxUSE_HYPERLINKCTRL
21 #include "wx/hyperlink.h"
22 #include "wx/uiaction.h"
23 #include "testableframe.h"
24 #include "asserthelper.h"
26 class HyperlinkCtrlTestCase
: public CppUnit::TestCase
29 HyperlinkCtrlTestCase() { }
35 CPPUNIT_TEST_SUITE( HyperlinkCtrlTestCase
);
36 CPPUNIT_TEST( Colour
);
38 WXUISIM_TEST( Click
);
39 CPPUNIT_TEST_SUITE_END();
45 wxHyperlinkCtrl
* m_hyperlink
;
47 DECLARE_NO_COPY_CLASS(HyperlinkCtrlTestCase
)
50 // register in the unnamed registry so that these tests are run by default
51 CPPUNIT_TEST_SUITE_REGISTRATION( HyperlinkCtrlTestCase
);
53 // also include in its own registry so that these tests can be run alone
54 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HyperlinkCtrlTestCase
, "HyperlinkCtrlTestCase" );
56 void HyperlinkCtrlTestCase::setUp()
58 m_hyperlink
= new wxHyperlinkCtrl(wxTheApp
->GetTopWindow(), wxID_ANY
,
59 "wxWidgets", "http://wxwidgets.org");
62 void HyperlinkCtrlTestCase::tearDown()
64 wxDELETE(m_hyperlink
);
67 void HyperlinkCtrlTestCase::Colour()
70 CPPUNIT_ASSERT(m_hyperlink
->GetHoverColour().IsOk());
71 CPPUNIT_ASSERT(m_hyperlink
->GetNormalColour().IsOk());
72 CPPUNIT_ASSERT(m_hyperlink
->GetVisitedColour().IsOk());
74 m_hyperlink
->SetHoverColour(*wxGREEN
);
75 m_hyperlink
->SetNormalColour(*wxRED
);
76 m_hyperlink
->SetVisitedColour(*wxBLUE
);
78 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_hyperlink
->GetHoverColour());
79 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_hyperlink
->GetNormalColour());
80 CPPUNIT_ASSERT_EQUAL(*wxBLUE
, m_hyperlink
->GetVisitedColour());
84 void HyperlinkCtrlTestCase::Url()
86 CPPUNIT_ASSERT_EQUAL("http://wxwidgets.org", m_hyperlink
->GetURL());
88 m_hyperlink
->SetURL("http://google.com");
90 CPPUNIT_ASSERT_EQUAL("http://google.com", m_hyperlink
->GetURL());
93 void HyperlinkCtrlTestCase::Click()
95 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
96 EventCounter
hyperlink(m_hyperlink
, wxEVT_HYPERLINK
);
98 wxUIActionSimulator sim
;
100 sim
.MouseMove(m_hyperlink
->GetScreenPosition() + wxPoint(10, 10));
106 CPPUNIT_ASSERT_EQUAL(1, hyperlink
.GetCount());
110 #endif //wxUSE_HYPERLINKCTRL