chromium/base/sequence_checker_unittest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/sequence_checker.h"

#include <stddef.h>

#include <memory>
#include <string>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/sequence_checker_impl.h"
#include "base/sequence_token.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/lock_subtle.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/task_environment.h"
#include "base/threading/simple_thread.h"
#include "base/threading/thread_local.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base::internal {

namespace {

// Runs a callback on another thread.
class RunCallbackThread : public SimpleThread {};

void ExpectCalledOnValidSequence(SequenceCheckerImpl* sequence_checker) {}

void ExpectNotCalledOnValidSequence(SequenceCheckerImpl* sequence_checker) {}

}  // namespace

TEST(SequenceCheckerTest, NoTaskScope) {}

TEST(SequenceCheckerTest, TaskScope) {}

TEST(SequenceCheckerTest, TaskScopeThreadBound) {}

TEST(SequenceCheckerTest, DifferentThreadNoTaskScope) {}

TEST(SequenceCheckerTest, DifferentThreadDifferentSequenceToken) {}

TEST(SequenceCheckerTest, DifferentThreadDifferentSequenceTokenThreadBound) {}

TEST(SequenceCheckerTest, DifferentThreadSameSequenceToken) {}

TEST(SequenceCheckerTest, DifferentThreadSameSequenceTokenThreadBound) {}

TEST(SequenceCheckerTest, SameThreadDifferentSequenceToken) {}

TEST(SequenceCheckerTest, DetachFromSequence) {}

TEST(SequenceCheckerTest, DetachFromSequenceNoSequenceToken) {}

TEST(SequenceCheckerTest, Move) {}

TEST(SequenceCheckerTest, MoveAssignIntoDetached) {}

TEST(SequenceCheckerTest, MoveFromDetachedRebinds) {}

TEST(SequenceCheckerTest, MoveOffSequenceBanned) {}

TEST(SequenceCheckerMacroTest, Macros) {}

// Owns a SequenceCheckerImpl, and asserts that CalledOnValidSequence() is valid
// in ~SequenceCheckerOwner.
class SequenceCheckerOwner {};

// Verifies SequenceCheckerImpl::CalledOnValidSequence() returns true if called
// during thread destruction.
TEST(SequenceCheckerTest, FromThreadDestruction) {}

// Verifies sequence checking while holding the same locks from different
// sequences.
//
// Note: This is only supported in DCHECK builds.
#if DCHECK_IS_ON()
TEST(SequenceCheckerTest, LockBasic) {}

TEST(SequenceCheckerTest, ManyLocks) {}

TEST(SequenceCheckerTest, LockAndSequence) {}

TEST(SequenceCheckerTest, LockDetachFromSequence) {}

TEST(SequenceCheckerTest, LockMoveConstruction) {}

TEST(SequenceCheckerTest, LockMoveAssignment) {}
#endif  // DCHECK_IS_ON()

}  // namespace base::internal