2009-10-06 18:02:26 +00:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-06 18:02:26 +00:00
|
|
|
|
|
|
|
#ifndef mozilla__ipdltest_IPDLUnitTests_h
|
|
|
|
#define mozilla__ipdltest_IPDLUnitTests_h 1
|
|
|
|
|
|
|
|
#include "base/message_loop.h"
|
2009-10-27 21:52:37 +00:00
|
|
|
#include "base/process.h"
|
2009-10-06 18:02:26 +00:00
|
|
|
#include "chrome/common/ipc_channel.h"
|
|
|
|
|
2009-12-03 08:16:28 +00:00
|
|
|
#include "nsIAppShell.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2009-11-06 23:07:52 +00:00
|
|
|
#include "nsDebug.h"
|
2009-12-03 08:16:28 +00:00
|
|
|
#include "nsServiceManagerUtils.h" // do_GetService()
|
|
|
|
#include "nsWidgetsCID.h" // NS_APPSHELL_CID
|
2009-12-07 06:03:49 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
2009-12-03 08:16:28 +00:00
|
|
|
|
2009-10-06 18:02:26 +00:00
|
|
|
|
|
|
|
#define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL"
|
|
|
|
#define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS"
|
2010-03-13 00:23:50 +00:00
|
|
|
#define MOZ_IPDL_TESTINFO_LABEL "TEST-INFO"
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace _ipdltest {
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// both processes
|
2016-05-04 05:36:50 +00:00
|
|
|
const char* IPDLUnitTestName();
|
2009-11-06 23:07:52 +00:00
|
|
|
|
2009-10-06 18:02:26 +00:00
|
|
|
// NB: these are named like the similar functions in
|
|
|
|
// xpcom/test/TestHarness.h. The names should nominally be kept in
|
|
|
|
// sync.
|
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
inline void fail(const char* fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName());
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
va_start(ap, fmt);
|
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
va_end(ap);
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
fputc('\n', stderr);
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
NS_RUNTIMEABORT("failed test");
|
|
|
|
}
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
inline void passed(const char* fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName());
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vprintf(fmt, ap);
|
|
|
|
va_end(ap);
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2009-11-06 23:07:52 +00:00
|
|
|
fputc('\n', stdout);
|
|
|
|
}
|
2009-10-06 18:02:26 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// parent process only
|
|
|
|
|
2009-12-18 00:12:01 +00:00
|
|
|
class IPDLUnitTestSubprocess;
|
|
|
|
|
|
|
|
extern void* gParentActor;
|
|
|
|
extern IPDLUnitTestSubprocess* gSubprocess;
|
|
|
|
|
2009-10-06 18:02:26 +00:00
|
|
|
void IPDLUnitTestMain(void* aData);
|
|
|
|
|
2009-12-07 06:03:49 +00:00
|
|
|
void QuitParent();
|
2009-10-06 18:02:26 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// child process only
|
|
|
|
|
2009-12-18 00:12:01 +00:00
|
|
|
extern void* gChildActor;
|
|
|
|
|
2009-10-27 21:52:37 +00:00
|
|
|
void IPDLUnitTestChildInit(IPC::Channel* transport,
|
2015-04-01 08:40:35 +00:00
|
|
|
base::ProcessId parentPid,
|
2009-10-27 21:52:37 +00:00
|
|
|
MessageLoop* worker);
|
2009-10-06 18:02:26 +00:00
|
|
|
|
2011-11-30 16:27:22 +00:00
|
|
|
void QuitChild();
|
2009-12-03 08:16:28 +00:00
|
|
|
|
2009-10-06 18:02:26 +00:00
|
|
|
} // namespace _ipdltest
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ifndef mozilla__ipdltest_IPDLUnitTests_h
|