ipc/ipdl/test/cxx/TestSanity.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial