diff options
Diffstat (limited to 'src/3rd_party-static/gmock-1.7.0/src/gmock-spec-builders.cc')
-rw-r--r-- | src/3rd_party-static/gmock-1.7.0/src/gmock-spec-builders.cc | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/3rd_party-static/gmock-1.7.0/src/gmock-spec-builders.cc b/src/3rd_party-static/gmock-1.7.0/src/gmock-spec-builders.cc index 1219a3a3c9..3943d09276 100644 --- a/src/3rd_party-static/gmock-1.7.0/src/gmock-spec-builders.cc +++ b/src/3rd_party-static/gmock-1.7.0/src/gmock-spec-builders.cc @@ -755,108 +755,6 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj) return expectations_met; } -bool Mock::AsyncVerifyAndClearExpectations(int timeout_msec) - GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - return AsyncVerifyAndClearExpectationsLocked(timeout_msec); -} - -bool Mock::AsyncVerifyAndClearExpectationsLocked(const int timeout_msec_in) - GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) { - internal::g_gmock_mutex.AssertHeld(); - MockObjectRegistry::StateMap& state_map = g_mock_object_registry.states(); - if (state_map.empty()) { - // No EXPECT_CALL() was set on the given mock object. - return true; - } - - // TODO(ezamakhov@gmail.com): refactor the next loops - bool expectations_met = true; - timeval first_register_time {0, 0}; - int timeout_msec = timeout_msec_in; - for (MockObjectRegistry::StateMap::iterator mock_it = state_map.begin(); - state_map.end() != mock_it; ++mock_it) { - MockObjectState& state = mock_it->second; - - // Verifies the expectations on each mock method in the - // given mock object. - FunctionMockers& mockers = state.function_mockers; - if (mockers.empty()) { - internal::Assert(!mockers.empty(), __FILE__, __LINE__, - "No functions mocked"); - return true; - } - - for (FunctionMockers::const_iterator it = mockers.begin(); - it != mockers.end(); ++it) { - internal::UntypedFunctionMockerBase* base = *it; - - const timeval register_time = base->RegisteredTime(); - if (!timerisset(&first_register_time) || - timercmp(®ister_time, &first_register_time, <)) { - first_register_time = register_time; - } - - // Waiting expectations loop - do { - const internal::ExpectationResult result = - base->VerifyExpectationsLocked(); - if (result == internal::OverSaturated) { - expectations_met = false; - // break waiting procedure - break; - } - if (result == internal::Satisfied) { - // break waiting procedure - break; - } - if (result == internal::NotSatisfied) { - // If timeout expared - if (timeout_msec <= 0) { - expectations_met = false; - // break waiting procedure - break; - } - // Unlock callbacks procedures - static const int sleep_msec = 10; - internal::UnlockAndSleep(sleep_msec * 1000); - timeout_msec -= sleep_msec; - } - } while (true); - } // mockers iteration - - if (expectations_met) { - const long elapsed_usecs = - // first_register_time is empty on no expectations in mocks - timerisset(&first_register_time) - ? internal::UsecsElapsed(first_register_time) - : 100 * 1000; - // To avoid waitings very long times. - const long max_sleep_time = timeout_msec_in * 10 * 1000; - if (max_sleep_time > elapsed_usecs * 2) { - // Wait double times - internal::UnlockAndSleep(elapsed_usecs * 2); - } - } - - // Verifies and clears the expectations on each mock method in the - // given mock object. - for (FunctionMockers::const_iterator it = mockers.begin(); - it != mockers.end(); ++it) { - internal::UntypedFunctionMockerBase* base = *it; - // Get finial result and clear expectation - const bool final_verification = base->VerifyAndClearExpectationsLocked(); - if (!final_verification) { - expectations_met = false; - } - } - } // state_map iteration - - // We don't clear the content of mockers, as they may still be - // needed by ClearDefaultActionsLocked(). - return expectations_met; -} - // Registers a mock object and a mock method it owns. void Mock::Register(const void* mock_obj, internal::UntypedFunctionMockerBase* mocker) |