]> git.saurik.com Git - wxWidgets.git/blob - tests/html/htmlwindow.cpp
re-adding script that is needed for xcode builds
[wxWidgets.git] / tests / html / htmlwindow.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/html/htmlwindow.cpp
3 // Purpose: wxHtmlWindow tests
4 // Author: Vaclav Slavik
5 // Created: 2008-10-15
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef WX_PRECOMP
21 #include "wx/app.h"
22 #endif // WX_PRECOMP
23
24 #include "wx/html/htmlwin.h"
25
26 // ----------------------------------------------------------------------------
27 // test class
28 // ----------------------------------------------------------------------------
29
30 class HtmlWindowTestCase : public CppUnit::TestCase
31 {
32 public:
33 HtmlWindowTestCase() { }
34
35 virtual void setUp();
36 virtual void tearDown();
37
38 private:
39 CPPUNIT_TEST_SUITE( HtmlWindowTestCase );
40 CPPUNIT_TEST( SelectionToText );
41 CPPUNIT_TEST_SUITE_END();
42
43 void SelectionToText();
44
45 wxHtmlWindow *m_win;
46
47 DECLARE_NO_COPY_CLASS(HtmlWindowTestCase)
48 };
49
50 // register in the unnamed registry so that these tests are run by default
51 CPPUNIT_TEST_SUITE_REGISTRATION( HtmlWindowTestCase );
52
53 // also include in it's own registry so that these tests can be run alone
54 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HtmlWindowTestCase, "HtmlWindowTestCase" );
55
56 // ----------------------------------------------------------------------------
57 // test initialization
58 // ----------------------------------------------------------------------------
59
60 void HtmlWindowTestCase::setUp()
61 {
62 m_win = new wxHtmlWindow(wxTheApp->GetTopWindow(), wxID_ANY);
63 }
64
65 void HtmlWindowTestCase::tearDown()
66 {
67 m_win->Destroy();
68 m_win = NULL;
69 }
70
71 // ----------------------------------------------------------------------------
72 // tests themselves
73 // ----------------------------------------------------------------------------
74
75 static const char *TEST_MARKUP =
76 "<html><body>"
77 " Title<p>"
78 " A longer line<br>"
79 " and the last line."
80 "</body></html>";
81
82 static const char *TEST_PLAIN_TEXT =
83 "Title\nA longer line\nand the last line.";
84
85 void HtmlWindowTestCase::SelectionToText()
86 {
87 m_win->SetPage(TEST_MARKUP);
88 m_win->SelectAll();
89
90 CPPUNIT_ASSERT_EQUAL( TEST_PLAIN_TEXT, m_win->SelectionToText() );
91 }