|
1 #include "base/basictypes.h" |
|
2 |
|
3 #include "TestRacyUndefer.h" |
|
4 |
|
5 #include "IPDLUnitTests.h" // fail etc. |
|
6 |
|
7 namespace mozilla { |
|
8 namespace _ipdltest { |
|
9 |
|
10 //----------------------------------------------------------------------------- |
|
11 // parent |
|
12 |
|
13 TestRacyUndeferParent::TestRacyUndeferParent() |
|
14 { |
|
15 MOZ_COUNT_CTOR(TestRacyUndeferParent); |
|
16 } |
|
17 |
|
18 TestRacyUndeferParent::~TestRacyUndeferParent() |
|
19 { |
|
20 MOZ_COUNT_DTOR(TestRacyUndeferParent); |
|
21 } |
|
22 |
|
23 void |
|
24 TestRacyUndeferParent::Main() |
|
25 { |
|
26 if (!SendStart()) |
|
27 fail("sending Start"); |
|
28 } |
|
29 |
|
30 bool |
|
31 TestRacyUndeferParent::AnswerSpam() |
|
32 { |
|
33 static bool spammed = false; |
|
34 static bool raced = false; |
|
35 if (!spammed) { |
|
36 spammed = true; |
|
37 |
|
38 if (!SendAwakenSpam()) |
|
39 fail("sending AwakenSpam"); |
|
40 } |
|
41 else if (!raced) { |
|
42 raced = true; |
|
43 |
|
44 if (!SendAwakenRaceWinTwice()) |
|
45 fail("sending WinRaceTwice"); |
|
46 |
|
47 if (!CallRace()) |
|
48 fail("calling Race1"); |
|
49 } |
|
50 return true; |
|
51 } |
|
52 |
|
53 bool |
|
54 TestRacyUndeferParent::AnswerRaceWinTwice() |
|
55 { |
|
56 return true; |
|
57 } |
|
58 |
|
59 bool |
|
60 TestRacyUndeferParent::RecvDone() |
|
61 { |
|
62 Close(); |
|
63 return true; |
|
64 } |
|
65 |
|
66 |
|
67 //----------------------------------------------------------------------------- |
|
68 // child |
|
69 |
|
70 TestRacyUndeferChild::TestRacyUndeferChild() |
|
71 { |
|
72 MOZ_COUNT_CTOR(TestRacyUndeferChild); |
|
73 } |
|
74 |
|
75 TestRacyUndeferChild::~TestRacyUndeferChild() |
|
76 { |
|
77 MOZ_COUNT_DTOR(TestRacyUndeferChild); |
|
78 } |
|
79 |
|
80 bool |
|
81 TestRacyUndeferChild::RecvStart() |
|
82 { |
|
83 if (!CallSpam()) |
|
84 fail("calling Spam"); |
|
85 |
|
86 if (!SendDone()) |
|
87 fail("sending Done"); |
|
88 |
|
89 return true; |
|
90 } |
|
91 |
|
92 bool |
|
93 TestRacyUndeferChild::RecvAwakenSpam() |
|
94 { |
|
95 if (!CallSpam()) |
|
96 fail("calling Spam"); |
|
97 return true; |
|
98 } |
|
99 |
|
100 bool |
|
101 TestRacyUndeferChild::RecvAwakenRaceWinTwice() |
|
102 { |
|
103 if (!CallRaceWinTwice()) |
|
104 fail("calling RaceWinTwice"); |
|
105 return true; |
|
106 } |
|
107 |
|
108 bool |
|
109 TestRacyUndeferChild::AnswerRace() |
|
110 { |
|
111 return true; |
|
112 } |
|
113 |
|
114 } // namespace _ipdltest |
|
115 } // namespace mozilla |