some code cleanup. more test coverage for uri loads and reloads.

a=asa for QA checkins that are not part of the default builds


git-svn-id: svn://10.0.0.236/trunk@122306 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
depstein%netscape.com 2002-05-30 01:11:53 +00:00
parent 43963340a9
commit feb7b283b1
3 changed files with 46 additions and 66 deletions

View File

@ -22,11 +22,8 @@
* Contributor(s):
* David Epstein <depstein@netscape.com>
* Ashish Bhatt <ashishbhatt@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@ -55,9 +52,7 @@
CnsIObserServ::CnsIObserServ()
{
mRefCnt = 1 ;
}
@ -83,13 +78,10 @@ ObserverElement ObserverTable[] = {
void CnsIObserServ::OnStartTests(UINT nMenuID)
{
// Calls all or indivdual test cases on the basis of the
// option selected from menu.
switch(nMenuID)
{
case ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS :
@ -97,12 +89,12 @@ void CnsIObserServ::OnStartTests(UINT nMenuID)
break;
case ID_INTERFACES_NSIOBSERVERSERVICE_ADDOBSERVERS :
AddObserversTest();
AddObserversTest(2);
break;
case ID_INTERFACES_NSIOBSERVERSERVICE_ENUMERATEOBSERVERS :
QAOutput("nsIObserverService::EnumerateObserversTest(). Adding observers first", 2);
AddObserversTest();
QAOutput("Adding observers first", 2);
AddObserversTest(1);
EnumerateObserversTest();
break;
@ -111,8 +103,8 @@ void CnsIObserServ::OnStartTests(UINT nMenuID)
break;
case ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS :
QAOutput("nsIObserverService::RemoveObserversTest(). Adding observers first.", 2);
AddObserversTest();
QAOutput("Adding observers first.", 2);
AddObserversTest(1);
RemoveObserversTest();
break;
@ -124,13 +116,13 @@ void CnsIObserServ::OnStartTests(UINT nMenuID)
void CnsIObserServ::RunAllTests()
{
AddObserversTest();
AddObserversTest(2);
EnumerateObserversTest();
NotifyObserversTest();
RemoveObserversTest();
}
void CnsIObserServ::AddObserversTest()
void CnsIObserServ::AddObserversTest(int displayType)
{
int i;
@ -143,19 +135,13 @@ void CnsIObserServ::AddObserversTest()
return;
}
observerService->AddObserver(this, "text/xml", PR_TRUE);
for (i=0; i<10; i++)
{
rv = observerService->AddObserver(this, ObserverTable[i].theTopic,
ObserverTable[i].theOwnsWeak);
ObserverTable[i].theOwnsWeak);
FormatAndPrintOutput("The observer to be added = ", ObserverTable[i].theTopic, 1);
RvTestResult(rv, "AddObservers() test", 2);
RvTestResult(rv, "AddObservers() test", displayType);
}
}
void CnsIObserServ::RemoveObserversTest()
@ -171,7 +157,6 @@ void CnsIObserServ::RemoveObserversTest()
return;
}
for (i=0; i<10; i++)
{
rv = observerService->RemoveObserver(this, ObserverTable[i].theTopic);
@ -217,7 +202,6 @@ void CnsIObserServ::EnumerateObserversTest()
rv = observerService->EnumerateObservers(ObserverTable[i].theTopic,
getter_AddRefs(simpleEnum));
RvTestResult(rv, "EnumerateObserversTest() test", 2);
if (!simpleEnum)
{
@ -239,7 +223,6 @@ void CnsIObserServ::EnumerateObserversTest()
// compare 'this' with observer object
// if (this ==(CnsIObserServ *)observer)
if( this == NS_REINTERPRET_CAST(CnsIObserServ*,NS_REINTERPRET_CAST(void*, observer.get())))
{
QAOutput("observers match. Test passes.");
@ -255,7 +238,6 @@ void CnsIObserServ::EnumerateObserversTest()
NS_IMPL_THREADSAFE_ISUPPORTS2(CnsIObserServ, nsIObserver, nsISupportsWeakReference);
NS_IMETHODIMP CnsIObserServ::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
{
nsresult rv = NS_OK;

View File

@ -22,11 +22,8 @@
* Contributor(s):
* David Epstein <depstein@netscape.com>
* Ashish Bhatt <ashishbhatt@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@ -65,9 +62,8 @@ public:
//nsCOMPtr<nsIWebBrowser> qaWebBrowser ;
void RunAllTests();
void AddObserversTest();
void AddObserversTest(int);
void RemoveObserversTest();
void NotifyObserversTest();
void EnumerateObserversTest();

View File

@ -85,7 +85,7 @@ NavElement UrlTable[] = {
{"https://www.yahoo.com/", nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE},
{"https://www.cisco.com", nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY},
{"about:plugins", nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE},
{"javascript:", nsIWebNavigation::LOAD_FLAGS_NONE},
// {"javascript:", nsIWebNavigation::LOAD_FLAGS_NONE},
{"file://C|/Program Files", nsIWebNavigation::LOAD_FLAGS_NONE}
};
@ -169,7 +169,7 @@ void CNsIWebNav::RunAllTests()
QAOutput("Run a few LoadURI() tests.", 2);
LoadUriandReload(11);
LoadUriandReload(10);
// Stop() tests
@ -189,39 +189,41 @@ void CNsIWebNav::RunAllTests()
void CNsIWebNav::LoadUriandReload(int URItotal)
{
int i=0;
int i=0, j=0;
// LoadURI() & reload tests
QAOutput("Run a few LoadURI() and Reload() tests.", 2);
for (i=0; i < URItotal; i++)
{
LoadUriTest(UrlTable[i].theUri, UrlTable[i].theFlag);
switch (i)
{
case 0:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE);
break;
case 1:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE);
break;
case 2:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY);
break;
// simulate shift-reload
case 3:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY);
break;
case 4:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE);
break;
case 5:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE);
break;
}
}
for (j=0; j < 9; j++)
{
for (i=0; i < URItotal; i++)
{
LoadUriTest(UrlTable[i].theUri, UrlTable[j].theFlag);
switch (i)
{
case 0:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE);
break;
case 1:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE);
break;
case 2:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY);
break;
// simulate shift-reload
case 3:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY);
break;
case 4:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE);
break;
case 5:
ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE);
break;
}
}
}
}
// ***********************************************************************
@ -314,7 +316,7 @@ void CNsIWebNav::ReloadTest(const unsigned long theFlag)
char theTotalString[500];
char theFlagName[200];
switch(theFlag)
switch(theFlag)
{
case nsIWebNavigation::LOAD_FLAGS_NONE:
strcpy(theFlagName, "LOAD_FLAGS_NONE");
@ -350,7 +352,7 @@ void CNsIWebNav::ReloadTest(const unsigned long theFlag)
rv = qaWebNav->Reload(theFlag);
sprintf(theTotalString, "%s%s%s%s", "Reload(): ", " w/ ", theFlagName, " test");
RvTestResult(rv, theTotalString, 2);
RvTestResult(rv, theTotalString, 1);
}
void CNsIWebNav::StopUriTest(char *theUrl, const unsigned long theFlag)
@ -428,5 +430,5 @@ void CNsIWebNav::GetSHTest()
rv = theSessionHistory->GetCount(&numOfElements);
RvTestResult(rv, "nsISHistory::GetCount() for nsIWebNav test", 1);
FormatAndPrintOutput("the sHist entry count = ", numOfElements, 2);
FormatAndPrintOutput("the sHist entry count = ", numOfElements, 2);
}