Merge the new GUI tests from SOC2010_GUI_TEST branch.
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
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_HTML
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
@@ -22,6 +24,8 @@
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/html/htmlwin.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
@@ -38,9 +42,19 @@ public:
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( HtmlWindowTestCase );
|
||||
CPPUNIT_TEST( SelectionToText );
|
||||
CPPUNIT_TEST( Title );
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
WXUISIM_TEST( CellClick );
|
||||
WXUISIM_TEST( LinkClick );
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
CPPUNIT_TEST( AppendToPage );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void SelectionToText();
|
||||
void Title();
|
||||
void CellClick();
|
||||
void LinkClick();
|
||||
void AppendToPage();
|
||||
|
||||
wxHtmlWindow *m_win;
|
||||
|
||||
@@ -59,13 +73,13 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HtmlWindowTestCase, "HtmlWindowTestCase"
|
||||
|
||||
void HtmlWindowTestCase::setUp()
|
||||
{
|
||||
m_win = new wxHtmlWindow(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_win = new wxHtmlWindow(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
}
|
||||
|
||||
void HtmlWindowTestCase::tearDown()
|
||||
{
|
||||
m_win->Destroy();
|
||||
m_win = NULL;
|
||||
wxDELETE(m_win);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -74,11 +88,17 @@ void HtmlWindowTestCase::tearDown()
|
||||
|
||||
static const char *TEST_MARKUP =
|
||||
"<html><body>"
|
||||
"<title>Page</title>"
|
||||
" Title<p>"
|
||||
" A longer line<br>"
|
||||
" and the last line."
|
||||
"</body></html>";
|
||||
|
||||
static const char *TEST_MARKUP_LINK =
|
||||
"<html><body>"
|
||||
"<a href=\"link\">link<\\a> "
|
||||
"</body></html>";
|
||||
|
||||
static const char *TEST_PLAIN_TEXT =
|
||||
"Title\nA longer line\nand the last line.";
|
||||
|
||||
@@ -89,3 +109,66 @@ void HtmlWindowTestCase::SelectionToText()
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( TEST_PLAIN_TEXT, m_win->SelectionToText() );
|
||||
}
|
||||
|
||||
void HtmlWindowTestCase::Title()
|
||||
{
|
||||
m_win->SetPage(TEST_MARKUP);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("Page", m_win->GetOpenedPageTitle());
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
void HtmlWindowTestCase::CellClick()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count1(m_win, wxEVT_COMMAND_HTML_CELL_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_win->SetPage(TEST_MARKUP);
|
||||
m_win->Update();
|
||||
m_win->Refresh();
|
||||
|
||||
sim.MouseMove(m_win->ClientToScreen(wxPoint(15, 15)));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
}
|
||||
|
||||
void HtmlWindowTestCase::LinkClick()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count1(m_win, wxEVT_COMMAND_HTML_LINK_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_win->SetPage(TEST_MARKUP_LINK);
|
||||
m_win->Update();
|
||||
m_win->Refresh();
|
||||
|
||||
sim.MouseMove(m_win->ClientToScreen(wxPoint(15, 15)));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
}
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
void HtmlWindowTestCase::AppendToPage()
|
||||
{
|
||||
m_win->SetPage(TEST_MARKUP_LINK);
|
||||
m_win->AppendToPage("A new paragraph");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("link A new paragraph", m_win->ToText());
|
||||
}
|
||||
|
||||
#endif //wxUSE_HTML
|
||||
|
Reference in New Issue
Block a user