xref: /haiku/src/tests/kits/app/bhandler/UnlockLooperTest.cpp (revision df8b692ac0ba4c71a968a22593d2195450466d27)
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  */
UnlockLooper1()29 void TUnlockLooperTest::UnlockLooper1()
30 {
31 #if !defined(TEST_R5)
32 	DEBUGGER_ESCAPE;
33 
34 	BHandler Handler;
35 	Handler.UnlockLooper();
36 #endif
37 }
38 //------------------------------------------------------------------------------
39 /**
40 	UnlockLooper()
41 	@case		handler has a looper which is initially unlocked
42 	@results	debug message "looper must be locked before proceeding" from
43 				BLooper::AssertLock()
44  */
UnlockLooper2()45 void TUnlockLooperTest::UnlockLooper2()
46 {
47 	DEBUGGER_ESCAPE;
48 
49 	BLooper Looper;
50 	BHandler Handler;
51 	Looper.AddHandler(&Handler);
52 	if (Looper.IsLocked())
53 	{
54 		// Make sure the looper is unlocked
55 		Looper.Unlock();
56 	}
57 	Handler.UnlockLooper();
58 }
59 //------------------------------------------------------------------------------
60 /**
61 	UnlockLooper()
62 	@case		handler has a looper which is initially locked
63 	@results	NONE
64  */
UnlockLooper3()65 void TUnlockLooperTest::UnlockLooper3()
66 {
67 	BLooper Looper;
68 	BHandler Handler;
69 	Looper.AddHandler(&Handler);
70 	if (!Looper.IsLocked())
71 	{
72 		Looper.Lock();
73 	}
74 	Handler.UnlockLooper();
75 }
76 //------------------------------------------------------------------------------
Suite()77 Test* TUnlockLooperTest::Suite()
78 {
79 	TestSuite* SuiteOfTests = new TestSuite("BHandler::UnlockLooper");
80 
81 	ADD_TEST4(BHandler, SuiteOfTests, TUnlockLooperTest, UnlockLooper1);
82 	ADD_TEST4(BHandler, SuiteOfTests, TUnlockLooperTest, UnlockLooper2);
83 	ADD_TEST4(BHandler, SuiteOfTests, TUnlockLooperTest, UnlockLooper3);
84 
85 	return SuiteOfTests;
86 }
87 //------------------------------------------------------------------------------
88 
89 /*
90  * $Log $
91  *
92  * $Id  $
93  *
94  */
95 
96 
97