chromium/ui/base/interaction/interactive_test_unittest.cc

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

#include "ui/base/interaction/interactive_test.h"

#include <functional>
#include <list>
#include <memory>
#include <string>

#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_test_util.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/expect_call_in_scope.h"
#include "ui/base/interaction/interaction_sequence.h"
#include "ui/base/interaction/state_observer.h"

#if !BUILDFLAG(IS_IOS)
#include "ui/base/accelerators/accelerator.h"
#endif

namespace ui::test {

namespace {

enum class ActionType {};

ActionRecord;

const ui::ElementContext kTestContext1(1);
const ui::ElementContext kTestContext2(2);

DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE();
DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE();

constexpr char kSetOnIncompatibleActionMessage[] =;

class TestSimulator : public InteractionTestUtil::Simulator {};

void DoFunction() {}

const TrackedElement* CheckElementFunction(const TrackedElement* el) {}

int ValueGeneratingFunction() {}

struct CallableObject {};

struct MutableCallableObject {};

struct EmptyCallableObject {};

}  // namespace

class InteractiveTestTest : public InteractiveTest {};

TEST_F(InteractiveTestTest, StepsConstructsMultiStep) {}

TEST_F(InteractiveTestTest, RunTestSequenceInContext) {}

TEST_F(InteractiveTestTest, WaitInAnyContext) {}

TEST_F(InteractiveTestTest, FlushInAnyContext) {}

TEST_F(InteractiveTestTest, InteractionVerbs) {}

TEST_F(InteractiveTestTest, InteractionVerbsInAnyContext) {}

TEST_F(InteractiveTestTest, InteractionVerbsInSameContext) {}

TEST_F(InteractiveTestTest, Do) {}

TEST_F(InteractiveTestTest, Check) {}

TEST_F(InteractiveTestTest, CheckFails) {}

TEST_F(InteractiveTestTest, CheckResult) {}

TEST_F(InteractiveTestTest, CheckResultFails) {}

TEST_F(InteractiveTestTest, CheckVariable) {}

TEST_F(InteractiveTestTest, CheckVariableFails) {}

TEST_F(InteractiveTestTest, CheckElement) {}

TEST_F(InteractiveTestTest, CheckElementFails) {}

TEST_F(InteractiveTestTest, CheckElementWithMatcher) {}

TEST_F(InteractiveTestTest, CheckElementWithMatcherFails) {}

TEST_F(InteractiveTestTest, After) {}

TEST_F(InteractiveTestTest, WaitFor) {}

TEST_F(InteractiveTestTest, PresentOrNotPresentInAnyContext) {}

TEST_F(InteractiveTestTest, WithElementFails) {}

TEST_F(InteractiveTestTest, EnsureNotPresentFails) {}

TEST_F(InteractiveTestTest, EnsureNotPresentInAnyContextFails) {}

TEST_F(InteractiveTestTest, EnsurePresentFails) {}

TEST_F(InteractiveTestTest, NameElementWithPointer) {}

TEST_F(InteractiveTestTest, NameElementWithReference) {}

TEST_F(InteractiveTestTest, NameElementWithCallback) {}

TEST_F(InteractiveTestTest, NameElementWithContext) {}

TEST_F(InteractiveTestTest, SimulatorSucceeds_SkipOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorSucceeds_IgnoreOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorFailureFails) {}

TEST_F(InteractiveTestTest, SimulatorFailureFails_SkipOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorFailureFails_IgnoreOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorCannotSimulateFails) {}

TEST_F(InteractiveTestTest, SimulatorCannotSimulateFails_SkipOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorCannotSimulateFails_IgnoreOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorNotSupportedFails) {}

TEST_F(InteractiveTestTest, SimulatorNotSupportedSkipsOnUnsupported) {}

TEST_F(InteractiveTestTest, SimulatorNotSupportedContinuesOnUnsupported) {}

TEST_F(InteractiveTestTest, CanChangeOnIncompatibleAction) {}

TEST_F(InteractiveTestTest, SimulatorNotSupportedHaltAndSucceedOnUnsupported) {}

TEST_F(InteractiveTestTest, ActuallySkipsTestOnSimulatorFailure) {}

TEST_F(InteractiveTestTest, IfTrue) {}

TEST_F(InteractiveTestTest, IfFalse) {}

TEST_F(InteractiveTestTest, IfMatcherTrue) {}

TEST_F(InteractiveTestTest, IfMatcherFalse) {}

TEST_F(InteractiveTestTest, IfImplicitMatcherTrue) {}

TEST_F(InteractiveTestTest, IfImplicitMatcherFalse) {}

TEST_F(InteractiveTestTest, IfWithMultiStep) {}

TEST_F(InteractiveTestTest, IfElementTrue) {}

TEST_F(InteractiveTestTest, IfElementFalse) {}

TEST_F(InteractiveTestTest, IfElementMatchesTrue) {}

TEST_F(InteractiveTestTest, IfElementMatchesFalse) {}

TEST_F(InteractiveTestTest, IfElementWithMultiStep) {}

TEST_F(InteractiveTestTest, IfFails) {}

TEST_F(InteractiveTestTest, IfThenElse_OnlyRunsThen) {}

TEST_F(InteractiveTestTest, IfThenElse_OnlyRunsElse) {}

TEST_F(InteractiveTestTest, IfThenElse_ThenFails) {}

TEST_F(InteractiveTestTest, IfThenElse_ElseFails) {}

TEST_F(InteractiveTestTest, InParallel) {}

TEST_F(InteractiveTestTest, InParallelMultiStep) {}

TEST_F(InteractiveTestTest, InParallelAsync) {}

// Parallel sequences where one sequence triggers a step in another.
TEST_F(InteractiveTestTest, InParallelDependent) {}

// Parallel sequences where one sequence triggers a step in another, which then
// triggers the final step in the first subsequence.
TEST_F(InteractiveTestTest, InParallelPingPong) {}

TEST_F(InteractiveTestTest, InParallelFails) {}

TEST_F(InteractiveTestTest, AnyOf) {}

TEST_F(InteractiveTestTest, AnyOfOneFailsOneSucceeds) {}

TEST_F(InteractiveTestTest, AnyOfAllFail) {}

// This is a regression test for an issue where there is a UAF when tearing down
// an AnyOf() inside an If().
TEST_F(InteractiveTestTest, AnyOfInsideIf) {}

// This test that various types of logging can compile with different types of
// parameters. The output of this test must be verified manually.
TEST_F(InteractiveTestTest, Log) {}

// This test ensures that binding of various types of functions and function
// arguments works correctly with actions. If the template logic is not correct,
// this test will likely not compile.
TEST_F(InteractiveTestTest, ActionBindingMethods) {}

// This test ensures that binding of various types of functions and function
// arguments works correctly with conditionals. If the template logic is not
// correct, this test will likely not compile.
TEST_F(InteractiveTestTest, ConditionalBindingMethods) {}

namespace {

template <typename T>
class TestObservable;

template <typename T>
class TestObserver : public base::CheckedObserver {};

template <typename T>
class TestObservable {};

template <typename T>
class TestStateObserver
    : public ObservationStateObserver<T, TestObservable<T>, TestObserver<T>> {};

struct MyStruct {};

DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(TestStateObserver<int>, kIntTestState);
DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(TestStateObserver<std::string>,
                                    kStringTestState);
DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(TestStateObserver<std::u16string>,
                                    kWStringTestState);
DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(TestStateObserver<MyStruct>,
                                    kStructTestState);

}  // namespace

TEST_F(InteractiveTestTest, ObserveStateFromUniquePtr) {}

TEST_F(InteractiveTestTest, ObserveExistingStateProceedsImmediately) {}

TEST_F(InteractiveTestTest, ObserveStateFromArgsWithReferences) {}

TEST_F(InteractiveTestTest, ObserveStateFromArgsWithFunctions) {}

TEST_F(InteractiveTestTest, ObserveStateResetsOnDestruction) {}

TEST_F(InteractiveTestTest, ObserveStateWithString) {}

TEST_F(InteractiveTestTest, ObserveStateWithWideString) {}

TEST_F(InteractiveTestTest, ObserveStateWithStruct) {}

TEST_F(InteractiveTestTest, StopObservingState) {}

DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(PollingStateObserver<int>,
                                    kPollingTestState);

TEST_F(InteractiveTestTest, PollingStateObserver) {}

// Tests that the callback is issued exactly once to determine its initial
// state, and not triggered unnecessarily once the desired condition is met.
TEST_F(InteractiveTestTest, PollingStateCalledOnce) {}

DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(PollingElementStateObserver<std::string>,
                                    kPollingElementTestState);

TEST_F(InteractiveTestTest, PollingElementStateObserver) {}

TEST_F(InteractiveTestTest, SubsequenceHidesElement) {}

}  // namespace ui::test