]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/hyperlinkctrltest.cpp
a6197c0a74375da6baf7898b63da6f05459d54cb
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/hyperlinkctrltest.cpp
3 // Purpose: wxHyperlinkCtrl unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
12 #if wxUSE_HYPERLINKCTRL
22 #include "wx/hyperlink.h"
23 #include "wx/uiaction.h"
24 #include "testableframe.h"
25 #include "asserthelper.h"
27 class HyperlinkCtrlTestCase
: public CppUnit::TestCase
30 HyperlinkCtrlTestCase() { }
36 CPPUNIT_TEST_SUITE( HyperlinkCtrlTestCase
);
37 CPPUNIT_TEST( Colour
);
39 WXUISIM_TEST( Click
);
40 CPPUNIT_TEST_SUITE_END();
46 wxHyperlinkCtrl
* m_hyperlink
;
48 DECLARE_NO_COPY_CLASS(HyperlinkCtrlTestCase
)
51 // register in the unnamed registry so that these tests are run by default
52 CPPUNIT_TEST_SUITE_REGISTRATION( HyperlinkCtrlTestCase
);
54 // also include in its own registry so that these tests can be run alone
55 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HyperlinkCtrlTestCase
, "HyperlinkCtrlTestCase" );
57 void HyperlinkCtrlTestCase::setUp()
59 m_hyperlink
= new wxHyperlinkCtrl(wxTheApp
->GetTopWindow(), wxID_ANY
,
60 "wxWidgets", "http://wxwidgets.org");
63 void HyperlinkCtrlTestCase::tearDown()
65 wxDELETE(m_hyperlink
);
68 void HyperlinkCtrlTestCase::Colour()
71 CPPUNIT_ASSERT(m_hyperlink
->GetHoverColour().IsOk());
72 CPPUNIT_ASSERT(m_hyperlink
->GetNormalColour().IsOk());
73 CPPUNIT_ASSERT(m_hyperlink
->GetVisitedColour().IsOk());
75 m_hyperlink
->SetHoverColour(*wxGREEN
);
76 m_hyperlink
->SetNormalColour(*wxRED
);
77 m_hyperlink
->SetVisitedColour(*wxBLUE
);
79 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_hyperlink
->GetHoverColour());
80 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_hyperlink
->GetNormalColour());
81 CPPUNIT_ASSERT_EQUAL(*wxBLUE
, m_hyperlink
->GetVisitedColour());
85 void HyperlinkCtrlTestCase::Url()
87 CPPUNIT_ASSERT_EQUAL("http://wxwidgets.org", m_hyperlink
->GetURL());
89 m_hyperlink
->SetURL("http://google.com");
91 CPPUNIT_ASSERT_EQUAL("http://google.com", m_hyperlink
->GetURL());
94 void HyperlinkCtrlTestCase::Click()
96 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
97 EventCounter
hyperlink(m_hyperlink
, wxEVT_COMMAND_HYPERLINK
);
99 wxUIActionSimulator sim
;
101 sim
.MouseMove(m_hyperlink
->GetScreenPosition() + wxPoint(10, 10));
107 CPPUNIT_ASSERT_EQUAL(1, hyperlink
.GetCount());
111 #endif //wxUSE_HYPERLINKCTRL