From 3ce14be7b96f53f07158442db34d3b8b2a7762c3 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Fri, 8 Jul 2011 14:46:51 +0000 Subject: [PATCH] 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 --- tests/controls/webtest.cpp | 45 ++++++++++++++------------------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/tests/controls/webtest.cpp b/tests/controls/webtest.cpp index aba7736346..23663a2232 100644 --- a/tests/controls/webtest.cpp +++ b/tests/controls/webtest.cpp @@ -48,6 +48,7 @@ private: void HistoryEnable(); void HistoryClear(); void HistoryList(); + void LoadUrl(const wxString& url, int times = 1); wxWebView* m_browser; @@ -70,6 +71,15 @@ void WebTestCase::tearDown() 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() { CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle()); @@ -79,8 +89,7 @@ void WebTestCase::Title() CPPUNIT_ASSERT_EQUAL("Title", m_browser->GetCurrentTitle()); //Test title after loading a url, we yield to let events process - m_browser->LoadUrl("about:blank"); - wxYield(); + LoadUrl("about:blank"); CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentTitle()); } @@ -88,22 +97,14 @@ void WebTestCase::Url() { CPPUNIT_ASSERT_EQUAL("", m_browser->GetCurrentURL()); - m_browser->LoadUrl("about:blank"); - wxYield(); + LoadUrl("about:blank"); 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(); + LoadUrl("about:blank", 3); CPPUNIT_ASSERT(m_browser->CanGoBack()); CPPUNIT_ASSERT(!m_browser->CanGoForward()); @@ -123,16 +124,13 @@ void WebTestCase::History() void WebTestCase::HistoryEnable() { - m_browser->LoadUrl("about:blank"); - wxYield(); - + LoadUrl("about:blank"); m_browser->EnableHistory(false); CPPUNIT_ASSERT(!m_browser->CanGoForward()); CPPUNIT_ASSERT(!m_browser->CanGoBack()); - m_browser->LoadUrl("about:blank"); - wxYield(); + LoadUrl("about:blank"); CPPUNIT_ASSERT(!m_browser->CanGoForward()); CPPUNIT_ASSERT(!m_browser->CanGoBack()); @@ -140,11 +138,7 @@ void WebTestCase::HistoryEnable() void WebTestCase::HistoryClear() { - m_browser->LoadUrl("about:blank"); - wxYield(); - - m_browser->LoadUrl("about:blank"); - wxYield(); + LoadUrl("about:blank", 2); //Now we are in the 'middle' of the history m_browser->GoBack(); @@ -160,12 +154,7 @@ void WebTestCase::HistoryClear() void WebTestCase::HistoryList() { - m_browser->LoadUrl("about:blank"); - wxYield(); - - m_browser->LoadUrl("about:blank"); - wxYield(); - + LoadUrl("about:blank", 2); m_browser->GoBack(); CPPUNIT_ASSERT_EQUAL(1, m_browser->GetBackwardHistory().size()); -- 2.45.2