chromium/components/user_education/webui/help_bubble_handler_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 "components/user_education/webui/help_bubble_handler.h"

#include <memory>
#include <vector>

#include "base/callback_list.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "components/user_education/common/help_bubble_factory_registry.h"
#include "components/user_education/common/help_bubble_params.h"
#include "components/user_education/test/test_help_bubble.h"
#include "components/user_education/webui/help_bubble_webui.h"
#include "components/user_education/webui/tracked_element_webui.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/web_ui_controller.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_tracker.h"
#include "ui/base/interaction/expect_call_in_scope.h"
#include "ui/webui/resources/cr_components/help_bubble/help_bubble.mojom-forward.h"
#include "ui/webui/resources/cr_components/help_bubble/help_bubble.mojom-shared.h"
#include "ui/webui/resources/cr_components/help_bubble/help_bubble.mojom.h"

namespace user_education {

namespace {

DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
constexpr gfx::RectF kElementBounds{};

// Mock version of the help bubble client so we don't need a remote (while being
// able to know when the remote methods would have been called).
class MockHelpBubbleClient : public help_bubble::mojom::HelpBubbleClient {};

// Handler that mocks the remote connection to the web side of the component.
// The mock is a strict mock and can be retrieved by calling the `mock()`
// method.
class TestHelpBubbleHandler : public HelpBubbleHandlerBase {};

MATCHER_P(MatchesHelpBubbleParams, expected, "") {}

}  // namespace

// Tests the interaction of HelpBubbleHandler, HelpBubbleWebUI, and
// TrackedElementWebUI. The three form a single system that all work together.
class HelpBubbleHandlerTest : public testing::Test {};

TEST_F(HelpBubbleHandlerTest, StartsWithNoElement) {}

TEST_F(HelpBubbleHandlerTest, ElementCreatedOnEvent) {}

TEST_F(HelpBubbleHandlerTest, ElementHiddenOnEvent) {}

TEST_F(HelpBubbleHandlerTest, ElementActivatedOnEvent) {}

TEST_F(HelpBubbleHandlerTest, ElementCustomEventOnEvent) {}

TEST_F(HelpBubbleHandlerTest, MultipleIdentifiers) {}

TEST_F(HelpBubbleHandlerTest, ShowHelpBubble) {}

// Regression test for possible cause of crbug.com/1474307.
TEST_F(HelpBubbleHandlerTest, ShowHelpBubbleTwice) {}

TEST_F(HelpBubbleHandlerTest, ShowHelpBubbleWithButtonsAndProgress) {}

TEST_F(HelpBubbleHandlerTest, FocusHelpBubble) {}

TEST_F(HelpBubbleHandlerTest, ExternalHelpBubbleUpdated) {}

TEST_F(HelpBubbleHandlerTest, HelpBubbleClosedWhenVisibilityChanges) {}

TEST_F(HelpBubbleHandlerTest, HelpBubbleClosedWhenClosedRemotely) {}

TEST_F(HelpBubbleHandlerTest, DestroyHandlerCleansUpElement) {}

// Asserts that closing the HelpBubble handle to a bubble instance destroys
// the bubble.
TEST_F(HelpBubbleHandlerTest, DestroyBubbleWrapperClosesHelpBubble) {}

TEST_F(HelpBubbleHandlerTest, HelpBubbleClosedWhenClosedByUserCallsDismiss) {}

TEST_F(HelpBubbleHandlerTest, ButtonPressedCallsCallback) {}

TEST_F(HelpBubbleHandlerTest, ShowMultipleBubblesAndCloseOneViaVisibility) {}

TEST_F(HelpBubbleHandlerTest, ShowMultipleBubblesAndCloseOneViaCallback) {}

// The following tests check that the WebContents visibility logic.

TEST_F(HelpBubbleHandlerTest, WebContentsNotVisibleResultsInNoElement) {}

TEST_F(HelpBubbleHandlerTest, WebContentsVisibilityNotAvailable) {}

TEST_F(HelpBubbleHandlerTest, ElementShownOnmWebContentsBecomingVisible) {}

TEST_F(HelpBubbleHandlerTest, ElementHiddenWebContentsBecomingInvisible) {}

TEST_F(HelpBubbleHandlerTest, ElementHiddenWebContentsBecomingUnknown) {}

TEST_F(HelpBubbleHandlerTest, RepeatedlyQueriesVisibility) {}

TEST_F(HelpBubbleHandlerTest, WebContentsVisibilityCanChangeMultipleTimes) {}

TEST_F(HelpBubbleHandlerTest, DestroyHandlerDuringCallback) {}

TEST_F(HelpBubbleHandlerTest,
       WebUIHelpBubblePreventsHideWhenVisibilityChanges) {}

}  // namespace user_education