xref: /haiku/src/tests/kits/app/blooper/RemoveCommonFilterTest.cpp (revision 0b55d6648fcc366172730f4e26cd38915e011c09)
1 //------------------------------------------------------------------------------
2 //	RemoveCommonFilterTest.cpp
3 //
4 //------------------------------------------------------------------------------
5 
6 // Standard Includes -----------------------------------------------------------
7 
8 // System Includes -------------------------------------------------------------
9 #include <Looper.h>
10 #include <MessageFilter.h>
11 
12 // Project Includes ------------------------------------------------------------
13 
14 // Local Includes --------------------------------------------------------------
15 #include "RemoveCommonFilterTest.h"
16 
17 // Local Defines ---------------------------------------------------------------
18 
19 // Globals ---------------------------------------------------------------------
20 
21 //------------------------------------------------------------------------------
22 /**
23 	RemoveCommonFilter(BMessageFilter* filter)
24 	@case		NULL filter
25 	@param		filter is NULL
26 	@results
27  */
RemoveCommonFilterTest1()28 void TRemoveCommonFilterTest::RemoveCommonFilterTest1()
29 {
30 	BLooper Looper;
31 	CPPUNIT_ASSERT(!Looper.RemoveCommonFilter(NULL));
32 }
33 //------------------------------------------------------------------------------
34 /**
35 	RemoveCommonFilter(BMessageFilter* filter)
36 	@case		Valid filter, looper not locked
37 	@param		Valid BMessageFilter pointer
38 	@results
39  */
RemoveCommonFilterTest2()40 void TRemoveCommonFilterTest::RemoveCommonFilterTest2()
41 {
42 	DEBUGGER_ESCAPE;
43 
44 	BLooper Looper;
45 	BMessageFilter* Filter = new BMessageFilter('1234');
46 	Looper.AddCommonFilter(Filter);
47 	Looper.Unlock();
48 	CPPUNIT_ASSERT(!Looper.RemoveCommonFilter(Filter));
49 }
50 //------------------------------------------------------------------------------
51 /**
52 	RemoveCommonFilter(BMessageFilter* filter)
53 	@case		Valid filter, not owned by looper
54 	@param		Valid BMessageFilter pointer
55 	@results
56  */
RemoveCommonFilterTest3()57 void TRemoveCommonFilterTest::RemoveCommonFilterTest3()
58 {
59 	BLooper Looper;
60 	BMessageFilter Filter('1234');
61 	CPPUNIT_ASSERT(!Looper.RemoveCommonFilter(&Filter));
62 }
63 //------------------------------------------------------------------------------
64 /**
65 	RemoveCommonFilter(BMessageFilter* filter)
66 	@case		Valid filter, owned by looper
67 	@param		Valid BMessageFilter pointer
68 	@results
69  */
RemoveCommonFilterTest4()70 void TRemoveCommonFilterTest::RemoveCommonFilterTest4()
71 {
72 	BLooper Looper;
73 	BMessageFilter Filter('1234');
74 	Looper.AddCommonFilter(&Filter);
75 	CPPUNIT_ASSERT(Looper.RemoveCommonFilter(&Filter));
76 }
77 //------------------------------------------------------------------------------
78 #ifdef ADD_TEST
79 #undef ADD_TEST
80 #endif
81 #define ADD_TEST(__test_name__)	\
82 	ADD_TEST4(BLooper, suite, TRemoveCommonFilterTest, __test_name__)
Suite()83 TestSuite* TRemoveCommonFilterTest::Suite()
84 {
85 	TestSuite* suite = new TestSuite("BLooper::RemoveCommonFilter(BMessageFilter*)");
86 
87 	ADD_TEST(RemoveCommonFilterTest1);
88 	ADD_TEST(RemoveCommonFilterTest2);
89 	ADD_TEST(RemoveCommonFilterTest3);
90 	ADD_TEST(RemoveCommonFilterTest4);
91 
92 	return suite;
93 }
94 //------------------------------------------------------------------------------
95 
96 /*
97  * $Log $
98  *
99  * $Id  $
100  *
101  */
102 
103