1//------------------------------------------------------------------------------ 2// AddHandlerTest.cpp 3// 4//------------------------------------------------------------------------------ 5/** 6 @note Most of AddHandler()'s functionality is indirectly exercised 7 by the tests for RemoveHandler(), CountHandler(), HandlerAt() and 8 IndexOf(). If AddHandler() isn't working correctly, it will show up 9 there. I do wonder if I should replicate those tests here anyway so 10 that any problem specifically show up in this test suite. 11 */ 12 13// Standard Includes ----------------------------------------------------------- 14 15// System Includes ------------------------------------------------------------- 16#include <Looper.h> 17 18// Project Includes ------------------------------------------------------------ 19 20// Local Includes -------------------------------------------------------------- 21#include "AddHandlerTest.h" 22 23// Local Defines --------------------------------------------------------------- 24 25// Globals --------------------------------------------------------------------- 26 27//------------------------------------------------------------------------------ 28/** 29 AddHandler(BHandler*) 30 @case handler is NULL 31 @param handler 32 @results Nothing (bad) should happen when AddHandler() is called, and 33 CountHandlers() should return 1 (for the looper itself). R5 34 can't handle this test; it has a segment violation. 35 */ 36void TAddHandlerTest::AddHandlerTest1() 37{ 38 BLooper Looper; 39#ifndef TEST_R5 40 Looper.AddHandler(NULL); 41#endif 42 CPPUNIT_ASSERT(Looper.CountHandlers() == 1); 43} 44//------------------------------------------------------------------------------ 45/** 46 AddHandler(BHandler*) 47 @case looper is unlocked 48 @param handler 49 @results Goes to debugger with message "Looper must be locked before 50 calling AddHandler." 51 */ 52void TAddHandlerTest::AddHandlerTest2() 53{ 54 DEBUGGER_ESCAPE; 55 56 BLooper Looper; 57 BHandler Handler; 58 Looper.Unlock(); 59 Looper.AddHandler(&Handler); 60} 61//------------------------------------------------------------------------------ 62TestSuite* TAddHandlerTest::Suite() 63{ 64 TestSuite* suite = new TestSuite("BLooper::AddHandler(BHandler*)"); 65 66 ADD_TEST4(BLooper, suite, TAddHandlerTest, AddHandlerTest1); 67 ADD_TEST4(BLooper, suite, TAddHandlerTest, AddHandlerTest2); 68 69 return suite; 70} 71//------------------------------------------------------------------------------ 72 73/* 74 * $Log $ 75 * 76 * $Id $ 77 * 78 */ 79 80 81