mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1366072 - MozPromise tests (r=jwwang)
MozReview-Commit-ID: 69OQb1f3UTd
This commit is contained in:
parent
eee9dad55a
commit
5066de8593
@ -19,7 +19,6 @@ UNIFIED_SOURCES += [
|
||||
'TestMediaDataDecoder.cpp',
|
||||
'TestMediaEventSource.cpp',
|
||||
'TestMediaMIMETypes.cpp',
|
||||
'TestMozPromise.cpp',
|
||||
'TestMP3Demuxer.cpp',
|
||||
'TestMP4Demuxer.cpp',
|
||||
'TestRust.cpp',
|
||||
|
@ -27,10 +27,7 @@ TestAsyncReturnsParent::~TestAsyncReturnsParent()
|
||||
void
|
||||
TestAsyncReturnsParent::Main()
|
||||
{
|
||||
if (!AbstractThread::MainThread()) {
|
||||
fail("AbstractThread not initalized");
|
||||
}
|
||||
SendNoReturn()->Then(AbstractThread::MainThread(), __func__,
|
||||
SendNoReturn()->Then(MessageLoop::current()->SerialEventTarget(), __func__,
|
||||
[](bool unused) {
|
||||
fail("resolve handler should not be called");
|
||||
},
|
||||
@ -42,7 +39,7 @@ TestAsyncReturnsParent::Main()
|
||||
}
|
||||
passed("reject handler called on channel close");
|
||||
});
|
||||
SendPing()->Then(AbstractThread::MainThread(), __func__,
|
||||
SendPing()->Then(MessageLoop::current()->SerialEventTarget(), __func__,
|
||||
[this](bool one) {
|
||||
if (one) {
|
||||
passed("take one argument");
|
||||
@ -88,10 +85,7 @@ TestAsyncReturnsChild::RecvNoReturn(NoReturnResolver&& aResolve)
|
||||
mozilla::ipc::IPCResult
|
||||
TestAsyncReturnsChild::RecvPing(PingResolver&& aResolve)
|
||||
{
|
||||
if (!AbstractThread::MainThread()) {
|
||||
fail("AbstractThread not initalized");
|
||||
}
|
||||
SendPong()->Then(AbstractThread::MainThread(), __func__,
|
||||
SendPong()->Then(MessageLoop::current()->SerialEventTarget(), __func__,
|
||||
[aResolve](const Tuple<uint32_t, uint32_t>& aParam) {
|
||||
if (Get<0>(aParam) == sMagic1 && Get<1>(aParam) == sMagic2) {
|
||||
passed("take two arguments");
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "base/message_loop.h"
|
||||
|
||||
#include "mozilla/TaskQueue.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
|
||||
@ -407,4 +409,24 @@ TEST(MozPromise, HeterogeneousChaining)
|
||||
});
|
||||
}
|
||||
|
||||
TEST(MozPromise, XPCOMEventTarget)
|
||||
{
|
||||
TestPromise::CreateAndResolve(42, __func__)->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[] (int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); },
|
||||
DO_FAIL);
|
||||
|
||||
// Spin the event loop.
|
||||
NS_ProcessPendingEvents(nullptr);
|
||||
}
|
||||
|
||||
TEST(MozPromise, MessageLoopEventTarget)
|
||||
{
|
||||
TestPromise::CreateAndResolve(42, __func__)->Then(MessageLoop::current()->SerialEventTarget(), __func__,
|
||||
[] (int aResolveValue) -> void { EXPECT_EQ(aResolveValue, 42); },
|
||||
DO_FAIL);
|
||||
|
||||
// Spin the event loop.
|
||||
NS_ProcessPendingEvents(nullptr);
|
||||
}
|
||||
|
||||
#undef DO_FAIL
|
@ -22,6 +22,7 @@ UNIFIED_SOURCES += [
|
||||
'TestFile.cpp',
|
||||
'TestGCPostBarriers.cpp',
|
||||
'TestID.cpp',
|
||||
'TestMozPromise.cpp',
|
||||
'TestMultiplexInputStream.cpp',
|
||||
'TestNsDeque.cpp',
|
||||
'TestNSPRLogModulesParser.cpp',
|
||||
@ -85,3 +86,5 @@ LOCAL_INCLUDES += [
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul-gtest'
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
Loading…
Reference in New Issue
Block a user