#include "chrome/browser/ui/views/frame/browser_view.h"
#include <memory>
#include "base/memory/scoped_refptr.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/actions/chrome_action_id.h"
#include "chrome/browser/ui/browser_actions.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/performance_controls/tab_resource_usage_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_activity_simulator.h"
#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/pinned_toolbar/pinned_toolbar_actions_model.h"
#include "chrome/browser/ui/toolbar/pinned_toolbar/pinned_toolbar_actions_model_factory.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/vector_icons/vector_icons.h"
#include "components/version_info/channel.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/web_contents_tester.h"
#include "ui/actions/actions.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/dialog_model.h"
#include "ui/base/text/bytes_formatting.h"
#include "ui/gfx/scrollbar_size.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/bubble/bubble_dialog_model_host.h"
#include "ui/views/controls/webview/webview.h"
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/ui/recently_audible_helper.h"
#endif
#if defined(USE_AURA)
#include "ui/aura/client/aura_constants.h"
#endif
namespace {
class BrowserViewTestWithStopLoadingAnimationForHiddenWindow
: public TestWithBrowserView { … };
gfx::Point ExpectedTabStripRegionOrigin(BrowserView* browser_view) { … }
std::u16string SubBrowserName(const char* fmt) { … }
}
class BrowserViewTest : public TestWithBrowserView { … };
TEST_F(BrowserViewTest, BrowserView) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(BrowserViewTest, OnTaskLockedBrowserView) {
ASSERT_TRUE(browser_view()->browser());
browser_view()->browser()->SetLockedForOnTask(true);
EXPECT_FALSE(browser_view()->CanMinimize());
EXPECT_FALSE(browser_view()->ShouldShowCloseButton());
}
TEST_F(BrowserViewTest, OnTaskUnlockedBrowserView) {
ASSERT_TRUE(browser_view()->browser());
browser_view()->browser()->SetLockedForOnTask(false);
EXPECT_TRUE(browser_view()->CanMinimize());
EXPECT_TRUE(browser_view()->ShouldShowCloseButton());
}
#endif
namespace {
class ScopedBrowser { … };
}
#if BUILDFLAG(IS_LINUX)
#define MAYBE_UpdateActiveBrowser …
#else
#define MAYBE_UpdateActiveBrowser …
#endif
TEST_F(BrowserViewTest, MAYBE_UpdateActiveBrowser) { … }
TEST_F(BrowserViewTest, DISABLED_BrowserViewLayout) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_FindBarBoundingBoxLocationBar …
#else
#define MAYBE_FindBarBoundingBoxLocationBar …
#endif
TEST_F(BrowserViewTest, MAYBE_FindBarBoundingBoxLocationBar) { … }
TEST_F(BrowserViewTest, FindBarBoundingBoxNoLocationBar) { … }
TEST_F(BrowserViewTest, FindBrowserWindowWithWebContents) { … }
TEST_F(BrowserViewTest, FindBrowserWindowWithWebContentsTabSwitch) { … }
#if !BUILDFLAG(IS_MAC)
TEST_F(BrowserViewTest, DISABLED_RepeatedAccelerators) { … }
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_BookmarkBarInvisibleOnShutdown …
#else
#define MAYBE_BookmarkBarInvisibleOnShutdown …
#endif
TEST_F(BrowserViewTest, MAYBE_BookmarkBarInvisibleOnShutdown) { … }
TEST_F(BrowserViewTest, DISABLED_AccessibleWindowTitle) { … }
TEST_F(BrowserViewTest, WindowTitleOmitsLowMemoryUsage) { … }
#if BUILDFLAG(IS_MAC)
TEST_F(BrowserViewTest, TitleAudioIndicators) {
std::u16string playing_icon = u"\U0001F50A";
std::u16string muted_icon = u"\U0001F507";
AddTab(browser_view()->browser(), GURL("about:blank"));
content::WebContents* contents = browser_view()->GetActiveWebContents();
RecentlyAudibleHelper* audible_helper =
RecentlyAudibleHelper::FromWebContents(contents);
audible_helper->SetNotRecentlyAudibleForTesting();
EXPECT_EQ(browser_view()->GetWindowTitle().find(playing_icon),
std::u16string::npos);
EXPECT_EQ(browser_view()->GetWindowTitle().find(muted_icon),
std::u16string::npos);
audible_helper->SetCurrentlyAudibleForTesting();
EXPECT_NE(browser_view()->GetWindowTitle().find(playing_icon),
std::u16string::npos);
EXPECT_EQ(browser_view()->GetWindowTitle().find(muted_icon),
std::u16string::npos);
audible_helper->SetRecentlyAudibleForTesting();
contents->SetAudioMuted(true);
EXPECT_EQ(browser_view()->GetWindowTitle().find(playing_icon),
std::u16string::npos);
EXPECT_NE(browser_view()->GetWindowTitle().find(muted_icon),
std::u16string::npos);
}
#endif
TEST_F(BrowserViewTest, RotatePaneFocusFromView) { … }
TEST_F(BrowserViewTest, AccessibleProperties) { … }
#if !BUILDFLAG(IS_MAC)
TEST_F(BrowserViewTest, CanFullscreenPolicyWatcher) { … }
class BrowserViewPipTest : public TestWithBrowserView { … };
TEST_F(BrowserViewPipTest, CanFullscreenPolicyDoesNotEnableFullscreen) { … }
#endif
class BrowserViewHostedAppTest : public TestWithBrowserView { … };
TEST_F(BrowserViewHostedAppTest, Layout) { … }
BrowserViewWindowTypeTest;
TEST_F(BrowserViewWindowTypeTest, TestWindowIsNotReturned) { … }
TEST_F(BrowserViewTestWithStopLoadingAnimationForHiddenWindow,
LoadingAnimationNotRenderedWhenWindowHidden) { … }