зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
de9486a254
Коммит
aea4240774
|
@ -6,7 +6,6 @@
|
||||||
[TestAudioBuffers]
|
[TestAudioBuffers]
|
||||||
skip-if = os == 'b2g' # Bug 1062937
|
skip-if = os == 'b2g' # Bug 1062937
|
||||||
[TestAudioMixer]
|
[TestAudioMixer]
|
||||||
[TestAutoRef]
|
|
||||||
[TestBinarySearch]
|
[TestBinarySearch]
|
||||||
[TestBind]
|
[TestBind]
|
||||||
[TestBloomFilter]
|
[TestBloomFilter]
|
||||||
|
|
|
@ -5,10 +5,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "nsAutoRef.h"
|
#include "nsAutoRef.h"
|
||||||
#include "TestHarness.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#define TEST(aCondition, aMsg) \
|
|
||||||
if (!(aCondition)) { fail("TestAutoRef: "#aMsg); exit(1); }
|
|
||||||
|
|
||||||
struct TestObjectA {
|
struct TestObjectA {
|
||||||
public:
|
public:
|
||||||
|
@ -16,7 +13,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~TestObjectA() {
|
~TestObjectA() {
|
||||||
TEST(mRefCnt == 0, "mRefCnt in destructor");
|
EXPECT_EQ(mRefCnt, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -43,20 +40,17 @@ public:
|
||||||
|
|
||||||
int nsAutoRefTraits<TestObjectA>::mTotalRefsCnt = 0;
|
int nsAutoRefTraits<TestObjectA>::mTotalRefsCnt = 0;
|
||||||
|
|
||||||
int main()
|
TEST(AutoRef, Assignment)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
nsCountedRef<TestObjectA> a(new TestObjectA());
|
nsCountedRef<TestObjectA> a(new TestObjectA());
|
||||||
TEST(a->mRefCnt == 1, "nsCountedRef instantiation with valid RawRef");
|
ASSERT_EQ(a->mRefCnt, 1);
|
||||||
|
|
||||||
nsCountedRef<TestObjectA> b;
|
nsCountedRef<TestObjectA> b;
|
||||||
TEST(b.get() == nullptr, "nsCountedRef instantiation with invalid RawRef");
|
ASSERT_EQ(b.get(), nullptr);
|
||||||
|
|
||||||
a.swap(b);
|
a.swap(b);
|
||||||
TEST(b->mRefCnt, "nsAutoRef::swap() t1");
|
ASSERT_EQ(b->mRefCnt, 1);
|
||||||
TEST(a.get() == nullptr, "nsAutoRef::swap() t2");
|
ASSERT_EQ(a.get(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(true, "All tests pass");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@
|
||||||
#include "nsIInputStream.h"
|
#include "nsIInputStream.h"
|
||||||
#include "nsIOutputStream.h"
|
#include "nsIOutputStream.h"
|
||||||
#include "nsIStorageStream.h"
|
#include "nsIStorageStream.h"
|
||||||
|
#include "nsTArray.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ UNIFIED_SOURCES += [
|
||||||
'Helpers.cpp',
|
'Helpers.cpp',
|
||||||
'TestAtoms.cpp',
|
'TestAtoms.cpp',
|
||||||
'TestAutoPtr.cpp',
|
'TestAutoPtr.cpp',
|
||||||
|
'TestAutoRef.cpp',
|
||||||
'TestCloneInputStream.cpp',
|
'TestCloneInputStream.cpp',
|
||||||
'TestCRT.cpp',
|
'TestCRT.cpp',
|
||||||
'TestEncoding.cpp',
|
'TestEncoding.cpp',
|
||||||
|
|
|
@ -46,7 +46,6 @@ if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']:
|
||||||
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
|
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
|
||||||
|
|
||||||
GeckoCppUnitTests([
|
GeckoCppUnitTests([
|
||||||
'TestAutoRef',
|
|
||||||
'TestCOMArray',
|
'TestCOMArray',
|
||||||
'TestCOMPtr',
|
'TestCOMPtr',
|
||||||
'TestCOMPtrEq',
|
'TestCOMPtrEq',
|
||||||
|
|
Загрузка…
Ссылка в новой задаче