Bug 1316888 - Port sdp_unittests to xul gtest; r=bwc
MozReview-Commit-ID: 12qrqpZq2pW
--- a/media/webrtc/moz.build
+++ b/media/webrtc/moz.build
@@ -96,16 +96,17 @@ if CONFIG['MOZ_WEBRTC_SIGNALING']:
if CONFIG['_MSC_VER']:
# Avoid warnings from third-party code that we can not modify.
if CONFIG['CLANG_CL']:
CXXFLAGS += ['-Wno-invalid-source-encoding']
else:
CXXFLAGS += ['-validate-charset-']
+ TEST_DIRS += ['signaling/gtest']
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
GYP_DIRS += ['trunk/testing']
GYP_DIRS['trunk/testing'].input = 'trunk/testing/gtest.gyp'
GYP_DIRS['trunk/testing'].variables = gyp_vars
# We allow warnings for third-party code that can be updated from upstream.
GYP_DIRS['trunk/testing'].sandbox_vars['ALLOW_COMPILER_WARNINGS'] = True
GYP_DIRS['trunk/testing'].non_unified_sources += webrtc_non_unified_sources
new file mode 100644
--- /dev/null
+++ b/media/webrtc/signaling/gtest/moz.build
@@ -0,0 +1,32 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# TODO: bug 1172551 - get these tests working on iOS
+if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'uikit':
+ DEFINES['MOZILLA_EXTERNAL_LINKAGE'] = True
+
+ LOCAL_INCLUDES += [
+ '/ipc/chromium/src',
+ '/media/mtransport',
+ '/media/webrtc/',
+ '/media/webrtc/signaling/src/common/time_profiling',
+ '/media/webrtc/signaling/src/peerconnection',
+ ]
+
+ SOURCES += [
+ 'sdp_unittests.cpp',
+ ]
+
+ FINAL_LIBRARY = 'xul-gtest'
+
+if CONFIG['GNU_CXX']:
+ CXXFLAGS += ['-Wno-error=shadow']
+
+if CONFIG['_MSC_VER']:
+ # This is intended as a temporary workaround to enable warning free building
+ # with VS2015.
+ # reinterpret_cast': conversion from 'DWORD' to 'HANDLE' of greater size
+ CXXFLAGS += ['-wd4312']
rename from media/webrtc/signaling/test/sdp_unittests.cpp
rename to media/webrtc/signaling/gtest/sdp_unittests.cpp
--- a/media/webrtc/signaling/test/sdp_unittests.cpp
+++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp
@@ -1,101 +1,69 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "timecard.h"
-#include "CSFLog.h"
-
#include <string>
#include <sstream>
#define GTEST_HAS_RTTI 0
#include "gtest/gtest.h"
-#include "gtest_utils.h"
#include "nspr.h"
#include "nss.h"
#include "ssl.h"
#include "nsThreadUtils.h"
-#include "FakeMediaStreams.h"
-#include "FakeMediaStreamsImpl.h"
-#include "FakeLogging.h"
#include "PeerConnectionImpl.h"
#include "PeerConnectionCtx.h"
-#include "mtransport_test_utils.h"
-MtransportTestUtils *test_utils;
-nsCOMPtr<nsIThread> gThread;
-
#include "signaling/src/sdp/SipccSdpParser.h"
#include "signaling/src/sdp/SdpMediaSection.h"
#include "signaling/src/sdp/SdpAttribute.h"
extern "C" {
#include "signaling/src/sdp/sipcc/sdp.h"
#include "signaling/src/sdp/sipcc/sdp_private.h"
}
#ifdef CRLF
#undef CRLF
#endif
#define CRLF "\r\n"
-#include "FakeIPC.h"
-#include "FakeIPC.cpp"
-
-#include "TestHarness.h"
-
using namespace mozilla;
namespace test {
-static bool SetupGlobalThread() {
- if (!gThread) {
- nsIThread *thread;
-
- nsresult rv = NS_NewNamedThread("pseudo-main",&thread);
- if (NS_FAILED(rv))
- return false;
-
- gThread = thread;
- PeerConnectionCtx::InitializeGlobal(gThread,
- test_utils->sts_target());
- }
- return true;
-}
-
class SdpTest : public ::testing::Test {
public:
SdpTest() : sdp_ptr_(nullptr) {
}
~SdpTest() {
sdp_free_description(sdp_ptr_);
}
static void SetUpTestCase() {
- ASSERT_TRUE(SetupGlobalThread());
+ NSS_NoDB_Init(nullptr);
+ NSS_SetDomesticPolicy();
}
void SetUp() {
final_level_ = 0;
sdp_ptr_ = nullptr;
}
static void TearDownTestCase() {
- if (gThread) {
- gThread->Shutdown();
- }
- gThread = nullptr;
+ PeerConnectionCtx::Destroy();
}
void ResetSdp() {
if (!sdp_ptr_) {
sdp_free_description(sdp_ptr_);
}
sdp_media_e supported_media[] = {
@@ -1411,17 +1379,17 @@ TEST_F(SdpTest, parseFmtpCbrWith0) {
TEST_F(SdpTest, parseFmtpCbrWith2) {
ParseSdp(kVideoSdp + "a=fmtp:120 cbr=2\r\n");
ASSERT_EQ(SDP_INVALID_PARAMETER, sdp_attr_get_fmtp_cbr(sdp_ptr_, 1, 0, 1, nullptr));
}
TEST_F(SdpTest, parseFmtpMaxPlaybackRate) {
ParseSdp(kVideoSdp + "a=fmtp:120 maxplaybackrate=47900\r\n");
sdp_attr_t *attr_p = sdp_find_attr(sdp_ptr_, 1, 0, SDP_ATTR_FMTP, 1);
- ASSERT_NE(NULL, attr_p);
+ ASSERT_NE(nullptr, attr_p);
ASSERT_EQ(47900U, attr_p->attr.fmtp.maxplaybackrate);
}
TEST_F(SdpTest, parseFmtpMaxPlaybackRateWith0) {
ParseSdp(kVideoSdp + "a=fmtp:120 maxplaybackrate=0\r\n");
sdp_attr_t *attr_p = sdp_find_attr(sdp_ptr_, 1, 0, SDP_ATTR_FMTP, 1);
ASSERT_EQ(NULL, attr_p);
}
@@ -5354,24 +5322,8 @@ TEST(NewSdpTestNoFixture, CheckRidSerial
rid.constraints.maxBr = 30000;
std::ostringstream os;
rid.Serialize(os);
ASSERT_EQ("foo send pt=96;max-br=30000", os.str());
}
}
} // End namespace test.
-
-int main(int argc, char **argv) {
- ScopedXPCOM xpcom("sdp_unittests");
-
- test_utils = new MtransportTestUtils();
- NSS_NoDB_Init(nullptr);
- NSS_SetDomesticPolicy();
-
- ::testing::InitGoogleTest(&argc, argv);
- int result = RUN_ALL_TESTS();
-
- PeerConnectionCtx::Destroy();
- delete test_utils;
-
- return result;
-}
--- a/media/webrtc/signaling/test/moz.build
+++ b/media/webrtc/signaling/test/moz.build
@@ -7,17 +7,16 @@
# TODO: bug 1172551 - get these tests working on iOS
if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'uikit':
GeckoCppUnitTests([
'jsep_session_unittest',
'jsep_track_unittest',
'mediaconduit_unittests',
'mediapipeline_unittest',
'sdp_file_parser',
- 'sdp_unittests',
'signaling_unittests',
])
include('/ipc/chromium/chromium-config.mozbuild')
include('common.build')
USE_LIBS += [
'/media/webrtc/signalingtest/signaling_ecc/ecc',
--- a/testing/cppunittest.ini
+++ b/testing/cppunittest.ini
@@ -71,18 +71,16 @@ skip-if = os == 'b2g' || os == 'android'
[multi_tcp_socket_unittest]
[nrappkit_unittest]
[rlogringbuffer_unittest]
[runnable_utils_unittest]
[sctp_unittest]
[jsep_track_unittest]
[jsep_session_unittest]
skip-if = os == 'android' # Bug 1147631
-[sdp_unittests]
-[sdp_unittests_standalone]
[signaling_unittests]
[signaling_unittests_standalone]
[simpletokenbucket_unittest]
[sockettransportservice_unittest]
[test_AsXXX_helpers]
[test_IHistory]
[test_StatementCache]
[test_asyncStatementExecution_transaction]