summaryrefslogtreecommitdiffstats
path: root/ipc/ipdl/test/cxx/TestStackHooks.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /ipc/ipdl/test/cxx/TestStackHooks.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'ipc/ipdl/test/cxx/TestStackHooks.cpp')
-rw-r--r--ipc/ipdl/test/cxx/TestStackHooks.cpp168
1 files changed, 168 insertions, 0 deletions
diff --git a/ipc/ipdl/test/cxx/TestStackHooks.cpp b/ipc/ipdl/test/cxx/TestStackHooks.cpp
new file mode 100644
index 000000000..b4181985c
--- /dev/null
+++ b/ipc/ipdl/test/cxx/TestStackHooks.cpp
@@ -0,0 +1,168 @@
+#include "TestStackHooks.h"
+
+#include "base/task.h"
+#include "IPDLUnitTests.h" // fail etc.
+
+
+
+namespace mozilla {
+namespace _ipdltest {
+
+//-----------------------------------------------------------------------------
+// parent
+
+TestStackHooksParent::TestStackHooksParent() :
+ mOnStack(false), mIncallDepth(0)
+{
+ MOZ_COUNT_CTOR(TestStackHooksParent);
+}
+
+TestStackHooksParent::~TestStackHooksParent()
+{
+ MOZ_COUNT_DTOR(TestStackHooksParent);
+}
+
+void
+TestStackHooksParent::Main()
+{
+ if (!SendStart())
+ fail("sending Start()");
+}
+
+
+bool
+TestStackHooksParent::AnswerStackFrame()
+{
+ if (!mOnStack)
+ fail("not on C++ stack?!");
+
+ if (!CallStackFrame())
+ fail("calling StackFrame()");
+
+ if (!mOnStack)
+ fail("not on C++ stack?!");
+
+ if (1 != mIncallDepth)
+ fail("missed EnteredCall or ExitedCall hook");
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+// child
+
+TestStackHooksChild::TestStackHooksChild() :
+ mOnStack(false),
+ mEntered(0),
+ mExited(0),
+ mIncallDepth(0)
+{
+ MOZ_COUNT_CTOR(TestStackHooksChild);
+}
+
+TestStackHooksChild::~TestStackHooksChild()
+{
+ MOZ_COUNT_DTOR(TestStackHooksChild);
+}
+
+namespace {
+void RunTestsFn() {
+ static_cast<TestStackHooksChild*>(gChildActor)->RunTests();
+}
+}
+
+bool
+TestStackHooksChild::RecvStart()
+{
+ if (!mOnStack)
+ fail("missed stack notification");
+
+ if (0 != mIncallDepth)
+ fail("EnteredCall/ExitedCall malfunction");
+
+ // kick off tests from a runnable so that we can start with
+ // MessageChannel code on the C++ stack
+ MessageLoop::current()->PostTask(NewRunnableFunction(RunTestsFn));
+
+ return true;
+}
+
+bool
+TestStackHooksChild::AnswerStackFrame()
+{
+ if (!mOnStack)
+ fail("missed stack notification");
+
+ if (1 != mIncallDepth)
+ fail("missed EnteredCall or ExitedCall hook");
+
+ if (PTestStackHooks::TEST4_3 == state()) {
+ if (!SendAsync())
+ fail("sending Async()");
+ }
+ else if (PTestStackHooks::TEST5_3 == state()) {
+ if (!SendSync())
+ fail("sending Sync()");
+ }
+ else {
+ fail("unexpected state");
+ }
+
+ if (!mOnStack)
+ fail("bad stack exit notification");
+
+ return true;
+}
+
+void
+TestStackHooksChild::RunTests()
+{
+ // 1 because of RecvStart()
+ if (1 != mEntered)
+ fail("missed stack notification");
+ if (mOnStack)
+ fail("spurious stack notification");
+ if (0 != mIncallDepth)
+ fail("EnteredCall/ExitedCall malfunction");
+
+ if (!SendAsync())
+ fail("sending Async()");
+ if (mOnStack)
+ fail("spurious stack notification");
+ if (0 != mIncallDepth)
+ fail("EnteredCall/ExitedCall malfunction");
+ if (2 != mEntered)
+ fail("missed stack notification");
+
+ if (!SendSync())
+ fail("sending Sync()");
+ if (mOnStack)
+ fail("spurious stack notification");
+ if (0 != mIncallDepth)
+ fail("EnteredCall/ExitedCall malfunction");
+ if (3 != mEntered)
+ fail("missed stack notification");
+
+ if (!CallRpc())
+ fail("calling RPC()");
+ if (mOnStack)
+ fail("spurious stack notification");
+ if (0 != mIncallDepth)
+ fail("EnteredCall/ExitedCall malfunction");
+ if (4 != mEntered)
+ fail("missed stack notification");
+
+ if (!CallStackFrame())
+ fail("calling StackFrame()");
+ if (mOnStack)
+ fail("spurious stack notification");
+ if (0 != mIncallDepth)
+ fail("EnteredCall/ExitedCall malfunction");
+ if (5 != mEntered)
+ fail("missed stack notification");
+
+ Close();
+}
+
+} // namespace _ipdltest
+} // namespace mozilla