gWindow->SetTitle("Pixel coverage test");
nsAutoString strTitle(NS_LITERAL_STRING("Pixel coverage test")); gWindow->SetTitle(strTitle);
nsresult CoverageTest(int *argc, char **argv){    // register xpcom classes    nsComponentManager::RegisterComponentLib(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);    nsComponentManager::RegisterComponentLib(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);        // register widget classes    nsComponentManager::RegisterComponentLib(kLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);    nsComponentManager::RegisterComponentLib(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);        nsComponentManager::RegisterComponentLib(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);    nsComponentManager::RegisterComponentLib(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);    static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID);     static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID);     static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);     static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);     nsComponentManager::RegisterComponentLib(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE);     nsComponentManager::RegisterComponentLib(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE);     nsComponentManager::RegisterComponentLib(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE);     nsComponentManager::RegisterComponentLib(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE);     nsresult  res;    // Create the Event Queue for the UI thread...    res = nsServiceManager::GetService(kEventQueueServiceCID,                                       kIEventQueueServiceIID,                                       (nsISupports **)&gEventQService);    if (NS_OK != res) {        NS_ASSERTION(PR_FALSE, "Could not obtain the event queue service");        return res;    }    res = gEventQService->CreateThreadEventQueue();    if (NS_OK != res) {        NS_ASSERTION(PR_FALSE, "Could not create the event queue for the thread");	      return res;    }      // Create a application shell    nsIAppShell *appShell;    nsComponentManager::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, (void**)&appShell);    if (appShell != nsnull) {      fputs("Created AppShell\n", stderr);      appShell->Create(argc, argv);    } else {      printf("AppShell is null!\n");    }    nsIDeviceContext* deviceContext = 0;    // Create a device context for the widgets    static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);    static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);    //    // create the main window    //    nsComponentManager::CreateInstance(kCWindowCID, nsnull, kIWidgetIID, (void**)&gWindow);    nsRect rect(100, 100, 600, 700);    gWindow->Create((nsIWidget*) nsnull, rect, HandleEvent,                    (nsIDeviceContext *) nsnull,                   appShell);    gWindow->SetTitle("Pixel coverage test");    //    // Create Device Context based on main window    //    res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&deviceContext);    if (NS_OK == res)    {      deviceContext->Init(gWindow->GetNativeData(NS_NATIVE_WIDGET));      NS_ADDREF(deviceContext);    }    gWindow->Show(PR_TRUE);     return(appShell->Run());}