ash: Add test for maximized app window frame switching

When app windows are maximized the normal window frame is replaced with a
special AppNonClientFrameViewAura. This adds a test for frame replacement
on maximize, restore and minimize.

BUG=156093
TEST=added test to browser_test AppNonClientFrameViewAuraTest


Review URL: https://chromiumcodereview.appspot.com/11192004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162382 0039d316-1c4b-4281-b951-d872f2087c98
parent eaafeb2a
...@@ -162,6 +162,9 @@ class AppNonClientFrameViewAura::FrameObserver : public views::WidgetObserver { ...@@ -162,6 +162,9 @@ class AppNonClientFrameViewAura::FrameObserver : public views::WidgetObserver {
DISALLOW_COPY_AND_ASSIGN(FrameObserver); DISALLOW_COPY_AND_ASSIGN(FrameObserver);
}; };
// static
const char AppNonClientFrameViewAura::kViewClassName[] =
"AppNonClientFrameViewAura";
// static // static
const char AppNonClientFrameViewAura::kControlWindowName[] = const char AppNonClientFrameViewAura::kControlWindowName[] =
"AppNonClientFrameViewAuraControls"; "AppNonClientFrameViewAuraControls";
...@@ -243,6 +246,10 @@ int AppNonClientFrameViewAura::GetThemeBackgroundXInset() const { ...@@ -243,6 +246,10 @@ int AppNonClientFrameViewAura::GetThemeBackgroundXInset() const {
void AppNonClientFrameViewAura::UpdateThrobber(bool running) { void AppNonClientFrameViewAura::UpdateThrobber(bool running) {
} }
std::string AppNonClientFrameViewAura::GetClassName() const {
return kViewClassName;
}
void AppNonClientFrameViewAura::OnBoundsChanged( void AppNonClientFrameViewAura::OnBoundsChanged(
const gfx::Rect& previous_bounds) { const gfx::Rect& previous_bounds) {
if (control_widget_) if (control_widget_)
......
...@@ -15,6 +15,7 @@ class Window; ...@@ -15,6 +15,7 @@ class Window;
// NonClientFrameViewAura implementation for apps. // NonClientFrameViewAura implementation for apps.
class AppNonClientFrameViewAura : public BrowserNonClientFrameView { class AppNonClientFrameViewAura : public BrowserNonClientFrameView {
public: public:
static const char kViewClassName[]; // visible for test
static const char kControlWindowName[]; // visible for test static const char kControlWindowName[]; // visible for test
AppNonClientFrameViewAura( AppNonClientFrameViewAura(
...@@ -41,6 +42,7 @@ class AppNonClientFrameViewAura : public BrowserNonClientFrameView { ...@@ -41,6 +42,7 @@ class AppNonClientFrameViewAura : public BrowserNonClientFrameView {
virtual void UpdateThrobber(bool running) OVERRIDE; virtual void UpdateThrobber(bool running) OVERRIDE;
// View: // View:
virtual std::string GetClassName() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
private: private:
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h"
#include "chrome/browser/ui/views/frame/app_non_client_frame_view_aura.h" #include "chrome/browser/ui/views/frame/app_non_client_frame_view_aura.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
...@@ -43,6 +44,10 @@ void MinimizeWindow(aura::Window* window) { ...@@ -43,6 +44,10 @@ void MinimizeWindow(aura::Window* window) {
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
} }
void RestoreWindow(Window* window) {
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
}
} // namespace } // namespace
class AppNonClientFrameViewAuraTest : public InProcessBrowserTest { class AppNonClientFrameViewAuraTest : public InProcessBrowserTest {
...@@ -64,11 +69,12 @@ class AppNonClientFrameViewAuraTest : public InProcessBrowserTest { ...@@ -64,11 +69,12 @@ class AppNonClientFrameViewAuraTest : public InProcessBrowserTest {
app_browser_->window()->Show(); app_browser_->window()->Show();
} }
AppNonClientFrameViewAura* GetAppFrameView() const { // Returns the class name of the NonClientFrameView.
std::string GetFrameClassName() const {
BrowserView* browser_view = BrowserView* browser_view =
static_cast<BrowserView*>(app_browser_->window()); static_cast<BrowserView*>(app_browser_->window());
BrowserFrame* frame = browser_view->frame(); BrowserFrame* browser_frame = browser_view->frame();
return static_cast<AppNonClientFrameViewAura*>(frame->GetFrameView()); return browser_frame->GetFrameView()->GetClassName();
} }
aura::RootWindow* GetRootWindow() const { aura::RootWindow* GetRootWindow() const {
...@@ -86,6 +92,39 @@ class AppNonClientFrameViewAuraTest : public InProcessBrowserTest { ...@@ -86,6 +92,39 @@ class AppNonClientFrameViewAuraTest : public InProcessBrowserTest {
Browser *app_browser_; Browser *app_browser_;
}; };
// Ensure that restoring the app window replaces the frame with a normal one,
// and maximizing again brings back the app frame. This has been the source of
// some crash bugs like crbug.com/155634
IN_PROC_BROWSER_TEST_F(AppNonClientFrameViewAuraTest, SwitchFrames) {
// We start with the app frame.
EXPECT_EQ(AppNonClientFrameViewAura::kViewClassName, GetFrameClassName());
// Restoring the window gives us the normal frame.
Window* native_window = app_browser()->window()->GetNativeWindow();
RestoreWindow(native_window);
EXPECT_EQ(BrowserNonClientFrameViewAsh::kViewClassName, GetFrameClassName());
// Maximizing the window switches back to the app frame.
MaximizeWindow(native_window);
EXPECT_EQ(AppNonClientFrameViewAura::kViewClassName, GetFrameClassName());
// Minimizing the window switches to normal frame.
// TODO(jamescook): This seems wasteful, since the user is likely to bring
// the window back to the maximized state.
MinimizeWindow(native_window);
EXPECT_EQ(BrowserNonClientFrameViewAsh::kViewClassName, GetFrameClassName());
// Coming back to maximized switches to app frame.
MaximizeWindow(native_window);
EXPECT_EQ(AppNonClientFrameViewAura::kViewClassName, GetFrameClassName());
// One more restore/maximize cycle for good measure.
RestoreWindow(native_window);
EXPECT_EQ(BrowserNonClientFrameViewAsh::kViewClassName, GetFrameClassName());
MaximizeWindow(native_window);
EXPECT_EQ(AppNonClientFrameViewAura::kViewClassName, GetFrameClassName());
}
// Ensure that we can click the close button when the controls are shown. // Ensure that we can click the close button when the controls are shown.
// In particular make sure that we can click it on the top pixel of the button. // In particular make sure that we can click it on the top pixel of the button.
IN_PROC_BROWSER_TEST_F(AppNonClientFrameViewAuraTest, ClickClose) { IN_PROC_BROWSER_TEST_F(AppNonClientFrameViewAuraTest, ClickClose) {
......
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