diff --git a/testing/cppunittest.ini b/testing/cppunittest.ini index 714e2158b622..41363d1e412f 100644 --- a/testing/cppunittest.ini +++ b/testing/cppunittest.ini @@ -6,7 +6,6 @@ [TestAudioBuffers] skip-if = os == 'b2g' # Bug 1062937 [TestAudioMixer] -[TestAutoRef] [TestBinarySearch] [TestBind] [TestBloomFilter] diff --git a/xpcom/tests/TestAutoRef.cpp b/xpcom/tests/gtest/TestAutoRef.cpp similarity index 66% rename from xpcom/tests/TestAutoRef.cpp rename to xpcom/tests/gtest/TestAutoRef.cpp index 744a80065fd9..49042e8fbd3f 100644 --- a/xpcom/tests/TestAutoRef.cpp +++ b/xpcom/tests/gtest/TestAutoRef.cpp @@ -5,10 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsAutoRef.h" -#include "TestHarness.h" - -#define TEST(aCondition, aMsg) \ - if (!(aCondition)) { fail("TestAutoRef: "#aMsg); exit(1); } +#include "gtest/gtest.h" struct TestObjectA { public: @@ -16,7 +13,7 @@ public: } ~TestObjectA() { - TEST(mRefCnt == 0, "mRefCnt in destructor"); + EXPECT_EQ(mRefCnt, 0); } public: @@ -43,20 +40,17 @@ public: int nsAutoRefTraits::mTotalRefsCnt = 0; -int main() +TEST(AutoRef, Assignment) { { nsCountedRef a(new TestObjectA()); - TEST(a->mRefCnt == 1, "nsCountedRef instantiation with valid RawRef"); + ASSERT_EQ(a->mRefCnt, 1); nsCountedRef b; - TEST(b.get() == nullptr, "nsCountedRef instantiation with invalid RawRef"); + ASSERT_EQ(b.get(), nullptr); a.swap(b); - TEST(b->mRefCnt, "nsAutoRef::swap() t1"); - TEST(a.get() == nullptr, "nsAutoRef::swap() t2"); + ASSERT_EQ(b->mRefCnt, 1); + ASSERT_EQ(a.get(), nullptr); } - - TEST(true, "All tests pass"); - return 0; } diff --git a/xpcom/tests/gtest/TestStorageStream.cpp b/xpcom/tests/gtest/TestStorageStream.cpp index f41f24c0d9b5..a49d6f6bcaba 100644 --- a/xpcom/tests/gtest/TestStorageStream.cpp +++ b/xpcom/tests/gtest/TestStorageStream.cpp @@ -12,6 +12,7 @@ #include "nsIInputStream.h" #include "nsIOutputStream.h" #include "nsIStorageStream.h" +#include "nsTArray.h" namespace { diff --git a/xpcom/tests/gtest/moz.build b/xpcom/tests/gtest/moz.build index 4cf092690234..39ccca0394cd 100644 --- a/xpcom/tests/gtest/moz.build +++ b/xpcom/tests/gtest/moz.build @@ -8,6 +8,7 @@ UNIFIED_SOURCES += [ 'Helpers.cpp', 'TestAtoms.cpp', 'TestAutoPtr.cpp', + 'TestAutoRef.cpp', 'TestCloneInputStream.cpp', 'TestCRT.cpp', 'TestEncoding.cpp', diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index 2d36ef39340f..7d135624af35 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -46,7 +46,6 @@ if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']: XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] GeckoCppUnitTests([ - 'TestAutoRef', 'TestCOMArray', 'TestCOMPtr', 'TestCOMPtrEq',