Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
CnsIChannelTests Class Reference

#include <nsichanneltests.h>

Collaboration diagram for CnsIChannelTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CnsIChannelTests (nsIWebBrowser *mWebBrowser, CBrowserImpl *mpBrowserImpl)
nsIChannelGetChannelObject (nsCAutoString)
nsIURIGetURIObject (nsCAutoString)
void SetOriginalURITest (nsIChannel *, nsCAutoString, PRInt16)
void GetOriginalURITest (nsIChannel *, PRInt16)
void GetURITest (nsIChannel *, PRInt16)
void SetOwnerTest (nsIChannel *, PRInt16)
void GetOwnerTest (nsIChannel *, PRInt16)
void SetNotificationsTest (nsIChannel *, PRInt16)
void GetNotificationsTest (nsIChannel *, PRInt16)
void GetSecurityInfoTest (nsIChannel *, PRInt16)
void SetContentTypeTest (nsIChannel *, PRInt16)
void GetContentTypeTest (nsIChannel *, PRInt16)
void SetContentCharsetTest (nsIChannel *, PRInt16)
void GetContentCharsetTest (nsIChannel *, PRInt16)
void SetContentLengthTest (nsIChannel *, PRInt16)
void GetContentLengthTest (nsIChannel *, PRInt16)
void OpenTest (nsIChannel *, PRInt16)
void AsyncOpenTest (nsIChannel *, PRInt16)
void PostAsyncOpenTests (nsIChannel *, PRInt16)
void OnStartTests (UINT nMenuID)
void RunAllTests ()
virtual ~CnsIChannelTests ()

Private Attributes

CBrowserImplqaBrowserImpl
nsCOMPtr< nsIWebBrowserqaWebBrowser
nsCOMPtr< nsIChanneltheChannel
nsCOMPtr< nsIURItheURI
nsCOMPtr< nsISupports > theSupports
nsCOMPtr< nsIInterfaceRequestortheIRequestor
nsCOMPtr< nsIInputStreamtheInputStream
nsCAutoString theSpec

Detailed Description

Definition at line 56 of file nsichanneltests.h.


Constructor & Destructor Documentation

CnsIChannelTests::CnsIChannelTests ( nsIWebBrowser mWebBrowser,
CBrowserImpl mpBrowserImpl 
)

Definition at line 64 of file nsichanneltests.cpp.

{
       qaWebBrowser = mWebBrowser;
       qaBrowserImpl = mpBrowserImpl;
}

Definition at line 71 of file nsichanneltests.cpp.

{
}

Member Function Documentation

void CnsIChannelTests::AsyncOpenTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 354 of file nsichanneltests.cpp.

{
       nsCOMPtr<nsIStreamListener> listener(NS_STATIC_CAST(nsIStreamListener*, qaBrowserImpl));
       nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
       qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener));
       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. AsyncOpenTest failed.", displayMode);
          return;
       }
       if (!listener) {
          QAOutput("Didn't get the stream listener object. AsyncOpenTest failed.", displayMode);
          return;
       }
       // this calls nsIStreamListener::OnDataAvailable()
       theSupports = do_QueryInterface(theChannel);
       if (!theSupports)
          QAOutput("Didn't get the nsISupports object. AsyncOpen() failed.", displayMode);

       SaveObject(theSupports);

       rv = theChannel->AsyncOpen(listener, theSupports);
       RvTestResult(rv, "AsyncOpen()", displayMode);
       if (displayMode == 1)
              RvTestResultDlg(rv, "AsyncOpen()");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 91 of file nsichanneltests.cpp.

{
       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);
       RvTestResult(rv, "NS_NewChannel", 1);
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. GetChannelObject Test failed.", 2);
          return nsnull;
       }
       return theChannel;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetContentCharsetTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 298 of file nsichanneltests.cpp.

