@@ -2836,14 +2836,13 @@ void TestInfo::Run() {
2836
2836
}
2837
2837
2838
2838
// Tells UnitTest where to store test result.
2839
- internal::UnitTestImpl* const impl = internal::GetUnitTestImpl ();
2840
- impl->set_current_test_info (this );
2839
+ UnitTest::GetInstance ()->set_current_test_info (this );
2841
2840
2842
2841
// Notifies the unit test event listeners that a test is about to start.
2843
2842
repeater->OnTestStart (*this );
2844
2843
result_.set_start_timestamp (internal::GetTimeInMillis ());
2845
2844
internal::Timer timer;
2846
- impl-> os_stack_trace_getter ()->UponLeavingGTest ();
2845
+ UnitTest::GetInstance ()->UponLeavingGTest ();
2847
2846
2848
2847
// Creates the test object.
2849
2848
Test* const test = internal::HandleExceptionsInMethodIfSupported (
@@ -2861,7 +2860,7 @@ void TestInfo::Run() {
2861
2860
2862
2861
if (test != nullptr ) {
2863
2862
// Deletes the test object.
2864
- impl-> os_stack_trace_getter ()->UponLeavingGTest ();
2863
+ UnitTest::GetInstance ()->UponLeavingGTest ();
2865
2864
internal::HandleExceptionsInMethodIfSupported (
2866
2865
test, &Test::DeleteSelf_, " the test fixture's destructor" );
2867
2866
}
@@ -2873,15 +2872,14 @@ void TestInfo::Run() {
2873
2872
2874
2873
// Tells UnitTest to stop associating assertion results to this
2875
2874
// test.
2876
- impl ->set_current_test_info (nullptr );
2875
+ UnitTest::GetInstance () ->set_current_test_info (nullptr );
2877
2876
}
2878
2877
2879
2878
// Skip and records a skipped test result for this object.
2880
2879
void TestInfo::Skip () {
2881
2880
if (!should_run_) return ;
2882
2881
2883
- internal::UnitTestImpl* const impl = internal::GetUnitTestImpl ();
2884
- impl->set_current_test_info (this );
2882
+ UnitTest::GetInstance ()->set_current_test_info (this );
2885
2883
2886
2884
TestEventListener* repeater = UnitTest::GetInstance ()->listeners ().repeater ();
2887
2885
@@ -2890,12 +2888,13 @@ void TestInfo::Skip() {
2890
2888
2891
2889
const TestPartResult test_part_result =
2892
2890
TestPartResult (TestPartResult::kSkip , this ->file (), this ->line (), " " );
2893
- impl->GetTestPartResultReporterForCurrentThread ()->ReportTestPartResult (
2894
- test_part_result);
2891
+ internal::GetUnitTestImpl ()
2892
+ ->GetTestPartResultReporterForCurrentThread ()
2893
+ ->ReportTestPartResult (test_part_result);
2895
2894
2896
2895
// Notifies the unit test event listener that a test has just finished.
2897
2896
repeater->OnTestEnd (*this );
2898
- impl ->set_current_test_info (nullptr );
2897
+ UnitTest::GetInstance () ->set_current_test_info (nullptr );
2899
2898
}
2900
2899
2901
2900
// class TestSuite
@@ -2991,8 +2990,7 @@ void TestSuite::AddTestInfo(TestInfo* test_info) {
2991
2990
void TestSuite::Run () {
2992
2991
if (!should_run_) return ;
2993
2992
2994
- internal::UnitTestImpl* const impl = internal::GetUnitTestImpl ();
2995
- impl->set_current_test_suite (this );
2993
+ UnitTest::GetInstance ()->set_current_test_suite (this );
2996
2994
2997
2995
TestEventListener* repeater = UnitTest::GetInstance ()->listeners ().repeater ();
2998
2996
@@ -3022,7 +3020,7 @@ void TestSuite::Run() {
3022
3020
repeater->OnTestCaseStart (*this );
3023
3021
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3024
3022
3025
- impl-> os_stack_trace_getter ()->UponLeavingGTest ();
3023
+ UnitTest::GetInstance ()->UponLeavingGTest ();
3026
3024
internal::HandleExceptionsInMethodIfSupported (
3027
3025
this , &TestSuite::RunSetUpTestSuite, " SetUpTestSuite()" );
3028
3026
@@ -3047,7 +3045,7 @@ void TestSuite::Run() {
3047
3045
}
3048
3046
elapsed_time_ = timer.Elapsed ();
3049
3047
3050
- impl-> os_stack_trace_getter ()->UponLeavingGTest ();
3048
+ UnitTest::GetInstance ()->UponLeavingGTest ();
3051
3049
internal::HandleExceptionsInMethodIfSupported (
3052
3050
this , &TestSuite::RunTearDownTestSuite, " TearDownTestSuite()" );
3053
3051
@@ -3058,15 +3056,14 @@ void TestSuite::Run() {
3058
3056
repeater->OnTestCaseEnd (*this );
3059
3057
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3060
3058
3061
- impl ->set_current_test_suite (nullptr );
3059
+ UnitTest::GetInstance () ->set_current_test_suite (nullptr );
3062
3060
}
3063
3061
3064
3062
// Skips all tests under this TestSuite.
3065
3063
void TestSuite::Skip () {
3066
3064
if (!should_run_) return ;
3067
3065
3068
- internal::UnitTestImpl* const impl = internal::GetUnitTestImpl ();
3069
- impl->set_current_test_suite (this );
3066
+ UnitTest::GetInstance ()->set_current_test_suite (this );
3070
3067
3071
3068
TestEventListener* repeater = UnitTest::GetInstance ()->listeners ().repeater ();
3072
3069
@@ -3088,7 +3085,7 @@ void TestSuite::Skip() {
3088
3085
repeater->OnTestCaseEnd (*this );
3089
3086
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3090
3087
3091
- impl ->set_current_test_suite (nullptr );
3088
+ UnitTest::GetInstance () ->set_current_test_suite (nullptr );
3092
3089
}
3093
3090
3094
3091
// Clears the results of all tests in this test suite.
@@ -5304,6 +5301,22 @@ TestSuite* UnitTest::GetMutableTestSuite(int i) {
5304
5301
return impl ()->GetMutableSuiteCase (i);
5305
5302
}
5306
5303
5304
+ void UnitTest::UponLeavingGTest () {
5305
+ impl ()->os_stack_trace_getter ()->UponLeavingGTest ();
5306
+ }
5307
+
5308
+ // Sets the TestSuite object for the test that's currently running.
5309
+ void UnitTest::set_current_test_suite (TestSuite* a_current_test_suite) {
5310
+ internal::MutexLock lock (&mutex_);
5311
+ impl_->set_current_test_suite (a_current_test_suite);
5312
+ }
5313
+
5314
+ // Sets the TestInfo object for the test that's currently running.
5315
+ void UnitTest::set_current_test_info (TestInfo* a_current_test_info) {
5316
+ internal::MutexLock lock (&mutex_);
5317
+ impl_->set_current_test_info (a_current_test_info);
5318
+ }
5319
+
5307
5320
// Returns the list of event listeners that can be used to track events
5308
5321
// inside Google Test.
5309
5322
TestEventListeners& UnitTest::listeners () { return *impl ()->listeners (); }
0 commit comments