Factor out url loading logic into a separate function to reduce repetition.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68191 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1a693ec8d9
commit
3ce14be7b9
@ -48,6 +48,7 @@ private:
|
|||||||
void HistoryEnable();
|
void HistoryEnable();
|
||||||
void HistoryClear();
|
void HistoryClear();
|
||||||
void HistoryList();
|
void HistoryList();
|
||||||
|
void LoadUrl(const wxString& url, int times = 1);
|
||||||
|
|
||||||
wxWebView* m_browser;
|
wxWebView* m_browser;
|
||||||
|
|
||||||
@ -70,6 +71,15 @@ void WebTestCase::tearDown()
|
|||||||
wxDELETE(m_browser);
|
wxDELETE(m_browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebTestCase::LoadUrl(const wxString& url, int times)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < times; i++)
|
||||||
|
{
|
||||||
|
m_browser->LoadUrl(url);
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebTestCase::Title()
|
void WebTestCase::Title()
|
||||||
{
|
{
|
||||||
CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle());
|
CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle());
|
||||||
@ -79,8 +89,7 @@ void WebTestCase::Title()
|
|||||||
CPPUNIT_ASSERT_EQUAL("Title", m_browser->GetCurrentTitle());
|
CPPUNIT_ASSERT_EQUAL("Title", m_browser->GetCurrentTitle());
|
||||||
|
|
||||||
//Test title after loading a url, we yield to let events process
|
//Test title after loading a url, we yield to let events process
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank");
|
||||||
wxYield();
|
|
||||||
CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle());
|
CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,22 +97,14 @@ void WebTestCase::Url()
|
|||||||
{
|
{
|
||||||
CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentURL());
|
CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentURL());
|
||||||
|
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank");
|
||||||
wxYield();
|
|
||||||
CPPUNIT_ASSERT_EQUAL("about:blank", m_browser->GetCurrentURL());
|
CPPUNIT_ASSERT_EQUAL("about:blank", m_browser->GetCurrentURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebTestCase::History()
|
void WebTestCase::History()
|
||||||
{
|
{
|
||||||
//We use about:blank to remove the need for a network connection
|
//We use about:blank to remove the need for a network connection
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank", 3);
|
||||||
wxYield();
|
|
||||||
|
|
||||||
m_browser->LoadUrl("about:blank");
|
|
||||||
wxYield();
|
|
||||||
|
|
||||||
m_browser->LoadUrl("about:blank");
|
|
||||||
wxYield();
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT(m_browser->CanGoBack());
|
CPPUNIT_ASSERT(m_browser->CanGoBack());
|
||||||
CPPUNIT_ASSERT(!m_browser->CanGoForward());
|
CPPUNIT_ASSERT(!m_browser->CanGoForward());
|
||||||
@ -123,16 +124,13 @@ void WebTestCase::History()
|
|||||||
|
|
||||||
void WebTestCase::HistoryEnable()
|
void WebTestCase::HistoryEnable()
|
||||||
{
|
{
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank");
|
||||||
wxYield();
|
|
||||||
|
|
||||||
m_browser->EnableHistory(false);
|
m_browser->EnableHistory(false);
|
||||||
|
|
||||||
CPPUNIT_ASSERT(!m_browser->CanGoForward());
|
CPPUNIT_ASSERT(!m_browser->CanGoForward());
|
||||||
CPPUNIT_ASSERT(!m_browser->CanGoBack());
|
CPPUNIT_ASSERT(!m_browser->CanGoBack());
|
||||||
|
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank");
|
||||||
wxYield();
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT(!m_browser->CanGoForward());
|
CPPUNIT_ASSERT(!m_browser->CanGoForward());
|
||||||
CPPUNIT_ASSERT(!m_browser->CanGoBack());
|
CPPUNIT_ASSERT(!m_browser->CanGoBack());
|
||||||
@ -140,11 +138,7 @@ void WebTestCase::HistoryEnable()
|
|||||||
|
|
||||||
void WebTestCase::HistoryClear()
|
void WebTestCase::HistoryClear()
|
||||||
{
|
{
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank", 2);
|
||||||
wxYield();
|
|
||||||
|
|
||||||
m_browser->LoadUrl("about:blank");
|
|
||||||
wxYield();
|
|
||||||
|
|
||||||
//Now we are in the 'middle' of the history
|
//Now we are in the 'middle' of the history
|
||||||
m_browser->GoBack();
|
m_browser->GoBack();
|
||||||
@ -160,12 +154,7 @@ void WebTestCase::HistoryClear()
|
|||||||
|
|
||||||
void WebTestCase::HistoryList()
|
void WebTestCase::HistoryList()
|
||||||
{
|
{
|
||||||
m_browser->LoadUrl("about:blank");
|
LoadUrl("about:blank", 2);
|
||||||
wxYield();
|
|
||||||
|
|
||||||
m_browser->LoadUrl("about:blank");
|
|
||||||
wxYield();
|
|
||||||
|
|
||||||
m_browser->GoBack();
|
m_browser->GoBack();
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(1, m_browser->GetBackwardHistory().size());
|
CPPUNIT_ASSERT_EQUAL(1, m_browser->GetBackwardHistory().size());
|
||||||
|
Loading…
Reference in New Issue
Block a user