#include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/extension_zoom_request_client.h"
#include "extensions/common/extension_builder.h"
#include "third_party/blink/public/mojom/frame/fullscreen.mojom.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/test/test_widget_observer.h"
#include "ui/views/test/widget_test.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/views/frame/immersive_mode_controller_chromeos.h"
#include "chromeos/ui/frame/immersive/immersive_fullscreen_controller_test_api.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/ui/browser_commands_mac.h"
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
#include "ui/views/test/button_test_api.h"
#endif
ZoomBubbleBrowserTest;
namespace {
void ShowInActiveTab(Browser* browser) { … }
}
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ContentFullscreen) { … }
#if BUILDFLAG(IS_MAC)
class ZoomBubbleImmersiveDisabledBrowserTest : public ZoomBubbleBrowserTest {
public:
ZoomBubbleImmersiveDisabledBrowserTest() {
scoped_feature_list_.InitAndDisableFeature(features::kImmersiveFullscreen);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
#else
ZoomBubbleImmersiveDisabledBrowserTest;
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_AnchorPositionsInFullscreen …
#else
#define MAYBE_AnchorPositionsInFullscreen …
#endif
IN_PROC_BROWSER_TEST_F(ZoomBubbleImmersiveDisabledBrowserTest,
MAYBE_AnchorPositionsInFullscreen) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ImmersiveFullscreen) {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
content::WebContents* web_contents = browser_view->GetActiveWebContents();
ImmersiveModeController* immersive_controller =
browser_view->immersive_mode_controller();
chromeos::ImmersiveFullscreenControllerTestApi(
static_cast<ImmersiveModeControllerChromeos*>(immersive_controller)
->controller())
.SetupForTest();
ui_test_utils::ToggleFullscreenModeAndWait(browser());
ASSERT_TRUE(immersive_controller->IsEnabled());
ASSERT_FALSE(immersive_controller->IsRevealed());
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
ASSERT_TRUE(ZoomBubbleView::GetZoomBubble());
const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble();
EXPECT_FALSE(zoom_bubble->GetAnchorView());
std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock =
immersive_controller->GetRevealedLock(
ImmersiveModeController::ANIMATE_REVEAL_NO);
ASSERT_TRUE(immersive_controller->IsRevealed());
EXPECT_EQ(nullptr, ZoomBubbleView::zoom_bubble_);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
zoom_bubble = ZoomBubbleView::GetZoomBubble();
ASSERT_TRUE(zoom_bubble);
EXPECT_TRUE(zoom_bubble->GetAnchorView());
immersive_reveal_lock.reset();
EXPECT_TRUE(immersive_controller->IsRevealed());
ZoomBubbleView::CloseCurrentBubble();
content::RunAllPendingInMessageLoop();
EXPECT_FALSE(immersive_controller->IsRevealed());
ui_test_utils::ToggleFullscreenModeAndWait(browser());
}
#endif
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, NoWebContentsIsSafe) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, TabSwitchCloses) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, DestroyedWebContents) { … }
namespace {
class TestZoomRequestClient : public extensions::ExtensionZoomRequestClient { … };
}
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest,
BubbleSuppressingExtensionRefreshesExistingBubble) { … }
class ZoomBubbleReuseTest : public ZoomBubbleBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ZoomBubbleReuseTest, BothUserInitiated) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleReuseTest, SameExtension) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleReuseTest, DifferentExtension) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleReuseTest, ExtensionThenUser) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleReuseTest, UserThenExtension) { … }
class ZoomBubbleDialogTest : public DialogBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ZoomBubbleDialogTest, InvokeUi_default) { … }
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, FocusPreventsClose) { … }