Added/tweaked tests for BLooper; fixes to BLooper stemming from those tests
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@389 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -154,9 +154,9 @@ static property_info gHandlerPropInfo[] =
|
|||||||
// name
|
// name
|
||||||
"Suites",
|
"Suites",
|
||||||
// commands
|
// commands
|
||||||
{B_GET_PROPERTY},
|
{ B_GET_PROPERTY },
|
||||||
// specifiers
|
// specifiers
|
||||||
{B_DIRECT_SPECIFIER},
|
{ B_DIRECT_SPECIFIER },
|
||||||
// usage
|
// usage
|
||||||
NULL,
|
NULL,
|
||||||
// extra data
|
// extra data
|
||||||
@@ -195,8 +195,8 @@ static property_info gHandlerPropInfo[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Messenger",
|
"Messenger",
|
||||||
{B_GET_PROPERTY},
|
{ B_GET_PROPERTY },
|
||||||
{B_DIRECT_SPECIFIER},
|
{ B_DIRECT_SPECIFIER },
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
{ B_MESSENGER_TYPE },
|
{ B_MESSENGER_TYPE },
|
||||||
{},
|
{},
|
||||||
@@ -204,8 +204,8 @@ static property_info gHandlerPropInfo[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"InternalName",
|
"InternalName",
|
||||||
{B_GET_PROPERTY},
|
{ B_GET_PROPERTY },
|
||||||
{B_DIRECT_SPECIFIER},
|
{ B_DIRECT_SPECIFIER },
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
{ B_STRING_TYPE },
|
{ B_STRING_TYPE },
|
||||||
{},
|
{},
|
||||||
@@ -675,7 +675,7 @@ BMessage: what = (0x0, or 0)
|
|||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
err = data->AddString("Suites", "suite/vnd.Be-handler");
|
err = data->AddString("suites", "suite/vnd.Be-handler");
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
BPropertyInfo PropertyInfo(gHandlerPropInfo);
|
BPropertyInfo PropertyInfo(gHandlerPropInfo);
|
||||||
|
|||||||
+65
-11
@@ -92,6 +92,35 @@ team_id BLooper::sTeamID = B_ERROR;
|
|||||||
|
|
||||||
static property_info gLooperPropInfo[] =
|
static property_info gLooperPropInfo[] =
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
"Handler"
|
||||||
|
{},
|
||||||
|
{B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER},
|
||||||
|
// TODO: what is the extra_data for?
|
||||||
|
NULL, 1,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Handlers"
|
||||||
|
{B_GET_PROPERTY},
|
||||||
|
{B_DIRECT_SPECIFIER},
|
||||||
|
NULL, 0,
|
||||||
|
{B_MESSENGER_TYPE},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Handler"
|
||||||
|
{B_COUNT_PROPERTIES},
|
||||||
|
{B_DIRECT_SPECIFIER},
|
||||||
|
NULL, 0,
|
||||||
|
{B_INT32_TYPE},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
},
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _loop_data_
|
struct _loop_data_
|
||||||
@@ -109,6 +138,12 @@ BLooper::BLooper(const char* name, int32 priority, int32 port_capacity)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
BLooper::~BLooper()
|
BLooper::~BLooper()
|
||||||
{
|
{
|
||||||
|
if (fRunCalled && !fTerminating)
|
||||||
|
{
|
||||||
|
debugger("You can't call delete on a BLooper object "
|
||||||
|
"once it is running.");
|
||||||
|
}
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
kill_thread(fTaskID);
|
kill_thread(fTaskID);
|
||||||
delete fQueue;
|
delete fQueue;
|
||||||
@@ -383,8 +418,6 @@ int32 BLooper::IndexOf(BHandler* handler) const
|
|||||||
debugger("Looper must be locked before calling IndexOf.");
|
debugger("Looper must be locked before calling IndexOf.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test
|
|
||||||
// ensure the B_ERROR gets returned if the handler isn't in the list
|
|
||||||
return fHandlers.IndexOf(handler);
|
return fHandlers.IndexOf(handler);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -412,9 +445,7 @@ thread_id BLooper::Run()
|
|||||||
if (fRunCalled)
|
if (fRunCalled)
|
||||||
{
|
{
|
||||||
// Not allowed to call Run() more than once
|
// Not allowed to call Run() more than once
|
||||||
// TODO: test
|
debugger("can't call BLooper::Run twice!");
|
||||||
// find out what message is actually here
|
|
||||||
debugger("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fTaskID = spawn_thread(_task0_, Name(), fInitPriority, this);
|
fTaskID = spawn_thread(_task0_, Name(), fInitPriority, this);
|
||||||
@@ -648,6 +679,11 @@ BHandler* BLooper::ResolveSpecifier(BMessage* msg, int32 index,
|
|||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BHandler::ResolveSpecifier(msg, index, specifier, form,
|
||||||
|
property);
|
||||||
|
}
|
||||||
|
|
||||||
BMessage Reply(B_MESSAGE_NOT_UNDERSTOOD);
|
BMessage Reply(B_MESSAGE_NOT_UNDERSTOOD);
|
||||||
Reply.AddInt32("error", B_BAD_SCRIPT_SYNTAX);
|
Reply.AddInt32("error", B_BAD_SCRIPT_SYNTAX);
|
||||||
@@ -659,7 +695,27 @@ BHandler* BLooper::ResolveSpecifier(BMessage* msg, int32 index,
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
status_t BLooper::GetSupportedSuites(BMessage* data)
|
status_t BLooper::GetSupportedSuites(BMessage* data)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
status_t err;
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
err = B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
err = data->AddString("Suites", "suite/vnd.Be-handler");
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
BPropertyInfo PropertyInfo(gLooperPropInfo);
|
||||||
|
err = data->AddFlat("message", &PropertyInfo);
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
err = BHandler::GetSupportedSuites(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void BLooper::AddCommonFilter(BMessageFilter* filter)
|
void BLooper::AddCommonFilter(BMessageFilter* filter)
|
||||||
@@ -980,14 +1036,12 @@ void BLooper::InitData(const char* name, int32 priority, int32 port_capacity)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void BLooper::AddMessage(BMessage* msg)
|
void BLooper::AddMessage(BMessage* msg)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// NOTE: Why is this here?
|
||||||
// Why is this here?
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void BLooper::_AddMessagePriv(BMessage* msg)
|
void BLooper::_AddMessagePriv(BMessage* msg)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// NOTE: No, really; why the hell is this here??
|
||||||
// No, really; why the hell is this here??
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
status_t BLooper::_task0_(void* arg)
|
status_t BLooper::_task0_(void* arg)
|
||||||
@@ -1294,7 +1348,7 @@ BHandler* BLooper::apply_filters(BList* list, BMessage* msg, BHandler* target)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void BLooper::check_lock()
|
void BLooper::check_lock()
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// NOTE: any use for this?
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
BHandler* BLooper::resolve_specifier(BHandler* target, BMessage* msg)
|
BHandler* BLooper::resolve_specifier(BHandler* target, BMessage* msg)
|
||||||
|
|||||||
@@ -3,12 +3,11 @@
|
|||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
@note Most of AddHandler()'s functionality is indirectly exercises
|
@note Most of AddHandler()'s functionality is indirectly exercised
|
||||||
indirectly by the tests for RemoveHandler(), CountHandler(),
|
by the tests for RemoveHandler(), CountHandler(), HandlerAt() and
|
||||||
HandlerAt() and IndexOf(). If AddHandler() isn't working correctly,
|
IndexOf(). If AddHandler() isn't working correctly, it will show up
|
||||||
it will show up there. I do wonder if I should replicate those
|
there. I do wonder if I should replicate those tests here anyway so
|
||||||
tests here anyway so that any problem specifically show up in this
|
that any problem specifically show up in this test suite.
|
||||||
test suite.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ case 5: handler is valid, looper is unlocked
|
|||||||
|
|
||||||
PreferredHandler() const;
|
PreferredHandler() const;
|
||||||
SetPreferredHandler(BHandler* handler);
|
SetPreferredHandler(BHandler* handler);
|
||||||
|
|
||||||
Run();
|
Run();
|
||||||
|
--------------
|
||||||
|
case 1: Attempt to call Run() twice
|
||||||
|
|
||||||
Quit();
|
Quit();
|
||||||
QuitRequested();
|
QuitRequested();
|
||||||
Lock();
|
Lock();
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// RunTest.cpp
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
|
// System Includes -------------------------------------------------------------
|
||||||
|
#include <Looper.h>
|
||||||
|
|
||||||
|
// Project Includes ------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Includes --------------------------------------------------------------
|
||||||
|
#include "RunTest.h"
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
|
||||||
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
Run()
|
||||||
|
@case Attempt to call Run() twice
|
||||||
|
@results
|
||||||
|
*/
|
||||||
|
void TRunTest::RunTest1()
|
||||||
|
{
|
||||||
|
BLooper Looper;
|
||||||
|
Looper.Run();
|
||||||
|
Looper.Run();
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
TestSuite* TRunTest::Suite()
|
||||||
|
{
|
||||||
|
TestSuite* suite = new TestSuite("BLooper::Run()");
|
||||||
|
|
||||||
|
ADD_TEST(suite, TRunTest, RunTest1);
|
||||||
|
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Log $
|
||||||
|
*
|
||||||
|
* $Id $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// RunTest.h
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef RUNTEST_H
|
||||||
|
#define RUNTEST_H
|
||||||
|
|
||||||
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
|
// System Includes -------------------------------------------------------------
|
||||||
|
|
||||||
|
// Project Includes ------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Includes --------------------------------------------------------------
|
||||||
|
#include "../common.h"
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
|
||||||
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TRunTest : public TestCase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TRunTest() {;}
|
||||||
|
TRunTest(std::string name) : TestCase(name) {;}
|
||||||
|
|
||||||
|
void RunTest1();
|
||||||
|
|
||||||
|
static TestSuite* Suite();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //RUNTEST_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Log $
|
||||||
|
*
|
||||||
|
* $Id $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
Reference in New Issue
Block a user