]>
Commit | Line | Data |
---|---|---|
2dad08ec SL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/controls/webtest.cpp | |
3 | // Purpose: wxWebView unit test | |
4 | // Author: Steven Lamerton | |
5 | // Created: 2011-07-08 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2011 Steven Lamerton | |
8 | /////////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #include "testprec.h" | |
11 | ||
12 | #if wxUSE_WEB | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/app.h" | |
20 | #endif // WX_PRECOMP | |
21 | ||
22 | #include "testableframe.h" | |
23 | #include "wx/uiaction.h" | |
24 | #include "wx/webview.h" | |
25 | #include "asserthelper.h" | |
26 | ||
27 | class WebTestCase : public CppUnit::TestCase | |
28 | { | |
29 | public: | |
30 | WebTestCase() { } | |
31 | ||
32 | void setUp(); | |
33 | void tearDown(); | |
34 | ||
35 | private: | |
36 | CPPUNIT_TEST_SUITE( WebTestCase ); | |
6a2ef29f | 37 | CPPUNIT_TEST( Title ); |
2dad08ec SL |
38 | CPPUNIT_TEST_SUITE_END(); |
39 | ||
6a2ef29f SL |
40 | void Title(); |
41 | ||
2dad08ec SL |
42 | wxWebView* m_browser; |
43 | ||
44 | DECLARE_NO_COPY_CLASS(WebTestCase) | |
45 | }; | |
46 | ||
47 | // register in the unnamed registry so that these tests are run by default | |
48 | CPPUNIT_TEST_SUITE_REGISTRATION( WebTestCase ); | |
49 | ||
50 | // also include in its own registry so that these tests can be run alone | |
51 | CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( WebTestCase, "WebTestCase" ); | |
52 | ||
53 | void WebTestCase::setUp() | |
54 | { | |
6a2ef29f | 55 | m_browser = wxWebView::New(wxTheApp->GetTopWindow(), wxID_ANY); |
2dad08ec SL |
56 | } |
57 | ||
58 | void WebTestCase::tearDown() | |
59 | { | |
60 | wxDELETE(m_browser); | |
61 | } | |
62 | ||
6a2ef29f SL |
63 | void WebTestCase::Title() |
64 | { | |
65 | CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle()); | |
66 | ||
67 | //Test title after loading raw html | |
68 | m_browser->SetPage("<html><title>Title</title></html>", ""); | |
69 | CPPUNIT_ASSERT_EQUAL("Title", m_browser->GetCurrentTitle()); | |
70 | ||
71 | //Test title after loading a url, we yield to let events process | |
72 | m_browser->LoadUrl("about:blank"); | |
73 | wxYield(); | |
74 | CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle()); | |
75 | } | |
76 | ||
2dad08ec | 77 | #endif //wxUSE_WEB |