ipc/ipdl/test/cxx/TestSyncHang.cpp

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 #include "TestSyncHang.h"
michael@0 2 #include "mozilla/ipc/GeckoChildProcessHost.h"
michael@0 3
michael@0 4 #include "IPDLUnitTests.h" // fail etc.
michael@0 5
michael@0 6 using std::vector;
michael@0 7 using std::string;
michael@0 8
michael@0 9 namespace mozilla {
michael@0 10 namespace _ipdltest {
michael@0 11
michael@0 12 //-----------------------------------------------------------------------------
michael@0 13 // parent
michael@0 14
michael@0 15 mozilla::ipc::GeckoChildProcessHost* gSyncHangSubprocess;
michael@0 16
michael@0 17 TestSyncHangParent::TestSyncHangParent()
michael@0 18 {
michael@0 19 MOZ_COUNT_CTOR(TestSyncHangParent);
michael@0 20 }
michael@0 21
michael@0 22 TestSyncHangParent::~TestSyncHangParent()
michael@0 23 {
michael@0 24 MOZ_COUNT_DTOR(TestSyncHangParent);
michael@0 25 }
michael@0 26
michael@0 27 void
michael@0 28 DeleteSyncHangSubprocess(MessageLoop* uiLoop)
michael@0 29 {
michael@0 30 delete gSyncHangSubprocess;
michael@0 31 }
michael@0 32
michael@0 33 void
michael@0 34 DeferredSyncHangParentShutdown()
michael@0 35 {
michael@0 36 // ping to DeleteSubprocess
michael@0 37 XRE_GetIOMessageLoop()->PostTask(
michael@0 38 FROM_HERE,
michael@0 39 NewRunnableFunction(DeleteSyncHangSubprocess, MessageLoop::current()));
michael@0 40 }
michael@0 41
michael@0 42 void
michael@0 43 TestSyncHangParent::Main()
michael@0 44 {
michael@0 45 vector<string> args;
michael@0 46 args.push_back("fake/path");
michael@0 47 gSyncHangSubprocess = new mozilla::ipc::GeckoChildProcessHost(GeckoProcessType_Plugin);
michael@0 48 bool launched = gSyncHangSubprocess->SyncLaunch(args, 2);
michael@0 49 if (launched)
michael@0 50 fail("Calling SyncLaunch with an invalid path should return false");
michael@0 51
michael@0 52 MessageLoop::current()->PostTask(
michael@0 53 FROM_HERE, NewRunnableFunction(DeferredSyncHangParentShutdown));
michael@0 54 Close();
michael@0 55 }
michael@0 56
michael@0 57 //-----------------------------------------------------------------------------
michael@0 58 // child
michael@0 59
michael@0 60 TestSyncHangChild::TestSyncHangChild()
michael@0 61 {
michael@0 62 MOZ_COUNT_CTOR(TestSyncHangChild);
michael@0 63 }
michael@0 64
michael@0 65 TestSyncHangChild::~TestSyncHangChild()
michael@0 66 {
michael@0 67 MOZ_COUNT_DTOR(TestSyncHangChild);
michael@0 68 }
michael@0 69
michael@0 70 } // namespace _ipdltest
michael@0 71 } // namespace mozilla

mercurial