|
1 #ifndef mozilla__ipdltest_TestJSON_h |
|
2 #define mozilla__ipdltest_TestJSON_h 1 |
|
3 |
|
4 #include "mozilla/_ipdltest/IPDLUnitTests.h" |
|
5 |
|
6 #include "mozilla/_ipdltest/PTestJSONParent.h" |
|
7 #include "mozilla/_ipdltest/PTestJSONChild.h" |
|
8 |
|
9 #include "mozilla/_ipdltest/PTestHandleParent.h" |
|
10 #include "mozilla/_ipdltest/PTestHandleChild.h" |
|
11 |
|
12 namespace mozilla { |
|
13 namespace _ipdltest { |
|
14 |
|
15 class TestHandleParent : |
|
16 public PTestHandleParent |
|
17 { |
|
18 public: |
|
19 TestHandleParent() { } |
|
20 virtual ~TestHandleParent() { } |
|
21 }; |
|
22 |
|
23 class TestJSONParent : |
|
24 public PTestJSONParent |
|
25 { |
|
26 public: |
|
27 TestJSONParent() { } |
|
28 virtual ~TestJSONParent() { } |
|
29 |
|
30 static bool RunTestInProcesses() { return true; } |
|
31 static bool RunTestInThreads() { return true; } |
|
32 |
|
33 void Main(); |
|
34 |
|
35 protected: |
|
36 virtual bool |
|
37 RecvTest(const JSONVariant& i, |
|
38 JSONVariant* o) MOZ_OVERRIDE; |
|
39 |
|
40 virtual PTestHandleParent* AllocPTestHandleParent() MOZ_OVERRIDE |
|
41 { |
|
42 return mKid = new TestHandleParent(); |
|
43 } |
|
44 |
|
45 virtual bool DeallocPTestHandleParent(PTestHandleParent* actor) MOZ_OVERRIDE |
|
46 { |
|
47 delete actor; |
|
48 return true; |
|
49 } |
|
50 |
|
51 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE |
|
52 { |
|
53 if (NormalShutdown != why) |
|
54 fail("unexpected destruction!"); |
|
55 passed("ok"); |
|
56 QuitParent(); |
|
57 } |
|
58 |
|
59 PTestHandleParent* mKid; |
|
60 }; |
|
61 |
|
62 |
|
63 class TestHandleChild : |
|
64 public PTestHandleChild |
|
65 { |
|
66 public: |
|
67 TestHandleChild() { } |
|
68 virtual ~TestHandleChild() { } |
|
69 }; |
|
70 |
|
71 class TestJSONChild : |
|
72 public PTestJSONChild |
|
73 { |
|
74 public: |
|
75 TestJSONChild() { } |
|
76 virtual ~TestJSONChild() { } |
|
77 |
|
78 protected: |
|
79 virtual bool |
|
80 RecvStart() MOZ_OVERRIDE; |
|
81 |
|
82 virtual PTestHandleChild* AllocPTestHandleChild() MOZ_OVERRIDE |
|
83 { |
|
84 return mKid = new TestHandleChild(); |
|
85 } |
|
86 |
|
87 virtual bool DeallocPTestHandleChild(PTestHandleChild* actor) MOZ_OVERRIDE |
|
88 { |
|
89 delete actor; |
|
90 return true; |
|
91 } |
|
92 |
|
93 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE |
|
94 { |
|
95 if (NormalShutdown != why) |
|
96 fail("unexpected destruction!"); |
|
97 QuitChild(); |
|
98 } |
|
99 |
|
100 PTestHandleChild* mKid; |
|
101 }; |
|
102 |
|
103 |
|
104 } // namespace _ipdltest |
|
105 } // namespace mozilla |
|
106 |
|
107 |
|
108 #endif // ifndef mozilla__ipdltest_TestJSON_h |