Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
TestStreamLoader.cpp File Reference
#include <stdio.h>
#include "TestCommon.h"
#include "nsNetUtil.h"
#include "nsEventQueueUtils.h"
#include "prlog.h"

Go to the source code of this file.

Classes

class  MyStreamLoaderObserver

Defines

#define LOG(args)   PR_LOG(gTestLog, PR_LOG_DEBUG, args)

Functions

int main (int argc, char **argv)
 The Xalan testcases app.

Variables

static PRBool gKeepRunning = PR_TRUE
static nsIEventQueuegEventQ = nsnull

Define Documentation

#define LOG (   args)    PR_LOG(gTestLog, PR_LOG_DEBUG, args)

Definition at line 13 of file TestStreamLoader.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 44 of file TestStreamLoader.cpp.

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

  if (argc < 2) {
    printf("usage: %s <url>\n", argv[0]);
    return -1;
  }

#if defined(PR_LOGGING)
  gTestLog = PR_NewLogModule("Test");
#endif

  nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
  if (NS_FAILED(rv))
    return -1;

  {
    // Create the Event Queue for this thread...
    rv = NS_GetMainEventQ(&gEventQ);
    if (NS_FAILED(rv))
      return -1;

    nsCOMPtr<nsIURI> uri;
    rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(argv[1]));
    if (NS_FAILED(rv))
      return -1;

    nsCOMPtr<nsIChannel> chan;
    rv = NS_NewChannel(getter_AddRefs(chan), uri);
    if (NS_FAILED(rv))
      return -1;

    nsCOMPtr<nsIStreamLoaderObserver> observer = new MyStreamLoaderObserver();
    if (!observer)
      return -1;

    nsCOMPtr<nsIStreamLoader> loader;
    rv = NS_NewStreamLoader(getter_AddRefs(loader), chan, observer, nsnull);
    if (NS_FAILED(rv))
      return -1;

    // Enter the message pump to allow the URL load to proceed.
    while (gKeepRunning) {
      PLEvent *e;
      gEventQ->WaitForEvent(&e);
      gEventQ->HandleEvent(e);
    }
  } // this scopes the nsCOMPtrs
  // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
  NS_ShutdownXPCOM(nsnull);
  return rv;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 16 of file TestStreamLoader.cpp.

Definition at line 15 of file TestStreamLoader.cpp.