diff --git a/src/kits/app/Handler.cpp b/src/kits/app/Handler.cpp index 3e4c0a1aec..63a6f3c088 100644 --- a/src/kits/app/Handler.cpp +++ b/src/kits/app/Handler.cpp @@ -154,9 +154,9 @@ static property_info gHandlerPropInfo[] = // name "Suites", // commands - {B_GET_PROPERTY}, + { B_GET_PROPERTY }, // specifiers - {B_DIRECT_SPECIFIER}, + { B_DIRECT_SPECIFIER }, // usage NULL, // extra data @@ -195,8 +195,8 @@ static property_info gHandlerPropInfo[] = }, { "Messenger", - {B_GET_PROPERTY}, - {B_DIRECT_SPECIFIER}, + { B_GET_PROPERTY }, + { B_DIRECT_SPECIFIER }, NULL, 0, { B_MESSENGER_TYPE }, {}, @@ -204,8 +204,8 @@ static property_info gHandlerPropInfo[] = }, { "InternalName", - {B_GET_PROPERTY}, - {B_DIRECT_SPECIFIER}, + { B_GET_PROPERTY }, + { B_DIRECT_SPECIFIER }, NULL, 0, { B_STRING_TYPE }, {}, @@ -675,7 +675,7 @@ BMessage: what = (0x0, or 0) if (!err) { - err = data->AddString("Suites", "suite/vnd.Be-handler"); + err = data->AddString("suites", "suite/vnd.Be-handler"); if (!err) { BPropertyInfo PropertyInfo(gHandlerPropInfo); diff --git a/src/kits/app/Looper.cpp b/src/kits/app/Looper.cpp index 04f5b0dcf7..37a35878d0 100644 --- a/src/kits/app/Looper.cpp +++ b/src/kits/app/Looper.cpp @@ -92,6 +92,35 @@ team_id BLooper::sTeamID = B_ERROR; 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_ @@ -109,6 +138,12 @@ BLooper::BLooper(const char* name, int32 priority, int32 port_capacity) //------------------------------------------------------------------------------ BLooper::~BLooper() { + if (fRunCalled && !fTerminating) + { + debugger("You can't call delete on a BLooper object " + "once it is running."); + } + Lock(); kill_thread(fTaskID); delete fQueue; @@ -383,8 +418,6 @@ int32 BLooper::IndexOf(BHandler* handler) const 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); } //------------------------------------------------------------------------------ @@ -412,9 +445,7 @@ thread_id BLooper::Run() if (fRunCalled) { // Not allowed to call Run() more than once - // TODO: test - // find out what message is actually here - debugger(""); + debugger("can't call BLooper::Run twice!"); } fTaskID = spawn_thread(_task0_, Name(), fInitPriority, this); @@ -648,6 +679,11 @@ BHandler* BLooper::ResolveSpecifier(BMessage* msg, int32 index, { return this; } + else + { + return BHandler::ResolveSpecifier(msg, index, specifier, form, + property); + } BMessage Reply(B_MESSAGE_NOT_UNDERSTOOD); Reply.AddInt32("error", B_BAD_SCRIPT_SYNTAX); @@ -659,7 +695,27 @@ BHandler* BLooper::ResolveSpecifier(BMessage* msg, int32 index, //------------------------------------------------------------------------------ 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) @@ -980,14 +1036,12 @@ void BLooper::InitData(const char* name, int32 priority, int32 port_capacity) //------------------------------------------------------------------------------ void BLooper::AddMessage(BMessage* msg) { - // TODO: implement - // Why is this here? + // NOTE: Why is this here? } //------------------------------------------------------------------------------ void BLooper::_AddMessagePriv(BMessage* msg) { - // TODO: implement - // No, really; why the hell is this here?? + // NOTE: No, really; why the hell is this here?? } //------------------------------------------------------------------------------ status_t BLooper::_task0_(void* arg) @@ -1294,7 +1348,7 @@ BHandler* BLooper::apply_filters(BList* list, BMessage* msg, BHandler* target) //------------------------------------------------------------------------------ void BLooper::check_lock() { - // TODO: implement + // NOTE: any use for this? } //------------------------------------------------------------------------------ BHandler* BLooper::resolve_specifier(BHandler* target, BMessage* msg) diff --git a/src/tests/kits/app/blooper/AddHandlerTest.cpp b/src/tests/kits/app/blooper/AddHandlerTest.cpp index d00abd30f6..38f27cb0c5 100644 --- a/src/tests/kits/app/blooper/AddHandlerTest.cpp +++ b/src/tests/kits/app/blooper/AddHandlerTest.cpp @@ -3,12 +3,11 @@ // //------------------------------------------------------------------------------ /** - @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. + @note Most of AddHandler()'s functionality is indirectly exercised + 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 ----------------------------------------------------------- diff --git a/src/tests/kits/app/blooper/BLooperCases b/src/tests/kits/app/blooper/BLooperCases index 5a8b9b9e2c..eeff028f96 100644 --- a/src/tests/kits/app/blooper/BLooperCases +++ b/src/tests/kits/app/blooper/BLooperCases @@ -62,7 +62,11 @@ case 5: handler is valid, looper is unlocked PreferredHandler() const; SetPreferredHandler(BHandler* handler); + Run(); +-------------- +case 1: Attempt to call Run() twice + Quit(); QuitRequested(); Lock(); diff --git a/src/tests/kits/app/blooper/RunTest.cpp b/src/tests/kits/app/blooper/RunTest.cpp new file mode 100644 index 0000000000..f131f86d35 --- /dev/null +++ b/src/tests/kits/app/blooper/RunTest.cpp @@ -0,0 +1,49 @@ +//------------------------------------------------------------------------------ +// RunTest.cpp +// +//------------------------------------------------------------------------------ + +// Standard Includes ----------------------------------------------------------- + +// System Includes ------------------------------------------------------------- +#include + +// 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 $ + * + */ + diff --git a/src/tests/kits/app/blooper/RunTest.h b/src/tests/kits/app/blooper/RunTest.h new file mode 100644 index 0000000000..de4e7d7718 --- /dev/null +++ b/src/tests/kits/app/blooper/RunTest.h @@ -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 $ + * + */ +