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