1 //------------------------------------------------------------------------------ 2 // RunTest.cpp 3 // 4 //------------------------------------------------------------------------------ 5 6 // Standard Includes ----------------------------------------------------------- 7 8 // System Includes ------------------------------------------------------------- 9 #include <Looper.h> 10 11 // Project Includes ------------------------------------------------------------ 12 13 // Local Includes -------------------------------------------------------------- 14 #include "RunTest.h" 15 16 // Local Defines --------------------------------------------------------------- 17 18 // Globals --------------------------------------------------------------------- 19 20 //------------------------------------------------------------------------------ 21 /** 22 Run() 23 @case Attempt to call Run() twice 24 @results debugger message "can't call BLooper::Run twice!" 25 */ 26 void TRunTest::RunTest1() 27 { 28 DEBUGGER_ESCAPE; 29 30 BLooper Looper; 31 Looper.Run(); 32 Looper.Run(); 33 Looper.Quit(); 34 } 35 //------------------------------------------------------------------------------ 36 /** 37 Run() 38 @case Check thread_id of Looper 39 @results Run() and Thread() return the same thread_id 40 */ 41 void TRunTest::RunTest2() 42 { 43 BLooper* Looper = new BLooper; 44 thread_id tid = Looper->Run(); 45 CPPUNIT_ASSERT(tid == Looper->Thread()); 46 Looper->Lock(); 47 Looper->Quit(); 48 } 49 //------------------------------------------------------------------------------ 50 /** 51 Run() 52 @case Delete looper after calling Run() 53 @results Debugger message "You can't call delete on a BLooper object 54 once it is running." 55 */ 56 void TRunTest::RunTest3() 57 { 58 BLooper* Looper = new BLooper; 59 Looper->Run(); 60 delete Looper; 61 } 62 //------------------------------------------------------------------------------ 63 #ifdef ADD_TEST 64 #undef ADD_TEST 65 #endif 66 #define ADD_TEST(__test_name__) \ 67 ADD_TEST4(BLooper, suite, TRunTest, __test_name__) 68 69 TestSuite* TRunTest::Suite() 70 { 71 TestSuite* suite = new TestSuite("BLooper::Run()"); 72 73 ADD_TEST(RunTest1); 74 ADD_TEST(RunTest2); 75 76 return suite; 77 } 78 //------------------------------------------------------------------------------ 79 80 /* 81 * $Log $ 82 * 83 * $Id $ 84 * 85 */ 86 87