More BLooper tests and minor tweaks.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@288 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
da94386c62
commit
19ba51b74d
@ -302,7 +302,15 @@ bool BLooper::IsMessageWaiting() const
|
||||
//------------------------------------------------------------------------------
|
||||
void BLooper::AddHandler(BHandler* handler)
|
||||
{
|
||||
AssertLocked();
|
||||
if (!handler)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsLocked())
|
||||
{
|
||||
debugger("Looper must be locked before calling AddHandler.");
|
||||
}
|
||||
|
||||
if (handler->Looper() == NULL)
|
||||
{
|
||||
|
80
src/tests/kits/app/blooper/AddHandlerTest.cpp
Normal file
80
src/tests/kits/app/blooper/AddHandlerTest.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// AddHandlerTest.cpp
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@note Most of AddHandler()'s functionality is indirectly exercises
|
||||
indirectly by the tests for RemoveHandler(), CountHandler(),
|
||||
HandlerAt() and IndexOf(). If AddHandler() isn't working correctly,
|
||||
it will show up there. I do wonder if I should replicate those
|
||||
tests here anyway so that any problem specifically show up in this
|
||||
test suite.
|
||||
*/
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <Looper.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "AddHandlerTest.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
AddHandler(BHandler*)
|
||||
@case handler is NULL
|
||||
@param handler
|
||||
@results Nothing (bad) should happen when AddHandler() is called, and
|
||||
CountHandlers() should return 1 (for the looper itself). R5
|
||||
can't handle this test; it has a segment violation.
|
||||
*/
|
||||
void TAddHandlerTest::AddHandlerTest1()
|
||||
{
|
||||
BLooper Looper;
|
||||
#ifndef TEST_R5
|
||||
Looper.AddHandler(NULL);
|
||||
#endif
|
||||
CPPUNIT_ASSERT(Looper.CountHandlers() == 1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
AddHandler(BHandler*)
|
||||
@case looper is unlocked
|
||||
@param handler
|
||||
@results Goes to debugger with message "Looper must be locked before
|
||||
calling AddHandler."
|
||||
*/
|
||||
void TAddHandlerTest::AddHandlerTest2()
|
||||
{
|
||||
DEBUGGER_ESCAPE;
|
||||
|
||||
BLooper Looper;
|
||||
BHandler Handler;
|
||||
Looper.Unlock();
|
||||
Looper.AddHandler(&Handler);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
TestSuite* TAddHandlerTest::Suite()
|
||||
{
|
||||
TestSuite* suite = new TestSuite("BLooper::AddHandler(BHandler*)");
|
||||
|
||||
ADD_TEST(suite, TAddHandlerTest, AddHandlerTest1);
|
||||
ADD_TEST(suite, TAddHandlerTest, AddHandlerTest2);
|
||||
|
||||
return suite;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
42
src/tests/kits/app/blooper/AddHandlerTest.h
Normal file
42
src/tests/kits/app/blooper/AddHandlerTest.h
Normal file
@ -0,0 +1,42 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// AddHandlerTest.h
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef ADDHANDLERTEST_H
|
||||
#define ADDHANDLERTEST_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "../common.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class TAddHandlerTest : public TestCase
|
||||
{
|
||||
public:
|
||||
TAddHandlerTest() {;}
|
||||
TAddHandlerTest(std::string name) : TestCase(name) {;}
|
||||
|
||||
void AddHandlerTest1();
|
||||
void AddHandlerTest2();
|
||||
|
||||
static TestSuite* Suite();
|
||||
};
|
||||
|
||||
#endif //ADDHANDLERTEST_H
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
@ -28,6 +28,9 @@ case 4: looper is locked and queue is filled
|
||||
case 5: looper is locked, message is posted, queue is emptied
|
||||
|
||||
AddHandler(BHandler* handler);
|
||||
--------------
|
||||
case : handler is NULL
|
||||
case : looper is unlocked
|
||||
|
||||
RemoveHandler(BHandler* handler)
|
||||
--------------
|
||||
|
@ -7,6 +7,7 @@ CommonUnitTest BLooperTester
|
||||
IndexOfTest.cpp
|
||||
CountHandlersTest.cpp
|
||||
HandlerAtTest.cpp
|
||||
AddHandlerTest.cpp
|
||||
: kits app
|
||||
: <boot!home!config!lib>libopenbeos.so be stdc++.r4
|
||||
: be stdc++.r4
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "IndexOfTest.h"
|
||||
#include "CountHandlersTest.h"
|
||||
#include "HandlerAtTest.h"
|
||||
#include "AddHandlerTest.h"
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
@ -45,6 +46,7 @@ Test* addonTestFunc(void)
|
||||
tests->addTest(TIndexOfTest::Suite());
|
||||
tests->addTest(TCountHandlersTest::Suite());
|
||||
tests->addTest(THandlerAtTest::Suite());
|
||||
tests->addTest(TAddHandlerTest::Suite());
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user