]> git.saurik.com Git - wxWidgets.git/commitdiff
Add tests for url and history support
authorSteve Lamerton <steve.lamerton@gmail.com>
Fri, 8 Jul 2011 13:11:17 +0000 (13:11 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Fri, 8 Jul 2011 13:11:17 +0000 (13:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68188 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/controls/webtest.cpp

index 9ac8303318c3101a49ba6faabf63c5190ffac0a2..f3b62668171473c762822158b8ec868e5bb0182a 100644 (file)
@@ -35,9 +35,13 @@ public:
 private:
     CPPUNIT_TEST_SUITE( WebTestCase );
         CPPUNIT_TEST( Title );
 private:
     CPPUNIT_TEST_SUITE( WebTestCase );
         CPPUNIT_TEST( Title );
+        CPPUNIT_TEST( Url );
+        CPPUNIT_TEST( History );
     CPPUNIT_TEST_SUITE_END();
 
     void Title();
     CPPUNIT_TEST_SUITE_END();
 
     void Title();
+    void Url();
+    void History();
 
     wxWebView* m_browser;
 
 
     wxWebView* m_browser;
 
@@ -74,4 +78,41 @@ void WebTestCase::Title()
     CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle());
 }
 
     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
 #endif //wxUSE_WEB