Last of the leftover files... that didn't include the API change.

This commit is contained in:
gagan%netscape.com 1999-11-03 09:33:03 +00:00
Родитель 39c882802c
Коммит 88d7ec557d
4 изменённых файлов: 132 добавлений и 131 удалений

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

@ -238,7 +238,7 @@ main(int argc, char* argv[])
// Create the socket transport...
nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, nsnull, &transport);
rv = sts->CreateTransport(hostName, port, nsnull, hostName, &transport);
// This stuff is used to test the output stream
#if 0

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

@ -157,7 +157,7 @@ main(int argc, char* argv[])
nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, nsnull, &transport);
rv = sts->CreateTransport(hostName, port, nsnull, hostName, &transport);
if (NS_SUCCEEDED(rv)) {
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer);

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

@ -277,7 +277,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
// Create a socket transport...
NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = sts->CreateTransport(aHostName, aPort, nsnull, &mTransport);
rv = sts->CreateTransport(aHostName, aPort, nsnull, aHostName, &mTransport);
}

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

@ -18,7 +18,7 @@
/*
A test file to check default URL parsing.
-Gagan Saksena 03/25/99
-Gagan Saksena 03/25/99
*/
#include <stdio.h>
@ -33,58 +33,58 @@
// Define CIDs...
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kStdURLCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kStdURLCID, NS_STANDARDURL_CID);
int writeout(const char* i_pURL, PRBool bUseStd =PR_TRUE)
{
if (i_pURL)
{
cout << "Analyzing " << i_pURL << endl;
cout << "Analyzing " << i_pURL << endl;
nsCOMPtr<nsIURI> pURL;
nsCOMPtr<nsIURI> pURL;
nsresult result = NS_OK;
if (bUseStd)
{
nsIURI* url;
result = nsComponentManager::CreateInstance(kStdURLCID, nsnull,
nsCOMTypeInfo<nsIURI>::GetIID(), (void**)&url);
if (NS_FAILED(result))
{
cout << "CreateInstance failed" << endl;
return result;
}
pURL = url;
pURL->SetSpec((char*)i_pURL);
}
else
{
NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &result);
if (NS_FAILED(result))
{
cout << "Service failed!" << endl;
return result;
}
if (bUseStd)
{
nsIURI* url;
result = nsComponentManager::CreateInstance(kStdURLCID, nsnull,
nsCOMTypeInfo<nsIURI>::GetIID(), (void**)&url);
if (NS_FAILED(result))
{
cout << "CreateInstance failed" << endl;
return result;
}
pURL = url;
pURL->SetSpec((char*)i_pURL);
}
else
{
NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &result);
if (NS_FAILED(result))
{
cout << "Service failed!" << endl;
return result;
}
result = pService->NewURI(i_pURL, nsnull, getter_AddRefs(pURL));
}
if (NS_SUCCEEDED(result))
{
nsXPIDLCString temp;
PRInt32 port;
pURL->GetScheme(getter_Copies(temp));
cout << "Got " << (temp ? (const char*)temp : "") << ',';
pURL->GetPreHost(getter_Copies(temp));
cout << (temp ? (const char*)temp : "") << ',';
pURL->GetHost(getter_Copies(temp));
cout << (temp ? (const char*)temp : "") << ',';
pURL->GetPort(&port);
cout << port << ',';
pURL->GetPath(getter_Copies(temp));
cout << (temp ? (const char*)temp : "") << endl;
} else {
cout << "Can not create URL" << endl;
}
result = pService->NewURI(i_pURL, nsnull, getter_AddRefs(pURL));
}
if (NS_SUCCEEDED(result))
{
nsXPIDLCString temp;
PRInt32 port;
pURL->GetScheme(getter_Copies(temp));
cout << "Got " << (temp ? (const char*)temp : "") << ',';
pURL->GetPreHost(getter_Copies(temp));
cout << (temp ? (const char*)temp : "") << ',';
pURL->GetHost(getter_Copies(temp));
cout << (temp ? (const char*)temp : "") << ',';
pURL->GetPort(&port);
cout << port << ',';
pURL->GetPath(getter_Copies(temp));
cout << (temp ? (const char*)temp : "") << endl;
} else {
cout << "Can not create URL" << endl;
}
return NS_OK;
}
return -1;
@ -94,79 +94,79 @@ int writeout(const char* i_pURL, PRBool bUseStd =PR_TRUE)
nsresult testURL(const char* i_pURL, PRBool bUseStd=PR_TRUE)
{
if (i_pURL)
return writeout(i_pURL, bUseStd);
if (i_pURL)
return writeout(i_pURL, bUseStd);
/*
If you add a test case then make sure you also add the expected
result in the resultset as well.
*/
/*
If you add a test case then make sure you also add the expected
result in the resultset as well.
*/
const int tests = 12;
const char* url[tests] =
{
"http://username:password@hostname.com:80/pathname/./more/stuff/../path",
"username@host:8080/path",
"http://gagan/",
"scheme:host/netlib",
"", //empty string
"mailbox:///foo", // No host specified path should be /foo
"scheme:user@hostname.edu:80/pathname", //this is always http:user and not user:pass
"http://username:password@hostname:80/pathname",
"resource:/pathname",
"ftp://uname%here.com:pwd@there.com/aPath/a.html",
"http://www.inf.bme.hu?foo=bar",
"http://test.com/aPath/a.html#/1/2"
};
{
"http://username:password@hostname.com:80/pathname/./more/stuff/../path",
"username@host:8080/path",
"http://gagan/",
"scheme:host/netlib",
"", //empty string
"mailbox:///foo", // No host specified path should be /foo
"scheme:user@hostname.edu:80/pathname", //this is always http:user and not user:pass
"http://username:password@hostname:80/pathname",
"resource:/pathname",
"ftp://uname%here.com:pwd@there.com/aPath/a.html",
"http://www.inf.bme.hu?foo=bar",
"http://test.com/aPath/a.html#/1/2"
};
const char* resultset[tests] =
{
"http,username:password,hostname.com,80,/pathname/more/path",
",username,host,8080,/path",
"http,,gagan,-1,/",
"scheme,,host,-1,/netlib",
",,,-1,/",
"mailbox,,,-1,/foo",
"scheme,user,hostname.edu,80,/pathname",
"http,username:password,hostname,80,/pathname",
"resource,,,-1,/pathname",
"ftp,uname%here.com:pwd,there.com,-1,/aPath/a.html",
"http,,www.inf.bme.hu,-1,/?foo=bar",
"http,,test.com,-1,/aPath/a.html#/1/2"
};
const char* resultset[tests] =
{
"http,username:password,hostname.com,80,/pathname/more/path",
",username,host,8080,/path",
"http,,gagan,-1,/",
"scheme,,host,-1,/netlib",
",,,-1,/",
"mailbox,,,-1,/foo",
"scheme,user,hostname.edu,80,/pathname",
"http,username:password,hostname,80,/pathname",
"resource,,,-1,/pathname",
"ftp,uname%here.com:pwd,there.com,-1,/aPath/a.html",
"http,,www.inf.bme.hu,-1,/?foo=bar",
"http,,test.com,-1,/aPath/a.html#/1/2"
};
// These tests will fail to create a URI from NS_NewURI calls...
// because of a missing scheme: in front. This set assumes
// an only working http handler is available. When we switch on mail these
// These tests will fail to create a URI from NS_NewURI calls...
// because of a missing scheme: in front. This set assumes
// an only working http handler is available. When we switch on mail these
// results will change!
PRBool failWithURI[tests] =
{
PR_FALSE,
PR_TRUE,
PR_FALSE,
PR_TRUE,
PR_TRUE,
PR_FALSE, // we now have mailbox:
PR_TRUE,
PR_FALSE,
PR_FALSE,
PR_FALSE,
PRBool failWithURI[tests] =
{
PR_FALSE,
PR_TRUE,
PR_FALSE,
PR_TRUE,
PR_TRUE,
PR_FALSE, // we now have mailbox:
PR_TRUE,
PR_FALSE,
PR_FALSE,
PR_FALSE,
PR_FALSE
};
nsresult stat;
for (int i = 0; i< tests; ++i)
{
cout << "--------------------" << endl;
if (!bUseStd)
cout << "Should" << (failWithURI[i] ? " not " : " ")
<< "create URL" << endl;
stat = writeout(url[i], bUseStd);
if (NS_FAILED(stat))
return stat;
if (bUseStd || !failWithURI[i])
cout << "Expect " << resultset[i] << endl << endl;
}
return 0;
};
nsresult stat;
for (int i = 0; i< tests; ++i)
{
cout << "--------------------" << endl;
if (!bUseStd)
cout << "Should" << (failWithURI[i] ? " not " : " ")
<< "create URL" << endl;
stat = writeout(url[i], bUseStd);
if (NS_FAILED(stat))
return stat;
if (bUseStd || !failWithURI[i])
cout << "Expect " << resultset[i] << endl << endl;
}
return 0;
}
int makeAbsTest(const char* i_BaseURI, const char* relativePortion)
@ -176,14 +176,14 @@ int makeAbsTest(const char* i_BaseURI, const char* relativePortion)
nsIURI* baseURL;
nsresult status = nsComponentManager::CreateInstance(kStdURLCID, nsnull,
nsCOMTypeInfo<nsIURI>::GetIID(), (void**)&baseURL);
if (NS_FAILED(status))
{
cout << "CreateInstance failed" << endl;
return status;
}
status = baseURL->SetSpec((char*)i_BaseURI);
nsresult status = nsComponentManager::CreateInstance(kStdURLCID, nsnull,
nsCOMTypeInfo<nsIURI>::GetIID(), (void**)&baseURL);
if (NS_FAILED(status))
{
cout << "CreateInstance failed" << endl;
return status;
}
status = baseURL->SetSpec((char*)i_BaseURI);
if (NS_FAILED(status)) return status;
nsCOMPtr<nsIURI> url;
@ -290,6 +290,7 @@ int doMakeAbsTest(const char* i_URL = 0, const char* i_relativePortion=0)
{ "g/h/../H?http://foo#bar", "http://a/b/c/g/H?http://foo#bar" },
{ "g/h/../H;baz?http://foo", "http://a/b/c/g/H;baz?http://foo" },
{ "g/h/../H;baz?http://foo#bar", "http://a/b/c/g/H;baz?http://foo#bar" },
{ "g/h/../H;baz?C:\\temp", "http://a/b/c/g/H;baz?C:\\temp" },
};
const int numTests = sizeof(tests) / sizeof(tests[0]);
@ -330,23 +331,23 @@ int main(int argc, char **argv)
}
result = NS_AutoregisterComponents();
if (NS_FAILED(result)) return result;
if (NS_FAILED(result)) return result;
cout << "------------------" << endl << endl; // end of all messages from register components...
cout << "------------------" << endl << endl; // end of all messages from register components...
PRBool bStdTest= PR_FALSE;
PRBool bTestAll= PR_FALSE;
PRBool bStdTest= PR_FALSE;
PRBool bTestAll= PR_FALSE;
PRBool bMakeAbs= PR_FALSE;
char* relativePath = 0;
char* url = 0;
for (int i=1; i<argc; i++) {
if (PL_strcasecmp(argv[i], "-std") == 0)
{
bStdTest = PR_TRUE;
{
bStdTest = PR_TRUE;
}
else if (PL_strcasecmp(argv[i], "-all") == 0)
{
bTestAll = PR_TRUE;
{
bTestAll = PR_TRUE;
}
else if (PL_strcasecmp(argv[i], "-abs") == 0)
{
@ -363,7 +364,7 @@ int main(int argc, char **argv)
{
url = argv[i];
}
}
}
PRTime startTime = PR_Now();
if (bMakeAbs)
{
@ -371,7 +372,7 @@ int main(int argc, char **argv)
}
else
{
rv = bTestAll ? testURL(0, bStdTest) : testURL(url, bStdTest);
rv = bTestAll ? testURL(0, bStdTest) : testURL(url, bStdTest);
}
if (bTestAll)
{