Changeset 2769


Ignore:
Timestamp:
Jun 17, 2009 12:36:36 PM (15 years ago)
Author:
bennylp
Message:

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
Location:
pjproject/trunk/pjlib/src/pjlib-test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pjlib-test/main_symbian.cpp

    r1269 r2769  
    4545 
    4646 
    47 //  Local Functions 
    48  
    49 LOCAL_C void MainL() 
    50 { 
    51     // 
    52     // add your program code here, example code below 
    53     // 
    54     test_main(); 
    55  
    56     console->Printf(_L(" [press any key]\n")); 
    57     console->Getch(); 
    58  
    59     CActiveScheduler::Stop(); 
    60 } 
    61  
    6247class MyScheduler : public CActiveScheduler 
    6348{ 
     
    7459} 
    7560 
    76 class ProgramStarter : public CActive 
    77 { 
    78 public: 
    79     static ProgramStarter *NewL(); 
    80     void Start(); 
    81  
    82 protected: 
    83     ProgramStarter(); 
    84     void ConstructL(); 
    85     virtual void RunL(); 
    86     virtual void DoCancel(); 
    87     TInt RunError(TInt aError); 
    88  
    89 private: 
    90     RTimer timer_; 
    91 }; 
    92  
    93 ProgramStarter::ProgramStarter() 
    94 : CActive(EPriorityNormal) 
    95 { 
    96 } 
    97  
    98 void ProgramStarter::ConstructL() 
    99 { 
    100     timer_.CreateLocal(); 
    101     CActiveScheduler::Add(this); 
    102 } 
    103  
    104 ProgramStarter *ProgramStarter::NewL() 
    105 { 
    106     ProgramStarter *self = new (ELeave) ProgramStarter; 
    107     CleanupStack::PushL(self); 
    108  
    109     self->ConstructL(); 
    110  
    111     CleanupStack::Pop(self); 
    112     return self; 
    113 } 
    114  
    115 void ProgramStarter::Start() 
    116 { 
    117     timer_.After(iStatus, 0); 
    118     SetActive(); 
    119 } 
    120  
    121 void ProgramStarter::RunL() 
    122 { 
    123     MainL(); 
    124 } 
    125  
    126 void ProgramStarter::DoCancel() 
    127 { 
    128 } 
    129  
    130 TInt ProgramStarter::RunError(TInt aError) 
    131 { 
    132     PJ_UNUSED_ARG(aError); 
    133     return KErrNone; 
    134 } 
    135  
    136  
    13761LOCAL_C void DoStartL() 
    13862    { 
     
    14266    CActiveScheduler::Install(scheduler); 
    14367 
    144     ProgramStarter *starter = ProgramStarter::NewL(); 
    145     starter->Start(); 
     68    test_main(); 
    14669 
    147     CActiveScheduler::Start(); 
     70    CActiveScheduler::Install(NULL); 
     71    CleanupStack::Pop(scheduler); 
     72    delete scheduler; 
    14873    } 
    14974 
     75#define WRITE_TO_DEBUG_CONSOLE 
     76 
     77#ifdef WRITE_TO_DEBUG_CONSOLE 
     78#include<e32debug.h> 
     79#endif 
    15080 
    15181//  Global Functions 
    152  
    15382static void log_writer(int level, const char *buf, int len) 
    15483{ 
    155     wchar_t buf16[PJ_LOG_MAX_SIZE]; 
     84    static wchar_t buf16[PJ_LOG_MAX_SIZE]; 
    15685 
    15786    PJ_UNUSED_ARG(level); 
    15887     
    15988    pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16)); 
    160  
     89    buf16[len] = 0; 
     90    buf16[len+1] = 0; 
     91     
    16192    TPtrC16 aBuf((const TUint16*)buf16, (TInt)len); 
    16293    console->Write(aBuf); 
     94     
     95#ifdef WRITE_TO_DEBUG_CONSOLE 
     96    RDebug::Print(aBuf); 
     97#endif 
    16398} 
    16499 
     
    181116    if (mainError) 
    182117        console->Printf(_L(" failed, leave code = %d"), mainError); 
     118     
    183119    console->Printf(_L(" [press any key]\n")); 
    184120    console->Getch(); 
     
    186122    delete console; 
    187123    delete cleanup; 
     124     
     125    CloseSTDLIB();  
     126     
    188127    __UHEAP_MARKEND; 
     128     
    189129    return KErrNone; 
    190130    } 
  • pjproject/trunk/pjlib/src/pjlib-test/string.c

    r2394 r2769  
    6666 
    6767#define HELLO_WORLD     "Hello World" 
     68#define HELLO_WORLD_LEN 11 
    6869#define JUST_HELLO      "Hello" 
     70#define JUST_HELLO_LEN  5 
    6971#define UL_VALUE        3456789012UL 
    7072 
     
    291293int string_test(void) 
    292294{ 
    293     const pj_str_t hello_world = { HELLO_WORLD, strlen(HELLO_WORLD) }; 
    294     const pj_str_t just_hello = { JUST_HELLO, strlen(JUST_HELLO) }; 
     295    const pj_str_t hello_world = { HELLO_WORLD, HELLO_WORLD_LEN }; 
     296    const pj_str_t just_hello = { JUST_HELLO, JUST_HELLO_LEN }; 
    295297    pj_str_t s1, s2, s3, s4, s5; 
    296298    enum { RCOUNT = 10, RLEN = 16 }; 
  • pjproject/trunk/pjlib/src/pjlib-test/test.c

    r2394 r2769  
    198198    else 
    199199        PJ_LOG(3,("test", "Test completed with error(s)")); 
     200     
     201    pj_shutdown(); 
     202     
    200203    return 0; 
    201204} 
Note: See TracChangeset for help on using the changeset viewer.