You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Test Plan for nsIGlobalHistory interface


The nsIGlobalHistory interface has methods to access and update the global history file. In order to test the Global History interface, you need to have nsIProfile support in your test driver. See nsIGlobalHistory.idl for more information.

To access the nsIGlobalHistory object, use getService and the Global History contract ID:

In C++:
    nsCOMPtr<nsIGlobalHistory> ghObject(do_GetService(NS_GLOBALHISTORY_CONTRACTID));

In JavaScript:
    ghObject = Components.classes["@mozilla.org/browser/global-history;1"].
                                     getService(Components.interfaces.nsIGlobalHistory);

Now you can call the methods using the ghObject object.

To see the test cases click on the desired methods below.

    methods:
    isVisited()
    addPage()
 

isVisited():

Introduction:
This method checks if the given url is already in the global history file. It accepts two input parameters: a url string (char *) and a return value boolean.

How to use:

    char *theUrl = "http://www.bogussite.com/";
    PRBool theRetVal = PR_FALSE;
    nsresult rv;

    rv = ghObject->IsVisited(theUrl, &theRetVal);
    if (NS_FAILED(rv))
    {
       WriteToOutputFile("rv test for IsVisited() failed");    // local method for text output
       return;
    }
    else
    {
       WriteToOutputFile("rv test for IsVisited() succeeded.");
       if (theRetVal)
          WriteToOutputFile("the url has been visited");
       else
          WriteToOutputFile("the url hasn't been visited");
    }

Notes:

In Case 3 below, to delete an entry, use RemovePage() method from nsIBrowserHistory.idl:

    nsCOMPtr<nsIBrowserHistory> bhObject  = do_QueryInterface(ghObject, &rv);
    rv = bhObject->RemovePage(theUrl);
 

Case Steps Expected Results Pass/Fail Comments
1 Enter a url in your browser. Call isVisited() using this url. theRetVal should return True. pass Testing default impl of isVisited()
2 Call isVisited() with a url that you have never entered in your browser. theRetVal should return False. pass Testing default impl of isVisited()
3 Delete a url entry in the gh file. Then use isVisited(). theRetVal should return False. pass Testing default impl of isVisited()

Back To Top

addPage():

Introduction:


This method adds the url to the global history file. It accepts one input parameter: a url string (char *).

Often, isVisited() is called first, and if the url isn't in the global history file, then addPage() will enter it.

How to use:

    nsresult rv;

    rv = ghObject->AddPage(theUrl);
    if (NS_FAILED(rv))
    {
       WriteToOutputFile("rv test for AddPage() failed.");
       return;
    }
    else
       WriteToOutputFile("rv test for AddPage() succeeded.");

Notes:

To confirm that the url is now in the global history file, call isVisited() again. If it returns true, which it should, then AddPage() has successfully added the url.

Case Steps Expected Results Pass/Fail Comments
1 Use AddPage() with a url that has been visited (in the global history file). The url should be added to the global history file. pass Using the default impl, it's difficult to query the database to see if there's a double entry (which there shouldn't be). Just use isVisited() to make sure the url is still there.
2 Use AddPage() with a url that has not been visited. The url should be added to the global history file. pass Using default impl
3 Delete an entry in the gh file (see Notes for IsVisited() ). Then use AddPage(). The url should be added to the global history file. pass Using default impl

Back To Top

Revision History:

Date                        Changed By              Comments

06/01/01                                                   Test Plan written by David Epstein.