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);
static NS_DEFINE_CID(kScreenManagerCID, NS_SCREENMANAGER_CID); static NS_DEFINE_IID(kCRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kCDeviceContextCID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kCFontMetricsCID, NS_FONT_METRICS_CID); static NS_DEFINE_IID(kCImageCID, NS_IMAGE_CID); static NS_DEFINE_IID(kCTimerCID, NS_TIMER_CID); static NS_DEFINE_IID(kCTimerManagerCID, NS_TIMERMANAGER_CID); nsComponentManager::RegisterComponentLib(kScreenManagerCID, "Screen Manager", "@mozilla.org/gfx/screenmanager;1", GFXWIN_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCRenderingContextCID, "Rendering Context", "@mozilla.org/gfx/renderingcontext;1", GFXWIN_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCDeviceContextCID, "Device Context", "@mozilla.org/gfx/devicecontext;1", GFXWIN_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCFontMetricsCID, "Font Metrics", "@mozilla.org/gfx/fontmetrics;1", GFXWIN_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCImageCID, "Image", "@mozilla.org/gfx/image;1", GFXWIN_DLL, PR_FALSE, PR_FALSE); #ifdef XP_PC nsComponentManager::RegisterComponentLib(kCTimerCID, "Timer", "@mozilla.org/timer;1", WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCTimerManagerCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); #endif
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());}