Bug 1313468: Convert XPCOM test TestAutoRef to a gtest. r=froydnj

MozReview-Commit-ID: GkEPSkzNeuB

--HG--
rename : xpcom/tests/TestAutoRef.cpp => xpcom/tests/gtest/TestAutoRef.cpp
This commit is contained in:
Eric Rahm 2016-11-03 17:55:16 -07:00
Родитель de9486a254
Коммит aea4240774
5 изменённых файлов: 9 добавлений и 15 удалений

Просмотреть файл

@ -6,7 +6,6 @@
[TestAudioBuffers]
skip-if = os == 'b2g' # Bug 1062937
[TestAudioMixer]
[TestAutoRef]
[TestBinarySearch]
[TestBind]
[TestBloomFilter]

Просмотреть файл

@ -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<TestObjectA>::mTotalRefsCnt = 0;
int main()
TEST(AutoRef, Assignment)
{
{
nsCountedRef<TestObjectA> a(new TestObjectA());
TEST(a->mRefCnt == 1, "nsCountedRef instantiation with valid RawRef");
ASSERT_EQ(a->mRefCnt, 1);
nsCountedRef<TestObjectA> 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;
}

Просмотреть файл

@ -12,6 +12,7 @@
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIStorageStream.h"
#include "nsTArray.h"
namespace {

Просмотреть файл

@ -8,6 +8,7 @@ UNIFIED_SOURCES += [
'Helpers.cpp',
'TestAtoms.cpp',
'TestAutoPtr.cpp',
'TestAutoRef.cpp',
'TestCloneInputStream.cpp',
'TestCRT.cpp',
'TestEncoding.cpp',

Просмотреть файл

@ -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',