xref: /haiku/src/tests/kits/app/bhandler/UnlockLooperTest.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 //------------------------------------------------------------------------------
2 //	UnlockLooperTest.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 "UnlockLooperTest.h"
15 
16 // Local Defines ---------------------------------------------------------------
17 
18 // Globals ---------------------------------------------------------------------
19 
20 //------------------------------------------------------------------------------
21 /**
22 	UnlockLooper()
23 	@case		handler has no looper
24 	@results	NONE
25 	@note		Original implementation apparently doesn't check to see if a
26 				looper actually exists before trying to call Unlock() on it.
27 				Disabled for TEST_R5.
28  */
29 void TUnlockLooperTest::UnlockLooper1()
30 {
31 #if !defined(TEST_R5)
32 	BHandler Handler;
33 	Handler.UnlockLooper();
34 #endif
35 }
36 //------------------------------------------------------------------------------
37 /**
38 	UnlockLooper()
39 	@case		handler has a looper which is initially unlocked
40 	@results	debug message "looper must be locked before proceeding" from
41 				BLooper::AssertLock()
42  */
43 void TUnlockLooperTest::UnlockLooper2()
44 {
45 	DEBUGGER_ESCAPE;
46 
47 	BLooper Looper;
48 	BHandler Handler;
49 	Looper.AddHandler(&Handler);
50 	if (Looper.IsLocked())
51 	{
52 		// Make sure the looper is unlocked
53 		Looper.Unlock();
54 	}
55 	Handler.UnlockLooper();
56 }
57 //------------------------------------------------------------------------------
58 /**
59 	UnlockLooper()
60 	@case		handler has a looper which is initially locked
61 	@results	NONE
62  */
63 void TUnlockLooperTest::UnlockLooper3()
64 {
65 	BLooper Looper;
66 	BHandler Handler;
67 	Looper.AddHandler(&Handler);
68 	if (!Looper.IsLocked())
69 	{
70 		Looper.Lock();
71 	}
72 	Handler.UnlockLooper();
73 }
74 //------------------------------------------------------------------------------
75 Test* TUnlockLooperTest::Suite()
76 {
77 	TestSuite* SuiteOfTests = new TestSuite("BHandler::UnlockLooper");
78 
79 	ADD_TEST4(BHandler, SuiteOfTests, TUnlockLooperTest, UnlockLooper1);
80 	ADD_TEST4(BHandler, SuiteOfTests, TUnlockLooperTest, UnlockLooper2);
81 	ADD_TEST4(BHandler, SuiteOfTests, TUnlockLooperTest, UnlockLooper3);
82 
83 	return SuiteOfTests;
84 }
85 //------------------------------------------------------------------------------
86 
87 /*
88  * $Log $
89  *
90  * $Id  $
91  *
92  */
93 
94 
95