Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
TestStandardURL.cpp File Reference
#include "TestCommon.h"
#include <stdlib.h>
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsNetCID.h"
#include "nsIURL.h"
#include "prinrval.h"
#include "nsString.h"

Go to the source code of this file.

Functions

static void run_test (const char *testname, int count, void(*testfunc)())
static void set_spec_test ()
static void get_spec_test ()
static void resolve_test ()
static void set_scheme_test ()
static void get_scheme_test ()
static void host_test ()
static void set_path_test ()
static void get_path_test ()
static void query_test ()
static void ref_test ()
int main (int argc, char **argv)
 The Xalan testcases app.

Variables

static nsIURLtest_url = 0
static nsCString test_param

Function Documentation

static void get_path_test ( ) [static]

Definition at line 65 of file TestStandardURL.cpp.

{
    nsCAutoString path;
    test_url->GetPath(path);
}

Here is the caller graph for this function:

static void get_scheme_test ( ) [static]

Definition at line 46 of file TestStandardURL.cpp.

{
    nsCAutoString scheme;
    test_url->GetScheme(scheme);
}

Here is the caller graph for this function:

static void get_spec_test ( ) [static]

Definition at line 29 of file TestStandardURL.cpp.

{
    nsCAutoString spec;
    test_url->GetSpec(spec);
}

Here is the caller graph for this function:

static void host_test ( ) [static]

Definition at line 52 of file TestStandardURL.cpp.

{
    nsCAutoString host;
    test_url->GetHost(host);
    test_url->SetHost(NS_LITERAL_CSTRING("www.yahoo.com"));
    test_url->SetHost(host);
}

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 87 of file TestStandardURL.cpp.

{
    if (test_common_init(&argc, &argv) != 0)
        return -1;

    if (argc < 2) {
        printf("usage: TestURL url [count]\n");
        return -1;
    }

    int count = 1000;
    if (argc == 3)
        count = atoi(argv[2]);
    else
        printf("using a default count of %d\n", count);

    nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
    if (!url) {
        printf("failed to instantiate component: %s\n", NS_STANDARDURL_CONTRACTID);
        return -1;
    }

    test_url = url;
    test_param = argv[1];

    run_test("SetSpec", count, set_spec_test);
    run_test("GetSpec", count, get_spec_test);
    run_test("Resolve", count, resolve_test);
    run_test("SetScheme", count, set_scheme_test);
    run_test("GetScheme", count, get_scheme_test);
    run_test("[GS]etHost", count, host_test);
    run_test("SetPath", count, set_path_test);
    run_test("GetPath", count, get_path_test);
    run_test("[GS]etQuery", count, query_test);
    run_test("[GS]etRef", count, ref_test);

    return 0;
}

Here is the call graph for this function:

static void query_test ( ) [static]

Definition at line 71 of file TestStandardURL.cpp.

{
    nsCAutoString query;
    test_url->GetQuery(query);
    test_url->SetQuery(NS_LITERAL_CSTRING("a=b&d=c&what-ever-you-want-to-be-called=45"));
    test_url->SetQuery(query);
}

Here is the caller graph for this function:

static void ref_test ( ) [static]

Definition at line 79 of file TestStandardURL.cpp.

{
    nsCAutoString ref;
    test_url->GetRef(ref);
    test_url->SetRef(NS_LITERAL_CSTRING("#some-book-mark"));
    test_url->SetRef(ref);
}

Here is the caller graph for this function:

static void resolve_test ( ) [static]

Definition at line 35 of file TestStandardURL.cpp.

{
    nsCAutoString spec;
    test_url->Resolve(NS_LITERAL_CSTRING("foo.html?q=45"), spec);
}

Here is the caller graph for this function:

static void run_test ( const char *  testname,
int  count,
void(*)()  testfunc 
) [static]

Definition at line 13 of file TestStandardURL.cpp.

{
    PRIntervalTime start, end;
    start = PR_IntervalNow();
    for (; count; --count)
        testfunc();
    end = PR_IntervalNow();
    printf("completed %s test in %u milliseconds\n", testname,
            PR_IntervalToMilliseconds(end - start));
}

Here is the caller graph for this function:

static void set_path_test ( ) [static]

Definition at line 60 of file TestStandardURL.cpp.

{
    test_url->SetPath(NS_LITERAL_CSTRING("/some-path/one-the-net/about.html?with-a-query#for-you"));
}

Here is the caller graph for this function:

static void set_scheme_test ( ) [static]

Definition at line 41 of file TestStandardURL.cpp.

{
    test_url->SetScheme(NS_LITERAL_CSTRING("foo"));
}

Here is the caller graph for this function:

static void set_spec_test ( ) [static]

Definition at line 24 of file TestStandardURL.cpp.

{
    test_url->SetSpec(test_param);
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 11 of file TestStandardURL.cpp.

nsIURL* test_url = 0 [static]

Definition at line 10 of file TestStandardURL.cpp.