1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/ipdl/test/cxx/TestRacyUndefer.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 1.4 +#include "base/basictypes.h" 1.5 + 1.6 +#include "TestRacyUndefer.h" 1.7 + 1.8 +#include "IPDLUnitTests.h" // fail etc. 1.9 + 1.10 +namespace mozilla { 1.11 +namespace _ipdltest { 1.12 + 1.13 +//----------------------------------------------------------------------------- 1.14 +// parent 1.15 + 1.16 +TestRacyUndeferParent::TestRacyUndeferParent() 1.17 +{ 1.18 + MOZ_COUNT_CTOR(TestRacyUndeferParent); 1.19 +} 1.20 + 1.21 +TestRacyUndeferParent::~TestRacyUndeferParent() 1.22 +{ 1.23 + MOZ_COUNT_DTOR(TestRacyUndeferParent); 1.24 +} 1.25 + 1.26 +void 1.27 +TestRacyUndeferParent::Main() 1.28 +{ 1.29 + if (!SendStart()) 1.30 + fail("sending Start"); 1.31 +} 1.32 + 1.33 +bool 1.34 +TestRacyUndeferParent::AnswerSpam() 1.35 +{ 1.36 + static bool spammed = false; 1.37 + static bool raced = false; 1.38 + if (!spammed) { 1.39 + spammed = true; 1.40 + 1.41 + if (!SendAwakenSpam()) 1.42 + fail("sending AwakenSpam"); 1.43 + } 1.44 + else if (!raced) { 1.45 + raced = true; 1.46 + 1.47 + if (!SendAwakenRaceWinTwice()) 1.48 + fail("sending WinRaceTwice"); 1.49 + 1.50 + if (!CallRace()) 1.51 + fail("calling Race1"); 1.52 + } 1.53 + return true; 1.54 +} 1.55 + 1.56 +bool 1.57 +TestRacyUndeferParent::AnswerRaceWinTwice() 1.58 +{ 1.59 + return true; 1.60 +} 1.61 + 1.62 +bool 1.63 +TestRacyUndeferParent::RecvDone() 1.64 +{ 1.65 + Close(); 1.66 + return true; 1.67 +} 1.68 + 1.69 + 1.70 +//----------------------------------------------------------------------------- 1.71 +// child 1.72 + 1.73 +TestRacyUndeferChild::TestRacyUndeferChild() 1.74 +{ 1.75 + MOZ_COUNT_CTOR(TestRacyUndeferChild); 1.76 +} 1.77 + 1.78 +TestRacyUndeferChild::~TestRacyUndeferChild() 1.79 +{ 1.80 + MOZ_COUNT_DTOR(TestRacyUndeferChild); 1.81 +} 1.82 + 1.83 +bool 1.84 +TestRacyUndeferChild::RecvStart() 1.85 +{ 1.86 + if (!CallSpam()) 1.87 + fail("calling Spam"); 1.88 + 1.89 + if (!SendDone()) 1.90 + fail("sending Done"); 1.91 + 1.92 + return true; 1.93 +} 1.94 + 1.95 +bool 1.96 +TestRacyUndeferChild::RecvAwakenSpam() 1.97 +{ 1.98 + if (!CallSpam()) 1.99 + fail("calling Spam"); 1.100 + return true; 1.101 +} 1.102 + 1.103 +bool 1.104 +TestRacyUndeferChild::RecvAwakenRaceWinTwice() 1.105 +{ 1.106 + if (!CallRaceWinTwice()) 1.107 + fail("calling RaceWinTwice"); 1.108 + return true; 1.109 +} 1.110 + 1.111 +bool 1.112 +TestRacyUndeferChild::AnswerRace() 1.113 +{ 1.114 + return true; 1.115 +} 1.116 + 1.117 +} // namespace _ipdltest 1.118 +} // namespace mozilla