ipc/ipdl/test/cxx/IPDLUnitTests.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:70913d8bf687
1 /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef mozilla__ipdltest_IPDLUnitTests_h
7 #define mozilla__ipdltest_IPDLUnitTests_h 1
8
9 #include "base/message_loop.h"
10 #include "base/process.h"
11 #include "chrome/common/ipc_channel.h"
12
13 #include "nsIAppShell.h"
14
15 #include "nsCOMPtr.h"
16 #include "nsDebug.h"
17 #include "nsServiceManagerUtils.h" // do_GetService()
18 #include "nsWidgetsCID.h" // NS_APPSHELL_CID
19 #include "nsXULAppAPI.h"
20
21
22 #define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL"
23 #define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS"
24 #define MOZ_IPDL_TESTINFO_LABEL "TEST-INFO"
25
26
27 namespace mozilla {
28 namespace _ipdltest {
29
30 //-----------------------------------------------------------------------------
31 // both processes
32 const char* const IPDLUnitTestName();
33
34 // NB: these are named like the similar functions in
35 // xpcom/test/TestHarness.h. The names should nominally be kept in
36 // sync.
37
38 inline void fail(const char* fmt, ...)
39 {
40 va_list ap;
41
42 fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName());
43
44 va_start(ap, fmt);
45 vfprintf(stderr, fmt, ap);
46 va_end(ap);
47
48 fputc('\n', stderr);
49
50 NS_RUNTIMEABORT("failed test");
51 }
52
53 inline void passed(const char* fmt, ...)
54 {
55 va_list ap;
56
57 printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName());
58
59 va_start(ap, fmt);
60 vprintf(fmt, ap);
61 va_end(ap);
62
63 fputc('\n', stdout);
64 }
65
66 //-----------------------------------------------------------------------------
67 // parent process only
68
69 class IPDLUnitTestSubprocess;
70
71 extern void* gParentActor;
72 extern IPDLUnitTestSubprocess* gSubprocess;
73
74 void IPDLUnitTestMain(void* aData);
75
76 void QuitParent();
77
78 //-----------------------------------------------------------------------------
79 // child process only
80
81 extern void* gChildActor;
82
83 void IPDLUnitTestChildInit(IPC::Channel* transport,
84 base::ProcessHandle parent,
85 MessageLoop* worker);
86
87 void QuitChild();
88
89 } // namespace _ipdltest
90 } // namespace mozilla
91
92
93 #endif // ifndef mozilla__ipdltest_IPDLUnitTests_h

mercurial