Back to index

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

#include <nsiHistory.h>

Collaboration diagram for CNsIHistory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CNsIHistory (nsIWebNavigation *mWebNav)
virtual ~CNsIHistory ()
void GetCountTest (nsISHistory *, PRInt32 *, PRInt16)
void GetIndexTest (nsISHistory *, PRInt32 *, PRInt16)
void GetMaxLengthTest (nsISHistory *, PRInt32 *, PRInt16)
void SetMaxLengthTest (nsISHistory *, PRInt32, PRInt16)
void GetEntryAtIndexTest (nsISHistory *, nsIHistoryEntry *, PRInt32 theIndex, PRInt16)
void GetURIHistTest (nsIHistoryEntry *, PRInt16)
void GetTitleHistTest (nsIHistoryEntry *, PRInt16)
void GetIsSubFrameTest (nsIHistoryEntry *, PRInt16)
void GetSHEnumTest (nsISHistory *, nsISimpleEnumerator *, PRInt16)
void SimpleEnumTest (nsISimpleEnumerator *, PRInt16)
void PurgeHistoryTest (nsISHistory *, PRInt32, PRInt16)
void RunAllTests ()
void OnStartTests (UINT nMenuID)
void RunAllHistoryEntryTests (PRInt16)

Public Attributes

nsCOMPtr< nsIWebNavigationqaWebNav
nsCOMPtr< nsIURItheURI

Detailed Description

Definition at line 49 of file nsiHistory.h.


Constructor & Destructor Documentation

Definition at line 59 of file nsiHistory.cpp.

{
       //qaTests = mTests;
       qaWebNav = mWebNav ;
}

Definition at line 66 of file nsiHistory.cpp.

{
}

Member Function Documentation

void CNsIHistory::GetCountTest ( nsISHistory theSessionHistory,
PRInt32 numEntries,
PRInt16  displayMode 
)

Definition at line 306 of file nsiHistory.cpp.

