1 //------------------------------------------------------------------------------
4 //------------------------------------------------------------------------------
6 // Standard Includes -----------------------------------------------------------
8 // System Includes -------------------------------------------------------------
11 // Project Includes ------------------------------------------------------------
13 // Local Includes --------------------------------------------------------------
14 #include "LockLooperTest.h"
15 #include "LockLooperTestCommon.h"
17 // Local Defines ---------------------------------------------------------------
19 // Globals ---------------------------------------------------------------------
21 //------------------------------------------------------------------------------
24 @case handler has no looper
25 @results Returns false
27 void TLockLooperTest::LockLooper1()
30 CPPUNIT_ASSERT(!Handler
.LockLooper());
32 //------------------------------------------------------------------------------
35 @case handler has a looper which is initially unlocked
38 void TLockLooperTest::LockLooper2()
42 Looper
.AddHandler(&Handler
);
43 if (Looper
.IsLocked())
45 // Make sure the looper is unlocked
48 CPPUNIT_ASSERT(Handler
.LockLooper());
50 //------------------------------------------------------------------------------
53 @case handler has a looper which is initially locked
56 void TLockLooperTest::LockLooper3()
60 Looper
.AddHandler(&Handler
);
62 CPPUNIT_ASSERT(Handler
.LockLooper());
64 //------------------------------------------------------------------------------
67 @case handler has a looper which is locked in another thread
68 @results Returns false
70 void TLockLooperTest::LockLooper4()
74 Looper
.AddHandler(&Handler
);
75 if (Looper
.IsLocked())
80 TLockLooperInfo
info(&Looper
);
81 thread_id tid
= spawn_thread(LockLooperThreadFunc
, "LockLooperHelperThread",
82 B_NORMAL_PRIORITY
, (void*)&info
);
86 CPPUNIT_ASSERT(!Handler
.LockLooper());
89 //------------------------------------------------------------------------------
90 Test
* TLockLooperTest::Suite()
92 TestSuite
* SuiteOfTests
= new TestSuite("BHandler::LockLooper");
94 ADD_TEST4(BHandler
, SuiteOfTests
, TLockLooperTest
, LockLooper1
);
95 ADD_TEST4(BHandler
, SuiteOfTests
, TLockLooperTest
, LockLooper2
);
96 ADD_TEST4(BHandler
, SuiteOfTests
, TLockLooperTest
, LockLooper3
);
97 // ADD_TEST4(BHandler, SuiteOfTests, TLockLooperTest, LockLooper4);
101 //------------------------------------------------------------------------------