1*dace24c6SIngo Weinhold // MessageRunnerTestHelpers.h 2*dace24c6SIngo Weinhold 3*dace24c6SIngo Weinhold #ifndef MESSAGE_RUNNER_TEST_HELPERS_H 4*dace24c6SIngo Weinhold #define MESSAGE_RUNNER_TEST_HELPERS_H 5*dace24c6SIngo Weinhold 6*dace24c6SIngo Weinhold #include <Application.h> 7*dace24c6SIngo Weinhold #include <List.h> 8*dace24c6SIngo Weinhold 9*dace24c6SIngo Weinhold enum { 10*dace24c6SIngo Weinhold MSG_RUNNER_MESSAGE = 'rmsg', 11*dace24c6SIngo Weinhold MSG_REPLY = 'rply', 12*dace24c6SIngo Weinhold }; 13*dace24c6SIngo Weinhold 14*dace24c6SIngo Weinhold // MessageRunnerTestHandler 15*dace24c6SIngo Weinhold class MessageRunnerTestHandler : public BHandler { 16*dace24c6SIngo Weinhold public: 17*dace24c6SIngo Weinhold MessageRunnerTestHandler(); 18*dace24c6SIngo Weinhold ~MessageRunnerTestHandler(); 19*dace24c6SIngo Weinhold 20*dace24c6SIngo Weinhold virtual void MessageReceived(BMessage *message); 21*dace24c6SIngo Weinhold CountReplies()22*dace24c6SIngo Weinhold int32 CountReplies() const { return fReplyCount; } 23*dace24c6SIngo Weinhold 24*dace24c6SIngo Weinhold private: 25*dace24c6SIngo Weinhold int32 fReplyCount; 26*dace24c6SIngo Weinhold }; 27*dace24c6SIngo Weinhold 28*dace24c6SIngo Weinhold // MessageRunnerTestLooper 29*dace24c6SIngo Weinhold class MessageRunnerTestLooper : public BLooper { 30*dace24c6SIngo Weinhold public: 31*dace24c6SIngo Weinhold MessageRunnerTestLooper(); 32*dace24c6SIngo Weinhold ~MessageRunnerTestLooper(); 33*dace24c6SIngo Weinhold 34*dace24c6SIngo Weinhold virtual void MessageReceived(BMessage *message); 35*dace24c6SIngo Weinhold 36*dace24c6SIngo Weinhold bool CheckMessages(bigtime_t startTime, bigtime_t interval, int32 count); 37*dace24c6SIngo Weinhold bool CheckMessages(int32 skip, bigtime_t startTime, bigtime_t interval, 38*dace24c6SIngo Weinhold int32 count); 39*dace24c6SIngo Weinhold 40*dace24c6SIngo Weinhold private: 41*dace24c6SIngo Weinhold struct MessageInfo; 42*dace24c6SIngo Weinhold 43*dace24c6SIngo Weinhold private: 44*dace24c6SIngo Weinhold MessageInfo *MessageInfoAt(int32 index) const; 45*dace24c6SIngo Weinhold 46*dace24c6SIngo Weinhold private: 47*dace24c6SIngo Weinhold BList fMessageInfos; 48*dace24c6SIngo Weinhold }; 49*dace24c6SIngo Weinhold 50*dace24c6SIngo Weinhold // MessageRunnerTestApp 51*dace24c6SIngo Weinhold class MessageRunnerTestApp : public BApplication { 52*dace24c6SIngo Weinhold public: 53*dace24c6SIngo Weinhold MessageRunnerTestApp(const char *signature); 54*dace24c6SIngo Weinhold ~MessageRunnerTestApp(); 55*dace24c6SIngo Weinhold 56*dace24c6SIngo Weinhold virtual void MessageReceived(BMessage *message); 57*dace24c6SIngo Weinhold virtual bool QuitRequested(); 58*dace24c6SIngo Weinhold CountReplies()59*dace24c6SIngo Weinhold int32 CountReplies() const { return fReplyCount; } 60*dace24c6SIngo Weinhold TestLooper()61*dace24c6SIngo Weinhold MessageRunnerTestLooper *TestLooper() const { return fLooper; } TestHandler()62*dace24c6SIngo Weinhold MessageRunnerTestHandler *TestHandler() const { return fHandler; } 63*dace24c6SIngo Weinhold 64*dace24c6SIngo Weinhold private: 65*dace24c6SIngo Weinhold static int32 _ThreadEntry(void *data); 66*dace24c6SIngo Weinhold 67*dace24c6SIngo Weinhold private: 68*dace24c6SIngo Weinhold thread_id fThread; 69*dace24c6SIngo Weinhold int32 fReplyCount; 70*dace24c6SIngo Weinhold MessageRunnerTestLooper *fLooper; 71*dace24c6SIngo Weinhold MessageRunnerTestHandler *fHandler; 72*dace24c6SIngo Weinhold }; 73*dace24c6SIngo Weinhold 74*dace24c6SIngo Weinhold #endif // MESSAGE_RUNNER_TEST_HELPERS_H 75