Added 'data:' url to nsIRequest tests. Now invoking simple string compare for input/output URL matching. GetTheURI() now returns the string.

a=asa for QA checkins that are not part of the default builds
This commit is contained in:
depstein%netscape.com 2002-09-21 01:51:36 +00:00
Родитель 3bfe9a680d
Коммит 54f8f432ff
4 изменённых файлов: 33 добавлений и 19 удалений

Просмотреть файл

@ -309,7 +309,7 @@ nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *webBrowser)
return (theDOMWindow); return (theDOMWindow);
} }
void GetTheUri(nsIURI *theUri, int displayMethod) nsCAutoString GetTheUri(nsIURI *theUri, int displayMethod)
{ {
nsresult rv; nsresult rv;
nsCAutoString uriString; nsCAutoString uriString;
@ -317,6 +317,8 @@ void GetTheUri(nsIURI *theUri, int displayMethod)
rv = theUri->GetSpec(uriString); rv = theUri->GetSpec(uriString);
RvTestResult(rv, "nsIURI::GetSpec() test", displayMethod); RvTestResult(rv, "nsIURI::GetSpec() test", displayMethod);
FormatAndPrintOutput("the uri = ", uriString, displayMethod); FormatAndPrintOutput("the uri = ", uriString, displayMethod);
return uriString;
} }
// used for web progress listener in BrowserImplWebPrgrsLstnr.cpp // used for web progress listener in BrowserImplWebPrgrsLstnr.cpp

Просмотреть файл

@ -65,7 +65,7 @@ extern void FormatAndPrintOutput(const char *, PRUint32, int);
extern void RequestName(nsIRequest *, nsCString &, int displayMethod=1); extern void RequestName(nsIRequest *, nsCString &, int displayMethod=1);
extern void WebProgDOMWindowTest(nsIWebProgress *, const char *,int displayMethod=1); extern void WebProgDOMWindowTest(nsIWebProgress *, const char *,int displayMethod=1);
extern nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *); extern nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *);
extern void GetTheUri(nsIURI *theUri, int displayMethod=1); extern nsCAutoString GetTheUri(nsIURI *theUri, int displayMethod=1);
extern void onStateChangeString(char *, char *, nsCString, PRUint32, int displayMethod=1); extern void onStateChangeString(char *, char *, nsCString, PRUint32, int displayMethod=1);
extern nsresult rv; extern nsresult rv;

Просмотреть файл

@ -531,8 +531,11 @@ void CTests::OnTestsAddUriContentListenerByOpenUri()
if (myDialog.DoModal() == IDOK) if (myDialog.DoModal() == IDOK)
{ {
NS_NewURI(getter_AddRefs(theURI), myDialog.m_urlfield); rv = NS_NewURI(getter_AddRefs(theURI), myDialog.m_urlfield);
NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull); RvTestResult(rv, "For OpenURI(): NS_NewURI() test", 1);
GetTheUri(theURI, 1);
rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
RvTestResult(rv, "For OpenURI(): NS_NewChannel() test", 1);
} }
else { else {
QAOutput("Didn't get a url. test failed", 2); QAOutput("Didn't get a url. test failed", 2);

Просмотреть файл

@ -81,24 +81,26 @@ CNsIRequest::~CNsIRequest()
// setLoadGroup & getLoadGroup tests respectively. // setLoadGroup & getLoadGroup tests respectively.
Element ReqTable[] = { Element ReqTable[] = {
{"http://www.netscape.com", 1, 1, 0, 0, 0, 1, 1}, {"http://www.netscape.com/", 1, 1, 0, 0, 0, 1, 1},
{"http://www.yahoo.com", 0, 0, 1, 1, 0, 0, 0}, {"http://www.yahoo.com/", 0, 0, 1, 1, 0, 0, 0},
{"http://www.cisco.com", 0, 0, 0, 0, 1, 0, 0}, {"http://www.cisco.com/", 0, 0, 0, 0, 1, 0, 0},
{"http://www.sun.com", 0, 0, 0, 0, 0, 1, 1}, {"http://www.sun.com/", 0, 0, 0, 0, 0, 1, 1},
{"http://www.intel.com", 1, 1, 1, 0, 0, 0, 0}, {"http://www.intel.com/", 1, 1, 1, 0, 0, 0, 0},
{"http://www.aol.com", 0, 1, 0, 0, 0, 1, 1}, {"http://www.aol.com/", 0, 1, 0, 0, 0, 1, 1},
{"https://www.yahoo.com", 1, 1, 1, 1, 0, 1, 1}, {"https://www.yahoo.com/", 1, 1, 1, 1, 0, 1, 1},
{"file://C|/Program Files", 1, 1, 1, 1, 0, 1, 1}, {"data:text/plain;charset=iso-8859-7,%be%fg%be",
{"ftp://ftp.netscape.com", 1, 1, 1, 1, 0, 1, 1}, 1, 1, 1, 1, 0, 1, 1},
{"ftp://ftp.mozilla.org", 0, 0, 0, 0, 1, 0, 0}, {"file://C|/Program Files/", 1, 1, 1, 1, 0, 1, 1},
{"ftp://ftp.netscape.com/", 1, 1, 1, 1, 0, 1, 1},
{"ftp://ftp.mozilla.org/", 0, 0, 0, 0, 1, 0, 0},
}; };
void CNsIRequest::OnStartTests(UINT nMenuID) void CNsIRequest::OnStartTests(UINT nMenuID)
{ {
if (nMenuID == ID_INTERFACES_NSIREQUEST_RUNALLTESTS) if (nMenuID == ID_INTERFACES_NSIREQUEST_RUNALLTESTS)
RunAllTests(8); RunAllTests(9);
else else
RunIndividualTests(nMenuID, 8); RunIndividualTests(nMenuID, 9);
} }
void CNsIRequest::RunIndividualTests(UINT nMenuID, int reqTotal) void CNsIRequest::RunIndividualTests(UINT nMenuID, int reqTotal)
@ -216,12 +218,12 @@ void CNsIRequest::RunAllTests(int reqTotal)
nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup) nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup)
{ {
nsCAutoString theSpec; nsCAutoString theSpec, retURI;
nsCOMPtr<nsIURI> theURI; nsCOMPtr<nsIURI> theURI;
nsCOMPtr<nsIChannel> theChannel; nsCOMPtr<nsIChannel> theChannel;
theSpec = ReqTable[i].theUrl; theSpec = ReqTable[i].theUrl;
FormatAndPrintOutput("the uri spec = ", theSpec, 2); FormatAndPrintOutput("the input uri = ", theSpec, 2);
rv = NS_NewURI(getter_AddRefs(theURI), theSpec); rv = NS_NewURI(getter_AddRefs(theURI), theSpec);
@ -230,8 +232,15 @@ nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup)
QAOutput("We didn't get the URI. Test failed.", 1); QAOutput("We didn't get the URI. Test failed.", 1);
return NULL; return NULL;
} }
else {
retURI = GetTheUri(theURI, 1);
// simple string compare to see if input & output URLs match
if (strcmp(ReqTable[i].theUrl, retURI.get()) == 0)
QAOutput("The URIs MATCH. Compare test passed.", 1);
else else
QAOutput("The URIs didn't MATCH. Compare test failed.", 1);
RvTestResult(rv, "NS_NewURI", 1); RvTestResult(rv, "NS_NewURI", 1);
}
rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup);
if (!theChannel) if (!theChannel)