{
       nsCAutoString charsetType;

       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. GetContentCharsetTest failed.", displayMode);
          return;
       }
       rv = theChannel->GetContentCharset(charsetType);
       RvTestResult(rv, "GetContentCharset", displayMode);
       FormatAndPrintOutput("the charset type = ", charsetType, displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetContentLengthTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 327 of file nsichanneltests.cpp.

{
       PRInt32 contentLength;

       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. GetContentLengthTest failed.", displayMode);
          return;
       }
       rv = theChannel->GetContentLength(&contentLength);
       RvTestResult(rv, "GetContentLength", displayMode);
       FormatAndPrintOutput("the content length = ", contentLength, displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetContentTypeTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 271 of file nsichanneltests.cpp.

{
       nsCAutoString contentType;

       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. GetContentTypeTest failed.", displayMode);
          return;
       }
       rv = theChannel->GetContentType(contentType);
       RvTestResult(rv, "GetContentType", displayMode);
       FormatAndPrintOutput("the content type = ", contentType, displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetNotificationsTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 231 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. GetNotificationsTest failed.", 2);
          return;
       }
       rv = theChannel->GetNotificationCallbacks(getter_AddRefs(theIRequestor));
       RvTestResult(rv, "GetNotificationCallbacks", displayMode);
       if (displayMode == 1)
              RvTestResultDlg(rv, "GetNotificationCallbacks");
       if(!theIRequestor)
          QAOutput("Didn't get nsIInterfaceRequestor object. GetNotificationsTest failed.", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetOriginalURITest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 141 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. GetOriginalURITest failed.", 2);
          return;
       }
       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;
       }
       GetTheURI(theURI);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetOwnerTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 195 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. GetOwnerTest failed.", 2);
          return;
       }
       rv = theChannel->GetOwner(getter_AddRefs(theSupports));
       RvTestResult(rv, "GetOwner", displayMode);
       if (displayMode == 1)
              RvTestResultDlg(rv, "GetOwner");
       if (!theSupports)
          QAOutput("Didn't get nsISupports object. GetOwnerTest failed.", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetSecurityInfoTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 246 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. GetSecurityInfoTest failed.", displayMode);
          return;
       }
       theSupports = do_QueryInterface(qaWebBrowser);
       rv = theChannel->GetSecurityInfo(getter_AddRefs(theSupports)); 
       RvTestResult(rv, "GetSecurityInfo", displayMode);
       if (!theSupports)
          QAOutput("Didn't get nsISupports object for GetSecurityInfoTest.", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 109 of file nsichanneltests.cpp.

{
       rv = NS_NewURI(getter_AddRefs(theURI), theSpec);
       RvTestResult(rv, "NS_NewURI", 1);
       if (!theURI)
       {
          QAOutput("Didn't get URI object. GetURIObject Test failed.", 2);
          return nsnull;
       }
//     nsIURI *retVal = theURI;
//     NS_ADDREF(retVal);
//     return retVal;
       return theURI;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::GetURITest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 160 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. GetURITest failed.", 2);
          return;
       }
       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;
       }
       GetTheURI(theURI);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 400 of file nsichanneltests.cpp.

