This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
#include "ash/ash_constants.h"
#include "ash/ash_switches.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/frame/header_painter.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "ui/base/hit_test.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/views/widget/widget.h"
using views::Widget;
typedef InProcessBrowserTest BrowserNonClientFrameViewAshTest;
IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewAshTest, NonClientHitTest) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
Widget* widget = browser_view->GetWidget();
BrowserNonClientFrameViewAsh* frame_view =
static_cast<BrowserNonClientFrameViewAsh*>(
widget->non_client_view()->frame_view());
const int kWindowWidth = 300;
const int kWindowHeight = 290;
widget->SetBounds(gfx::Rect(10, 10, kWindowWidth, kWindowHeight));
gfx::Point top_edge(kWindowWidth / 2, 0);
EXPECT_EQ(HTTOP, frame_view->NonClientHitTest(top_edge));
gfx::Point below_resize(kWindowWidth / 2, ash::kResizeInsideBoundsSize);
EXPECT_EQ(HTCAPTION, frame_view->NonClientHitTest(below_resize));
widget->Maximize();
EXPECT_EQ(HTCLIENT, frame_view->NonClientHitTest(top_edge));
}
IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewAshTest,
NonImmersiveFullscreen) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
content::WebContents* web_contents = browser_view->GetActiveWebContents();
Widget* widget = browser_view->GetWidget();
BrowserNonClientFrameViewAsh* frame_view =
static_cast<BrowserNonClientFrameViewAsh*>(
widget->non_client_view()->frame_view());
EXPECT_TRUE(frame_view->ShouldPaint());
{
scoped_ptr<FullscreenNotificationObserver> waiter(
new FullscreenNotificationObserver());
browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
web_contents, true);
waiter->Wait();
}
EXPECT_FALSE(browser_view->immersive_mode_controller()->IsEnabled());
EXPECT_FALSE(frame_view->ShouldPaint());
EXPECT_EQ(0, frame_view->GetBoundsForClientView().y());
{
scoped_ptr<FullscreenNotificationObserver> waiter(
new FullscreenNotificationObserver());
chrome::ToggleFullscreenMode(browser());
waiter->Wait();
}
EXPECT_TRUE(frame_view->ShouldPaint());
EXPECT_TRUE(frame_view->caption_button_container_->visible());
}
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewAshTest, ImmersiveFullscreen) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
content::WebContents* web_contents = browser_view->GetActiveWebContents();
Widget* widget = browser_view->GetWidget();
BrowserNonClientFrameViewAsh* frame_view =
static_cast<BrowserNonClientFrameViewAsh*>(
widget->non_client_view()->frame_view());
ImmersiveModeController* immersive_mode_controller =
browser_view->immersive_mode_controller();
immersive_mode_controller->SetupForTest();
ASSERT_FALSE(widget->IsFullscreen());
EXPECT_FALSE(immersive_mode_controller->IsEnabled());
EXPECT_TRUE(frame_view->ShouldPaint());
EXPECT_LT(Tab::GetImmersiveHeight(),
frame_view->header_painter_->GetHeaderHeightForPainting());
{
scoped_ptr<FullscreenNotificationObserver> waiter(
new FullscreenNotificationObserver());
chrome::ToggleFullscreenMode(browser());
waiter->Wait();
}
{
scoped_ptr<FullscreenNotificationObserver> waiter(
new FullscreenNotificationObserver());
browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
web_contents, true);
waiter->Wait();
}
EXPECT_TRUE(immersive_mode_controller->IsEnabled());
scoped_ptr<ImmersiveRevealedLock> revealed_lock(
immersive_mode_controller->GetRevealedLock(
ImmersiveModeController::ANIMATE_REVEAL_NO));
EXPECT_TRUE(immersive_mode_controller->IsRevealed());
EXPECT_TRUE(frame_view->ShouldPaint());
EXPECT_TRUE(frame_view->caption_button_container_->visible());
EXPECT_FALSE(frame_view->UseImmersiveLightbarHeaderStyle());
revealed_lock.reset();
EXPECT_FALSE(immersive_mode_controller->IsRevealed());
EXPECT_FALSE(frame_view->ShouldPaint());
EXPECT_EQ(0, frame_view->header_painter_->GetHeaderHeightForPainting());
{
scoped_ptr<FullscreenNotificationObserver> waiter(
new FullscreenNotificationObserver());
browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
web_contents, false);
waiter->Wait();
}
revealed_lock.reset(immersive_mode_controller->GetRevealedLock(
ImmersiveModeController::ANIMATE_REVEAL_NO));
EXPECT_TRUE(immersive_mode_controller->IsRevealed());
EXPECT_TRUE(frame_view->ShouldPaint());
EXPECT_TRUE(frame_view->caption_button_container_->visible());
EXPECT_FALSE(frame_view->UseImmersiveLightbarHeaderStyle());
EXPECT_LT(Tab::GetImmersiveHeight(),
frame_view->header_painter_->GetHeaderHeightForPainting());
revealed_lock.reset();
EXPECT_TRUE(frame_view->ShouldPaint());
EXPECT_FALSE(frame_view->caption_button_container_->visible());
EXPECT_TRUE(frame_view->UseImmersiveLightbarHeaderStyle());
EXPECT_EQ(Tab::GetImmersiveHeight(),
frame_view->header_painter_->GetHeaderHeightForPainting());
{
scoped_ptr<FullscreenNotificationObserver> waiter(
new FullscreenNotificationObserver());
browser_view->ExitFullscreen();
waiter->Wait();
}
EXPECT_FALSE(immersive_mode_controller->IsEnabled());
EXPECT_TRUE(frame_view->ShouldPaint());
EXPECT_TRUE(frame_view->caption_button_container_->visible());
EXPECT_FALSE(frame_view->UseImmersiveLightbarHeaderStyle());
EXPECT_LT(Tab::GetImmersiveHeight(),
frame_view->header_painter_->GetHeaderHeightForPainting());
}
#endif
IN_PROC_BROWSER_TEST_F(BrowserNonClientFrameViewAshTest,
ToggleMaximizeModeRelayout) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
Widget* widget = browser_view->GetWidget();
BrowserNonClientFrameViewAsh* frame_view =
static_cast<BrowserNonClientFrameViewAsh*>(
widget->non_client_view()->frame_view());
const gfx::Rect initial = frame_view->caption_button_container_->bounds();
ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
const gfx::Rect during_maximize = frame_view->caption_button_container_->
bounds();
EXPECT_GT(initial.width(), during_maximize.width());
ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
const gfx::Rect after_restore = frame_view->caption_button_container_->
bounds();
EXPECT_EQ(initial, after_restore);
}