ipc/ipdl/test/cxx/TestSyncHang.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/ipdl/test/cxx/TestSyncHang.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +#include "TestSyncHang.h"
     1.5 +#include "mozilla/ipc/GeckoChildProcessHost.h"
     1.6 +
     1.7 +#include "IPDLUnitTests.h"      // fail etc.
     1.8 +
     1.9 +using std::vector;
    1.10 +using std::string;
    1.11 +
    1.12 +namespace mozilla {
    1.13 +namespace _ipdltest {
    1.14 +
    1.15 +//-----------------------------------------------------------------------------
    1.16 +// parent
    1.17 +
    1.18 +mozilla::ipc::GeckoChildProcessHost* gSyncHangSubprocess;
    1.19 +
    1.20 +TestSyncHangParent::TestSyncHangParent()
    1.21 +{
    1.22 +    MOZ_COUNT_CTOR(TestSyncHangParent);
    1.23 +}
    1.24 +
    1.25 +TestSyncHangParent::~TestSyncHangParent()
    1.26 +{
    1.27 +    MOZ_COUNT_DTOR(TestSyncHangParent);
    1.28 +}
    1.29 +
    1.30 +void
    1.31 +DeleteSyncHangSubprocess(MessageLoop* uiLoop)
    1.32 +{
    1.33 +  delete gSyncHangSubprocess;
    1.34 +}
    1.35 +
    1.36 +void
    1.37 +DeferredSyncHangParentShutdown()
    1.38 +{
    1.39 +  // ping to DeleteSubprocess
    1.40 +  XRE_GetIOMessageLoop()->PostTask(
    1.41 +      FROM_HERE,
    1.42 +      NewRunnableFunction(DeleteSyncHangSubprocess, MessageLoop::current()));
    1.43 +}
    1.44 +
    1.45 +void
    1.46 +TestSyncHangParent::Main()
    1.47 +{
    1.48 +  vector<string> args;
    1.49 +  args.push_back("fake/path");
    1.50 +  gSyncHangSubprocess = new mozilla::ipc::GeckoChildProcessHost(GeckoProcessType_Plugin);
    1.51 +  bool launched = gSyncHangSubprocess->SyncLaunch(args, 2);
    1.52 +  if (launched)
    1.53 +    fail("Calling SyncLaunch with an invalid path should return false");
    1.54 +
    1.55 +  MessageLoop::current()->PostTask(
    1.56 +  				   FROM_HERE, NewRunnableFunction(DeferredSyncHangParentShutdown));
    1.57 +  Close();
    1.58 +}
    1.59 +
    1.60 +//-----------------------------------------------------------------------------
    1.61 +// child
    1.62 +
    1.63 +TestSyncHangChild::TestSyncHangChild()
    1.64 +{
    1.65 +    MOZ_COUNT_CTOR(TestSyncHangChild);
    1.66 +}
    1.67 +
    1.68 +TestSyncHangChild::~TestSyncHangChild()
    1.69 +{
    1.70 +    MOZ_COUNT_DTOR(TestSyncHangChild);
    1.71 +}
    1.72 +
    1.73 +} // namespace _ipdltest
    1.74 +} // namespace mozilla

mercurial