michael@0: #include "base/basictypes.h" michael@0: michael@0: #include "TestRacyUndefer.h" michael@0: michael@0: #include "IPDLUnitTests.h" // fail etc. michael@0: michael@0: namespace mozilla { michael@0: namespace _ipdltest { michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // parent michael@0: michael@0: TestRacyUndeferParent::TestRacyUndeferParent() michael@0: { michael@0: MOZ_COUNT_CTOR(TestRacyUndeferParent); michael@0: } michael@0: michael@0: TestRacyUndeferParent::~TestRacyUndeferParent() michael@0: { michael@0: MOZ_COUNT_DTOR(TestRacyUndeferParent); michael@0: } michael@0: michael@0: void michael@0: TestRacyUndeferParent::Main() michael@0: { michael@0: if (!SendStart()) michael@0: fail("sending Start"); michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferParent::AnswerSpam() michael@0: { michael@0: static bool spammed = false; michael@0: static bool raced = false; michael@0: if (!spammed) { michael@0: spammed = true; michael@0: michael@0: if (!SendAwakenSpam()) michael@0: fail("sending AwakenSpam"); michael@0: } michael@0: else if (!raced) { michael@0: raced = true; michael@0: michael@0: if (!SendAwakenRaceWinTwice()) michael@0: fail("sending WinRaceTwice"); michael@0: michael@0: if (!CallRace()) michael@0: fail("calling Race1"); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferParent::AnswerRaceWinTwice() michael@0: { michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferParent::RecvDone() michael@0: { michael@0: Close(); michael@0: return true; michael@0: } michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // child michael@0: michael@0: TestRacyUndeferChild::TestRacyUndeferChild() michael@0: { michael@0: MOZ_COUNT_CTOR(TestRacyUndeferChild); michael@0: } michael@0: michael@0: TestRacyUndeferChild::~TestRacyUndeferChild() michael@0: { michael@0: MOZ_COUNT_DTOR(TestRacyUndeferChild); michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferChild::RecvStart() michael@0: { michael@0: if (!CallSpam()) michael@0: fail("calling Spam"); michael@0: michael@0: if (!SendDone()) michael@0: fail("sending Done"); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferChild::RecvAwakenSpam() michael@0: { michael@0: if (!CallSpam()) michael@0: fail("calling Spam"); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferChild::RecvAwakenRaceWinTwice() michael@0: { michael@0: if (!CallRaceWinTwice()) michael@0: fail("calling RaceWinTwice"); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TestRacyUndeferChild::AnswerRace() michael@0: { michael@0: return true; michael@0: } michael@0: michael@0: } // namespace _ipdltest michael@0: } // namespace mozilla