ipc/ipdl/test/cxx/TestSelfManageRoot.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #include "TestSelfManageRoot.h"
     3 #include "IPDLUnitTests.h"      // fail etc.
     5 #define ASSERT(c)                               \
     6     do {                                        \
     7         if (!(c))                               \
     8             fail(#c);                           \
     9     } while (0)
    11 namespace mozilla {
    12 namespace _ipdltest {
    14 //-----------------------------------------------------------------------------
    15 // parent
    17 void
    18 TestSelfManageRootParent::Main()
    19 {
    20     TestSelfManageParent* a =
    21         static_cast<TestSelfManageParent*>(SendPTestSelfManageConstructor());
    22     if (!a)
    23         fail("constructing PTestSelfManage");
    25     ASSERT(1 == ManagedPTestSelfManageParent().Length());
    27     TestSelfManageParent* aa =
    28         static_cast<TestSelfManageParent*>(a->SendPTestSelfManageConstructor());
    29     if (!aa)
    30         fail("constructing PTestSelfManage");
    32     ASSERT(1 == ManagedPTestSelfManageParent().Length() &&
    33            1 == a->ManagedPTestSelfManageParent().Length());
    35     if (!PTestSelfManageParent::Send__delete__(aa))
    36         fail("destroying PTestSelfManage");
    37     ASSERT(Deletion == aa->mWhy &&
    38            1 == ManagedPTestSelfManageParent().Length() &&
    39            0 == a->ManagedPTestSelfManageParent().Length());
    40     delete aa;
    42     aa =
    43         static_cast<TestSelfManageParent*>(a->SendPTestSelfManageConstructor());
    44     if (!aa)
    45         fail("constructing PTestSelfManage");
    47     ASSERT(1 == ManagedPTestSelfManageParent().Length() &&
    48            1 == a->ManagedPTestSelfManageParent().Length());
    50     if (!PTestSelfManageParent::Send__delete__(a))
    51         fail("destroying PTestSelfManage");
    52     ASSERT(Deletion == a->mWhy &&
    53            AncestorDeletion == aa->mWhy &&
    54            0 == ManagedPTestSelfManageParent().Length() &&
    55            0 == a->ManagedPTestSelfManageParent().Length());
    56     delete a;
    57     delete aa;
    59     Close();
    60 }
    62 } // namespace _ipdltest
    63 } // namespace mozilla

mercurial