From 5336026593592ee0b4eacaacd93d9d119f40020e Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 17 Jun 2009 12:36:36 +0000 Subject: Part of ticket #887: - added pj_shutdown() in pjlib-test's test.c - refactor main_symbian.cpp (it's not been used for a while) - compilation error/warning about initializing pj_str_t struct from non-constant value git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2769 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pjlib-test/main_symbian.cpp | 104 +++++++--------------------------- pjlib/src/pjlib-test/string.c | 6 +- pjlib/src/pjlib-test/test.c | 3 + 3 files changed, 29 insertions(+), 84 deletions(-) (limited to 'pjlib/src') diff --git a/pjlib/src/pjlib-test/main_symbian.cpp b/pjlib/src/pjlib-test/main_symbian.cpp index e57b080d..a91b671f 100644 --- a/pjlib/src/pjlib-test/main_symbian.cpp +++ b/pjlib/src/pjlib-test/main_symbian.cpp @@ -44,21 +44,6 @@ int main() LOCAL_D CConsoleBase* console; // write all messages to this -// Local Functions - -LOCAL_C void MainL() -{ - // - // add your program code here, example code below - // - test_main(); - - console->Printf(_L(" [press any key]\n")); - console->Getch(); - - CActiveScheduler::Stop(); -} - class MyScheduler : public CActiveScheduler { public: @@ -73,67 +58,6 @@ void MyScheduler::Error(TInt aError) const PJ_UNUSED_ARG(aError); } -class ProgramStarter : public CActive -{ -public: - static ProgramStarter *NewL(); - void Start(); - -protected: - ProgramStarter(); - void ConstructL(); - virtual void RunL(); - virtual void DoCancel(); - TInt RunError(TInt aError); - -private: - RTimer timer_; -}; - -ProgramStarter::ProgramStarter() -: CActive(EPriorityNormal) -{ -} - -void ProgramStarter::ConstructL() -{ - timer_.CreateLocal(); - CActiveScheduler::Add(this); -} - -ProgramStarter *ProgramStarter::NewL() -{ - ProgramStarter *self = new (ELeave) ProgramStarter; - CleanupStack::PushL(self); - - self->ConstructL(); - - CleanupStack::Pop(self); - return self; -} - -void ProgramStarter::Start() -{ - timer_.After(iStatus, 0); - SetActive(); -} - -void ProgramStarter::RunL() -{ - MainL(); -} - -void ProgramStarter::DoCancel() -{ -} - -TInt ProgramStarter::RunError(TInt aError) -{ - PJ_UNUSED_ARG(aError); - return KErrNone; -} - - LOCAL_C void DoStartL() { // Create active scheduler (to run active objects) @@ -141,25 +65,36 @@ LOCAL_C void DoStartL() CleanupStack::PushL(scheduler); CActiveScheduler::Install(scheduler); - ProgramStarter *starter = ProgramStarter::NewL(); - starter->Start(); + test_main(); - CActiveScheduler::Start(); + CActiveScheduler::Install(NULL); + CleanupStack::Pop(scheduler); + delete scheduler; } +#define WRITE_TO_DEBUG_CONSOLE -// Global Functions +#ifdef WRITE_TO_DEBUG_CONSOLE +#include +#endif +// Global Functions static void log_writer(int level, const char *buf, int len) { - wchar_t buf16[PJ_LOG_MAX_SIZE]; + static wchar_t buf16[PJ_LOG_MAX_SIZE]; PJ_UNUSED_ARG(level); pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16)); - + buf16[len] = 0; + buf16[len+1] = 0; + TPtrC16 aBuf((const TUint16*)buf16, (TInt)len); console->Write(aBuf); + +#ifdef WRITE_TO_DEBUG_CONSOLE + RDebug::Print(aBuf); +#endif } @@ -180,12 +115,17 @@ GLDEF_C TInt E32Main() TRAPD(mainError, DoStartL()); if (mainError) console->Printf(_L(" failed, leave code = %d"), mainError); + console->Printf(_L(" [press any key]\n")); console->Getch(); delete console; delete cleanup; + + CloseSTDLIB(); + __UHEAP_MARKEND; + return KErrNone; } diff --git a/pjlib/src/pjlib-test/string.c b/pjlib/src/pjlib-test/string.c index 18cfb6c5..4f0e325d 100644 --- a/pjlib/src/pjlib-test/string.c +++ b/pjlib/src/pjlib-test/string.c @@ -65,7 +65,9 @@ #endif #define HELLO_WORLD "Hello World" +#define HELLO_WORLD_LEN 11 #define JUST_HELLO "Hello" +#define JUST_HELLO_LEN 5 #define UL_VALUE 3456789012UL #if 1 @@ -290,8 +292,8 @@ static int strcmp_test(void) int string_test(void) { - const pj_str_t hello_world = { HELLO_WORLD, strlen(HELLO_WORLD) }; - const pj_str_t just_hello = { JUST_HELLO, strlen(JUST_HELLO) }; + const pj_str_t hello_world = { HELLO_WORLD, HELLO_WORLD_LEN }; + const pj_str_t just_hello = { JUST_HELLO, JUST_HELLO_LEN }; pj_str_t s1, s2, s3, s4, s5; enum { RCOUNT = 10, RLEN = 16 }; pj_str_t random[RCOUNT]; diff --git a/pjlib/src/pjlib-test/test.c b/pjlib/src/pjlib-test/test.c index dafedd3c..b3e2951d 100644 --- a/pjlib/src/pjlib-test/test.c +++ b/pjlib/src/pjlib-test/test.c @@ -197,6 +197,9 @@ on_return: PJ_LOG(3,("test", "Looks like everything is okay!..")); else PJ_LOG(3,("test", "Test completed with error(s)")); + + pj_shutdown(); + return 0; } -- cgit v1.2.3