1 //------------------------------------------------------------------------------ 2 // CountHandlersTest.cpp 3 // 4 //------------------------------------------------------------------------------ 5 6 // Standard Includes ----------------------------------------------------------- 7 8 // System Includes ------------------------------------------------------------- 9 #include <Handler.h> 10 #include <Looper.h> 11 12 // Project Includes ------------------------------------------------------------ 13 14 // Local Includes -------------------------------------------------------------- 15 #include "CountHandlersTest.h" 16 17 // Local Defines --------------------------------------------------------------- 18 19 // Globals --------------------------------------------------------------------- 20 21 //------------------------------------------------------------------------------ 22 /** 23 CountHandlers() 24 @case No handlers added 25 @results 26 */ 27 void TCountHandlersTest::CountHandlersTest1() 28 { 29 BLooper Looper; 30 CPPUNIT_ASSERT(Looper.CountHandlers() == 1); 31 } 32 //------------------------------------------------------------------------------ 33 /** 34 CountHandlers() 35 @case Several handlers added, then removed 36 @results 37 */ 38 void TCountHandlersTest::CountHandlersTest2() 39 { 40 BLooper Looper; 41 BHandler Handler1; 42 BHandler Handler2; 43 BHandler Handler3; 44 45 Looper.AddHandler(&Handler1); 46 CPPUNIT_ASSERT(Looper.CountHandlers() == 2); 47 Looper.AddHandler(&Handler2); 48 CPPUNIT_ASSERT(Looper.CountHandlers() == 3); 49 Looper.AddHandler(&Handler3); 50 CPPUNIT_ASSERT(Looper.CountHandlers() == 4); 51 52 Looper.RemoveHandler(&Handler3); 53 CPPUNIT_ASSERT(Looper.CountHandlers() == 3); 54 Looper.RemoveHandler(&Handler2); 55 CPPUNIT_ASSERT(Looper.CountHandlers() == 2); 56 Looper.RemoveHandler(&Handler1); 57 CPPUNIT_ASSERT(Looper.CountHandlers() == 1); 58 } 59 //------------------------------------------------------------------------------ 60 TestSuite* TCountHandlersTest::Suite() 61 { 62 TestSuite* suite = new TestSuite("BLooper::CountHandlers()"); 63 64 ADD_TEST4(BLooper, suite, TCountHandlersTest, CountHandlersTest1); 65 ADD_TEST4(BLooper, suite, TCountHandlersTest, CountHandlersTest2); 66 67 return suite; 68 } 69 //------------------------------------------------------------------------------ 70 71 /* 72 * $Log $ 73 * 74 * $Id $ 75 * 76 */ 77 78 79