From d07fd8b021ee185cc0e7bdc439cc8a282f78d824 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Fri, 8 Jul 2011 13:11:17 +0000 Subject: [PATCH] Add tests for url and history support git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68188 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/controls/webtest.cpp | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/controls/webtest.cpp b/tests/controls/webtest.cpp index 9ac8303318..f3b6266817 100644 --- a/tests/controls/webtest.cpp +++ b/tests/controls/webtest.cpp @@ -35,9 +35,13 @@ public: private: CPPUNIT_TEST_SUITE( WebTestCase ); CPPUNIT_TEST( Title ); + CPPUNIT_TEST( Url ); + CPPUNIT_TEST( History ); CPPUNIT_TEST_SUITE_END(); void Title(); + void Url(); + void History(); wxWebView* m_browser; @@ -74,4 +78,41 @@ void WebTestCase::Title() CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle()); } +void WebTestCase::Url() +{ + CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentURL()); + + m_browser->LoadUrl("about:blank"); + wxYield(); + CPPUNIT_ASSERT_EQUAL("about:blank", m_browser->GetCurrentURL()); +} + +void WebTestCase::History() +{ + //We use about:blank to remove the need for a network connection + m_browser->LoadUrl("about:blank"); + wxYield(); + + m_browser->LoadUrl("about:blank"); + wxYield(); + + m_browser->LoadUrl("about:blank"); + wxYield(); + + CPPUNIT_ASSERT(m_browser->CanGoBack()); + CPPUNIT_ASSERT(!m_browser->CanGoForward()); + + m_browser->GoBack(); + + CPPUNIT_ASSERT(m_browser->CanGoBack()); + CPPUNIT_ASSERT(m_browser->CanGoForward()); + + m_browser->GoBack(); + m_browser->GoBack(); + + //We should now be at the start of the history + CPPUNIT_ASSERT(!m_browser->CanGoBack()); + CPPUNIT_ASSERT(m_browser->CanGoForward()); +} + #endif //wxUSE_WEB -- 2.47.2