{
       theSpec = "http://www.netscape.com";
       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  :
                     AsyncOpenTest(theChannel, 1);
                     GetSecurityInfoTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_SETCONTENTTYPE :
                     AsyncOpenTest(theChannel, 1);
                     SetContentTypeTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_GETCONTENTTYPE :
                     AsyncOpenTest(theChannel, 1);
                     GetContentTypeTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_SETCONTENTCHARSET  :
                     AsyncOpenTest(theChannel, 1);
                     SetContentCharsetTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_GETCONTENTCHARSET :
                     AsyncOpenTest(theChannel, 1);
                     GetContentCharsetTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_SETCONTENTLENGTH :
                     AsyncOpenTest(theChannel, 1);
                     SetContentLengthTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_GETCONTENTLENGTH :
                     AsyncOpenTest(theChannel, 1);
                     GetContentLengthTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_OPEN  :
                     OpenTest(theChannel, 2);
                     break ;
              case ID_INTERFACES_NSICHANNEL_ASYNCOPEN  :
                     AsyncOpenTest(theChannel, 2);
                     break ;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::OpenTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 341 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. OpenTest failed.", displayMode);
          return;
       }
       rv =  theChannel->Open(getter_AddRefs(theInputStream));
       RvTestResult(rv, "OpenTest", displayMode);
       if (!theInputStream)
          QAOutput("Didn't get theInputStream object. OpenTest failed.", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::PostAsyncOpenTests ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 381 of file nsichanneltests.cpp.

{
       // These tests are run after the channel is opened (using AsyncOpen())
       // To run them in TestEmbed, select Tests > asyncOpen menu and enter complete URL with protocol
              GetOriginalURITest(theChannel, displayMode);
              GetURITest(theChannel, displayMode);
              SetOwnerTest(theChannel, displayMode);
              GetOwnerTest(theChannel, displayMode);
              SetNotificationsTest(theChannel, displayMode);
              GetNotificationsTest(theChannel, displayMode);
              GetSecurityInfoTest(theChannel, displayMode);
              SetContentTypeTest(theChannel, displayMode);
              GetContentTypeTest(theChannel, displayMode);
              SetContentCharsetTest(theChannel, displayMode);
              GetContentCharsetTest(theChannel, displayMode);
              SetContentLengthTest(theChannel, displayMode);
              GetContentLengthTest(theChannel, displayMode);
}

Here is the call graph for this function:

Definition at line 472 of file nsichanneltests.cpp.

{
       int i;

       for (i=0; i<10; i++)
       {
              theSpec = ChannelTable[i].theURL;
              theChannel = GetChannelObject(theSpec);
              if (!theChannel)
              {
                 QAOutput("Didn't get nsIChannel object. RunAllTests not run.", 2);
                 return;
              }
              QAOutput("\nStart nsIChannel Tests: ");
              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);
        // PostAsyncOpenTests() called from nsIRequestObserver::OnStartRequest (in BrowserImpl.cpp)
              QAOutput("\n");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::SetContentCharsetTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 285 of file nsichanneltests.cpp.

{
       nsCAutoString charsetType;

       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. SetContentCharsetTest failed.", displayMode);
          return;
       }
       rv = theChannel->SetContentCharset(NS_LITERAL_CSTRING("ISO-8859-1"));
       RvTestResult(rv, "SetContentCharset", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::SetContentLengthTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 312 of file nsichanneltests.cpp.

{
       PRInt32 contentLength;

       contentLength = 10000;

       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. SetContentLengthTest failed.", displayMode);
          return;
       }
       rv = theChannel->SetContentLength(contentLength);
       RvTestResult(rv, "SetContentLength", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::SetContentTypeTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 260 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get nsIChannel object. SetContentTypeTest failed.", displayMode);
          return;
       }
       rv = theChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
       RvTestResult(rv, "SetContentType", displayMode); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::SetNotificationsTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 210 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. SetNotificationsTest failed.", 2);
          return;
       }
       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");
       if (!theIRequestor)
          QAOutput("Didn't get nsIInterfaceRequestor object. SetNotificationsTest failed.", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::SetOriginalURITest ( nsIChannel theChannel,
nsCAutoString  theSpec,
PRInt16  displayMode 
)

Definition at line 124 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. SetOriginalURITest failed.", 2);
          return;
       }
       theURI = GetURIObject(theSpec);
       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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CnsIChannelTests::SetOwnerTest ( nsIChannel theChannel,
PRInt16  displayMode 
)

Definition at line 179 of file nsichanneltests.cpp.

{
       if (!theChannel)
       {
          QAOutput("Didn't get Channel object. SetOwnerTest failed.", 2);
          return;
       }
       theSupports = do_QueryInterface(qaWebBrowser);
       rv = theChannel->SetOwner(theChannel);
       RvTestResult(rv, "SetOwner", displayMode);
       if (displayMode == 1)
              RvTestResultDlg(rv, "SetOwner");
       if (!theSupports)
          QAOutput("Didn't get nsISupports object. SetOwnerTest failed.", displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 97 of file nsichanneltests.h.

Definition at line 98 of file nsichanneltests.h.

Definition at line 99 of file nsichanneltests.h.

Definition at line 103 of file nsichanneltests.h.

Definition at line 102 of file nsichanneltests.h.

Definition at line 104 of file nsichanneltests.h.

nsCOMPtr<nsISupports> CnsIChannelTests::theSupports [private]

Definition at line 101 of file nsichanneltests.h.

Definition at line 100 of file nsichanneltests.h.


The documentation for this class was generated from the following files: