Commit 6b283b6a authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Fix tab detaching from immersive fullscreen windows

When detaching a tab to a new browser, we used to just fullscreen
the window, which is different from the immersive fullscreen window.
This caused the new window to block showing the shelf as well as
revealing the tab strip.

BUG=776557
TEST=interactive_ui_tests --gtest_filter=TabDragging/DetachToBrowserTabDragControllerTest.DetachToOwnWindowWhileInImmersiveFullscreenMode/*

Change-Id: Idd3714fc9ec00e0e771ed93f77b40113c68b0ff9
Reviewed-on: https://chromium-review.googlesource.com/804174Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521094}
parent 5cda9b7a
......@@ -17,6 +17,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_features.h"
......@@ -1535,7 +1536,11 @@ void TabDragController::MaximizeAttachedWindow() {
if (was_source_fullscreen_) {
// In fullscreen mode it is only possible to get here if the source
// was in "immersive fullscreen" mode, so toggle it back on.
GetAttachedBrowserWidget()->SetFullscreen(true);
BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(
GetAttachedBrowserWidget()->GetNativeWindow());
DCHECK(browser_view);
if (!browser_view->IsFullscreen())
chrome::ToggleFullscreenMode(browser_view->browser());
}
#endif
}
......
......@@ -1026,6 +1026,70 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
EXPECT_TRUE(new_browser->window()->IsMaximized());
}
#if defined(OS_CHROMEOS)
// This test makes sense only on Chrome OS where we have the immersive
// fullscreen mode. The detached tab to a new browser window should remain in
// immersive fullscreen mode.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DetachToOwnWindowWhileInImmersiveFullscreenMode) {
// Toggle the immersive fullscreen mode for the initial browser.
chrome::ToggleFullscreenMode(browser());
ASSERT_TRUE(BrowserView::GetBrowserViewForBrowser(browser())
->immersive_mode_controller()
->IsEnabled());
// Add another tab.
AddTabAndResetBrowser(browser());
TabStripImpl* tab_strip = GetTabStripForBrowser(browser());
// Move to the first tab and drag it enough so that it detaches.
gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
ASSERT_TRUE(PressInput(tab_0_center));
ASSERT_TRUE(DragInputToNotifyWhenDone(
tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
base::Bind(&DetachToOwnWindowStep2, this)));
if (input_source() == INPUT_SOURCE_MOUSE) {
ASSERT_TRUE(ReleaseMouseAsync());
QuitWhenNotDragging();
}
// Should no longer be dragging.
ASSERT_FALSE(tab_strip->IsDragSessionActive());
ASSERT_FALSE(TabDragController::IsActive());
// There should now be another browser.
ASSERT_EQ(2u, browser_list->size());
Browser* new_browser = browser_list->get(1);
ASSERT_TRUE(new_browser->window()->IsActive());
TabStripImpl* tab_strip2 = GetTabStripForBrowser(new_browser);
ASSERT_FALSE(tab_strip2->IsDragSessionActive());
EXPECT_EQ("0", IDString(new_browser->tab_strip_model()));
EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
// The bounds of the initial window should not have changed.
EXPECT_TRUE(browser()->window()->IsFullscreen());
ASSERT_TRUE(BrowserView::GetBrowserViewForBrowser(browser())
->immersive_mode_controller()
->IsEnabled());
EXPECT_FALSE(GetIsDragged(browser()));
EXPECT_FALSE(GetIsDragged(new_browser));
// After this both windows should still be manageable.
EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow()));
EXPECT_TRUE(
IsWindowPositionManaged(new_browser->window()->GetNativeWindow()));
// The new browser should be in immersive fullscreen mode.
ASSERT_TRUE(BrowserView::GetBrowserViewForBrowser(new_browser)
->immersive_mode_controller()
->IsEnabled());
EXPECT_TRUE(new_browser->window()->IsFullscreen());
}
#endif
// Deletes a tab being dragged before the user moved enough to start a drag.
IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
DeleteBeforeStartedDragging) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment