]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/webtest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/webtest.cpp
3 // Purpose: wxWebView unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2011 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
22 #include "testableframe.h"
23 #include "wx/uiaction.h"
24 #include "wx/webview.h"
25 #include "asserthelper.h"
27 class WebTestCase
: public CppUnit::TestCase
36 CPPUNIT_TEST_SUITE( WebTestCase
);
37 CPPUNIT_TEST( Title
);
39 CPPUNIT_TEST( History
);
40 CPPUNIT_TEST_SUITE_END();
48 DECLARE_NO_COPY_CLASS(WebTestCase
)
51 // register in the unnamed registry so that these tests are run by default
52 CPPUNIT_TEST_SUITE_REGISTRATION( WebTestCase
);
54 // also include in its own registry so that these tests can be run alone
55 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( WebTestCase
, "WebTestCase" );
57 void WebTestCase::setUp()
59 m_browser
= wxWebView::New(wxTheApp
->GetTopWindow(), wxID_ANY
);
62 void WebTestCase::tearDown()
67 void WebTestCase::Title()
69 CPPUNIT_ASSERT_EQUAL("", m_browser
->GetCurrentTitle());
71 //Test title after loading raw html
72 m_browser
->SetPage("<html><title>Title</title></html>", "");
73 CPPUNIT_ASSERT_EQUAL("Title", m_browser
->GetCurrentTitle());
75 //Test title after loading a url, we yield to let events process
76 m_browser
->LoadUrl("about:blank");
78 CPPUNIT_ASSERT_EQUAL("", m_browser
->GetCurrentTitle());
81 void WebTestCase::Url()
83 CPPUNIT_ASSERT_EQUAL("", m_browser
->GetCurrentURL());
85 m_browser
->LoadUrl("about:blank");
87 CPPUNIT_ASSERT_EQUAL("about:blank", m_browser
->GetCurrentURL());
90 void WebTestCase::History()
92 //We use about:blank to remove the need for a network connection
93 m_browser
->LoadUrl("about:blank");
96 m_browser
->LoadUrl("about:blank");
99 m_browser
->LoadUrl("about:blank");
102 CPPUNIT_ASSERT(m_browser
->CanGoBack());
103 CPPUNIT_ASSERT(!m_browser
->CanGoForward());
107 CPPUNIT_ASSERT(m_browser
->CanGoBack());
108 CPPUNIT_ASSERT(m_browser
->CanGoForward());
113 //We should now be at the start of the history
114 CPPUNIT_ASSERT(!m_browser
->CanGoBack());
115 CPPUNIT_ASSERT(m_browser
->CanGoForward());