summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-06-25 20:49:23 (GMT)
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-06-25 20:49:23 (GMT)
commitaaebfcdc4005afb22b68df61b58edd1ccc002913 (patch)
treebc94526059c6fbb60f7443ef2e95b5f340d9d8af /test
parente6095deec89dcf5237948b3460d84a137622f16c (diff)
downloadgoogletest-aaebfcdc4005afb22b68df61b58edd1ccc002913.zip
googletest-aaebfcdc4005afb22b68df61b58edd1ccc002913.tar.gz
googletest-aaebfcdc4005afb22b68df61b58edd1ccc002913.tar.bz2
Refactors for the event listener API (by Vlad Losev): hides some methods in UnitTest; implements the result printers using the public API.
Diffstat (limited to 'test')
-rw-r--r--test/gtest-death-test_test.cc21
-rw-r--r--test/gtest_unittest.cc7
2 files changed, 13 insertions, 15 deletions
diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc
index 9dd477b..8b2173b 100644
--- a/test/gtest-death-test_test.cc
+++ b/test/gtest-death-test_test.cc
@@ -67,6 +67,7 @@ using testing::internal::DeathTest;
using testing::internal::DeathTestFactory;
using testing::internal::FilePath;
using testing::internal::GetLastErrnoDescription;
+using testing::internal::GetUnitTestImpl;
using testing::internal::ParseNaturalNumber;
using testing::internal::String;
@@ -77,22 +78,22 @@ namespace internal {
// single UnitTest object during their lifetimes.
class ReplaceDeathTestFactory {
public:
- ReplaceDeathTestFactory(UnitTest* parent, DeathTestFactory* new_factory)
- : parent_impl_(parent->impl()) {
- old_factory_ = parent_impl_->death_test_factory_.release();
- parent_impl_->death_test_factory_.reset(new_factory);
+ explicit ReplaceDeathTestFactory(DeathTestFactory* new_factory)
+ : unit_test_impl_(GetUnitTestImpl()) {
+ old_factory_ = unit_test_impl_->death_test_factory_.release();
+ unit_test_impl_->death_test_factory_.reset(new_factory);
}
~ReplaceDeathTestFactory() {
- parent_impl_->death_test_factory_.release();
- parent_impl_->death_test_factory_.reset(old_factory_);
+ unit_test_impl_->death_test_factory_.release();
+ unit_test_impl_->death_test_factory_.reset(old_factory_);
}
private:
// Prevents copying ReplaceDeathTestFactory objects.
ReplaceDeathTestFactory(const ReplaceDeathTestFactory&);
void operator=(const ReplaceDeathTestFactory&);
- UnitTestImpl* parent_impl_;
+ UnitTestImpl* unit_test_impl_;
DeathTestFactory* old_factory_;
};
@@ -846,8 +847,7 @@ class MacroLogicDeathTest : public testing::Test {
static void SetUpTestCase() {
factory_ = new MockDeathTestFactory;
- replacer_ = new testing::internal::ReplaceDeathTestFactory(
- testing::UnitTest::GetInstance(), factory_);
+ replacer_ = new testing::internal::ReplaceDeathTestFactory(factory_);
}
static void TearDownTestCase() {
@@ -959,8 +959,7 @@ TEST_F(MacroLogicDeathTest, ChildDoesNotDie) {
// Returns the number of successful parts in the current test.
static size_t GetSuccessfulTestPartCount() {
- return testing::UnitTest::GetInstance()->impl()->current_test_result()->
- successful_part_count();
+ return GetUnitTestImpl()->current_test_result()->successful_part_count();
}
// Tests that a successful death test does not register a successful
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index b1a161b..4e43092 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -136,6 +136,7 @@ using testing::internal::GetCurrentOsStackTraceExceptTop;
using testing::internal::GetFailedPartCount;
using testing::internal::GetTestTypeId;
using testing::internal::GetTypeId;
+using testing::internal::GetUnitTestImpl;
using testing::internal::GTestFlagSaver;
using testing::internal::Int32;
using testing::internal::Int32FromEnvOrDie;
@@ -3600,8 +3601,7 @@ TEST(AssertionSyntaxTest, WorksWithConst) {
// Returns the number of successful parts in the current test.
static size_t GetSuccessfulPartCount() {
- return UnitTest::GetInstance()->impl()->current_test_result()->
- successful_part_count();
+ return GetUnitTestImpl()->current_test_result()->successful_part_count();
}
namespace testing {
@@ -4416,8 +4416,7 @@ namespace testing {
class TestInfoTest : public Test {
protected:
static TestInfo * GetTestInfo(const char* test_name) {
- return UnitTest::GetInstance()->impl()->
- GetTestCase("TestInfoTest", "", NULL, NULL)->
+ return GetUnitTestImpl()->GetTestCase("TestInfoTest", "", NULL, NULL)->
GetTestInfo(test_name);
}