2001-09-26 02:58:40 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2001-09-22 04:49:38 +04:00
|
|
|
*
|
2001-09-26 02:58:40 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
2001-09-22 04:49:38 +04:00
|
|
|
*
|
2001-09-26 02:58:40 +04: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.
|
2001-09-22 04:49:38 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-26 02:58:40 +04:00
|
|
|
* 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.
|
2001-09-22 04:49:38 +04:00
|
|
|
*
|
2001-09-26 02:58:40 +04:00
|
|
|
* Contributor(s):
|
2001-09-22 04:49:38 +04:00
|
|
|
* David Epstein <depstein@netscape.com>
|
|
|
|
* Ashish Bhatt <ashishbhatt@netscape.com>
|
2001-09-26 02:58:40 +04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// File Overview....
|
|
|
|
//
|
|
|
|
// Test cases for the nsiHistory Interface
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "TestEmbed.h"
|
|
|
|
#include "BrowserImpl.h"
|
|
|
|
#include "BrowserFrm.h"
|
|
|
|
#include "UrlDialog.h"
|
|
|
|
#include "ProfileMgr.h"
|
|
|
|
#include "ProfilesDlg.h"
|
|
|
|
#include "QaUtils.h"
|
2001-11-27 00:47:06 +03:00
|
|
|
#include "nsihistory.h"
|
2001-09-22 04:49:38 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CNsIHistory
|
|
|
|
|
2001-11-27 00:47:06 +03:00
|
|
|
CNsIHistory::CNsIHistory(nsIWebNavigation *mWebNav)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
2001-11-27 00:47:06 +03:00
|
|
|
//qaTests = mTests;
|
|
|
|
qaWebNav = mWebNav ;
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CNsIHistory::~CNsIHistory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CNsIHistory message handlers
|
|
|
|
// ***********************************************************************
|
|
|
|
// ***********************************************************************
|
|
|
|
// nsIHistory iface
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
// ***********************************************************************
|
|
|
|
// nsISHistory & nsIHistoryEntry ifaces:
|
|
|
|
|
2001-11-27 00:47:06 +03:00
|
|
|
void CNsIHistory::OnStartTests(UINT nMenuID)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Calls all or indivdual test cases on the basis of the
|
|
|
|
// option selected from menu.
|
|
|
|
PRInt32 numEntries = 5;
|
|
|
|
PRInt32 theIndex;
|
2002-01-25 01:18:53 +03:00
|
|
|
PRInt32 theMaxLength = 100;
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
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)
|
|
|
|
qaWebNav->GetSessionHistory( getter_AddRefs(theSessionHistory));
|
|
|
|
|
|
|
|
if (!theSessionHistory)
|
|
|
|
{
|
|
|
|
QAOutput("theSessionHistory object wasn't created. No session history tests performed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-01-25 01:18:53 +03:00
|
|
|
else {
|
2001-11-27 00:47:06 +03:00
|
|
|
QAOutput("theSessionHistory object was created.", 2);
|
2002-01-25 01:18:53 +03:00
|
|
|
theSessionHistory->GetCount(&numEntries);
|
|
|
|
}
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
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 :
|
|
|
|
RunAllTests();
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETCOUNT :
|
|
|
|
GetCountTest(theSessionHistory, &numEntries);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETINDEX :
|
|
|
|
GetIndexTest(theSessionHistory, &theIndex);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETMAXLENGTH :
|
|
|
|
GetMaxLengthTest(theSessionHistory, &theMaxLength);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_SETMAXLENGTH :
|
|
|
|
SetMaxLengthTest(theSessionHistory, theMaxLength);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETENTRYATINDEX :
|
|
|
|
//GetEntryAtIndex(0, PR_FALSE, getter_AddRefs(theHistoryEntry));
|
2002-01-29 04:31:15 +03:00
|
|
|
for (theIndex = 0; theIndex < numEntries; theIndex++)
|
|
|
|
{
|
|
|
|
FormatAndPrintOutput("the index = ", theIndex, 2);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
GetURIHistTest(theHistoryEntry);
|
|
|
|
GetTitleHistTest(theHistoryEntry);
|
|
|
|
GetIsSubFrameTest(theHistoryEntry);
|
|
|
|
} // end for loop
|
|
|
|
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_PURGEHISTORY :
|
|
|
|
PurgeHistoryTest(theSessionHistory, numEntries);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETSHISTORYENUMERATOR :
|
|
|
|
//GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
2002-01-29 04:31:15 +03:00
|
|
|
|
|
|
|
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
|
|
|
if (!theSimpleEnum)
|
|
|
|
QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
|
|
|
|
else
|
|
|
|
RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 2);
|
|
|
|
SimpleEnumTest(theSimpleEnum);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
2002-01-29 04:31:15 +03:00
|
|
|
|
2001-11-27 00:47:06 +03:00
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_RUNALLTESTS :
|
2001-11-27 23:11:41 +03:00
|
|
|
RunAllHistoryEntryTests();
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETURI :
|
|
|
|
GetURIHistTest(theHistoryEntry);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETTITLE :
|
|
|
|
GetTitleHistTest(theHistoryEntry);
|
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETISSUBFRAME :
|
|
|
|
GetIsSubFrameTest(theHistoryEntry);
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::RunAllTests()
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
//nsresult rv;
|
|
|
|
|
|
|
|
PRInt32 numEntries = 5;
|
|
|
|
PRInt32 theIndex;
|
2002-01-25 01:18:53 +03:00
|
|
|
PRInt32 theMaxLength = 100;
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
CString shString;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISHistory> theSessionHistory;
|
|
|
|
nsCOMPtr<nsIHistoryEntry> theHistoryEntry;
|
|
|
|
|
|
|
|
//nsCOMPtr<nsIURI> theUri;
|
|
|
|
// do_QueryInterface
|
|
|
|
// NS_HISTORYENTRY_CONTRACTID
|
|
|
|
// NS_SHISTORYLISTENER_CONTRACTID
|
|
|
|
|
|
|
|
// get Session History through web nav iface
|
2001-11-27 00:47:06 +03:00
|
|
|
if (qaWebNav)
|
|
|
|
qaWebNav->GetSessionHistory( getter_AddRefs(theSessionHistory));
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
if (!theSessionHistory)
|
|
|
|
{
|
|
|
|
QAOutput("theSessionHistory object wasn't created. No session history tests performed.", 2);
|
|
|
|
return;
|
|
|
|
}
|
2002-01-25 01:18:53 +03:00
|
|
|
else {
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("theSessionHistory object was created.", 2);
|
2002-01-25 01:18:53 +03:00
|
|
|
theSessionHistory->GetCount(&numEntries);
|
|
|
|
}
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// test count attribute in nsISHistory.idl
|
|
|
|
GetCountTest(theSessionHistory, &numEntries);
|
|
|
|
|
|
|
|
// test index attribute in nsISHistory.idl
|
|
|
|
GetIndexTest(theSessionHistory, &theIndex);
|
|
|
|
|
|
|
|
// test maxLength attribute in nsISHistory.idl
|
|
|
|
SetMaxLengthTest(theSessionHistory, theMaxLength);
|
|
|
|
GetMaxLengthTest(theSessionHistory, &theMaxLength);
|
|
|
|
|
|
|
|
QAOutput("Start nsiHistoryEntry tests.", 2);
|
|
|
|
|
|
|
|
// get theHistoryEntry object
|
|
|
|
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
|
2001-10-25 22:32:34 +04:00
|
|
|
if (theMaxLength < numEntries)
|
|
|
|
{
|
|
|
|
QAOutput("Setting number of entries to maximum length!", 1);
|
|
|
|
numEntries = theMaxLength;
|
|
|
|
}
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
for (theIndex = 0; theIndex < numEntries; theIndex++)
|
|
|
|
{
|
|
|
|
FormatAndPrintOutput("the index = ", theIndex, 2);
|
|
|
|
|
|
|
|
//GetEntryAtIndexTest(theSessionHistory,theHistoryEntry, theIndex);
|
|
|
|
|
|
|
|
theSessionHistory->GetEntryAtIndex(theIndex, PR_FALSE, getter_AddRefs(theHistoryEntry));
|
2001-10-05 04:35:44 +04:00
|
|
|
if (!theHistoryEntry)
|
|
|
|
{
|
|
|
|
QAOutput("We didn't get the History Entry object. No more tests performed.", 1);
|
|
|
|
return;
|
|
|
|
}
|
2001-09-22 04:49:38 +04:00
|
|
|
// nsiHistoryEntry.idl tests
|
|
|
|
|
|
|
|
// test URI attribute in nsIHistoryEntry.idl
|
|
|
|
GetURIHistTest(theHistoryEntry);
|
|
|
|
|
|
|
|
// test title attribute in nsIHistoryEntry.idl
|
|
|
|
GetTitleHistTest(theHistoryEntry);
|
|
|
|
|
|
|
|
// test isSubFrame attribute in nsIHistoryEntry.idl
|
|
|
|
GetIsSubFrameTest(theHistoryEntry);
|
|
|
|
|
|
|
|
} // end for loop
|
|
|
|
} // end outer else
|
|
|
|
|
|
|
|
|
|
|
|
// test SHistoryEnumerator attribute in nsISHistory.idl
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> theSimpleEnum;
|
|
|
|
|
|
|
|
// GetSHEnumTest(theSessionHistory, theSimpleEnum);
|
|
|
|
|
|
|
|
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
|
|
|
if (!theSimpleEnum)
|
|
|
|
QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
|
|
|
|
else
|
|
|
|
RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 2);
|
|
|
|
|
|
|
|
SimpleEnumTest(theSimpleEnum);
|
|
|
|
|
|
|
|
// PurgeHistory() test
|
|
|
|
|
|
|
|
PurgeHistoryTest(theSessionHistory, numEntries);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
// Individual nsISHistory tests
|
|
|
|
|
|
|
|
void CNsIHistory::GetCountTest(nsISHistory *theSessionHistory, PRInt32 *numEntries)
|
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetCount(numEntries);
|
|
|
|
if (*numEntries < 0)
|
|
|
|
QAOutput("numEntries for GetCount() < 0. Test failed.", 1);
|
|
|
|
else {
|
2002-01-29 04:31:15 +03:00
|
|
|
FormatAndPrintOutput("GetCount():number of entries = ", *numEntries, 2);
|
2001-09-22 04:49:38 +04:00
|
|
|
RvTestResult(rv, "GetCount() (count attribute) test", 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::GetIndexTest(nsISHistory *theSessionHistory, PRInt32 *theIndex)
|
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetIndex(theIndex);
|
|
|
|
if (*theIndex <0)
|
|
|
|
QAOutput("theIndex for GetIndex() < 0. Test failed.", 1);
|
2002-01-29 04:31:15 +03:00
|
|
|
else {
|
|
|
|
FormatAndPrintOutput("GetIndex():the index = ", *theIndex, 2);
|
2001-09-22 04:49:38 +04:00
|
|
|
RvTestResult(rv, "GetIndex() (index attribute) test", 2);
|
2002-01-29 04:31:15 +03:00
|
|
|
}
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::SetMaxLengthTest(nsISHistory *theSessionHistory, PRInt32 theMaxLength)
|
|
|
|
{
|
|
|
|
rv = theSessionHistory->SetMaxLength(theMaxLength);
|
|
|
|
RvTestResult(rv, "SetMaxLength() (MaxLength attribute) test", 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::GetMaxLengthTest(nsISHistory *theSessionHistory, PRInt32 *theMaxLength)
|
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetMaxLength(theMaxLength);
|
|
|
|
if (*theMaxLength<0)
|
|
|
|
QAOutput("theMaxLength for GetMaxLength() < 0. Test failed.", 1);
|
|
|
|
else {
|
2002-01-29 04:31:15 +03:00
|
|
|
FormatAndPrintOutput("GetMaxLength():theMaxLength = ", *theMaxLength, 2);
|
2001-09-22 04:49:38 +04:00
|
|
|
RvTestResult(rv, "GetMaxLength() (MaxLength attribute) test", 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*void CNsIHistory::GetEntryAtIndexTest(nsISHistory *theSessionHistory,
|
|
|
|
nsIHistoryEntry *theHistoryEntry,
|
|
|
|
PRInt32 theIndex)
|
|
|
|
{
|
|
|
|
theSessionHistory->GetEntryAtIndex(theIndex, PR_FALSE,&theHistoryEntry);
|
|
|
|
|
|
|
|
// test URI attribute in nsIHistoryEntry.idl
|
|
|
|
//GetURIHistTest(theHistoryEntry);
|
|
|
|
|
|
|
|
// test title attribute in nsIHistoryEntry.idl
|
|
|
|
//GetTitleHistTest(theHistoryEntry);
|
|
|
|
|
|
|
|
// test isSubFrame attribute in nsIHistoryEntry.idl
|
|
|
|
//GetIsSubFrameTest(theHistoryEntry);
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
void CNsIHistory::GetURIHistTest(nsIHistoryEntry* theHistoryEntry)
|
|
|
|
{
|
2001-11-27 00:47:06 +03:00
|
|
|
rv = theHistoryEntry->GetURI(getter_AddRefs(theUri));
|
|
|
|
if (!theUri)
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("theUri for GetURI() invalid. Test failed.", 1);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RvTestResult(rv, "GetURI() (URI attribute) test", 1);
|
2002-03-16 05:31:53 +03:00
|
|
|
nsCAutoString uriString;
|
|
|
|
rv = theUri->GetSpec(uriString);
|
2001-09-22 04:49:38 +04:00
|
|
|
if (NS_FAILED(rv))
|
2002-03-16 05:31:53 +03:00
|
|
|
QAOutput("We didn't get the uriString.", 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
else
|
2002-03-16 05:31:53 +03:00
|
|
|
FormatAndPrintOutput("The SH Url = ", uriString, 2);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::GetTitleHistTest(nsIHistoryEntry* theHistoryEntry)
|
|
|
|
{
|
|
|
|
nsXPIDLString theTitle;
|
|
|
|
const char * titleCString;
|
|
|
|
|
|
|
|
rv = theHistoryEntry->GetTitle(getter_Copies(theTitle));
|
|
|
|
if (!theTitle) {
|
|
|
|
QAOutput("theTitle for GetTitle() is blank. Test failed.", 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
RvTestResult(rv, "GetTitle() (title attribute) test", 1);
|
|
|
|
titleCString = NS_ConvertUCS2toUTF8(theTitle).get();
|
|
|
|
FormatAndPrintOutput("The title = ", (char *)titleCString, 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::GetIsSubFrameTest(nsIHistoryEntry* theHistoryEntry)
|
|
|
|
{
|
|
|
|
PRBool isSubFrame;
|
|
|
|
|
|
|
|
rv = theHistoryEntry->GetIsSubFrame(&isSubFrame);
|
|
|
|
|
|
|
|
RvTestResult(rv, "GetIsSubFrame() (isSubFrame attribute) test", 1);
|
|
|
|
FormatAndPrintOutput("The subFrame boolean value = ", isSubFrame, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
void CNsIHistory::GetSHEnumTest(nsISHistory *theSessionHistory,
|
|
|
|
nsISimpleEnumerator *theSimpleEnum)
|
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
|
|
|
if (!theSimpleEnum)
|
|
|
|
QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
|
|
|
|
else
|
|
|
|
RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 2);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CNsIHistory::SimpleEnumTest(nsISimpleEnumerator *theSimpleEnum)
|
|
|
|
{
|
|
|
|
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;
|
2001-11-27 00:47:06 +03:00
|
|
|
rv = nextHistoryEntry->GetURI(getter_AddRefs(theUri));
|
2002-03-16 05:31:53 +03:00
|
|
|
nsCAutoString uriString;
|
|
|
|
rv = theUri->GetSpec(uriString);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
QAOutput("uriString for GetSpec() invalid. Test failed.", 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
else
|
2002-03-16 05:31:53 +03:00
|
|
|
FormatAndPrintOutput("The SimpleEnum URL = ", uriString, 2);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNsIHistory::PurgeHistoryTest(nsISHistory* theSessionHistory, PRInt32 numEntries)
|
|
|
|
{
|
|
|
|
rv = theSessionHistory->PurgeHistory(numEntries);
|
|
|
|
RvTestResult(rv, "PurgeHistory() test", 2);
|
2002-01-25 04:00:26 +03:00
|
|
|
FormatAndPrintOutput("PurgeHistory(): num requested entries for removal = ", numEntries, 2);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
2001-11-27 00:47:06 +03:00
|
|
|
|
2001-11-27 23:11:41 +03:00
|
|
|
void CNsIHistory::RunAllHistoryEntryTests()
|
2001-11-27 00:47:06 +03:00
|
|
|
{
|
|
|
|
PRInt32 numEntries = 5;
|
|
|
|
PRInt32 theIndex;
|
2002-01-25 01:18:53 +03:00
|
|
|
PRInt32 theMaxLength = 100;
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
CString shString;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISHistory> theSessionHistory;
|
|
|
|
nsCOMPtr<nsIHistoryEntry> theHistoryEntry;
|
|
|
|
|
|
|
|
//nsCOMPtr<nsIURI> theUri;
|
|
|
|
// do_QueryInterface
|
|
|
|
// NS_HISTORYENTRY_CONTRACTID
|
|
|
|
// NS_SHISTORYLISTENER_CONTRACTID
|
|
|
|
|
|
|
|
// 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.", 2);
|
|
|
|
|
|
|
|
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, 2);
|
|
|
|
|
|
|
|
//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);
|
|
|
|
|
|
|
|
// test title attribute in nsIHistoryEntry.idl
|
|
|
|
GetTitleHistTest(theHistoryEntry);
|
|
|
|
|
|
|
|
// test isSubFrame attribute in nsIHistoryEntry.idl
|
|
|
|
GetIsSubFrameTest(theHistoryEntry);
|
|
|
|
|
|
|
|
} // end for loop
|
|
|
|
} // end outer else
|
|
|
|
}
|