chromium/chrome/browser/ui/views/accessibility/caption_bubble_controller_views_browsertest.cc

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

#include <memory>

#include "base/functional/callback_forward.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_mock_time_message_loop_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/views/accessibility/caption_bubble_context_views.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/live_caption/caption_util.h"
#include "components/live_caption/pref_names.h"
#include "components/live_caption/views/caption_bubble.h"
#include "components/live_caption/views/caption_bubble_controller_views.h"
#include "components/prefs/pref_service.h"
#include "components/soda/soda_installer.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/scoped_accessibility_mode_override.h"
#include "content/public/test/test_navigation_observer.h"
#include "media/base/media_switches.h"
#include "media/mojo/mojom/speech_recognition_service.mojom.h"
#include "ui/accessibility/ax_mode.h"
#include "ui/base/buildflags.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/test/widget_activation_waiter.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"

#if defined(USE_AURA)
#include "ui/aura/client/focus_client.h"
#include "ui/views/widget/native_widget_aura.h"
#endif  // USE_AURA

namespace captions {

class CaptionBubbleControllerViewsTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, ShowsCaptionInBubble) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, LaysOutCaptionLabel) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       CaptionTitleShownAtFirst) {}

// TODO(crbug.com/40900150): Flaky on Linux Tests.
#if BUILDFLAG(IS_LINUX)
#define MAYBE_BubblePositioning
#else
#define MAYBE_BubblePositioning
#endif
IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       MAYBE_BubblePositioning) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, ShowsAndHidesError) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, CloseButtonCloses) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       ClosesOnAudioStreamEnd) {}

// TODO(crbug.com/40119836): Renable this test once it is passing. Tab
// traversal works in app but doesn't work in tests right now.
IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       DISABLED_FocusableInTabOrder) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       UpdateCaptionStyleTextSize) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       UpdateCaptionStyleFontFamily) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       UpdateCaptionStyleTextColor) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       UpdateCaptionStyleBackgroundColor) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       PartialAndFinalTranscriptions) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, ShowsAndHidesBubble) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, ChangeMedia) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, TruncatesFinalText) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       DestroysWithoutCrashing) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, ExpandsAndCollapses) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, PinAndUnpin) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, NonAsciiCharacter) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, AccessibleTextSetUp) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       AccessibleTextSplitsIntoNodesByLine) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       AccessibleTextClearsWhenBubbleCloses) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       AccessibleTextChangesWhenMediaChanges) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       AccessibleTextTruncates) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       AccessibleTextIsSometimesFocusable) {}

// Disable due to flaky, https://crbug.com/1206677
IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       DISABLED_HidesAfterInactivity) {}

// TODO(crbug.com/40181252): Flaky test.
#if BUILDFLAG(IS_OZONE)
#define MAYBE_ClearsTextAfterInactivity
#else
#define MAYBE_ClearsTextAfterInactivity
#endif
IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       MAYBE_ClearsTextAfterInactivity) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       HasAccessibleWindowTitle) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       BackToTabButtonActivatesTab) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       ErrorHidesAfterInactivity) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, LiveTranslateLabel) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, HeaderView) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       NavigateToCaptionSettings) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest, LabelTextDirection) {}

#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       DownloadProgressLabel) {}

IN_PROC_BROWSER_TEST_F(CaptionBubbleControllerViewsTest,
                       AutomaticLanguageDownload) {}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

}  // namespace captions