2001-09-26 02:58:40 +04: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
|
2001-09-22 04:49:38 +04: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/
|
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.
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 02:58:40 +04:00
|
|
|
* 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):
|
2004-04-19 02:01:16 +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
|
2004-04-19 02:01:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 02:58:40 +04: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.
|
2001-09-26 02:58:40 +04:00
|
|
|
*
|
|
|
|
* ***** 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;
|
|
|
|
|
|
|
|
|
2004-05-20 06:15:10 +04:00
|
|
|
//nsCOMPtr<nsIURI> theURI;
|
2001-11-27 00:47:06 +03:00
|
|
|
// do_QueryInterface
|
|
|
|
// NS_HISTORYENTRY_CONTRACTID
|
|
|
|
|
|
|
|
// get Session History through web nav iface
|
2002-08-09 06:43:04 +04:00
|
|
|
if (qaWebNav) {
|
2002-10-12 05:51:18 +04:00
|
|
|
rv = qaWebNav->GetSessionHistory(getter_AddRefs(theSessionHistory));
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetSessionHistory() object", 1);
|
|
|
|
RvTestResultDlg(rv, "GetSessionHistory() object", true);
|
|
|
|
}
|
2001-11-27 00:47:06 +03: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 {
|
2002-08-09 06:43:04 +04:00
|
|
|
QAOutput("theSessionHistory object was created.", 1);
|
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 :
|
2002-10-05 08:03:32 +04:00
|
|
|
QAOutput("Begin nsISHistory tests.", 1);
|
2001-11-27 00:47:06 +03:00
|
|
|
RunAllTests();
|
2002-10-05 08:03:32 +04:00
|
|
|
QAOutput("End nsISHistory tests.", 1);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETCOUNT :
|
2002-09-28 05:41:25 +04:00
|
|
|
GetCountTest(theSessionHistory, &numEntries, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETINDEX :
|
2002-09-28 05:41:25 +04:00
|
|
|
GetIndexTest(theSessionHistory, &theIndex, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETMAXLENGTH :
|
2002-09-28 05:41:25 +04:00
|
|
|
GetMaxLengthTest(theSessionHistory, &theMaxLength, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_SETMAXLENGTH :
|
2002-09-28 05:41:25 +04:00
|
|
|
SetMaxLengthTest(theSessionHistory, theMaxLength, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
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++)
|
|
|
|
{
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("the index = ", theIndex, 1);
|
2002-01-29 04:31:15 +03:00
|
|
|
|
2002-08-09 06:43:04 +04:00
|
|
|
rv = theSessionHistory->GetEntryAtIndex(theIndex, PR_FALSE, getter_AddRefs(theHistoryEntry));
|
|
|
|
RvTestResult(rv, "GetEntryAtIndex() test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetEntryAtIndex() test");
|
2002-01-29 04:31:15 +03:00
|
|
|
if (!theHistoryEntry)
|
|
|
|
{
|
|
|
|
QAOutput("We didn't get the History Entry object. No more tests performed.", 1);
|
|
|
|
return;
|
|
|
|
}
|
2002-09-28 05:41:25 +04:00
|
|
|
GetURIHistTest(theHistoryEntry, 2);
|
|
|
|
GetTitleHistTest(theHistoryEntry, 2);
|
|
|
|
GetIsSubFrameTest(theHistoryEntry, 2);
|
2002-01-29 04:31:15 +03:00
|
|
|
} // end for loop
|
|
|
|
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_PURGEHISTORY :
|
2002-09-28 05:41:25 +04:00
|
|
|
PurgeHistoryTest(theSessionHistory, numEntries, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_GETSHISTORYENUMERATOR :
|
|
|
|
//GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
2002-01-29 04:31:15 +03:00
|
|
|
|
|
|
|
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetSHistoryEnumerator() test");
|
|
|
|
|
|
|
|
if (!theSimpleEnum) {
|
2002-01-29 04:31:15 +03:00
|
|
|
QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
|
2002-08-09 06:43:04 +04:00
|
|
|
return;
|
|
|
|
}
|
2002-09-28 05:41:25 +04:00
|
|
|
SimpleEnumTest(theSimpleEnum, 2);
|
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 :
|
2002-09-28 05:41:25 +04:00
|
|
|
RunAllHistoryEntryTests(2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETURI :
|
2002-09-28 05:41:25 +04:00
|
|
|
GetURIHistTest(theHistoryEntry, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETTITLE :
|
2002-09-28 05:41:25 +04:00
|
|
|
GetTitleHistTest(theHistoryEntry, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
break ;
|
|
|
|
case ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETISSUBFRAME :
|
2002-09-28 05:41:25 +04:00
|
|
|
GetIsSubFrameTest(theHistoryEntry, 2);
|
2001-11-27 00:47:06 +03:00
|
|
|
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;
|
|
|
|
|
|
|
|
// 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 {
|
2002-09-28 05:41:25 +04:00
|
|
|
QAOutput("theSessionHistory object was created.", 1);
|
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
|
2002-09-28 05:41:25 +04:00
|
|
|
GetCountTest(theSessionHistory, &numEntries, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// test index attribute in nsISHistory.idl
|
2002-09-28 05:41:25 +04:00
|
|
|
GetIndexTest(theSessionHistory, &theIndex, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// test maxLength attribute in nsISHistory.idl
|
2002-09-28 05:41:25 +04:00
|
|
|
SetMaxLengthTest(theSessionHistory, theMaxLength, 1);
|
|
|
|
GetMaxLengthTest(theSessionHistory, &theMaxLength, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
QAOutput("Start nsiHistoryEntry tests.", 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// get theHistoryEntry object
|
2002-08-09 06:43:04 +04:00
|
|
|
rv = theSessionHistory->GetEntryAtIndex(0, PR_FALSE, getter_AddRefs(theHistoryEntry));
|
|
|
|
RvTestResult(rv, "GetEntryAtIndex() test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetEntryAtIndex() test");
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
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++)
|
|
|
|
{
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("the index = ", theIndex, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
//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
|
2002-09-28 05:41:25 +04:00
|
|
|
GetURIHistTest(theHistoryEntry, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// test title attribute in nsIHistoryEntry.idl
|
2002-09-28 05:41:25 +04:00
|
|
|
GetTitleHistTest(theHistoryEntry, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// test isSubFrame attribute in nsIHistoryEntry.idl
|
2002-09-28 05:41:25 +04:00
|
|
|
GetIsSubFrameTest(theHistoryEntry, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
} // end for loop
|
|
|
|
} // end outer else
|
|
|
|
|
|
|
|
|
|
|
|
// test SHistoryEnumerator attribute in nsISHistory.idl
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> theSimpleEnum;
|
|
|
|
|
|
|
|
// GetSHEnumTest(theSessionHistory, theSimpleEnum);
|
|
|
|
|
|
|
|
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetSHistoryEnumerator() (SHistoryEnumerator attribute) test");
|
|
|
|
|
2001-09-22 04:49:38 +04:00
|
|
|
if (!theSimpleEnum)
|
|
|
|
QAOutput("theSimpleEnum for GetSHistoryEnumerator() invalid. Test failed.", 1);
|
|
|
|
else
|
2002-09-28 05:41:25 +04:00
|
|
|
SimpleEnumTest(theSimpleEnum, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
|
|
|
|
// PurgeHistory() test
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
PurgeHistoryTest(theSessionHistory, numEntries, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
// Individual nsISHistory tests
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::GetCountTest(nsISHistory *theSessionHistory, PRInt32 *numEntries,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetCount(numEntries);
|
2002-08-09 06:43:04 +04:00
|
|
|
if (*numEntries < 0)
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("numEntries for GetCount() < 0. Test failed.", 1);
|
|
|
|
else {
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("GetCount():number of entries = ", *numEntries, displayMode);
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetCount() (count attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetCount() (count attribute) test");
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::GetIndexTest(nsISHistory *theSessionHistory, PRInt32 *theIndex,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetIndex(theIndex);
|
2002-08-09 06:43:04 +04:00
|
|
|
if (*theIndex <0)
|
2001-09-22 04:49:38 +04:00
|
|
|
QAOutput("theIndex for GetIndex() < 0. Test failed.", 1);
|
2002-01-29 04:31:15 +03:00
|
|
|
else {
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("GetIndex():the index = ", *theIndex, displayMode);
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetIndex() (index attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetIndex() (index attribute) test");
|
2002-01-29 04:31:15 +03:00
|
|
|
}
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::SetMaxLengthTest(nsISHistory *theSessionHistory, PRInt32 theMaxLength,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
rv = theSessionHistory->SetMaxLength(theMaxLength);
|
2002-08-09 06:43:04 +04:00
|
|
|
if (theMaxLength < 0)
|
|
|
|
QAOutput("theMaxLength for SetMaxLength() < 0. Test failed.", 1);
|
|
|
|
else {
|
2002-09-28 05:41:25 +04:00
|
|
|
RvTestResult(rv, "SetMaxLength() (MaxLength attribute) test", displayMode);
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResultDlg(rv, "SetMaxLength() (MaxLength attribute) test");
|
|
|
|
}
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::GetMaxLengthTest(nsISHistory *theSessionHistory, PRInt32 *theMaxLength,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
rv = theSessionHistory->GetMaxLength(theMaxLength);
|
|
|
|
if (*theMaxLength<0)
|
|
|
|
QAOutput("theMaxLength for GetMaxLength() < 0. Test failed.", 1);
|
|
|
|
else {
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("GetMaxLength():theMaxLength = ", *theMaxLength, displayMode);
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetMaxLength() (MaxLength attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetMaxLength() (MaxLength attribute) test");
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*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);
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::GetURIHistTest(nsIHistoryEntry* theHistoryEntry,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
2004-05-20 06:15:10 +04:00
|
|
|
rv = theHistoryEntry->GetURI(getter_AddRefs(theURI));
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetURI() (URI attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetURI() (URI attribute) test");
|
2004-05-20 06:15:10 +04:00
|
|
|
if (!theURI)
|
|
|
|
QAOutput("theURI for GetURI() invalid. Test failed.", 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
else
|
|
|
|
{
|
2002-03-16 05:31:53 +03:00
|
|
|
nsCAutoString uriString;
|
2004-05-20 06:15:10 +04:00
|
|
|
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-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("The SH Url = ", uriString, displayMode);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::GetTitleHistTest(nsIHistoryEntry* theHistoryEntry,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
nsXPIDLString theTitle;
|
|
|
|
|
|
|
|
rv = theHistoryEntry->GetTitle(getter_Copies(theTitle));
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "GetTitle() (title attribute) test", 1);
|
|
|
|
RvTestResultDlg(rv, "GetTitle() (title attribute) test");
|
2001-09-22 04:49:38 +04:00
|
|
|
if (!theTitle) {
|
|
|
|
QAOutput("theTitle for GetTitle() is blank. Test failed.", 1);
|
|
|
|
return;
|
|
|
|
}
|
2002-08-09 06:43:04 +04:00
|
|
|
|
2004-02-03 21:23:41 +03:00
|
|
|
FormatAndPrintOutput("The title = ",
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_ConvertUTF16toUTF8(theTitle).get(), displayMode);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::GetIsSubFrameTest(nsIHistoryEntry* theHistoryEntry,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
PRBool isSubFrame;
|
|
|
|
|
|
|
|
rv = theHistoryEntry->GetIsSubFrame(&isSubFrame);
|
|
|
|
|
|
|
|
RvTestResult(rv, "GetIsSubFrame() (isSubFrame attribute) test", 1);
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResultDlg(rv, "GetIsSubFrame() (isSubFrame attribute) test");
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("The subFrame boolean value = ", isSubFrame, displayMode);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::SimpleEnumTest(nsISimpleEnumerator *theSimpleEnum,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
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;
|
2004-05-20 06:15:10 +04:00
|
|
|
rv = nextHistoryEntry->GetURI(getter_AddRefs(theURI));
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "theSimpleEnum nsIHistoryEntry->GetURI() test", 1);
|
|
|
|
RvTestResultDlg(rv, "theSimpleEnum nsIHistoryEntry->GetURI() test");
|
2002-03-16 05:31:53 +03:00
|
|
|
nsCAutoString uriString;
|
2004-05-20 06:15:10 +04:00
|
|
|
rv = theURI->GetSpec(uriString);
|
2002-03-16 05:31:53 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
QAOutput("uriString for GetSpec() invalid. Test failed.", 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
else
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("The SimpleEnum URL = ", uriString, displayMode);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::PurgeHistoryTest(nsISHistory* theSessionHistory, PRInt32 numEntries,
|
|
|
|
PRInt16 displayMode)
|
2001-09-22 04:49:38 +04:00
|
|
|
{
|
|
|
|
rv = theSessionHistory->PurgeHistory(numEntries);
|
2002-08-09 06:43:04 +04:00
|
|
|
RvTestResult(rv, "PurgeHistory() test", 1);
|
|
|
|
RvTestResultDlg(rv, "PurgeHistory() test");
|
|
|
|
FormatAndPrintOutput("PurgeHistory(): num requested entries for removal = ", numEntries, 1);
|
2001-09-22 04:49:38 +04:00
|
|
|
}
|
2001-11-27 00:47:06 +03:00
|
|
|
|
2002-09-28 05:41:25 +04:00
|
|
|
void CNsIHistory::RunAllHistoryEntryTests(PRInt16 displayMode)
|
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;
|
|
|
|
|
|
|
|
// get Session History through web nav iface
|
|
|
|
if (qaWebNav)
|
|
|
|
qaWebNav->GetSessionHistory( getter_AddRefs(theSessionHistory));
|
|
|
|
|
|
|
|
if (!theSessionHistory)
|
|
|
|
{
|
2002-09-28 05:41:25 +04:00
|
|
|
QAOutput("theSessionHistory object wasn't created. No session history tests performed.", displayMode);
|
2001-11-27 00:47:06 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2002-08-09 06:43:04 +04:00
|
|
|
QAOutput("theSessionHistory object was created.", 1);
|
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);
|
|
|
|
|
|
|
|
// getEntryAtIndex() tests
|
|
|
|
if (theMaxLength < numEntries)
|
|
|
|
{
|
|
|
|
QAOutput("Setting number of entries to maximum length!", 1);
|
|
|
|
numEntries = theMaxLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (theIndex = 0; theIndex < numEntries; theIndex++)
|
|
|
|
{
|
2002-09-28 05:41:25 +04:00
|
|
|
FormatAndPrintOutput("the index = ", theIndex, displayMode);
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
//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
|
2002-09-28 05:41:25 +04:00
|
|
|
GetURIHistTest(theHistoryEntry, displayMode);
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
// test title attribute in nsIHistoryEntry.idl
|
2002-09-28 05:41:25 +04:00
|
|
|
GetTitleHistTest(theHistoryEntry, displayMode);
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
// test isSubFrame attribute in nsIHistoryEntry.idl
|
2002-09-28 05:41:25 +04:00
|
|
|
GetIsSubFrameTest(theHistoryEntry, displayMode);
|
2001-11-27 00:47:06 +03:00
|
|
|
|
|
|
|
} // end for loop
|
|
|
|
} // end outer else
|
|
|
|
}
|