/* * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// This class is dead code, but its purpose is to make sure that // SequenceChecker is compatible with the RTC_GUARDED_BY and RTC_RUN_ON // attributes that are checked at compile-time. class CompileTimeTestForGuardedBy { public: int CalledOnSequence() RTC_RUN_ON(sequence_checker_) { return guarded_; }
TEST(SequenceCheckerTest, DestructorAllowedOnDifferentThread) { auto sequence_checker = std::make_unique<SequenceChecker>();
RunOnDifferentThread([&] { // Verify that the destructor doesn't assert when called on a different // thread.
sequence_checker.reset();
});
}
#if RTC_DCHECK_IS_ON
TEST(SequenceCheckerTest, OnlyCurrentOnOneThread) {
SequenceChecker sequence_checker(SequenceChecker::kDetached);
RunOnDifferentThread([&] {
EXPECT_TRUE(sequence_checker.IsCurrent()); // Spawn a new thread from within the first one to guarantee that we have // two concurrently active threads (and that there's no chance of the // thread ref being reused).
RunOnDifferentThread([&] { EXPECT_FALSE(sequence_checker.IsCurrent()); });
});
} #endif
// IsCurrent should return false in debug builds after moving to // another task queue.
TaskQueueForTest queue2;
queue2.SendTask(
[&] { EXPECT_EQ(sequence_checker.IsCurrent(), !RTC_DCHECK_IS_ON); });
}
// Test for the base class
webrtc_sequence_checker_internal::SequenceCheckerImpl* sequence_checker_base =
&sequence_checker;
EXPECT_THAT(ExpectationToString(sequence_checker_base),
HasSubstr("# Expected: TQ:"));
#if RTC_DCHECK_IS_ON // Note: Ending the test suite name with 'DeathTest' is important as it causes // gtest to order this test before any other non-death-tests, to avoid potential // global process state pollution such as shared worker threads being started // (e.g. a side effect of calling InitCocoaMultiThreading() on Mac causes one or // two additional threads to be created).
TEST(SequenceCheckerDeathTest, TestAnnotationsOnWrongQueueDebug) {
ASSERT_DEATH({ TestAnnotationsOnWrongQueue(); }, "");
} #else
TEST(SequenceCheckerTest, TestAnnotationsOnWrongQueueRelease) {
TestAnnotationsOnWrongQueue();
} #endif #endif// GTEST_HAS_DEATH_TEST
} // namespace webrtc
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.