From abc1ed2795378ba214f3b5049a5368f4a5a0fd25 Mon Sep 17 00:00:00 2001 From: "gordon%netscape.com" Date: Fri, 13 Aug 1999 22:18:34 +0000 Subject: [PATCH] This is just a NECKO test app. Updating to work on Mac. --- netwerk/test/TestSocketTransport.cpp | 42 +++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/netwerk/test/TestSocketTransport.cpp b/netwerk/test/TestSocketTransport.cpp index 99cb3b26932..0338b68e004 100644 --- a/netwerk/test/TestSocketTransport.cpp +++ b/netwerk/test/TestSocketTransport.cpp @@ -38,6 +38,13 @@ #include "nsCRT.h" +#if defined(XP_MAC) +#include "macstdlibextras.h" + // Set up the toolbox and (if DEBUG) the console. Do this in a static initializer, + // to make it as unlikely as possible that somebody calls printf() before we get initialized. +static struct MacInitializer { MacInitializer() { InitializeMacToolbox(); InitializeSIOUX(true); } } gInitializer; +#endif // XP_MAC + // forward declarations... class TestConnection; @@ -55,8 +62,12 @@ static nsIThread* gThreads[NUM_TEST_THREADS]; //static nsITimer* gPeriodicTimer; -void Pump_PLEvents(void) +void Pump_PLEvents(nsIEventQueueService * eventQService); +void Pump_PLEvents(nsIEventQueueService * eventQService) { + nsIEventQueue* eventQ = nsnull; + eventQService->GetThreadEventQueue(PR_CurrentThread(), &eventQ); + while ( gKeepRunning ) { #ifdef WIN32 MSG msg; @@ -67,15 +78,11 @@ void Pump_PLEvents(void) } else { gKeepRunning = FALSE; } -#else -#ifdef XP_MAC - /* Mac stuff is missing here! */ #else nsresult rv; PLEvent *gEvent; - rv = gEventQ->GetEvent(&gEvent); - rv = gEventQ->HandleEvent(gEvent); -#endif /* XP_UNIX */ + rv = eventQ->GetEvent(&gEvent); + rv = eventQ->HandleEvent(gEvent); #endif /* !WIN32 */ } @@ -214,6 +221,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort, PRBool aAsy rv = sts->CreateTransport(aHostName, aPort, &mTransport); } + if (NS_SUCCEEDED(rv)) { if (mIsAsync) { // Create a stream for the data being written to the server... @@ -302,7 +310,7 @@ TestConnection::Run(void) } else { rv = WriteBuffer(); } - Pump_PLEvents(); + Pump_PLEvents(eventQService); } else { while (NS_SUCCEEDED(rv)) { @@ -484,6 +492,7 @@ void TimerCallback(nsITimer* aTimer, void* aClosure) #endif /* USE_TIMERS */ +nsresult NS_AutoregisterComponents(); nsresult NS_AutoregisterComponents() { nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); @@ -509,6 +518,7 @@ main(int argc, char* argv[]) char* hostName = nsnull; int i; + for (i=1; iCreateThreadEventQueue(); if (NS_FAILED(rv)) return rv; - eventQService->GetThreadEventQueue(PR_CurrentThread(), &gEventQ); - // // Create the connections and threads... // @@ -549,6 +563,7 @@ main(int argc, char* argv[]) rv = NS_NewThread(&gThreads[i], gConnections[i]); } + #if defined(USE_TIMERS) // // Start up the timer to test Suspend/Resume APIs on the transport... @@ -560,11 +575,12 @@ main(int argc, char* argv[]) // Enter the message pump to allow the URL load to proceed. - Pump_PLEvents(); + Pump_PLEvents(eventQService); PRTime endTime; endTime = PR_Now(); - printf("Elapsed time: %ld\n", (PRInt32)(endTime/1000UL-gElapsedTime/1000UL)); + +// printf("Elapsed time: %ld\n", (PRInt32)(endTime/1000UL - gElapsedTime/1000UL)); NS_RELEASE(eventQService);