ipc/ipdl/test/cxx/IPDLUnitTests.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/ipdl/test/cxx/IPDLUnitTests.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla__ipdltest_IPDLUnitTests_h
    1.10 +#define mozilla__ipdltest_IPDLUnitTests_h 1
    1.11 +
    1.12 +#include "base/message_loop.h"
    1.13 +#include "base/process.h"
    1.14 +#include "chrome/common/ipc_channel.h"
    1.15 +
    1.16 +#include "nsIAppShell.h"
    1.17 +
    1.18 +#include "nsCOMPtr.h"
    1.19 +#include "nsDebug.h"
    1.20 +#include "nsServiceManagerUtils.h" // do_GetService()
    1.21 +#include "nsWidgetsCID.h"       // NS_APPSHELL_CID
    1.22 +#include "nsXULAppAPI.h"
    1.23 +
    1.24 +
    1.25 +#define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL"
    1.26 +#define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS"
    1.27 +#define MOZ_IPDL_TESTINFO_LABEL "TEST-INFO"
    1.28 +
    1.29 +
    1.30 +namespace mozilla {
    1.31 +namespace _ipdltest {
    1.32 +
    1.33 +//-----------------------------------------------------------------------------
    1.34 +// both processes
    1.35 +const char* const IPDLUnitTestName();
    1.36 +
    1.37 +// NB: these are named like the similar functions in
    1.38 +// xpcom/test/TestHarness.h.  The names should nominally be kept in
    1.39 +// sync.
    1.40 +
    1.41 +inline void fail(const char* fmt, ...)
    1.42 +{
    1.43 +  va_list ap;
    1.44 +
    1.45 +  fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName());
    1.46 +
    1.47 +  va_start(ap, fmt);
    1.48 +  vfprintf(stderr, fmt, ap);
    1.49 +  va_end(ap);
    1.50 +
    1.51 +  fputc('\n', stderr);
    1.52 +
    1.53 +  NS_RUNTIMEABORT("failed test");
    1.54 +}
    1.55 +
    1.56 +inline void passed(const char* fmt, ...)
    1.57 +{
    1.58 +  va_list ap;
    1.59 +
    1.60 +  printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName());
    1.61 +
    1.62 +  va_start(ap, fmt);
    1.63 +  vprintf(fmt, ap);
    1.64 +  va_end(ap);
    1.65 +
    1.66 +  fputc('\n', stdout);
    1.67 +}
    1.68 +
    1.69 +//-----------------------------------------------------------------------------
    1.70 +// parent process only
    1.71 +
    1.72 +class IPDLUnitTestSubprocess;
    1.73 +
    1.74 +extern void* gParentActor;
    1.75 +extern IPDLUnitTestSubprocess* gSubprocess;
    1.76 +
    1.77 +void IPDLUnitTestMain(void* aData);
    1.78 +
    1.79 +void QuitParent();
    1.80 +
    1.81 +//-----------------------------------------------------------------------------
    1.82 +// child process only
    1.83 +
    1.84 +extern void* gChildActor;
    1.85 +
    1.86 +void IPDLUnitTestChildInit(IPC::Channel* transport,
    1.87 +                           base::ProcessHandle parent,
    1.88 +                           MessageLoop* worker);
    1.89 +
    1.90 +void QuitChild();
    1.91 +
    1.92 +} // namespace _ipdltest
    1.93 +} // namespace mozilla
    1.94 +
    1.95 +
    1.96 +#endif // ifndef mozilla__ipdltest_IPDLUnitTests_h

mercurial