1 //------------------------------------------------------------------------------
2 // AddFilterTest.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 "AddFilterTest.h"
16
17 // Local Defines ---------------------------------------------------------------
18
19 // Globals ---------------------------------------------------------------------
20
21 //------------------------------------------------------------------------------
22 /**
23 AddFilter(BMessageFilter* filter)
24 @case filter is NULL
25 @param filter NULL
26 @results None (i.e., no seg faults, etc.)
27 @note Contrary to documentation, BHandler doesn't seem to care if
28 it belongs to a BLooper when a filter gets added. Also,
29 the original implementation does not handle a NULL param
30 gracefully, so this test is not enabled against it.
31 */
AddFilter1()32 void TAddFilterTest::AddFilter1()
33 {
34 #if !defined(TEST_R5)
35 BHandler Handler;
36 Handler.AddFilter(NULL);
37 #endif
38 }
39 //------------------------------------------------------------------------------
40 /**
41 AddFilter(BMessageFilter* filter)
42 @case filter is valid, handler has no looper
43 @param filter Valid BMessageFilter pointer
44 @results None (i.e., no seg faults, etc.)
45 @note Contrary to documentation, BHandler doesn't seem to care if
46 it belongs to a BLooper when a filter gets added.
47 */
AddFilter2()48 void TAddFilterTest::AddFilter2()
49 {
50 BHandler Handler;
51 BMessageFilter* Filter = new BMessageFilter('1234');
52 Handler.AddFilter(Filter);
53 }
54 //------------------------------------------------------------------------------
55 /**
56 AddFilter(BMessageFilter* filter)
57 @case filter is valid, handler has looper, looper isn't locked
58 @param filter Valid BMessageFilter pointer
59 @results None (i.e., no seg faults, etc.)
60 @note Contrary to documentation, BHandler doesn't seem to care if
61 if belongs to a BLooper when a filter gets added, or
62 whether the looper is locked.
63 */
AddFilter3()64 void TAddFilterTest::AddFilter3()
65 {
66 BLooper Looper;
67 BHandler Handler;
68 BMessageFilter* Filter = new BMessageFilter('1234');
69 Looper.AddHandler(&Handler);
70 Handler.AddFilter(Filter);
71 }
72 //------------------------------------------------------------------------------
73 /**
74 AddFilter(BMessageFilter* filter)
75 @case filter is valid, handler has looper, looper is locked
76 @param filter Valid BMessageFilter pointer
77 @results None (i.e., no seg faults, etc.)
78 */
AddFilter4()79 void TAddFilterTest::AddFilter4()
80 {
81 BLooper Looper;
82 BHandler Handler;
83 BMessageFilter* Filter = new BMessageFilter('1234');
84 Looper.Lock();
85 Looper.AddHandler(&Handler);
86 Handler.AddFilter(Filter);
87 }
88 //------------------------------------------------------------------------------
Suite()89 Test* TAddFilterTest::Suite()
90 {
91 TestSuite* SuiteOfTests = new TestSuite("BHandler::AddFilter");
92
93 ADD_TEST4(BHandler, SuiteOfTests, TAddFilterTest, AddFilter1);
94 ADD_TEST4(BHandler, SuiteOfTests, TAddFilterTest, AddFilter2);
95 ADD_TEST4(BHandler, SuiteOfTests, TAddFilterTest, AddFilter3);
96 ADD_TEST4(BHandler, SuiteOfTests, TAddFilterTest, AddFilter4);
97
98 return SuiteOfTests;
99 }
100 //------------------------------------------------------------------------------
101
102 /*
103 * $Log $
104 *
105 * $Id $
106 *
107 */
108
109
110