refactored code, changes to object error checking handling. not part of the build.

This commit is contained in:
depstein%netscape.com 2002-11-28 22:39:58 +00:00
Родитель 1433aa3313
Коммит 9e5d6d7d78
6 изменённых файлов: 98 добавлений и 94 удалений

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

@ -463,7 +463,9 @@ NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility)
}
//*****************************************************************************
// CBrowserImpl::nsIStreamListener (used for nsIRequest & UriContentListener)
// CBrowserImpl::nsIStreamListener
// (used for nsIRequest, nsIChannel, and UriContentListener)
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnDataAvailable(nsIRequest *request,
nsISupports *ctxt, nsIInputStream *input,
@ -497,12 +499,17 @@ NS_IMETHODIMP CBrowserImpl::OnDataAvailable(nsIRequest *request,
return NS_OK;
}
//*****************************************************************************
// CBrowserImpl::nsIRequestObserver
// (used for nsIRequest, nsIChannel, and UriContentListener)
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnStartRequest(nsIRequest *request,
nsISupports *ctxt)
{
nsCString stringMsg;
QAOutput("##### BEGIN: nsIStreamListener::OnStartRequest() #####");
QAOutput("##### BEGIN: nsIRequestObserver::OnStartRequest() #####");
RequestName(request, stringMsg, 1);
if (!ctxt)
@ -518,7 +525,7 @@ NS_IMETHODIMP CBrowserImpl::OnStopRequest(nsIRequest *request,
{
nsCString stringMsg;
RvTestResult(rv, "nsIStreamListener::OnStopRequest rv input", 1);
RvTestResult(rv, "nsIRequestObserver::OnStopRequest rv input", 1);
RequestName(request, stringMsg, 1);
if (!ctxt)
@ -534,7 +541,8 @@ NS_IMETHODIMP CBrowserImpl::OnStopRequest(nsIRequest *request,
}
//*****************************************************************************
// Tool Tip Listener
// CBrowserImpl::Tool Tip Listener
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
const PRUnichar *aTipText)
@ -554,7 +562,8 @@ NS_IMETHODIMP CBrowserImpl::OnHideTooltip()
//*****************************************************************************
// UriContentListener
// CBrowserImpl::UriContentListener
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
{

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

@ -54,7 +54,7 @@ void CnsICmdParams::GetValueTypeTest(const char *aCommand, const char *stateType
if (cmdParamObj) {
FormatAndPrintOutput("The input command name = ", aCommand, displayMode);
FormatAndPrintOutput("The input state type = ", stateType, displayMode);
cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser);
cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser, displayMode);
if (!cmdMgrObj) {
QAOutput("We didn't get nsICommandMgr object. Test fails.", displayMode);
return;
@ -79,7 +79,7 @@ void CnsICmdParams::GetBooleanValueTest(const char *aCommand, const char *stateT
if (cmdParamObj) {
FormatAndPrintOutput("The input command name = ", aCommand, displayMode);
FormatAndPrintOutput("The input state type = ", stateType, displayMode);
cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser);
cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser, displayMode);
if (!cmdMgrObj) {
QAOutput("We didn't get nsICommandMgr object. Test fails.", displayMode);
return;
@ -153,7 +153,7 @@ void CnsICmdParams::GetCStringValueTest(const char *aCommand, const char *stateT
if (cmdParamObj) {
FormatAndPrintOutput("The input command name = ", aCommand, displayMode);
FormatAndPrintOutput("The input state type = ", stateType, displayMode);
cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser);
cmdMgrObj = CnsICommandMgr::GetCommandMgrObject(qaWebBrowser, displayMode);
if (!cmdMgrObj) {
QAOutput("We didn't get nsICommandMgr object. Test fails.", displayMode);
return;

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

@ -126,11 +126,11 @@ CommandTest CommandTable[] = {
{"cmd_cutOrDelete", "", "state_enabled", PR_FALSE, 50000, 5.798, "hello", "HELLO"},
};
nsICommandManager * CnsICommandMgr::GetCommandMgrObject(nsIWebBrowser *aWebBrowser)
nsICommandManager * CnsICommandMgr::GetCommandMgrObject(nsIWebBrowser *aWebBrowser, PRInt16 displayMethod)
{
nsCOMPtr<nsIWebBrowser> wb(aWebBrowser);
nsCOMPtr<nsICommandManager> cmdMgrObj = do_GetInterface(wb, &rv);
RvTestResult(rv, "GetCommandMgrObject() test", 1);
RvTestResult(rv, "GetCommandMgrObject() test", displayMethod);
if (!cmdMgrObj) {
QAOutput("Didn't get nsICommandManager object.");
return nsnull;
@ -138,7 +138,7 @@ nsICommandManager * CnsICommandMgr::GetCommandMgrObject(nsIWebBrowser *aWebBrows
return cmdMgrObj;
}
nsICommandManager * CnsICommandMgr::GetCommandMgrWithContractIDObject()
nsICommandManager * CnsICommandMgr::GetCommandMgrWithContractIDObject(PRInt16 displayMethod)
{
nsCOMPtr<nsICommandManager> cmdMgrObj = do_CreateInstance(NS_COMMAND_MANAGER_CONTRACTID, &rv);
RvTestResult(rv, "GetCommandMgrWithContractIDObject() test", 1);
@ -149,74 +149,72 @@ nsICommandManager * CnsICommandMgr::GetCommandMgrWithContractIDObject()
return cmdMgrObj;
}
void CnsICommandMgr::IsCommandSupportedTest(const char *aCommandName, int displayMethod)
void CnsICommandMgr::IsCommandSupportedTest(const char *aCommandName, PRInt16 displayMethod)
{
PRBool isSupported;
FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser, displayMethod);
if (!cmdMgrObj) {
QAOutput("Didn't get nsICommandManager object.");
QAOutput("Didn't get nsICommandManager object. Test failed.");
return;
}
cmdMgrObj = GetCommandMgrObject(qaWebBrowser);
rv = cmdMgrObj->IsCommandSupported(aCommandName, nsnull, &isSupported);
RvTestResult(rv, "IsCommandSupported() test", displayMethod);
if (displayMethod == 1)
RvTestResultDlg(rv, "IsCommandSupported() test", true);
FormatAndPrintOutput("isSupported boolean = ", isSupported, displayMethod);
}
void CnsICommandMgr::IsCommandEnabledTest(const char *aCommandName, int displayMethod)
void CnsICommandMgr::IsCommandEnabledTest(const char *aCommandName, PRInt16 displayMethod)
{
PRBool isEnabled;
FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser, displayMethod);
if (!cmdMgrObj) {
QAOutput("Didn't get nsICommandManager object.");
return;
}
rv = cmdMgrObj->IsCommandEnabled(aCommandName, nsnull, &isEnabled);
RvTestResult(rv, "IsCommandEnabled() test", displayMethod);
if (displayMethod == 1)
RvTestResultDlg(rv, "IsCommandEnabled() test");
FormatAndPrintOutput("isEnabled boolean = ", isEnabled, displayMethod);
}
void CnsICommandMgr::GetCommandStateTest(const char *aCommandName, int displayMethod)
void CnsICommandMgr::GetCommandStateTest(const char *aCommandName, PRInt16 displayMethod)
{
PRBool enabled = PR_FALSE;
FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser, displayMethod);
cmdParamObj = CnsICmdParams::GetCommandParamObject();
if (!cmdMgrObj) {
QAOutput("Didn't get nsICommandManager object.");
return;
}
else if (!cmdParamObj) {
QAOutput("Didn't get nsICommandParams object.");
return;
}
else {
rv = cmdMgrObj->GetCommandState(aCommandName, nsnull, cmdParamObj);
RvTestResult(rv, "GetCommandState() test", displayMethod);
}
rv = cmdMgrObj->GetCommandState(aCommandName, nsnull, cmdParamObj);
RvTestResult(rv, "GetCommandState() test", displayMethod);
if (displayMethod == 1)
RvTestResultDlg(rv, "GetCommandState() test");
if (!cmdParamObj)
QAOutput("Didn't get nsICommandParams object for GetCommandStateTest.");
}
void CnsICommandMgr::DoCommandTest(const char *aCommandName,
const char *doCommandState,
int displayMethod)
PRInt16 displayMethod)
{
nsCAutoString value;
FormatAndPrintOutput("the Command input = ", aCommandName, displayMethod);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser);
cmdMgrObj = GetCommandMgrObject(qaWebBrowser, displayMethod);
cmdParamObj = CnsICmdParams::GetCommandParamObject();
if (!cmdMgrObj) {
QAOutput("Didn't get nsICommandManager object. Tests fail");
return;
}
if (!cmdMgrObj) {
QAOutput("Didn't get nsICommandParam object. Test fail");
return;
}
if (strcmp(doCommandState, "state_attribute") == 0)
{
@ -227,10 +225,16 @@ void CnsICommandMgr::DoCommandTest(const char *aCommandName,
value = "Helvetica, Ariel, san-serif";
else
value = "left";
cmdParamObj->SetCStringValue("state_attribute", value.get());
if (cmdParamObj)
cmdParamObj->SetCStringValue("state_attribute", value.get());
else
QAOutput("Didn't get nsICommandParam object for nsICommandMgr test.");
}
rv = cmdMgrObj->DoCommand(aCommandName, cmdParamObj, nsnull);
RvTestResult(rv, "DoCommand() test", displayMethod);
if (displayMethod == 1)
RvTestResultDlg(rv, "DoCommand() test");
}
@ -276,7 +280,6 @@ void CnsICommandMgr::RunAllTests()
DoCommandTest(CommandTable[i].mCmdName,
CommandTable[i].mDoCmdState, 1);
}
QAOutput("Tests completed.", 2);
}

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

@ -69,12 +69,12 @@ public:
nsCOMPtr<nsICommandParams> cmdParamObj;
// test methods
public:
static nsICommandManager * GetCommandMgrObject(nsIWebBrowser *aWebBrowser);
static nsICommandManager * GetCommandMgrWithContractIDObject();
void IsCommandSupportedTest(const char *, int);
void IsCommandEnabledTest(const char *, int);
void GetCommandStateTest(const char *, int);
void DoCommandTest(const char *, const char *, int);
static nsICommandManager * GetCommandMgrObject(nsIWebBrowser *aWebBrowser, PRInt16);
static nsICommandManager * GetCommandMgrWithContractIDObject(PRInt16);
void IsCommandSupportedTest(const char *, PRInt16);
void IsCommandEnabledTest(const char *, PRInt16);
void GetCommandStateTest(const char *, PRInt16);
void DoCommandTest(const char *, const char *, PRInt16);
void OnStartTests(UINT nMenuID);
void RunAllTests();
// Operations

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

@ -85,40 +85,45 @@ void CnsIEditSession::InitTest(PRInt16 displayMode)
{
editingSession = GetEditSessionObject();
domWindow = GetTheDOMWindow(qaWebBrowser);
if (domWindow && editingSession) {
if (editingSession) {
rv = editingSession->Init(domWindow);
RvTestResult(rv, "Init() test", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "Init() test", true);
if (!domWindow)
QAOutput("Didn't get domWindow object for InitTest() test. Test failed.", displayMode);
}
else
QAOutput("Didn't get object(s) for InitTest() test. Test failed.", 1);
QAOutput("Didn't get editingSession object for InitTest() test. Test failed.", displayMode);
}
void CnsIEditSession::MakeWinEditTest(PRBool afterUriLoad, PRInt16 displayMode)
{
editingSession = GetEditSessionObject();
domWindow = GetTheDOMWindow(qaWebBrowser);
if (domWindow && editingSession) {
// aEditorType (2nd param) is crashing with null entry. bug 174151
if (editingSession) {
rv= editingSession->MakeWindowEditable(domWindow, "text", afterUriLoad);
RvTestResult(rv, "MakeWindowEditable() test", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "MakeWindowEditable() test");
if (!domWindow)
QAOutput("Didn't get domWindow object for MakeWindowEditable() test. Test failed.", displayMode);
}
else
QAOutput("Didn't get object(s) for MakeWindowEditable() test. Test failed.", 1);
QAOutput("Didn't get editingSession object for MakeWindowEditable() test. Test failed.", 1);
}
void CnsIEditSession::WinIsEditTest(PRBool outIsEditable, PRInt16 displayMode)
{
editingSession = GetEditSessionObject();
domWindow = GetTheDOMWindow(qaWebBrowser);
if (domWindow && editingSession) {
if (editingSession) {
rv = editingSession->WindowIsEditable(domWindow, &outIsEditable);
RvTestResult(rv, "WindowIsEditable() test", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "WindowIsEditable() test");
if (!domWindow)
QAOutput("Didn't get domWindow object for WindowIsEditable() test. Test failed.", displayMode);
FormatAndPrintOutput("the outIsEditable boolean = ", outIsEditable, displayMode);
}
else
@ -131,11 +136,14 @@ void CnsIEditSession::GetEditorWinTest(PRInt16 displayMode)
// nsIEditor *theEditor = nsnull;
editingSession = GetEditSessionObject();
domWindow = GetTheDOMWindow(qaWebBrowser);
if (domWindow && editingSession) {
if (editingSession) {
rv = editingSession->GetEditorForWindow(domWindow, getter_AddRefs(theEditor));
RvTestResult(rv, "GetEditorForWindow() test", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetEditorForWindow() test");
if (!domWindow)
QAOutput("Didn't get domWindow object for GetEditorForWindow() test. Test failed.", displayMode);
if (!theEditor)
QAOutput("Didn't get the Editor object.");
}
@ -147,11 +155,13 @@ void CnsIEditSession::SetEditorWinTest(PRInt16 displayMode)
{
editingSession = GetEditSessionObject();
domWindow = GetTheDOMWindow(qaWebBrowser);
if (domWindow && editingSession) {
if (editingSession) {
rv = editingSession->SetupEditorOnWindow(domWindow);
RvTestResult(rv, "SetupEditorOnWindow() test", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "SetupEditorOnWindow() test");
if (!domWindow)
QAOutput("Didn't get domWindow object for SetupEditorOnWindow() test. Test failed.", displayMode);
}
else
QAOutput("Didn't get object(s) for SetEditorWinTest() test. Test failed.", 1);
@ -161,11 +171,13 @@ void CnsIEditSession::TearEditorWinTest(PRInt16 displayMode)
{
editingSession = GetEditSessionObject();
domWindow = GetTheDOMWindow(qaWebBrowser);
if (domWindow && editingSession) {
if (editingSession) {
rv = editingSession->TearDownEditorOnWindow(domWindow);
RvTestResult(rv, "TearDownEditorOnWindow() test", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "TearDownEditorOnWindow() test");
if (!domWindow)
QAOutput("Didn't get domWindow object for TearDownEditorOnWindow() test. Test failed.", displayMode);
}
else
QAOutput("Didn't get object(s) for TearEditorWinTest() test. Test failed.", 1);

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

@ -112,70 +112,61 @@ void CnsIChannelTests::SetOriginalURITest(nsIChannel *theChannel, nsCAutoString
PRInt16 displayMode)
{
theURI = GetURIObject(theSpec);
if (!theURI)
{
QAOutput("Didn't get URI object. SetOriginalURITest failed.", displayMode);
return;
}
rv = theChannel->SetOriginalURI(theURI);
RvTestResult(rv, "SetOriginalURITest", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "SetOriginalURITest", true);
if (!theURI)
QAOutput("Didn't get URI object. SetOriginalURITest failed.", displayMode);
}
void CnsIChannelTests::GetOriginalURITest(nsIChannel *theChannel, PRInt16 displayMode)
{
rv = theChannel->GetOriginalURI(getter_AddRefs(theURI));
RvTestResult(rv, "GetOriginalURITest", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetOriginalURITest");
if (!theURI)
{
QAOutput("Didn't get URI object. GetOriginalURITest failed.", displayMode);
return;
}
RvTestResult(rv, "GetOriginalURITest", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetOriginalURITest");
GetTheUri(theURI);
}
void CnsIChannelTests::GetURITest(nsIChannel *theChannel, PRInt16 displayMode)
{
rv = theChannel->GetURI(getter_AddRefs(theURI));
RvTestResult(rv, "GetURITest", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetURITest");
if (!theURI)
{
QAOutput("Didn't get URI object. GetURITest failed.", displayMode);
return;
}
RvTestResult(rv, "GetURITest", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetURITest");
GetTheUri(theURI);
}
void CnsIChannelTests::SetOwnerTest(nsIChannel *theChannel, PRInt16 displayMode)
{
theSupports = do_QueryInterface(theChannel);
if (!theSupports)
{
QAOutput("Didn't get nsISupports object. SetOwnerTest failed.", displayMode);
return;
}
theChannel->SetOwner(theSupports);
rv = theChannel->SetOwner(theSupports);
RvTestResult(rv, "SetOwner", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "SetOwner");
if (!theSupports)
QAOutput("Didn't get nsISupports object. SetOwnerTest failed.", displayMode);
}
void CnsIChannelTests::GetOwnerTest(nsIChannel *theChannel, PRInt16 displayMode)
{
rv = theChannel->GetOwner(getter_AddRefs(theSupports));
if (!theSupports)
{
QAOutput("Didn't get nsISupports object. GetOwnerTest failed.", displayMode);
return;
}
RvTestResult(rv, "GetOwner", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetOwner");
if (!theSupports)
QAOutput("Didn't get nsISupports object. GetOwnerTest failed.", displayMode);
}
void CnsIChannelTests::SetNotificationsTest(nsIChannel *theChannel, PRInt16 displayMode)
@ -186,52 +177,44 @@ void CnsIChannelTests::SetNotificationsTest(nsIChannel *theChannel, PRInt16 disp
return;
}
theIRequestor = do_QueryInterface(qaWebBrowser);
if (!theIRequestor)
{
QAOutput("Didn't get nsIInterfaceRequestor object. SetNotificationsTest failed.", displayMode);
return;
}
rv = theChannel->SetNotificationCallbacks(theIRequestor);
RvTestResult(rv, "SetNotificationCallbacks", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "SetNotificationCallbacks");
if (!theIRequestor)
QAOutput("Didn't get nsIInterfaceRequestor object. SetNotificationsTest failed.", displayMode);
}
void CnsIChannelTests::GetNotificationsTest(nsIChannel *theChannel, PRInt16 displayMode)
{
rv = theChannel->GetNotificationCallbacks(getter_AddRefs(theIRequestor));
if (!theIRequestor)
{
QAOutput("Didn't get nsIInterfaceRequestor object. GetNotificationsTest failed.", displayMode);
return;
}
RvTestResult(rv, "GetNotificationCallbacks", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetNotificationCallbacks");
if(!theIRequestor)
QAOutput("Didn't get nsIInterfaceRequestor object. GetNotificationsTest failed.", displayMode);
}
void CnsIChannelTests::GetSecurityInfoTest(nsIChannel *theChannel, PRInt16 displayMode)
{
// theSupports = do_QueryInterface(theChannel);
theSupports = do_QueryInterface(theChannel);
if (!theChannel)
{
QAOutput("Didn't get nsIChannel object. GetSecurityInfoTest failed.", displayMode);
return;
}
rv = theChannel->GetSecurityInfo(getter_AddRefs(theSupports));
if (!theSupports)
{
QAOutput("Didn't get nsISupports object. GetSecurityInfoTest failed.", displayMode);
return;
}
rv = theChannel->GetSecurityInfo(getter_AddRefs(theSupports));
RvTestResult(rv, "GetSecurityInfo", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "GetSecurityInfo");
if (!theSupports)
QAOutput("Didn't get nsISupports object for GetSecurityInfoTest.", displayMode);
}
void CnsIChannelTests::SetContentTypeTest(nsIChannel *theChannel, PRInt16 displayMode)
{
rv = theChannel->SetContentType(NS_LITERAL_CSTRING("text/html"));
rv = theChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
RvTestResult(rv, "SetContentType", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "SetContentType");
@ -273,7 +256,7 @@ void CnsIChannelTests::SetContentLengthTest(nsIChannel *theChannel, PRInt16 disp
{
PRInt32 contentLength;
contentLength = 100;
contentLength = 10000;
rv = theChannel->SetContentLength(contentLength);
RvTestResult(rv, "SetContentLength", displayMode);
if (displayMode == 1)
@ -294,14 +277,11 @@ void CnsIChannelTests::GetContentLengthTest(nsIChannel *theChannel, PRInt16 disp
void CnsIChannelTests::OpenTest(nsIChannel *theChannel, PRInt16 displayMode)
{
rv = theChannel->Open(getter_AddRefs(theInputStream));
if (!theInputStream)
{
QAOutput("Didn't get theInputStream object. OpenTest failed.", displayMode);
return;
}
RvTestResult(rv, "OpenTest", displayMode);
if (displayMode == 1)
RvTestResultDlg(rv, "OpenTest");
if (!theInputStream)
QAOutput("Didn't get theInputStream object. OpenTest failed.", displayMode);
}
void CnsIChannelTests::AsyncOpenTest(nsIChannel *theChannel, PRInt16 displayMode)