mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Bug 807259: Fix shutdown for WebRTC standalone unit tests. r=anant
This commit is contained in:
parent
801e322ecb
commit
988e5fc796
@ -31,7 +31,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
bool stream_added = false;
|
bool stream_added = false;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||||||
void Gather() {
|
void Gather() {
|
||||||
nsresult res;
|
nsresult res;
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(ice_ctx_, &NrIceCtx::StartGathering, &res),
|
WrapRunnableRet(ice_ctx_, &NrIceCtx::StartGathering, &res),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||||||
void Connect(IceTestPeer *remote, TrickleMode trickle_mode) {
|
void Connect(IceTestPeer *remote, TrickleMode trickle_mode) {
|
||||||
nsresult res;
|
nsresult res;
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(ice_ctx_,
|
WrapRunnableRet(ice_ctx_,
|
||||||
&NrIceCtx::ParseGlobalAttributes, remote->GetGlobalAttributes(), &res),
|
&NrIceCtx::ParseGlobalAttributes, remote->GetGlobalAttributes(), &res),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
@ -108,7 +108,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||||||
|
|
||||||
if (trickle_mode == TRICKLE_NONE) {
|
if (trickle_mode == TRICKLE_NONE) {
|
||||||
for (size_t i=0; i<streams_.size(); ++i) {
|
for (size_t i=0; i<streams_.size(); ++i) {
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(streams_[i], &NrIceMediaStream::ParseAttributes,
|
WrapRunnableRet(streams_[i], &NrIceMediaStream::ParseAttributes,
|
||||||
remote->GetCandidates(remote->streams_[i]->name()),
|
remote->GetCandidates(remote->streams_[i]->name()),
|
||||||
&res), NS_DISPATCH_SYNC);
|
&res), NS_DISPATCH_SYNC);
|
||||||
@ -119,7 +119,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||||||
// Parse empty attributes and then trickle them out later
|
// Parse empty attributes and then trickle them out later
|
||||||
for (size_t i=0; i<streams_.size(); ++i) {
|
for (size_t i=0; i<streams_.size(); ++i) {
|
||||||
std::vector<std::string> empty_attrs;
|
std::vector<std::string> empty_attrs;
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(streams_[i], &NrIceMediaStream::ParseAttributes,
|
WrapRunnableRet(streams_[i], &NrIceMediaStream::ParseAttributes,
|
||||||
empty_attrs,
|
empty_attrs,
|
||||||
&res), NS_DISPATCH_SYNC);
|
&res), NS_DISPATCH_SYNC);
|
||||||
@ -129,7 +129,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now start checks
|
// Now start checks
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(ice_ctx_, &NrIceCtx::StartChecks, &res),
|
WrapRunnableRet(ice_ctx_, &NrIceCtx::StartChecks, &res),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||||
@ -142,7 +142,7 @@ class IceTestPeer : public sigslot::has_slots<> {
|
|||||||
remote->GetCandidates(remote->streams_[i]->name());
|
remote->GetCandidates(remote->streams_[i]->name());
|
||||||
|
|
||||||
for (size_t j=0; j<candidates.size(); j++) {
|
for (size_t j=0; j<candidates.size(); j++) {
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(streams_[i], &NrIceMediaStream::ParseTrickleCandidate,
|
WrapRunnableRet(streams_[i], &NrIceMediaStream::ParseTrickleCandidate,
|
||||||
candidates[j],
|
candidates[j],
|
||||||
&res), NS_DISPATCH_SYNC);
|
&res), NS_DISPATCH_SYNC);
|
||||||
@ -304,12 +304,14 @@ TEST_F(IceTest, TestSendReceive) {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
test_utils.InitServices();
|
test_utils = new MtransportTestUtils();
|
||||||
NSS_NoDB_Init(nullptr);
|
NSS_NoDB_Init(nullptr);
|
||||||
NSS_SetDomesticPolicy();
|
NSS_SetDomesticPolicy();
|
||||||
|
|
||||||
// Start the tests
|
// Start the tests
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -25,26 +25,31 @@
|
|||||||
#ifdef MOZ_CRASHREPORTER
|
#ifdef MOZ_CRASHREPORTER
|
||||||
#include "nsICrashReporter.h"
|
#include "nsICrashReporter.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "nsPISocketTransportService.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "TestHarness.h"
|
||||||
|
#include "mozilla/mozPoisonWrite.h"
|
||||||
|
|
||||||
class MtransportTestUtils {
|
class MtransportTestUtils {
|
||||||
public:
|
public:
|
||||||
bool InitServices() {
|
MtransportTestUtils() : xpcom_("") {
|
||||||
|
if (!sts_) {
|
||||||
|
InitServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~MtransportTestUtils() {
|
||||||
|
sts_->Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitServices() {
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
NS_InitXPCOM2(getter_AddRefs(servMan_), nullptr, nullptr);
|
|
||||||
manager_ = do_QueryInterface(servMan_);
|
|
||||||
rv = manager_->CreateInstanceByContractID(NS_IOSERVICE_CONTRACTID,
|
|
||||||
nullptr, NS_GET_IID(nsIIOService),
|
|
||||||
getter_AddRefs(ioservice_));
|
|
||||||
if (!NS_SUCCEEDED(rv))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||||
if (!NS_SUCCEEDED(rv))
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||||
return false;
|
|
||||||
|
sts_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||||
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||||
|
|
||||||
#ifdef MOZ_CRASHREPORTER
|
#ifdef MOZ_CRASHREPORTER
|
||||||
char *crashreporter = PR_GetEnv("MOZ_CRASHREPORTER");
|
char *crashreporter = PR_GetEnv("MOZ_CRASHREPORTER");
|
||||||
@ -61,28 +66,31 @@ class MtransportTestUtils {
|
|||||||
rv = dirsvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
rv = dirsvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||||
NS_GET_IID(nsIFile),
|
NS_GET_IID(nsIFile),
|
||||||
getter_AddRefs(cwd));
|
getter_AddRefs(cwd));
|
||||||
if (!NS_SUCCEEDED(rv))
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||||
return false;
|
|
||||||
crashreporter_->SetEnabled(true);
|
crashreporter_->SetEnabled(true);
|
||||||
crashreporter_->SetMinidumpPath(cwd);
|
crashreporter_->SetMinidumpPath(cwd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> sts_target() { return sts_target_; }
|
nsCOMPtr<nsIEventTarget> sts_target() { return sts_target_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIServiceManager> servMan_;
|
ScopedXPCOM xpcom_;
|
||||||
nsCOMPtr<nsIComponentManager> manager_;
|
|
||||||
nsCOMPtr<nsIIOService> ioservice_;
|
|
||||||
nsCOMPtr<nsIEventTarget> sts_target_;
|
nsCOMPtr<nsIEventTarget> sts_target_;
|
||||||
|
nsCOMPtr<nsPISocketTransportService> sts_;
|
||||||
#ifdef MOZ_CRASHREPORTER
|
#ifdef MOZ_CRASHREPORTER
|
||||||
nsCOMPtr<nsICrashReporter> crashreporter_;
|
nsCOMPtr<nsICrashReporter> crashreporter_;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MtransportTestUtils *mtransport_test_utils;
|
||||||
|
|
||||||
|
#define SETUP_MTRANSPORT_TEST_UTILS() \
|
||||||
|
MtransportTestUtils utils_; mtransport_test_utils = &utils_
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class TimerTest : public ::testing::Test {
|
|||||||
int ArmTimer(int timeout) {
|
int ArmTimer(int timeout) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(this, &TimerTest::ArmTimer_w, timeout, &ret),
|
WrapRunnableRet(this, &TimerTest::ArmTimer_w, timeout, &ret),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class TimerTest : public ::testing::Test {
|
|||||||
int CancelTimer() {
|
int CancelTimer() {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(this, &TimerTest::CancelTimer_w, &ret),
|
WrapRunnableRet(this, &TimerTest::CancelTimer_w, &ret),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -88,12 +88,13 @@ TEST_F(TimerTest, CancelTimer) {
|
|||||||
ASSERT_FALSE(fired_);
|
ASSERT_FALSE(fired_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
test_utils = new MtransportTestUtils();
|
||||||
test_utils.InitServices();
|
|
||||||
|
|
||||||
// Start the tests
|
// Start the tests
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -157,11 +157,13 @@ TEST_F(DispatchTest, TestRet) {
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
test_utils.InitServices();
|
test_utils = new MtransportTestUtils();
|
||||||
|
|
||||||
// Start the tests
|
// Start the tests
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
MOZ_MTLOG_MODULE("mtransport");
|
MOZ_MTLOG_MODULE("mtransport");
|
||||||
|
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
static bool sctp_logging = false;
|
static bool sctp_logging = false;
|
||||||
static int port_number = 5000;
|
static int port_number = 5000;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
static_cast<void *>(flow_.get()) << std::endl;
|
static_cast<void *>(flow_.get()) << std::endl;
|
||||||
usrsctp_close(sctp_);
|
usrsctp_close(sctp_);
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(WrapRunnable(this,
|
test_utils->sts_target()->Dispatch(WrapRunnable(this,
|
||||||
&TransportTestPeer::DisconnectInt),
|
&TransportTestPeer::DisconnectInt),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
|
|
||||||
void StartTransfer(size_t to_send) {
|
void StartTransfer(size_t to_send) {
|
||||||
periodic_ = new SendPeriodic(this, to_send);
|
periodic_ = new SendPeriodic(this, to_send);
|
||||||
timer_->SetTarget(test_utils.sts_target());
|
timer_->SetTarget(test_utils->sts_target());
|
||||||
timer_->InitWithCallback(periodic_, 10, nsITimer::TYPE_REPEATING_SLACK);
|
timer_->InitWithCallback(periodic_, 10, nsITimer::TYPE_REPEATING_SLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ TEST_F(TransportTest, TestTransfer) {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
test_utils.InitServices();
|
test_utils = new MtransportTestUtils();
|
||||||
// Start the tests
|
// Start the tests
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
@ -358,5 +358,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class SocketTransportServiceTest : public ::testing::Test {
|
class SocketTransportServiceTest : public ::testing::Test {
|
||||||
@ -202,10 +202,12 @@ TEST_F(SocketTransportServiceTest, SendPacket) {
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
test_utils.InitServices();
|
test_utils = new MtransportTestUtils();
|
||||||
|
|
||||||
// Start the tests
|
// Start the tests
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,7 @@
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
MOZ_MTLOG_MODULE("mtransport");
|
MOZ_MTLOG_MODULE("mtransport");
|
||||||
|
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
|
|
||||||
// Class to simulate various kinds of network lossage
|
// Class to simulate various kinds of network lossage
|
||||||
class TransportLayerLossy : public TransportLayer {
|
class TransportLayerLossy : public TransportLayer {
|
||||||
@ -127,7 +126,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~TransportTestPeer() {
|
~TransportTestPeer() {
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(this, &TransportTestPeer::DestroyFlow),
|
WrapRunnable(this, &TransportTestPeer::DestroyFlow),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
}
|
}
|
||||||
@ -209,7 +208,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
layers.push(ice_);
|
layers.push(ice_);
|
||||||
layers.push(dtls_);
|
layers.push(dtls_);
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(flow_, &TransportFlow::PushLayers, layers, &res),
|
WrapRunnableRet(flow_, &TransportFlow::PushLayers, layers, &res),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -220,7 +219,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
flow_->SignalStateChange.connect(this, &TransportTestPeer::StateChanged);
|
flow_->SignalStateChange.connect(this, &TransportTestPeer::StateChanged);
|
||||||
|
|
||||||
// Start gathering
|
// Start gathering
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(ice_ctx_, &NrIceCtx::StartGathering, &res),
|
WrapRunnableRet(ice_ctx_, &NrIceCtx::StartGathering, &res),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||||
@ -252,7 +251,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First send attributes
|
// First send attributes
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(peer_->ice_ctx_,
|
WrapRunnableRet(peer_->ice_ctx_,
|
||||||
&NrIceCtx::ParseGlobalAttributes,
|
&NrIceCtx::ParseGlobalAttributes,
|
||||||
ice_ctx_->GetGlobalAttributes(), &res),
|
ice_ctx_->GetGlobalAttributes(), &res),
|
||||||
@ -260,7 +259,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||||
|
|
||||||
for (size_t i=0; i<streams_.size(); ++i) {
|
for (size_t i=0; i<streams_.size(); ++i) {
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(peer_->streams_[i], &NrIceMediaStream::ParseAttributes,
|
WrapRunnableRet(peer_->streams_[i], &NrIceMediaStream::ParseAttributes,
|
||||||
candidates_[streams_[i]->name()], &res), NS_DISPATCH_SYNC);
|
candidates_[streams_[i]->name()], &res), NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -268,7 +267,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start checks on the other peer.
|
// Start checks on the other peer.
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(peer_->ice_ctx_, &NrIceCtx::StartChecks, &res),
|
WrapRunnableRet(peer_->ice_ctx_, &NrIceCtx::StartChecks, &res),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||||
@ -277,7 +276,7 @@ class TransportTestPeer : public sigslot::has_slots<> {
|
|||||||
TransportResult SendPacket(const unsigned char* data, size_t len) {
|
TransportResult SendPacket(const unsigned char* data, size_t len) {
|
||||||
TransportResult ret;
|
TransportResult ret;
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(flow_, &TransportFlow::SendPacket, data, len, &ret),
|
WrapRunnableRet(flow_, &TransportFlow::SendPacket, data, len, &ret),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -368,10 +367,10 @@ class TransportTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConnectSocket() {
|
void ConnectSocket() {
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(p1_, &TransportTestPeer::ConnectSocket, p2_),
|
WrapRunnable(p1_, &TransportTestPeer::ConnectSocket, p2_),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(p2_, &TransportTestPeer::ConnectSocket, p1_),
|
WrapRunnable(p2_, &TransportTestPeer::ConnectSocket, p1_),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -380,10 +379,10 @@ class TransportTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConnectSocketExpectFail() {
|
void ConnectSocketExpectFail() {
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(p1_, &TransportTestPeer::ConnectSocket, p2_),
|
WrapRunnable(p1_, &TransportTestPeer::ConnectSocket, p2_),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(p2_, &TransportTestPeer::ConnectSocket, p1_),
|
WrapRunnable(p2_, &TransportTestPeer::ConnectSocket, p1_),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
ASSERT_TRUE_WAIT(p1_->failed(), 10000);
|
ASSERT_TRUE_WAIT(p1_->failed(), 10000);
|
||||||
@ -497,11 +496,14 @@ TEST_F(TransportTest, TestTransferIce) {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
test_utils.InitServices();
|
test_utils = new MtransportTestUtils();
|
||||||
|
|
||||||
NSS_NoDB_Init(nullptr);
|
NSS_NoDB_Init(nullptr);
|
||||||
NSS_SetDomesticPolicy();
|
NSS_SetDomesticPolicy();
|
||||||
// Start the tests
|
// Start the tests
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ using namespace std;
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
#include "mtransport_test_utils.h"
|
#include "mtransport_test_utils.h"
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
//Video Frame Color
|
//Video Frame Color
|
||||||
const int COLOR = 0x80; //Gray
|
const int COLOR = 0x80; //Gray
|
||||||
@ -749,9 +749,11 @@ TEST_F(TransportConduitTest, TestVideoConduitCodecAPI) {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
test_utils.InitServices();
|
test_utils = new MtransportTestUtils();
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,8 +38,7 @@
|
|||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
MOZ_MTLOG_MODULE("mediapipeline");
|
MOZ_MTLOG_MODULE("mediapipeline");
|
||||||
|
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class TestAgent {
|
class TestAgent {
|
||||||
@ -65,8 +64,9 @@ class TestAgent {
|
|||||||
res = audio_prsock_->Init();
|
res = audio_prsock_->Init();
|
||||||
ASSERT_EQ((nsresult)NS_OK, res);
|
ASSERT_EQ((nsresult)NS_OK, res);
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(WrapRunnable(audio_prsock_, &TransportLayerPrsock::Import,
|
test_utils->sts_target()->Dispatch(
|
||||||
fd, &res), NS_DISPATCH_SYNC);
|
WrapRunnable(audio_prsock_, &TransportLayerPrsock::Import,
|
||||||
|
fd, &res), NS_DISPATCH_SYNC);
|
||||||
ASSERT_TRUE(NS_SUCCEEDED(res));
|
ASSERT_TRUE(NS_SUCCEEDED(res));
|
||||||
|
|
||||||
ASSERT_EQ((nsresult)NS_OK, audio_flow_->PushLayer(audio_prsock_));
|
ASSERT_EQ((nsresult)NS_OK, audio_flow_->PushLayer(audio_prsock_));
|
||||||
@ -85,7 +85,7 @@ class TestAgent {
|
|||||||
|
|
||||||
MOZ_MTLOG(PR_LOG_DEBUG, "Starting");
|
MOZ_MTLOG(PR_LOG_DEBUG, "Starting");
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(audio_->GetStream(),
|
WrapRunnableRet(audio_->GetStream(),
|
||||||
&Fake_MediaStream::Start, &ret),
|
&Fake_MediaStream::Start, &ret),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
@ -103,7 +103,7 @@ class TestAgent {
|
|||||||
void Stop() {
|
void Stop() {
|
||||||
MOZ_MTLOG(PR_LOG_DEBUG, "Stopping");
|
MOZ_MTLOG(PR_LOG_DEBUG, "Stopping");
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(this, &TestAgent::StopInt),
|
WrapRunnable(this, &TestAgent::StopInt),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class TestAgentSend : public TestAgent {
|
|||||||
EXPECT_EQ(mozilla::kMediaConduitNoError, err);
|
EXPECT_EQ(mozilla::kMediaConduitNoError, err);
|
||||||
|
|
||||||
audio_pipeline_ = new mozilla::MediaPipelineTransmit(NULL,
|
audio_pipeline_ = new mozilla::MediaPipelineTransmit(NULL,
|
||||||
test_utils.sts_target(),
|
test_utils->sts_target(),
|
||||||
audio_, audio_conduit_, audio_flow_, NULL);
|
audio_, audio_conduit_, audio_flow_, NULL);
|
||||||
|
|
||||||
// video_ = new Fake_nsDOMMediaStream(new Fake_VideoStreamSource());
|
// video_ = new Fake_nsDOMMediaStream(new Fake_VideoStreamSource());
|
||||||
@ -171,7 +171,7 @@ class TestAgentReceive : public TestAgent {
|
|||||||
EXPECT_EQ(mozilla::kMediaConduitNoError, err);
|
EXPECT_EQ(mozilla::kMediaConduitNoError, err);
|
||||||
|
|
||||||
audio_pipeline_ = new mozilla::MediaPipelineReceiveAudio(NULL,
|
audio_pipeline_ = new mozilla::MediaPipelineReceiveAudio(NULL,
|
||||||
test_utils.sts_target(),
|
test_utils->sts_target(),
|
||||||
audio_,
|
audio_,
|
||||||
static_cast<mozilla::AudioSessionConduit *>(audio_conduit_.get()),
|
static_cast<mozilla::AudioSessionConduit *>(audio_conduit_.get()),
|
||||||
audio_flow_, NULL);
|
audio_flow_, NULL);
|
||||||
@ -191,10 +191,10 @@ class MediaPipelineTest : public ::testing::Test {
|
|||||||
PRStatus status = PR_NewTCPSocketPair(fds_);
|
PRStatus status = PR_NewTCPSocketPair(fds_);
|
||||||
ASSERT_EQ(status, PR_SUCCESS);
|
ASSERT_EQ(status, PR_SUCCESS);
|
||||||
|
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(&p1_, &TestAgent::ConnectSocket, fds_[0], false),
|
WrapRunnable(&p1_, &TestAgent::ConnectSocket, fds_[0], false),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnable(&p2_, &TestAgent::ConnectSocket, fds_[1], false),
|
WrapRunnable(&p2_, &TestAgent::ConnectSocket, fds_[1], false),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
}
|
}
|
||||||
@ -217,15 +217,16 @@ TEST_F(MediaPipelineTest, AudioSend) {
|
|||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
test_utils = new MtransportTestUtils();
|
||||||
test_utils.InitServices();
|
|
||||||
// Start the tests
|
// Start the tests
|
||||||
NSS_NoDB_Init(NULL);
|
NSS_NoDB_Init(NULL);
|
||||||
NSS_SetDomesticPolicy();
|
NSS_SetDomesticPolicy();
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
int rv = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@ using namespace std;
|
|||||||
#include "nsIDOMRTCPeerConnection.h"
|
#include "nsIDOMRTCPeerConnection.h"
|
||||||
|
|
||||||
#include "mtransport_test_utils.h"
|
#include "mtransport_test_utils.h"
|
||||||
MtransportTestUtils test_utils;
|
MtransportTestUtils *test_utils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int kDefaultTimeout = 5000;
|
static int kDefaultTimeout = 5000;
|
||||||
|
|
||||||
@ -255,7 +257,7 @@ TestObserver::OnAddStream(nsIDOMMediaStream *stream, const char *type)
|
|||||||
Fake_SourceMediaStream *fs = static_cast<Fake_SourceMediaStream *>(ms->GetStream());
|
Fake_SourceMediaStream *fs = static_cast<Fake_SourceMediaStream *>(ms->GetStream());
|
||||||
|
|
||||||
nsresult ret;
|
nsresult ret;
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(fs, &Fake_SourceMediaStream::Start, &ret),
|
WrapRunnableRet(fs, &Fake_SourceMediaStream::Start, &ret),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -485,7 +487,7 @@ class SignalingAgent {
|
|||||||
new Fake_AudioStreamSource();
|
new Fake_AudioStreamSource();
|
||||||
|
|
||||||
nsresult ret;
|
nsresult ret;
|
||||||
test_utils.sts_target()->Dispatch(
|
test_utils->sts_target()->Dispatch(
|
||||||
WrapRunnableRet(audio_stream, &Fake_MediaStream::Start, &ret),
|
WrapRunnableRet(audio_stream, &Fake_MediaStream::Start, &ret),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
|
|
||||||
@ -945,9 +947,8 @@ TEST_F(SignalingTest, FullCallTrickle)
|
|||||||
|
|
||||||
} // End namespace test.
|
} // End namespace test.
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
test_utils = new MtransportTestUtils();
|
||||||
test_utils.InitServices();
|
|
||||||
NSS_NoDB_Init(NULL);
|
NSS_NoDB_Init(NULL);
|
||||||
NSS_SetDomesticPolicy();
|
NSS_SetDomesticPolicy();
|
||||||
|
|
||||||
@ -957,10 +958,10 @@ int main(int argc, char **argv)
|
|||||||
if (!strcmp(argv[i],"-t")) {
|
if (!strcmp(argv[i],"-t")) {
|
||||||
kDefaultTimeout = 20000;
|
kDefaultTimeout = 20000;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::testing::AddGlobalTestEnvironment(new test::SignalingEnvironment);
|
::testing::AddGlobalTestEnvironment(new test::SignalingEnvironment);
|
||||||
int result = RUN_ALL_TESTS();
|
int result = RUN_ALL_TESTS();
|
||||||
|
delete test_utils;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user