Tweaks to deal with new repository hierarchy and use of unified CppUnit;
some bug fixes and a couple of new tests for BLooper. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -46,6 +46,9 @@
|
||||
|
||||
class BMessage;
|
||||
class BMessageQueue;
|
||||
namespace BPrivate {
|
||||
class BLooperList;
|
||||
}
|
||||
struct _loop_data_;
|
||||
|
||||
// Port (Message Queue) Capacity -----------------------------------------------
|
||||
@@ -138,6 +141,7 @@ private:
|
||||
friend class BMessenger;
|
||||
friend class BView;
|
||||
friend class BHandler;
|
||||
friend class BPrivate::BLooperList;
|
||||
friend port_id _get_looper_port_(const BLooper* );
|
||||
friend status_t _safe_get_server_token_(const BLooper* , int32* );
|
||||
friend team_id _find_cur_team_id_();
|
||||
|
||||
@@ -6,6 +6,7 @@ include $(SUBDIR)/support/support.src ;
|
||||
|
||||
UsePrivateHeaders app ;
|
||||
UsePrivateHeaders interface ;
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders support ;
|
||||
|
||||
UsePublicHeaders app ;
|
||||
|
||||
@@ -380,14 +380,6 @@ const char* BHandler::Name() const
|
||||
//------------------------------------------------------------------------------
|
||||
void BHandler::SetNextHandler(BHandler* handler)
|
||||
{
|
||||
// NOTE: This is called by BLooper::RemoveHandler() with NULL as the param,
|
||||
// so we need to handle that possiblity.
|
||||
if (!handler)
|
||||
{
|
||||
fNextHandler = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fLooper)
|
||||
{
|
||||
debugger("handler must belong to looper before setting NextHandler");
|
||||
@@ -395,20 +387,16 @@ void BHandler::SetNextHandler(BHandler* handler)
|
||||
return;
|
||||
}
|
||||
|
||||
if (fLooper != handler->Looper())
|
||||
if (!fLooper->IsLocked())
|
||||
{
|
||||
debugger("The handler and its NextHandler must have the same looper");
|
||||
debugger("The handler's looper must be locked before setting NextHandler");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fLooper->IsLocked())
|
||||
if (handler && fLooper != handler->Looper())
|
||||
{
|
||||
//debugger("Owning Looper must be locked before calling SetNextHandler");
|
||||
// NOTE: Original implementation allows setting the next handler here
|
||||
// anyway. The documentation *clearly* says otherwise. Can we get away
|
||||
// with being more strict?
|
||||
|
||||
// return;
|
||||
debugger("The handler and its NextHandler must have the same looper");
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: I'm sure some sort of threading protection should happen here,
|
||||
|
||||
+91
-7
@@ -55,7 +55,9 @@
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "TokenSpace.h"
|
||||
#include <LooperList.h>
|
||||
#include <ObjectLocker.h>
|
||||
#include <TokenSpace.h>
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
#define FILTER_LIST_BLOCK_SIZE 5
|
||||
@@ -63,6 +65,9 @@
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
using BPrivate::gDefaultTokens;
|
||||
using BPrivate::gLooperList;
|
||||
using BPrivate::BObjectLocker;
|
||||
using BPrivate::BLooperList;
|
||||
|
||||
typedef bool (*find_loop_pred)(_loop_data_* data, void* data);
|
||||
_loop_data_* find_loop_data(_loop_data_* begin, _loop_data_* end,
|
||||
@@ -104,19 +109,23 @@ BLooper::BLooper(const char* name, int32 priority, int32 port_capacity)
|
||||
//------------------------------------------------------------------------------
|
||||
BLooper::~BLooper()
|
||||
{
|
||||
Lock();
|
||||
kill_thread(fTaskID);
|
||||
delete fQueue;
|
||||
delete_sem(fLockSem);
|
||||
delete_port(fMsgPort);
|
||||
|
||||
UnlockFully();
|
||||
|
||||
// Clean up our filters
|
||||
SetCommonFilterList(NULL);
|
||||
|
||||
BObjectLocker<BLooperList> ListLock(gLooperList);
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
#endif
|
||||
RemoveHandler(this);
|
||||
RemoveLooper(this);
|
||||
|
||||
UnlockFully();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BLooper::BLooper(BMessage* data)
|
||||
@@ -263,7 +272,8 @@ bool BLooper::IsMessageWaiting() const
|
||||
if (!IsLocked())
|
||||
{
|
||||
// TODO: test
|
||||
debugger("");
|
||||
debugger("The Looper must be locked before calling IsMsgWaiting");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fQueue->IsEmpty())
|
||||
@@ -271,6 +281,14 @@ bool BLooper::IsMessageWaiting() const
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@note: What we're doing here differs slightly from the R5 implementation.
|
||||
It appears that they probably return count != 0, which gives a false
|
||||
true (!) result when port_buffer_size_etc() would block -- which
|
||||
indicates that the port's buffer is empty, so we should return false.
|
||||
Since we don't actually care about what the error is, we just return
|
||||
count > 0.
|
||||
*/
|
||||
int32 count;
|
||||
do
|
||||
{
|
||||
@@ -302,9 +320,19 @@ void BLooper::AddHandler(BHandler* handler)
|
||||
//------------------------------------------------------------------------------
|
||||
bool BLooper::RemoveHandler(BHandler* handler)
|
||||
{
|
||||
// BeBook says looper must be locked for calls to this, but testing shows that
|
||||
// just ain't so.
|
||||
// AssertLocked();
|
||||
// R5 implementation didn't bother to check its params, thus NULL handlers
|
||||
// will seg fault. Bad form, you know.
|
||||
if (!handler)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Correction; testing shows the looper *does* need to be locked for this;
|
||||
// it just doesn't use AssertLocked() for that.
|
||||
if (!IsLocked())
|
||||
{
|
||||
debugger("Looper must be locked before calling RemoveHandler.");
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
// Need to ensure this algo reflects what actually happens
|
||||
@@ -516,7 +544,10 @@ bool BLooper::IsLocked() const
|
||||
{
|
||||
// We have to lock the list for the call to IsLooperValid(). Has the side
|
||||
// effect of not letting the looper get deleted while we're here.
|
||||
BObjectLocker<BLooperList> ListLock(gLooperList);
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
#endif
|
||||
|
||||
if (!ListLock.IsLocked())
|
||||
{
|
||||
@@ -551,6 +582,12 @@ team_id BLooper::Team() const
|
||||
//------------------------------------------------------------------------------
|
||||
BLooper* BLooper::LooperForThread(thread_id tid)
|
||||
{
|
||||
BObjectLocker<BLooperList> ListLock (gLooperList);
|
||||
if (ListLock.IsLocked())
|
||||
{
|
||||
return gLooperList.LooperForThread(tid);
|
||||
}
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
if (ListLock.IsLocked())
|
||||
{
|
||||
@@ -564,6 +601,7 @@ BLooper* BLooper::LooperForThread(thread_id tid)
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
thread_id BLooper::LockingThread() const
|
||||
@@ -715,7 +753,10 @@ BLooper::BLooper(int32 priority, port_id port, const char* name)
|
||||
status_t BLooper::_PostMessage(BMessage* msg, BHandler* handler,
|
||||
BHandler* reply_to)
|
||||
{
|
||||
BObjectLocker<BLooperList> ListLock(gLooperList);
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
#endif
|
||||
if (!ListLock.IsLocked())
|
||||
{
|
||||
return B_BAD_VALUE;
|
||||
@@ -788,7 +829,10 @@ DBG(OUT("BLooper::_Lock() done 1\n"));
|
||||
well to remove itself).
|
||||
*/
|
||||
{
|
||||
BObjectLocker<BLooperList> ListLock(gLooperList);
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
#endif
|
||||
if (!ListLock.IsLocked())
|
||||
{
|
||||
// If we can't lock, the semaphore is probably
|
||||
@@ -912,7 +956,10 @@ void BLooper::InitData(const char* name, int32 priority, int32 port_capacity)
|
||||
|
||||
fInitPriority = priority;
|
||||
|
||||
BObjectLocker<BLooperList> ListLock(gLooperList);
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
#endif
|
||||
AddLooper(this);
|
||||
AddHandler(this);
|
||||
}
|
||||
@@ -1237,6 +1284,11 @@ void BLooper::UnlockFully()
|
||||
//------------------------------------------------------------------------------
|
||||
void BLooper::AddLooper(BLooper* loop)
|
||||
{
|
||||
if (gLooperList.IsLocked())
|
||||
{
|
||||
gLooperList.AddLooper(loop);
|
||||
}
|
||||
#if 0
|
||||
if (sLooperListLock.IsLocked())
|
||||
{
|
||||
#if defined(CHECK_ADD_LOOPER)
|
||||
@@ -1293,10 +1345,16 @@ DBG(OUT("BLooper::AddLooper(): looper added at %ld\n", looperCount));
|
||||
{
|
||||
debugger("sLooperList is not locked!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool BLooper::IsLooperValid(const BLooper* l)
|
||||
{
|
||||
if (gLooperList.IsLocked())
|
||||
{
|
||||
return gLooperList.IsLooperValid(l);
|
||||
}
|
||||
#if 0
|
||||
if (sLooperListLock.IsLocked())
|
||||
{
|
||||
return find_loop_data(sLooperList, sLooperList + sLooperCount,
|
||||
@@ -1304,10 +1362,16 @@ bool BLooper::IsLooperValid(const BLooper* l)
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BLooper::RemoveLooper(BLooper* l)
|
||||
{
|
||||
if (gLooperList.IsLocked())
|
||||
{
|
||||
gLooperList.RemoveLooper(l);
|
||||
}
|
||||
#if 0
|
||||
if (sLooperListLock.IsLocked())
|
||||
{
|
||||
_loop_data_* result = find_loop_data(sLooperList,
|
||||
@@ -1327,20 +1391,33 @@ void BLooper::RemoveLooper(BLooper* l)
|
||||
sLooperListSize = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BLooper::GetLooperList(BList* list)
|
||||
{
|
||||
BObjectLocker<BLooperList> ListLock(gLooperList);
|
||||
if (ListLock.IsLocked())
|
||||
{
|
||||
gLooperList.GetLooperList(list);
|
||||
}
|
||||
#if 0
|
||||
BAutolock ListLock(sLooperListLock);
|
||||
if (ListLock.IsLocked())
|
||||
{
|
||||
find_loop_data(sLooperList, sLooperList + sLooperCount,
|
||||
copy_list_pred, (void*)list);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BLooper* BLooper::LooperForName(const char* name)
|
||||
{
|
||||
if (gLooperList.IsLocked())
|
||||
{
|
||||
return gLooperList.LooperForName(name);
|
||||
}
|
||||
#if 0
|
||||
if (sLooperListLock.IsLocked())
|
||||
{
|
||||
_loop_data_* result = find_loop_data(sLooperList,
|
||||
@@ -1351,12 +1428,18 @@ BLooper* BLooper::LooperForName(const char* name)
|
||||
return result->looper;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BLooper* BLooper::LooperForPort(port_id port)
|
||||
{
|
||||
if (gLooperList.IsLocked())
|
||||
{
|
||||
return gLooperList.LooperForPort(port);
|
||||
}
|
||||
#if 0
|
||||
if (sLooperListLock.IsLocked())
|
||||
{
|
||||
_loop_data_* result = find_loop_data(sLooperList,
|
||||
@@ -1367,6 +1450,7 @@ BLooper* BLooper::LooperForPort(port_id port)
|
||||
return result->looper;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ APP_KIT_SOURCE =
|
||||
Handler.cpp
|
||||
Invoker.cpp
|
||||
Looper.cpp
|
||||
LooperList.cpp
|
||||
MessageFilter.cpp
|
||||
MessageQueue.cpp
|
||||
Messenger.cpp
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
void TBHandlerTester::BHandler1()
|
||||
{
|
||||
BHandler Handler((const char*)NULL);
|
||||
assert(Handler.Name() == NULL);
|
||||
CPPUNIT_ASSERT(Handler.Name() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ void TBHandlerTester::BHandler1()
|
||||
void TBHandlerTester::BHandler2()
|
||||
{
|
||||
BHandler Handler("name");
|
||||
assert(string("name") == Handler.Name());
|
||||
CPPUNIT_ASSERT(string("name") == Handler.Name());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ void TBHandlerTester::BHandler3()
|
||||
BMessage Archive;
|
||||
Archive.AddString("_name", "the name");
|
||||
BHandler Handler(&Archive);
|
||||
assert(string("the name") == Handler.Name());
|
||||
CPPUNIT_ASSERT(string("the name") == Handler.Name());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ void TBHandlerTester::BHandler4()
|
||||
{
|
||||
BMessage Archive;
|
||||
BHandler Handler(&Archive);
|
||||
assert(Handler.Name() == NULL);
|
||||
CPPUNIT_ASSERT(Handler.Name() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ void TBHandlerTester::BHandler5()
|
||||
{
|
||||
#if !defined(TEST_R5)
|
||||
BHandler Handler((BMessage*)NULL);
|
||||
assert(Handler.Name() == NULL);
|
||||
CPPUNIT_ASSERT(Handler.Name() == NULL);
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -110,7 +110,7 @@ void TBHandlerTester::Archive1()
|
||||
{
|
||||
#if !defined(TEST_R5)
|
||||
BHandler Handler;
|
||||
assert(Handler.Archive(NULL, false) == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Handler.Archive(NULL, false) == B_BAD_VALUE);
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -127,7 +127,7 @@ void TBHandlerTester::Archive2()
|
||||
{
|
||||
#if !defined(TEST_R5)
|
||||
BHandler Handler;
|
||||
assert(Handler.Archive(NULL) == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Handler.Archive(NULL) == B_BAD_VALUE);
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -146,13 +146,13 @@ void TBHandlerTester::Archive3()
|
||||
{
|
||||
BMessage Archive;
|
||||
BHandler Handler("a name");
|
||||
assert(Handler.Archive(&Archive, false) == B_OK);
|
||||
CPPUNIT_ASSERT(Handler.Archive(&Archive, false) == B_OK);
|
||||
|
||||
const char* data;
|
||||
assert(Archive.FindString("_name", &data) == B_OK);
|
||||
assert(string("a name") == data);
|
||||
assert(Archive.FindString("class", &data) == B_OK);
|
||||
assert(string("BHandler") == data);
|
||||
CPPUNIT_ASSERT(Archive.FindString("_name", &data) == B_OK);
|
||||
CPPUNIT_ASSERT(string("a name") == data);
|
||||
CPPUNIT_ASSERT(Archive.FindString("class", &data) == B_OK);
|
||||
CPPUNIT_ASSERT(string("BHandler") == data);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -170,13 +170,13 @@ void TBHandlerTester::Archive4()
|
||||
{
|
||||
BMessage Archive;
|
||||
BHandler Handler("another name");
|
||||
assert(Handler.Archive(&Archive) == B_OK);
|
||||
CPPUNIT_ASSERT(Handler.Archive(&Archive) == B_OK);
|
||||
|
||||
const char* data;
|
||||
assert(Archive.FindString("_name", &data) == B_OK);
|
||||
assert(string("another name") == data);
|
||||
assert(Archive.FindString("class", &data) == B_OK);
|
||||
assert(string("BHandler") == data);
|
||||
CPPUNIT_ASSERT(Archive.FindString("_name", &data) == B_OK);
|
||||
CPPUNIT_ASSERT(string("another name") == data);
|
||||
CPPUNIT_ASSERT(Archive.FindString("class", &data) == B_OK);
|
||||
CPPUNIT_ASSERT(string("BHandler") == data);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -190,8 +190,8 @@ void TBHandlerTester::Archive4()
|
||||
void TBHandlerTester::Instantiate1()
|
||||
{
|
||||
#if !defined(TEST_R5)
|
||||
assert(BHandler::Instantiate(NULL) == NULL);
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(BHandler::Instantiate(NULL) == NULL);
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -211,9 +211,9 @@ void TBHandlerTester::Instantiate2()
|
||||
|
||||
BHandler* Handler =
|
||||
dynamic_cast<BHandler*>(BHandler::Instantiate(&Archive));
|
||||
assert(Handler != NULL);
|
||||
assert(string("a name") == Handler->Name());
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Handler != NULL);
|
||||
CPPUNIT_ASSERT(string("a name") == Handler->Name());
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -231,9 +231,9 @@ void TBHandlerTester::Instantiate3()
|
||||
|
||||
BHandler* Handler =
|
||||
dynamic_cast<BHandler*>(BHandler::Instantiate(&Archive));
|
||||
assert(Handler != NULL);
|
||||
assert(Handler->Name() == NULL);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Handler != NULL);
|
||||
CPPUNIT_ASSERT(Handler->Name() == NULL);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -247,10 +247,10 @@ void TBHandlerTester::Instantiate3()
|
||||
void TBHandlerTester::SetName1()
|
||||
{
|
||||
BHandler Handler("a name");
|
||||
assert(string("a name") == Handler.Name());
|
||||
CPPUNIT_ASSERT(string("a name") == Handler.Name());
|
||||
|
||||
Handler.SetName(NULL);
|
||||
assert(Handler.Name() == NULL);
|
||||
CPPUNIT_ASSERT(Handler.Name() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -263,10 +263,10 @@ void TBHandlerTester::SetName1()
|
||||
void TBHandlerTester::SetName2()
|
||||
{
|
||||
BHandler Handler("a name");
|
||||
assert(string("a name") == Handler.Name());
|
||||
CPPUNIT_ASSERT(string("a name") == Handler.Name());
|
||||
|
||||
Handler.SetName("another name");
|
||||
assert(string("another name") == Handler.Name());
|
||||
CPPUNIT_ASSERT(string("another name") == Handler.Name());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -279,7 +279,7 @@ void TBHandlerTester::SetName2()
|
||||
void TBHandlerTester::Perform1()
|
||||
{
|
||||
BHandler Handler;
|
||||
assert(Handler.Perform(0, NULL) == B_ERROR);
|
||||
CPPUNIT_ASSERT(Handler.Perform(0, NULL) == B_ERROR);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -290,7 +290,7 @@ void TBHandlerTester::Perform1()
|
||||
void TBHandlerTester::FilterList1()
|
||||
{
|
||||
BHandler Handler;
|
||||
assert(!Handler.FilterList());
|
||||
CPPUNIT_ASSERT(!Handler.FilterList());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TBHandlerTester::Suite()
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
void TIsWatchedTest::IsWatched1()
|
||||
{
|
||||
assert(!fHandler.IsWatched());
|
||||
CPPUNIT_ASSERT(!fHandler.IsWatched());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -39,11 +39,11 @@ void TIsWatchedTest::IsWatched2()
|
||||
{
|
||||
BHandler Watcher;
|
||||
fHandler.StartWatching(&Watcher, '1234');
|
||||
assert(fHandler.IsWatched() == true);
|
||||
CPPUNIT_ASSERT(fHandler.IsWatched() == true);
|
||||
|
||||
fHandler.StopWatching(&Watcher, '1234');
|
||||
#ifndef TEST_R5
|
||||
assert(fHandler.IsWatched() == false);
|
||||
CPPUNIT_ASSERT(fHandler.IsWatched() == false);
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
void TLockLooperTest::LockLooper1()
|
||||
{
|
||||
BHandler Handler;
|
||||
assert(!Handler.LockLooper());
|
||||
CPPUNIT_ASSERT(!Handler.LockLooper());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ void TLockLooperTest::LockLooper2()
|
||||
// Make sure the looper is unlocked
|
||||
Looper.Unlock();
|
||||
}
|
||||
assert(Handler.LockLooper());
|
||||
CPPUNIT_ASSERT(Handler.LockLooper());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ void TLockLooperTest::LockLooper3()
|
||||
BHandler Handler;
|
||||
Looper.AddHandler(&Handler);
|
||||
Looper.Lock();
|
||||
assert(Handler.LockLooper());
|
||||
CPPUNIT_ASSERT(Handler.LockLooper());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ void TLockLooperTest::LockLooper4()
|
||||
resume_thread(tid);
|
||||
info.LockTest();
|
||||
|
||||
assert(!Handler.LockLooper());
|
||||
CPPUNIT_ASSERT(!Handler.LockLooper());
|
||||
info.UnlockThread();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
void TLockLooperWithTimeoutTest::LockLooperWithTimeout1()
|
||||
{
|
||||
BHandler Handler;
|
||||
assert(Handler.LockLooperWithTimeout(10000) == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Handler.LockLooperWithTimeout(10000) == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ void TLockLooperWithTimeoutTest::LockLooperWithTimeout2()
|
||||
// Make sure the looper is unlocked
|
||||
Looper.Unlock();
|
||||
}
|
||||
assert(Handler.LockLooperWithTimeout(10000) == B_OK);
|
||||
CPPUNIT_ASSERT(Handler.LockLooperWithTimeout(10000) == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ void TLockLooperWithTimeoutTest::LockLooperWithTimeout3()
|
||||
BHandler Handler;
|
||||
Looper.AddHandler(&Handler);
|
||||
Looper.Lock();
|
||||
assert(Handler.LockLooperWithTimeout(10000) == B_OK);
|
||||
CPPUNIT_ASSERT(Handler.LockLooperWithTimeout(10000) == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ void TLockLooperWithTimeoutTest::LockLooperWithTimeout4()
|
||||
resume_thread(tid);
|
||||
info.LockTest();
|
||||
|
||||
assert(Handler.LockLooperWithTimeout(10000) == B_TIMED_OUT);
|
||||
CPPUNIT_ASSERT(Handler.LockLooperWithTimeout(10000) == B_TIMED_OUT);
|
||||
info.UnlockThread();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
void TLooperTest::LooperTest1()
|
||||
{
|
||||
assert(fHandler.Looper() == NULL);
|
||||
CPPUNIT_ASSERT(fHandler.Looper() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -37,10 +37,10 @@ void TLooperTest::LooperTest2()
|
||||
{
|
||||
BLooper Looper;
|
||||
Looper.AddHandler(&fHandler);
|
||||
assert(fHandler.Looper() == &Looper);
|
||||
CPPUNIT_ASSERT(fHandler.Looper() == &Looper);
|
||||
|
||||
assert(Looper.RemoveHandler(&fHandler));
|
||||
assert(fHandler.Looper() == NULL);
|
||||
CPPUNIT_ASSERT(Looper.RemoveHandler(&fHandler));
|
||||
CPPUNIT_ASSERT(fHandler.Looper() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TLooperTest::Suite()
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
void TNextHandlerTest::NextHandler1()
|
||||
{
|
||||
BHandler Handler;
|
||||
assert(Handler.NextHandler() == NULL);
|
||||
CPPUNIT_ASSERT(Handler.NextHandler() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ void TNextHandlerTest::NextHandler2()
|
||||
BHandler Handler;
|
||||
BLooper Looper;
|
||||
Looper.AddHandler(&Handler);
|
||||
assert(Handler.NextHandler() == &Looper);
|
||||
CPPUNIT_ASSERT(Handler.NextHandler() == &Looper);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TNextHandlerTest::Suite()
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
void TRemoveFilterTest::RemoveFilter1()
|
||||
{
|
||||
BHandler Handler;
|
||||
assert(!Handler.RemoveFilter(NULL));
|
||||
CPPUNIT_ASSERT(!Handler.RemoveFilter(NULL));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ void TRemoveFilterTest::RemoveFilter2()
|
||||
BHandler Handler;
|
||||
BMessageFilter* Filter = new BMessageFilter('1234');
|
||||
Handler.AddFilter(Filter);
|
||||
assert(Handler.RemoveFilter(Filter));
|
||||
CPPUNIT_ASSERT(Handler.RemoveFilter(Filter));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ void TRemoveFilterTest::RemoveFilter3()
|
||||
Looper.AddHandler(&Handler);
|
||||
BMessageFilter* Filter = new BMessageFilter('1234');
|
||||
Handler.AddFilter(Filter);
|
||||
assert(Handler.RemoveFilter(Filter));
|
||||
CPPUNIT_ASSERT(Handler.RemoveFilter(Filter));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ void TRemoveFilterTest::RemoveFilter4()
|
||||
Looper.Lock();
|
||||
BMessageFilter* Filter = new BMessageFilter('1234');
|
||||
Handler.AddFilter(Filter);
|
||||
assert(Handler.RemoveFilter(Filter));
|
||||
CPPUNIT_ASSERT(Handler.RemoveFilter(Filter));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ void TRemoveFilterTest::RemoveFilter5()
|
||||
{
|
||||
BHandler Handler;
|
||||
BMessageFilter* Filter = new BMessageFilter('1234');
|
||||
assert(!Handler.RemoveFilter(Filter));
|
||||
CPPUNIT_ASSERT(!Handler.RemoveFilter(Filter));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ void TRemoveFilterTest::RemoveFilter6()
|
||||
BHandler Handler;
|
||||
Looper.AddHandler(&Handler);
|
||||
BMessageFilter* Filter = new BMessageFilter('1234');
|
||||
assert(!Handler.RemoveFilter(Filter));
|
||||
CPPUNIT_ASSERT(!Handler.RemoveFilter(Filter));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ void TRemoveFilterTest::RemoveFilter7()
|
||||
Looper.AddHandler(&Handler);
|
||||
Looper.Lock();
|
||||
BMessageFilter* Filter = new BMessageFilter('1234');
|
||||
assert(!Handler.RemoveFilter(Filter));
|
||||
CPPUNIT_ASSERT(!Handler.RemoveFilter(Filter));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TRemoveFilterTest::Suite()
|
||||
|
||||
@@ -33,7 +33,7 @@ void TSetFilterListTest::SetFilterList1()
|
||||
{
|
||||
BHandler Handler;
|
||||
Handler.SetFilterList(NULL);
|
||||
assert(!Handler.FilterList());
|
||||
CPPUNIT_ASSERT(!Handler.FilterList());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ void TSetFilterListTest::SetFilterList2()
|
||||
Filters->AddItem((void*)Filter);
|
||||
BHandler Handler;
|
||||
Handler.SetFilterList(Filters);
|
||||
assert(Handler.FilterList() == Filters);
|
||||
CPPUNIT_ASSERT(Handler.FilterList() == Filters);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -62,6 +62,8 @@ void TSetFilterListTest::SetFilterList2()
|
||||
*/
|
||||
void TSetFilterListTest::SetFilterList3()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
|
||||
@@ -76,7 +78,7 @@ void TSetFilterListTest::SetFilterList3()
|
||||
}
|
||||
|
||||
Handler.SetFilterList(Filters);
|
||||
assert(!Handler.FilterList());
|
||||
CPPUNIT_ASSERT(!Handler.FilterList());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -95,7 +97,7 @@ void TSetFilterListTest::SetFilterList4()
|
||||
Looper.Lock();
|
||||
Looper.AddHandler(&Handler);
|
||||
Handler.SetFilterList(Filters);
|
||||
assert(Handler.FilterList() == Filters);
|
||||
CPPUNIT_ASSERT(Handler.FilterList() == Filters);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -114,10 +116,10 @@ void TSetFilterListTest::SetFilterList5()
|
||||
Looper.Lock();
|
||||
Looper.AddHandler(&Handler);
|
||||
Handler.SetFilterList(Filters);
|
||||
assert(Handler.FilterList() == Filters);
|
||||
CPPUNIT_ASSERT(Handler.FilterList() == Filters);
|
||||
|
||||
Handler.SetFilterList(NULL);
|
||||
assert(!Handler.FilterList());
|
||||
CPPUNIT_ASSERT(!Handler.FilterList());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TSetFilterListTest::Suite()
|
||||
|
||||
@@ -35,10 +35,10 @@ void TSetNextHandlerTest::SetNextHandler0()
|
||||
Looper.AddHandler(&Handler2);
|
||||
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Handler2);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Handler2);
|
||||
|
||||
Handler1.SetNextHandler(NULL);
|
||||
assert(!Handler1.NextHandler());
|
||||
CPPUNIT_ASSERT(!Handler1.NextHandler());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -52,10 +52,12 @@ void TSetNextHandlerTest::SetNextHandler0()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler1()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == NULL);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -64,17 +66,20 @@ void TSetNextHandlerTest::SetNextHandler1()
|
||||
@case Handler1 belongs to a unlocked BLooper, Handler2 does not
|
||||
@param handler Valid BHandler pointer
|
||||
@results NextHandler() returns BLooper
|
||||
debug message "The handler and its NextHandler must have
|
||||
the same looper"
|
||||
debug message "The handler's looper must be locked before
|
||||
setting NextHandler"
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler2()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper;
|
||||
Looper.AddHandler(&Handler1);
|
||||
Looper.Unlock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Looper);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -88,13 +93,14 @@ void TSetNextHandlerTest::SetNextHandler2()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler3()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper;
|
||||
Looper.AddHandler(&Handler1);
|
||||
Looper.Lock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Looper);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -108,12 +114,15 @@ void TSetNextHandlerTest::SetNextHandler3()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler4()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper;
|
||||
Looper.AddHandler(&Handler2);
|
||||
Looper.Unlock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == NULL);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -127,13 +136,14 @@ void TSetNextHandlerTest::SetNextHandler4()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler5()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper;
|
||||
Looper.AddHandler(&Handler2);
|
||||
Looper.Lock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == NULL);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -147,14 +157,18 @@ void TSetNextHandlerTest::SetNextHandler5()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler6()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper1;
|
||||
BLooper Looper2;
|
||||
Looper1.AddHandler(&Handler1);
|
||||
Looper2.AddHandler(&Handler2);
|
||||
Looper1.Unlock();
|
||||
Looper2.Unlock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Looper1);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -169,15 +183,17 @@ void TSetNextHandlerTest::SetNextHandler6()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler7()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper1;
|
||||
BLooper Looper2;
|
||||
Looper1.AddHandler(&Handler1);
|
||||
Looper2.AddHandler(&Handler2);
|
||||
Looper1.Lock();
|
||||
Looper2.Unlock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Looper1);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -192,15 +208,17 @@ void TSetNextHandlerTest::SetNextHandler7()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler8()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper1;
|
||||
BLooper Looper2;
|
||||
Looper1.AddHandler(&Handler1);
|
||||
Looper2.AddHandler(&Handler2);
|
||||
Looper2.Lock();
|
||||
Looper1.Unlock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Looper1);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -214,16 +232,16 @@ void TSetNextHandlerTest::SetNextHandler8()
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler9()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
BLooper Looper1;
|
||||
BLooper Looper2;
|
||||
Looper1.AddHandler(&Handler1);
|
||||
Looper2.AddHandler(&Handler2);
|
||||
Looper1.Lock();
|
||||
Looper2.Lock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Looper1);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -232,18 +250,23 @@ void TSetNextHandlerTest::SetNextHandler9()
|
||||
@case Handler1 and Handler2 belong to the same unlocked BLooper
|
||||
@param handler Valid BHandler pointer
|
||||
@results Returns Handler2
|
||||
@note Docs say the looper must be locked, but the original
|
||||
implementation allows the next handler to be set anyway.
|
||||
debug message "The handler's looper must be locked before
|
||||
setting NextHandler"
|
||||
@note R5 implementation allows the next handler to be set anyway;
|
||||
we do the same.
|
||||
*/
|
||||
void TSetNextHandlerTest::SetNextHandler10()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
BHandler Handler1;
|
||||
BHandler Handler2;
|
||||
Looper.AddHandler(&Handler1);
|
||||
Looper.AddHandler(&Handler2);
|
||||
Looper.Unlock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Handler2);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Looper);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -260,9 +283,8 @@ void TSetNextHandlerTest::SetNextHandler11()
|
||||
BHandler Handler2;
|
||||
Looper.AddHandler(&Handler1);
|
||||
Looper.AddHandler(&Handler2);
|
||||
Looper.Lock();
|
||||
Handler1.SetNextHandler(&Handler2);
|
||||
assert(Handler1.NextHandler() == &Handler2);
|
||||
CPPUNIT_ASSERT(Handler1.NextHandler() == &Handler2);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TSetNextHandlerTest::Suite()
|
||||
@@ -270,15 +292,15 @@ Test* TSetNextHandlerTest::Suite()
|
||||
TestSuite* SuiteOfTests = new TestSuite("BHandler::SetNextHandler");
|
||||
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler0);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler1);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler2);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler3);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler4);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler5);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler6);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler7);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler8);
|
||||
// ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler9);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler1);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler2);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler3);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler4);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler5);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler6);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler7);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler8);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler9);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler10);
|
||||
ADD_TEST(SuiteOfTests, TSetNextHandlerTest, SetNextHandler11);
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ void TUnlockLooperTest::UnlockLooper1()
|
||||
*/
|
||||
void TUnlockLooperTest::UnlockLooper2()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
Looper.AddHandler(&Handler);
|
||||
|
||||
@@ -8,4 +8,8 @@ case 5: looper is locked, message is posted, queue is emptied
|
||||
|
||||
RemoveHandler(BHandler* handler)
|
||||
--------------
|
||||
case : handler is NULL
|
||||
case : handler doesn't belong to this looper
|
||||
case : handler is valid, looper is unlocked
|
||||
case : handler doesn't belong to this looper, looper is unlocked
|
||||
case : handler has filters; FilterList() should be NULL on remove
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <iostream>
|
||||
#include <posix/string.h>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <Looper.h>
|
||||
#include <Message.h>
|
||||
#include <MessageQueue.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
@@ -24,20 +26,22 @@ port_id _get_looper_port_(const BLooper* looper);
|
||||
//case 1: looper is unlocked and queue is empty
|
||||
void TIsMessageWaitingTest::IsMessageWaiting1()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
#ifndef TEST_R5
|
||||
assert(!Looper.IsMessageWaiting());
|
||||
#else
|
||||
assert(Looper.IsMessageWaiting());
|
||||
#endif
|
||||
Looper.Unlock();
|
||||
CPPUNIT_ASSERT(!Looper.IsMessageWaiting());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
//case 2: looper is unlocked and queue is filled
|
||||
void TIsMessageWaitingTest::IsMessageWaiting2()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
Looper.Unlock();
|
||||
Looper.PostMessage('1234');
|
||||
assert(Looper.IsMessageWaiting());
|
||||
CPPUNIT_ASSERT(!Looper.IsMessageWaiting());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
//case 3: looper is locked and queue is empty
|
||||
@@ -46,9 +50,24 @@ void TIsMessageWaitingTest::IsMessageWaiting3()
|
||||
BLooper Looper;
|
||||
Looper.Lock();
|
||||
#ifndef TEST_R5
|
||||
assert(!Looper.IsMessageWaiting());
|
||||
CPPUNIT_ASSERT(!Looper.IsMessageWaiting());
|
||||
#else
|
||||
assert(Looper.IsMessageWaiting());
|
||||
#if 0
|
||||
// Testing to figure out why we get false positives from the R5
|
||||
// implementation of BLooper::IsMessageWaiting().
|
||||
CPPUNIT_ASSERT(Looper.IsLocked());
|
||||
CPPUNIT_ASSERT(Looper.MessageQueue()->IsEmpty());
|
||||
|
||||
int32 count;
|
||||
do
|
||||
{
|
||||
count = port_buffer_size_etc(_get_looper_port_(&Looper), B_TIMEOUT, 0);
|
||||
} while (count == B_INTERRUPTED);
|
||||
|
||||
CPPUNIT_ASSERT(count < 0);
|
||||
cout << endl << "port_buffer_size_etc: " << strerror(count) << endl;
|
||||
#endif
|
||||
CPPUNIT_ASSERT(Looper.IsMessageWaiting());
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -58,7 +77,7 @@ void TIsMessageWaitingTest::IsMessageWaiting4()
|
||||
BLooper Looper;
|
||||
Looper.Lock();
|
||||
Looper.PostMessage('1234');
|
||||
assert(Looper.IsMessageWaiting());
|
||||
CPPUNIT_ASSERT(Looper.IsMessageWaiting());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
//case 5: looper is locked, message is posted, queue is empty
|
||||
@@ -70,8 +89,21 @@ void TIsMessageWaitingTest::IsMessageWaiting5()
|
||||
// Prevent a port read
|
||||
Looper->Lock();
|
||||
Looper->PostMessage('1234');
|
||||
assert(Looper->MessageQueue()->IsEmpty());
|
||||
assert(Looper->IsMessageWaiting());
|
||||
CPPUNIT_ASSERT(Looper->MessageQueue()->IsEmpty());
|
||||
CPPUNIT_ASSERT(Looper->IsMessageWaiting());
|
||||
|
||||
int32 count;
|
||||
do
|
||||
{
|
||||
count = port_buffer_size_etc(_get_looper_port_(Looper), B_TIMEOUT, 0);
|
||||
} while (count == B_INTERRUPTED);
|
||||
|
||||
cout << endl << "port_buffer_size_etc: ";
|
||||
if (count < 0)
|
||||
cout << strerror(count);
|
||||
else
|
||||
cout << count;
|
||||
cout << endl;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TIsMessageWaitingTest::Suite()
|
||||
|
||||
@@ -19,6 +19,67 @@
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
RemoveHandler(BHandler* handler)
|
||||
@case handler is NULL
|
||||
@param handler NULL
|
||||
@results RemoveHandler() returns false. R5 implementation seg faults;
|
||||
we've fixed that.
|
||||
*/
|
||||
void TRemoveHandlerTest::RemoveHandler1()
|
||||
{
|
||||
BLooper Looper;
|
||||
#ifndef TEST_R5
|
||||
CPPUNIT_ASSERT(!Looper.RemoveHandler(NULL));
|
||||
#endif
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
RemoveHandler(BHandler* handler)
|
||||
@case handler doesn't belong to this looper
|
||||
@param handler Valid BHandler pointer, not assigned to looper
|
||||
@results
|
||||
*/
|
||||
void TRemoveHandlerTest::RemoveHandler2()
|
||||
{
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
CPPUNIT_ASSERT(!Looper.RemoveHandler(&Handler));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
RemoveHandler(BHandler* handler)
|
||||
@case handler is valid, looper is unlocked
|
||||
@param handler Valid BHandler pointer, assigned to looper
|
||||
@results goes to debugger, but removes handler anyway
|
||||
*/
|
||||
void TRemoveHandlerTest::RemoveHandler3()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
Looper.AddHandler(&Handler);
|
||||
Looper.Unlock();
|
||||
CPPUNIT_ASSERT(Looper.RemoveHandler(&Handler));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
RemoveHandler(BHandler* handler)
|
||||
@case handler doesn't belong to this looper, looper is unlocked
|
||||
@param handler Valid BHandler pointer, not assigned to looper
|
||||
@results
|
||||
*/
|
||||
void TRemoveHandlerTest::RemoveHandler4()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
Looper.Unlock();
|
||||
CPPUNIT_ASSERT(!Looper.RemoveHandler(&Handler));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
RemoveHandler(BHandler* handler)
|
||||
@@ -27,7 +88,7 @@
|
||||
@results RemoveHandler() returns true
|
||||
handler->FilterList() returns NULL after removal
|
||||
*/
|
||||
void TRemoveHandlerTest::RemoveHandler1()
|
||||
void TRemoveHandlerTest::RemoveHandler5()
|
||||
{
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
@@ -35,8 +96,8 @@ void TRemoveHandlerTest::RemoveHandler1()
|
||||
|
||||
Handler.AddFilter(MessageFilter);
|
||||
Looper.AddHandler(&Handler);
|
||||
Looper.RemoveHandler(&Handler);
|
||||
assert(Handler.FilterList());
|
||||
CPPUNIT_ASSERT(Looper.RemoveHandler(&Handler));
|
||||
CPPUNIT_ASSERT(Handler.FilterList());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TRemoveHandlerTest::Suite()
|
||||
@@ -44,6 +105,10 @@ Test* TRemoveHandlerTest::Suite()
|
||||
TestSuite* suite = new TestSuite("BLooper::RemoveHandler(BHandler* handler)");
|
||||
|
||||
ADD_TEST(suite, TRemoveHandlerTest, RemoveHandler1);
|
||||
ADD_TEST(suite, TRemoveHandlerTest, RemoveHandler2);
|
||||
ADD_TEST(suite, TRemoveHandlerTest, RemoveHandler3);
|
||||
ADD_TEST(suite, TRemoveHandlerTest, RemoveHandler4);
|
||||
ADD_TEST(suite, TRemoveHandlerTest, RemoveHandler5);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ class TRemoveHandlerTest : public TestCase
|
||||
TRemoveHandlerTest(std::string name) : TestCase(name) {;}
|
||||
|
||||
void RemoveHandler1();
|
||||
void RemoveHandler2();
|
||||
void RemoveHandler3();
|
||||
void RemoveHandler4();
|
||||
void RemoveHandler5();
|
||||
|
||||
static Test* Suite();
|
||||
};
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
cout << endl << "status_t == \"" << strerror((status__)) << "\" (" \
|
||||
<< (status__) << ") in " << __PRETTY_FUNCTION__ << endl
|
||||
|
||||
#ifdef USE_DEBUGGER_TESTS
|
||||
#define DEBUGGER_ESCAPE
|
||||
#else
|
||||
#define DEBUGGER_ESCAPE return
|
||||
#endif
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
using namespace CppUnit;
|
||||
|
||||
Reference in New Issue
Block a user