{
    rv = theSessionHistory->GetCount(numEntries);
       if (*numEntries < 0) 
              QAOutput("numEntries for GetCount() < 0. Test failed.", 1);
       else {
              FormatAndPrintOutput("GetCount():number of entries = ", *numEntries, displayMode);
              RvTestResult(rv, "GetCount() (count attribute) test", 1);
              RvTestResultDlg(rv, "GetCount() (count attribute) test");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::GetIndexTest ( nsISHistory theSessionHistory,
PRInt32 theIndex,
PRInt16  displayMode 
)

Definition at line 319 of file nsiHistory.cpp.

{
       rv = theSessionHistory->GetIndex(theIndex);
       if (*theIndex <0) 
              QAOutput("theIndex for GetIndex() < 0. Test failed.", 1);
       else {
              FormatAndPrintOutput("GetIndex():the index = ", *theIndex, displayMode);
              RvTestResult(rv, "GetIndex() (index attribute) test", 1);
              RvTestResultDlg(rv, "GetIndex() (index attribute) test");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::GetIsSubFrameTest ( nsIHistoryEntry theHistoryEntry,
PRInt16  displayMode 
)

Definition at line 412 of file nsiHistory.cpp.

{
       PRBool isSubFrame;

       rv = theHistoryEntry->GetIsSubFrame(&isSubFrame);
       
       RvTestResult(rv, "GetIsSubFrame() (isSubFrame attribute) test", 1);
       RvTestResultDlg(rv, "GetIsSubFrame() (isSubFrame attribute) test");
       FormatAndPrintOutput("The subFrame boolean value = ", isSubFrame, displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::GetMaxLengthTest ( nsISHistory theSessionHistory,
PRInt32 theMaxLength,
PRInt16  displayMode 
)

Definition at line 344 of file nsiHistory.cpp.

{
       rv = theSessionHistory->GetMaxLength(theMaxLength);
       if (*theMaxLength<0)
              QAOutput("theMaxLength for GetMaxLength() < 0. Test failed.", 1);
       else {
              FormatAndPrintOutput("GetMaxLength():theMaxLength = ", *theMaxLength, displayMode); 
              RvTestResult(rv, "GetMaxLength() (MaxLength attribute) test", 1);
              RvTestResultDlg(rv, "GetMaxLength() (MaxLength attribute) test");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::GetTitleHistTest ( nsIHistoryEntry theHistoryEntry,
PRInt16  displayMode 
)

Definition at line 395 of file nsiHistory.cpp.

{
   nsXPIDLString theTitle;

       rv = theHistoryEntry->GetTitle(getter_Copies(theTitle));
       RvTestResult(rv, "GetTitle() (title attribute) test", 1);
       RvTestResultDlg(rv, "GetTitle() (title attribute) test");
       if (!theTitle) {
              QAOutput("theTitle for GetTitle() is blank. Test failed.", 1);
              return;
       }

       FormatAndPrintOutput("The title = ",
                        NS_ConvertUCS2toUTF8(theTitle).get(), displayMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::GetURIHistTest ( nsIHistoryEntry theHistoryEntry,
PRInt16  displayMode 
)

Definition at line 376 of file nsiHistory.cpp.

{
       rv = theHistoryEntry->GetURI(getter_AddRefs(theURI));
       RvTestResult(rv, "GetURI() (URI attribute) test", 1);
       RvTestResultDlg(rv, "GetURI() (URI attribute) test");
       if (!theURI)
              QAOutput("theURI for GetURI() invalid. Test failed.", 1);
       else
       {
              nsCAutoString uriString;
              rv = theURI->GetSpec(uriString);
              if (NS_FAILED(rv))
                     QAOutput("We didn't get the uriString.", 1);
              else
                     FormatAndPrintOutput("The SH Url = ", uriString, displayMode);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file nsiHistory.cpp.

{

       // Calls  all or indivdual test cases on the basis of the 
       // option selected from menu.
   PRInt32 numEntries = 5;
   PRInt32 theIndex;
   PRInt32 theMaxLength = 100;

   CString shString;

   nsCOMPtr<nsISHistory> theSessionHistory;
   nsCOMPtr<nsIHistoryEntry> theHistoryEntry;
   nsCOMPtr<nsISimpleEnumerator> theSimpleEnum;


   //nsCOMPtr<nsIURI> theURI;
   // do_QueryInterface
   // NS_HISTORYENTRY_CONTRACTID
   // NS_SHISTORYLISTENER_CONTRACTID

       // get Session History through web nav iface
   if (qaWebNav) {
         rv = qaWebNav->GetSessionHistory(getter_AddRefs(theSessionHistory));
         RvTestResult(rv, "GetSessionHistory() object", 1);
         RvTestResultDlg(rv, "GetSessionHistory() object", true);
   }

   if (!theSessionHistory)
   {
          QAOutput("theSessionHistory object wasn't created. No session history tests performed.", 2);
          return;
   }
   else {
          QAOutput("theSessionHistory object was created.", 1);
          theSessionHistory->GetCount(&numEntries);
   }

       theSessionHistory->GetEntryAtIndex(0, PR_FALSE, getter_AddRefs(theHistoryEntry));
       if (!theHistoryEntry)
              QAOutput("We didn't get the History Entry object.", 1);
       else 
              QAOutput("We have the History Entry object!", 1);       



       switch(nMenuID)
       {
              case ID_INTERFACES_NSISHISTORY_RUNALLTESTS :
                     QAOutput("Begin nsISHistory tests.", 1);
                     RunAllTests();
                     QAOutput("End nsISHistory tests.", 1);
                     break ;
              case ID_INTERFACES_NSISHISTORY_GETCOUNT :
                     GetCountTest(theSessionHistory, &numEntries, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_GETINDEX :
                     GetIndexTest(theSessionHistory, &theIndex, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_GETMAXLENGTH :
                     GetMaxLengthTest(theSessionHistory, &theMaxLength, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_SETMAXLENGTH :
                     SetMaxLengthTest(theSessionHistory, theMaxLength, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_GETENTRYATINDEX :
                     //GetEntryAtIndex(0, PR_FALSE, getter_AddRefs(theHistoryEntry));
                     for (theIndex = 0; theIndex < numEntries; theIndex++)
                     { 
                            FormatAndPrintOutput("the index = ", theIndex, 1); 

                            rv = theSessionHistory->GetEntryAtIndex(theIndex, PR_FALSE, getter_AddRefs(theHistoryEntry));
                            RvTestResult(rv, "GetEntryAtIndex() test", 1);
                            RvTestResultDlg(rv, "GetEntryAtIndex() test");
                            if (!theHistoryEntry)
                            {
                                   QAOutput("We didn't get the History Entry object. No more tests performed.", 1);
                                   return;
                            }
                            GetURIHistTest(theHistoryEntry, 2);
                            GetTitleHistTest(theHistoryEntry, 2);
                            GetIsSubFrameTest(theHistoryEntry, 2);
                     }      // end for loop

                     break ;
              case ID_INTERFACES_NSISHISTORY_PURGEHISTORY :
                     PurgeHistoryTest(theSessionHistory, numEntries, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_GETSHISTORYENUMERATOR :
                     //GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));

                     rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
                     RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 1);
                     RvTestResultDlg(rv, "GetSHistoryEnumerator() test");

                     if (!theSimpleEnum) {
                        QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
                        return;
                     }
                     SimpleEnumTest(theSimpleEnum, 2);
                     break ;

              case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_RUNALLTESTS :
                     RunAllHistoryEntryTests(2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETURI :
                     GetURIHistTest(theHistoryEntry, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETTITLE :
                     GetTitleHistTest(theHistoryEntry, 2);
                     break ;
              case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETISSUBFRAME :
                     GetIsSubFrameTest(theHistoryEntry, 2);
                     break ;
       }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::PurgeHistoryTest ( nsISHistory theSessionHistory,
PRInt32  numEntries,
PRInt16  displayMode 
)

Definition at line 463 of file nsiHistory.cpp.

{
   rv = theSessionHistory->PurgeHistory(numEntries);
   RvTestResult(rv, "PurgeHistory() test", 1);
   RvTestResultDlg(rv, "PurgeHistory() test");
   FormatAndPrintOutput("PurgeHistory(): num requested entries for removal = ", numEntries, 1);           
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 472 of file nsiHistory.cpp.

{
   PRInt32 numEntries = 5;
   PRInt32 theIndex;
   PRInt32 theMaxLength = 100;

   CString shString;

   nsCOMPtr<nsISHistory> theSessionHistory;
   nsCOMPtr<nsIHistoryEntry> theHistoryEntry;

       // get Session History through web nav iface
   if (qaWebNav)
              qaWebNav->GetSessionHistory( getter_AddRefs(theSessionHistory));

   if (!theSessionHistory)
   {
          QAOutput("theSessionHistory object wasn't created. No session history tests performed.", displayMode);
          return;
   }
   else
          QAOutput("theSessionHistory object was created.", 1);

       theSessionHistory->GetEntryAtIndex(0, PR_FALSE, getter_AddRefs(theHistoryEntry));
       if (!theHistoryEntry)
              QAOutput("We didn't get the History Entry object.", 1);
       else 
       {
              QAOutput("We have the History Entry object!", 1);       

                         // getEntryAtIndex() tests
              if (theMaxLength < numEntries)
              {
                     QAOutput("Setting number of entries to maximum length!", 1);
                     numEntries = theMaxLength;
              }

              for (theIndex = 0; theIndex < numEntries; theIndex++)
              { 
                     FormatAndPrintOutput("the index = ", theIndex, displayMode); 

                     //GetEntryAtIndexTest(theSessionHistory,theHistoryEntry, theIndex);

                     theSessionHistory->GetEntryAtIndex(theIndex, PR_FALSE, getter_AddRefs(theHistoryEntry));
                     if (!theHistoryEntry)
                     {
                            QAOutput("We didn't get the History Entry object. No more tests performed.", 1);
                            return;
                     }
                     // nsiHistoryEntry.idl tests       

                     // test URI attribute in nsIHistoryEntry.idl
                     GetURIHistTest(theHistoryEntry, displayMode);

                     // test title attribute in nsIHistoryEntry.idl
                     GetTitleHistTest(theHistoryEntry, displayMode);

                     // test isSubFrame attribute in nsIHistoryEntry.idl
                     GetIsSubFrameTest(theHistoryEntry, displayMode);

              }      // end for loop
       }             // end outer else
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file nsiHistory.cpp.

{
   //nsresult rv;  

   PRInt32 numEntries = 5;
   PRInt32 theIndex;
   PRInt32 theMaxLength = 100;

   CString shString;

   nsCOMPtr<nsISHistory> theSessionHistory;
   nsCOMPtr<nsIHistoryEntry> theHistoryEntry;

       // get Session History through web nav iface
   if (qaWebNav)
              qaWebNav->GetSessionHistory( getter_AddRefs(theSessionHistory));

   if (!theSessionHistory)
   {
          QAOutput("theSessionHistory object wasn't created. No session history tests performed.", 2);
          return;
   }
   else {
          QAOutput("theSessionHistory object was created.", 1);
          theSessionHistory->GetCount(&numEntries);
   }

              // test count attribute in nsISHistory.idl
   GetCountTest(theSessionHistory, &numEntries, 1);

              // test index attribute in nsISHistory.idl
   GetIndexTest(theSessionHistory, &theIndex, 1);

              // test maxLength attribute in nsISHistory.idl
   SetMaxLengthTest(theSessionHistory, theMaxLength, 1);
   GetMaxLengthTest(theSessionHistory, &theMaxLength, 1);

       QAOutput("Start nsiHistoryEntry tests.", 1); 

              // get theHistoryEntry object
       rv = theSessionHistory->GetEntryAtIndex(0, PR_FALSE, getter_AddRefs(theHistoryEntry));
       RvTestResult(rv, "GetEntryAtIndex() test", 1);
       RvTestResultDlg(rv, "GetEntryAtIndex() test");

       if (!theHistoryEntry)
              QAOutput("We didn't get the History Entry object.", 1);
       else 
       {
              QAOutput("We have the History Entry object!", 1);       

                         // getEntryAtIndex() tests
              if (theMaxLength < numEntries)
              {
                     QAOutput("Setting number of entries to maximum length!", 1);
                     numEntries = theMaxLength;
              }

              for (theIndex = 0; theIndex < numEntries; theIndex++)
              { 
                     FormatAndPrintOutput("the index = ", theIndex, 1); 

                     //GetEntryAtIndexTest(theSessionHistory,theHistoryEntry, theIndex);

                     theSessionHistory->GetEntryAtIndex(theIndex, PR_FALSE, getter_AddRefs(theHistoryEntry));
                     if (!theHistoryEntry)
                     {
                            QAOutput("We didn't get the History Entry object. No more tests performed.", 1);
                            return;
                     }
                     // nsiHistoryEntry.idl tests       

                     // test URI attribute in nsIHistoryEntry.idl
                     GetURIHistTest(theHistoryEntry, 1);

                     // test title attribute in nsIHistoryEntry.idl
                     GetTitleHistTest(theHistoryEntry, 1);

                     // test isSubFrame attribute in nsIHistoryEntry.idl
                     GetIsSubFrameTest(theHistoryEntry, 1);

              }      // end for loop
       }             // end outer else


       // test SHistoryEnumerator attribute in nsISHistory.idl
       nsCOMPtr<nsISimpleEnumerator> theSimpleEnum;

//     GetSHEnumTest(theSessionHistory, theSimpleEnum);

       rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
       RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 1);
       RvTestResultDlg(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test");

       if (!theSimpleEnum)
          QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
       else
              SimpleEnumTest(theSimpleEnum, 1);

       // PurgeHistory() test

       PurgeHistoryTest(theSessionHistory, numEntries, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::SetMaxLengthTest ( nsISHistory theSessionHistory,
PRInt32  theMaxLength,
PRInt16  displayMode 
)

Definition at line 332 of file nsiHistory.cpp.

{
       rv = theSessionHistory->SetMaxLength(theMaxLength);
       if (theMaxLength < 0)
              QAOutput("theMaxLength for SetMaxLength() < 0. Test failed.", 1);
       else {
              RvTestResult(rv, "SetMaxLength() (MaxLength attribute) test", displayMode);
              RvTestResultDlg(rv, "SetMaxLength() (MaxLength attribute) test");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CNsIHistory::SimpleEnumTest ( nsISimpleEnumerator theSimpleEnum,
PRInt16  displayMode 
)

Definition at line 436 of file nsiHistory.cpp.

{
  PRBool bMore = PR_FALSE;
  nsCOMPtr<nsISupports> nextObj;
  nsCOMPtr<nsIHistoryEntry> nextHistoryEntry;

  while (NS_SUCCEEDED(theSimpleEnum->HasMoreElements(&bMore)) && bMore)
  {
        theSimpleEnum->GetNext(getter_AddRefs(nextObj));
        if (!nextObj)
              continue;
        nextHistoryEntry = do_QueryInterface(nextObj);
        if (!nextHistoryEntry)
              continue;
        rv = nextHistoryEntry->GetURI(getter_AddRefs(theURI));
        RvTestResult(rv, "theSimpleEnum nsIHistoryEntry->GetURI() test", 1);
        RvTestResultDlg(rv, "theSimpleEnum nsIHistoryEntry->GetURI() test");
        nsCAutoString uriString;
        rv = theURI->GetSpec(uriString);
        if (NS_FAILED(rv))
              QAOutput("uriString for GetSpec() invalid. Test failed.", 1);
        else
              FormatAndPrintOutput("The SimpleEnum URL = ", uriString, displayMode);               
  } 
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 59 of file nsiHistory.h.

Definition at line 60 of file nsiHistory.h.


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