michael@0: /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla__ipdltest_IPDLUnitTests_h michael@0: #define mozilla__ipdltest_IPDLUnitTests_h 1 michael@0: michael@0: #include "base/message_loop.h" michael@0: #include "base/process.h" michael@0: #include "chrome/common/ipc_channel.h" michael@0: michael@0: #include "nsIAppShell.h" michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsDebug.h" michael@0: #include "nsServiceManagerUtils.h" // do_GetService() michael@0: #include "nsWidgetsCID.h" // NS_APPSHELL_CID michael@0: #include "nsXULAppAPI.h" michael@0: michael@0: michael@0: #define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL" michael@0: #define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS" michael@0: #define MOZ_IPDL_TESTINFO_LABEL "TEST-INFO" michael@0: michael@0: michael@0: namespace mozilla { michael@0: namespace _ipdltest { michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // both processes michael@0: const char* const IPDLUnitTestName(); michael@0: michael@0: // NB: these are named like the similar functions in michael@0: // xpcom/test/TestHarness.h. The names should nominally be kept in michael@0: // sync. michael@0: michael@0: inline void fail(const char* fmt, ...) michael@0: { michael@0: va_list ap; michael@0: michael@0: fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName()); michael@0: michael@0: va_start(ap, fmt); michael@0: vfprintf(stderr, fmt, ap); michael@0: va_end(ap); michael@0: michael@0: fputc('\n', stderr); michael@0: michael@0: NS_RUNTIMEABORT("failed test"); michael@0: } michael@0: michael@0: inline void passed(const char* fmt, ...) michael@0: { michael@0: va_list ap; michael@0: michael@0: printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName()); michael@0: michael@0: va_start(ap, fmt); michael@0: vprintf(fmt, ap); michael@0: va_end(ap); michael@0: michael@0: fputc('\n', stdout); michael@0: } michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // parent process only michael@0: michael@0: class IPDLUnitTestSubprocess; michael@0: michael@0: extern void* gParentActor; michael@0: extern IPDLUnitTestSubprocess* gSubprocess; michael@0: michael@0: void IPDLUnitTestMain(void* aData); michael@0: michael@0: void QuitParent(); michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // child process only michael@0: michael@0: extern void* gChildActor; michael@0: michael@0: void IPDLUnitTestChildInit(IPC::Channel* transport, michael@0: base::ProcessHandle parent, michael@0: MessageLoop* worker); michael@0: michael@0: void QuitChild(); michael@0: michael@0: } // namespace _ipdltest michael@0: } // namespace mozilla michael@0: michael@0: michael@0: #endif // ifndef mozilla__ipdltest_IPDLUnitTests_h