2002-11-28 06:31:43 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-19 02:01:16 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2002-11-28 06:31:43 +03:00
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2002-11-28 06:31:43 +03:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* David Epstein <depstein@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"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-19 02:01:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2002-11-28 06:31:43 +03:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-19 02:01:16 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2002-11-28 06:31:43 +03:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
// nsIChannelTests.h : implementation file for nsIChannel test cases
|
|
|
|
|
|
|
|
// nsIChannelTests.cpp : implementation file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "testembed.h"
|
|
|
|
#include "nsIChannelTests.h"
|
|
|
|
#include "BrowserImpl.h"
|
|
|
|
#include "BrowserFrm.h"
|
|
|
|
#include "UrlDialog.h"
|
|
|
|
#include "ProfileMgr.h"
|
|
|
|
#include "ProfilesDlg.h"
|
|
|
|
#include "QaUtils.h"
|
|
|
|
#include "Tests.h"
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#undef THIS_FILE
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIChannelTests
|
|
|
|
|
|
|
|
CnsIChannelTests::CnsIChannelTests(nsIWebBrowser *mWebBrowser,
|
|
|
|
CBrowserImpl *mpBrowserImpl)
|
|
|
|
{
|
|
|
|
qaWebBrowser = mWebBrowser;
|
|
|
|
qaBrowserImpl = mpBrowserImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
CnsIChannelTests::~CnsIChannelTests()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-12-10 07:23:16 +03:00
|
|
|
ChannelRow ChannelTable[] = {
|
|
|
|
{"http://www.netscape.com/", "text/plain"},
|
|
|
|
{"https://www.sun.com/", "text/html"},
|
|
|
|
{"ftp://ftp.mozilla.org/", "image/gif"},
|
|
|
|
{"gopher://gopher.tc.umn.edu/", "application/vnd.mozilla.xul+xml"},
|
2002-12-16 06:48:36 +03:00
|
|
|
{"http://www.mozilla.org/projects/embedding", "text/plain"},
|
2002-12-10 07:23:16 +03:00
|
|
|
{"file://C|/Program Files", "image/jpeg"},
|
2002-12-16 06:48:36 +03:00
|
|
|
{"about:mozilla", ""},
|
2002-12-10 07:23:16 +03:00
|
|
|
{"javascript:document.write('hi')", ""},
|
|
|
|
{"data:text/plain;charset=iso-8859-7,%be%fg%be", ""},
|
2004-06-20 05:42:05 +04:00
|
|
|
{"jar:resource:///chrome/toolkit.jar!/content/global/plugins.html", ""},
|
2002-12-10 07:23:16 +03:00
|
|
|
};
|
2002-11-28 06:31:43 +03:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIChannelTests message handlers
|
|
|
|
|
|
|
|
nsIChannel * CnsIChannelTests::GetChannelObject(nsCAutoString theSpec)
|
|
|
|
{
|
|
|
|
theURI = GetURIObject(theSpec);
|
|
|
|
if (!theURI)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get URI object. Test failed.", 2);
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
|
2002-12-10 07:23:16 +03:00
|
|
|
RvTestResult(rv, "NS_NewChannel", 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. GetChannelObject Test failed.", 2);
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
return theChannel;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIURI * CnsIChannelTests::GetURIObject(nsCAutoString theSpec)
|
|
|
|
{
|
|
|
|
rv = NS_NewURI(getter_AddRefs(theURI), theSpec);
|
2002-12-10 07:23:16 +03:00
|
|
|
RvTestResult(rv, "NS_NewURI", 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
if (!theURI)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get URI object. GetURIObject Test failed.", 2);
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
// nsIURI *retVal = theURI;
|
|
|
|
// NS_ADDREF(retVal);
|
|
|
|
// return retVal;
|
|
|
|
return theURI;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::SetOriginalURITest(nsIChannel *theChannel, nsCAutoString theSpec,
|
|
|
|
PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. SetOriginalURITest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
theURI = GetURIObject(theSpec);
|
|
|
|
rv = theChannel->SetOriginalURI(theURI);
|
|
|
|
RvTestResult(rv, "SetOriginalURITest", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "SetOriginalURITest", true);
|
2002-11-29 01:39:58 +03:00
|
|
|
if (!theURI)
|
|
|
|
QAOutput("Didn't get URI object. SetOriginalURITest failed.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetOriginalURITest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. GetOriginalURITest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetOriginalURI(getter_AddRefs(theURI));
|
2002-11-29 01:39:58 +03:00
|
|
|
RvTestResult(rv, "GetOriginalURITest", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "GetOriginalURITest");
|
2002-11-28 06:31:43 +03:00
|
|
|
if (!theURI)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get URI object. GetOriginalURITest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-20 06:15:10 +04:00
|
|
|
GetTheURI(theURI);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetURITest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. GetURITest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetURI(getter_AddRefs(theURI));
|
2002-11-29 01:39:58 +03:00
|
|
|
RvTestResult(rv, "GetURITest", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "GetURITest");
|
2002-11-28 06:31:43 +03:00
|
|
|
if (!theURI)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get URI object. GetURITest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-20 06:15:10 +04:00
|
|
|
GetTheURI(theURI);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::SetOwnerTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. SetOwnerTest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-12-25 00:22:59 +03:00
|
|
|
theSupports = do_QueryInterface(qaWebBrowser);
|
|
|
|
rv = theChannel->SetOwner(theChannel);
|
2002-11-28 06:31:43 +03:00
|
|
|
RvTestResult(rv, "SetOwner", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "SetOwner");
|
2002-11-29 01:39:58 +03:00
|
|
|
if (!theSupports)
|
|
|
|
QAOutput("Didn't get nsISupports object. SetOwnerTest failed.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetOwnerTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. GetOwnerTest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetOwner(getter_AddRefs(theSupports));
|
|
|
|
RvTestResult(rv, "GetOwner", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "GetOwner");
|
2002-11-29 01:39:58 +03:00
|
|
|
if (!theSupports)
|
|
|
|
QAOutput("Didn't get nsISupports object. GetOwnerTest failed.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::SetNotificationsTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. SetNotificationsTest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
if (!qaWebBrowser)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIWebBrowser object. SetNotificationsTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
theIRequestor = do_QueryInterface(qaWebBrowser);
|
|
|
|
rv = theChannel->SetNotificationCallbacks(theIRequestor);
|
|
|
|
RvTestResult(rv, "SetNotificationCallbacks", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "SetNotificationCallbacks");
|
2002-11-29 01:39:58 +03:00
|
|
|
if (!theIRequestor)
|
|
|
|
QAOutput("Didn't get nsIInterfaceRequestor object. SetNotificationsTest failed.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetNotificationsTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get Channel object. GetNotificationsTest failed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetNotificationCallbacks(getter_AddRefs(theIRequestor));
|
|
|
|
RvTestResult(rv, "GetNotificationCallbacks", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "GetNotificationCallbacks");
|
2002-11-29 01:39:58 +03:00
|
|
|
if(!theIRequestor)
|
|
|
|
QAOutput("Didn't get nsIInterfaceRequestor object. GetNotificationsTest failed.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetSecurityInfoTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. GetSecurityInfoTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2003-02-27 04:39:35 +03:00
|
|
|
theSupports = do_QueryInterface(qaWebBrowser);
|
2002-11-29 01:39:58 +03:00
|
|
|
rv = theChannel->GetSecurityInfo(getter_AddRefs(theSupports));
|
2002-11-28 06:31:43 +03:00
|
|
|
RvTestResult(rv, "GetSecurityInfo", displayMode);
|
2002-11-29 01:39:58 +03:00
|
|
|
if (!theSupports)
|
|
|
|
QAOutput("Didn't get nsISupports object for GetSecurityInfoTest.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::SetContentTypeTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. SetContentTypeTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-29 01:39:58 +03:00
|
|
|
rv = theChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
|
2003-01-22 07:11:05 +03:00
|
|
|
RvTestResult(rv, "SetContentType", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetContentTypeTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
nsCAutoString contentType;
|
|
|
|
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. GetContentTypeTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetContentType(contentType);
|
|
|
|
RvTestResult(rv, "GetContentType", displayMode);
|
|
|
|
FormatAndPrintOutput("the content type = ", contentType, displayMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::SetContentCharsetTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
nsCAutoString charsetType;
|
|
|
|
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. SetContentCharsetTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->SetContentCharset(NS_LITERAL_CSTRING("ISO-8859-1"));
|
|
|
|
RvTestResult(rv, "SetContentCharset", displayMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetContentCharsetTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
nsCAutoString charsetType;
|
|
|
|
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. GetContentCharsetTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetContentCharset(charsetType);
|
|
|
|
RvTestResult(rv, "GetContentCharset", displayMode);
|
|
|
|
FormatAndPrintOutput("the charset type = ", charsetType, displayMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::SetContentLengthTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
PRInt32 contentLength;
|
|
|
|
|
2002-11-29 01:39:58 +03:00
|
|
|
contentLength = 10000;
|
2003-02-27 04:39:35 +03:00
|
|
|
|
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. SetContentLengthTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->SetContentLength(contentLength);
|
|
|
|
RvTestResult(rv, "SetContentLength", displayMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::GetContentLengthTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
|
|
|
PRInt32 contentLength;
|
|
|
|
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. GetContentLengthTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->GetContentLength(&contentLength);
|
|
|
|
RvTestResult(rv, "GetContentLength", displayMode);
|
|
|
|
FormatAndPrintOutput("the content length = ", contentLength, displayMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::OpenTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. OpenTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
rv = theChannel->Open(getter_AddRefs(theInputStream));
|
|
|
|
RvTestResult(rv, "OpenTest", displayMode);
|
2002-11-29 01:39:58 +03:00
|
|
|
if (!theInputStream)
|
|
|
|
QAOutput("Didn't get theInputStream object. OpenTest failed.", displayMode);
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::AsyncOpenTest(nsIChannel *theChannel, PRInt16 displayMode)
|
|
|
|
{
|
2007-07-08 11:08:56 +04:00
|
|
|
nsCOMPtr<nsIStreamListener> listener(static_cast<nsIStreamListener*>(qaBrowserImpl));
|
2003-07-25 23:06:59 +04:00
|
|
|
nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
|
2002-11-28 06:31:43 +03:00
|
|
|
qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener));
|
2003-02-27 04:39:35 +03:00
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. AsyncOpenTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
if (!listener) {
|
|
|
|
QAOutput("Didn't get the stream listener object. AsyncOpenTest failed.", displayMode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// this calls nsIStreamListener::OnDataAvailable()
|
2002-12-25 00:22:59 +03:00
|
|
|
theSupports = do_QueryInterface(theChannel);
|
|
|
|
if (!theSupports)
|
|
|
|
QAOutput("Didn't get the nsISupports object. AsyncOpen() failed.", displayMode);
|
2004-06-20 05:42:05 +04:00
|
|
|
|
|
|
|
SaveObject(theSupports);
|
2002-12-25 00:22:59 +03:00
|
|
|
|
|
|
|
rv = theChannel->AsyncOpen(listener, theSupports);
|
2002-11-28 06:31:43 +03:00
|
|
|
RvTestResult(rv, "AsyncOpen()", displayMode);
|
|
|
|
if (displayMode == 1)
|
|
|
|
RvTestResultDlg(rv, "AsyncOpen()");
|
|
|
|
}
|
|
|
|
|
2004-05-07 06:43:23 +04:00
|
|
|
void CnsIChannelTests::PostAsyncOpenTests(nsIChannel *theChannel, PRInt16 displayMode)
|
2002-12-12 05:38:49 +03:00
|
|
|
{
|
2004-06-20 05:42:05 +04:00
|
|
|
// These tests are run after the channel is opened (using AsyncOpen())
|
2004-05-07 06:43:23 +04:00
|
|
|
// To run them in TestEmbed, select Tests > asyncOpen menu and enter complete URL with protocol
|
2004-06-20 05:42:05 +04:00
|
|
|
GetOriginalURITest(theChannel, displayMode);
|
|
|
|
GetURITest(theChannel, displayMode);
|
|
|
|
SetOwnerTest(theChannel, displayMode);
|
|
|
|
GetOwnerTest(theChannel, displayMode);
|
|
|
|
SetNotificationsTest(theChannel, displayMode);
|
|
|
|
GetNotificationsTest(theChannel, displayMode);
|
2002-12-12 05:38:49 +03:00
|
|
|
GetSecurityInfoTest(theChannel, displayMode);
|
|
|
|
SetContentTypeTest(theChannel, displayMode);
|
|
|
|
GetContentTypeTest(theChannel, displayMode);
|
|
|
|
SetContentCharsetTest(theChannel, displayMode);
|
|
|
|
GetContentCharsetTest(theChannel, displayMode);
|
|
|
|
SetContentLengthTest(theChannel, displayMode);
|
|
|
|
GetContentLengthTest(theChannel, displayMode);
|
|
|
|
}
|
2002-11-28 06:31:43 +03:00
|
|
|
|
|
|
|
void CnsIChannelTests::OnStartTests(UINT nMenuID)
|
|
|
|
{
|
2002-12-30 11:52:13 +03:00
|
|
|
theSpec = "http://www.netscape.com";
|
2002-11-28 06:31:43 +03:00
|
|
|
theChannel = GetChannelObject(theSpec);
|
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. Test not run.", 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch(nMenuID)
|
|
|
|
{
|
|
|
|
case ID_INTERFACES_NSICHANNEL_RUNALLTESTS :
|
|
|
|
RunAllTests();
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_SETORIGINALURI :
|
|
|
|
SetOriginalURITest(theChannel, theSpec, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETORIGINALURI :
|
|
|
|
GetOriginalURITest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETURI :
|
|
|
|
GetURITest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_SETOWNER :
|
|
|
|
SetOwnerTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETOWNER :
|
|
|
|
GetOwnerTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_SETNOTIFICATIONS :
|
|
|
|
SetNotificationsTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETNOTIFICATIONS :
|
|
|
|
GetNotificationsTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETSECURITYINFO :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
GetSecurityInfoTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_SETCONTENTTYPE :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
SetContentTypeTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETCONTENTTYPE :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
GetContentTypeTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_SETCONTENTCHARSET :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
SetContentCharsetTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETCONTENTCHARSET :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
GetContentCharsetTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_SETCONTENTLENGTH :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
SetContentLengthTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_GETCONTENTLENGTH :
|
2002-12-07 03:55:15 +03:00
|
|
|
AsyncOpenTest(theChannel, 1);
|
2002-11-28 06:31:43 +03:00
|
|
|
GetContentLengthTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_OPEN :
|
|
|
|
OpenTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSICHANNEL_ASYNCOPEN :
|
|
|
|
AsyncOpenTest(theChannel, 2);
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CnsIChannelTests::RunAllTests()
|
|
|
|
{
|
2002-12-10 07:23:16 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<10; i++)
|
2002-11-28 06:31:43 +03:00
|
|
|
{
|
2002-12-10 07:23:16 +03:00
|
|
|
theSpec = ChannelTable[i].theURL;
|
|
|
|
theChannel = GetChannelObject(theSpec);
|
|
|
|
if (!theChannel)
|
|
|
|
{
|
|
|
|
QAOutput("Didn't get nsIChannel object. RunAllTests not run.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-07 06:43:23 +04:00
|
|
|
QAOutput("\nStart nsIChannel Tests: ");
|
2002-12-10 07:23:16 +03:00
|
|
|
SetOriginalURITest(theChannel, theSpec, 1);
|
|
|
|
GetOriginalURITest(theChannel, 1);
|
|
|
|
GetURITest(theChannel, 1);
|
|
|
|
SetOwnerTest(theChannel, 1);
|
|
|
|
GetOwnerTest(theChannel, 1);
|
|
|
|
SetNotificationsTest(theChannel, 1);
|
|
|
|
GetNotificationsTest(theChannel, 1);
|
|
|
|
AsyncOpenTest(theChannel, 1);
|
2004-06-20 05:42:05 +04:00
|
|
|
// PostAsyncOpenTests() called from nsIRequestObserver::OnStartRequest (in BrowserImpl.cpp)
|
2002-12-10 07:23:16 +03:00
|
|
|
QAOutput("\n");
|
2002-11-28 06:31:43 +03:00
|
|
|
}
|
|
|
|
}
|