|
1 #include "TestSanity.h" |
|
2 |
|
3 #include "IPDLUnitTests.h" // fail etc. |
|
4 |
|
5 namespace mozilla { |
|
6 namespace _ipdltest { |
|
7 |
|
8 //----------------------------------------------------------------------------- |
|
9 // parent |
|
10 |
|
11 TestSanityParent::TestSanityParent() |
|
12 { |
|
13 MOZ_COUNT_CTOR(TestSanityParent); |
|
14 } |
|
15 |
|
16 TestSanityParent::~TestSanityParent() |
|
17 { |
|
18 MOZ_COUNT_DTOR(TestSanityParent); |
|
19 } |
|
20 |
|
21 void |
|
22 TestSanityParent::Main() |
|
23 { |
|
24 if (!SendPing(0, 0.5f, 0)) |
|
25 fail("sending Ping"); |
|
26 } |
|
27 |
|
28 |
|
29 bool |
|
30 TestSanityParent::RecvPong(const int& one, const float& zeroPtTwoFive, |
|
31 const uint8_t&/*unused*/) |
|
32 { |
|
33 if (1 != one) |
|
34 fail("invalid argument `%d', should have been `1'", one); |
|
35 |
|
36 if (0.25f != zeroPtTwoFive) |
|
37 fail("invalid argument `%g', should have been `0.25'", zeroPtTwoFive); |
|
38 |
|
39 Close(); |
|
40 |
|
41 return true; |
|
42 } |
|
43 |
|
44 |
|
45 //----------------------------------------------------------------------------- |
|
46 // child |
|
47 |
|
48 TestSanityChild::TestSanityChild() |
|
49 { |
|
50 MOZ_COUNT_CTOR(TestSanityChild); |
|
51 } |
|
52 |
|
53 TestSanityChild::~TestSanityChild() |
|
54 { |
|
55 MOZ_COUNT_DTOR(TestSanityChild); |
|
56 } |
|
57 |
|
58 bool |
|
59 TestSanityChild::RecvPing(const int& zero, const float& zeroPtFive, |
|
60 const int8_t&/*unused*/) |
|
61 { |
|
62 if (0 != zero) |
|
63 fail("invalid argument `%d', should have been `0'", zero); |
|
64 |
|
65 if (0.5f != zeroPtFive) |
|
66 fail("invalid argument `%g', should have been `0.5'", zeroPtFive); |
|
67 |
|
68 if (!SendPong(1, 0.25f, 0)) |
|
69 fail("sending Pong"); |
|
70 return true; |
|
71 } |
|
72 |
|
73 |
|
74 } // namespace _ipdltest |
|
75 } // namespace mozilla |