chromium/content/browser/accessibility/scoped_mode_collection_unittest.cc

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

#include "content/browser/accessibility/scoped_mode_collection.h"

#include <memory>
#include <optional>

#include "base/functional/callback_helpers.h"
#include "base/test/mock_callback.h"
#include "content/public/browser/scoped_accessibility_mode.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_mode.h"

namespace content {

_;
DoAll;
WithArg;
WithoutArgs;

MockModeChangedCallback;

// An action that evaluates an expectation that `collection` is or is not
// empty.
ACTION_P(ExpectCollectionModeEqualsArg, collection) {}

class ScopedModeCollectionTest : public ::testing::Test {};

// Tests the most basic use of adding/removing a scoper.
TEST_F(ScopedModeCollectionTest, SimpleAddRemove) {}

// Tests multiple scopers perfectly nested.
TEST_F(ScopedModeCollectionTest, MultipleNested) {}

// Tests multiple scopers deleted out of order.
TEST_F(ScopedModeCollectionTest, MultipleNotNested) {}

// Tests that deleting the collection while it holds a scoper should neither
// crash nor run the callback when the scoper is destroyed. (Note: by
// "outstanding", we mean that there remains a scoper alive. We are not making a
// judgement about this particular scoper being better in any way than another
// scoper. All scopers are equal in the transistors of the CPU.)
TEST_F(ScopedModeCollectionTest, OutstandingScoper) {}

// An action that evaluates an expectation that `collection` is empty.
ACTION_P(ExpectCollectionIsEmpty, collection) {}

// An action that evaluates an expectation that `collection` is not empty.
ACTION_P(ExpectCollectionIsNotEmpty, collection) {}

// Tests that `empty()` works.
TEST_F(ScopedModeCollectionTest, Empty) {}

// Tests that destroying a collection from within its callback does not crash,
// even if scopers are still alive.
TEST_F(ScopedModeCollectionTest, DestroyFromCallback) {}

}  // namespace content