| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/accelerators/accelerator_commands.h" | 5 #include "ash/common/accelerators/accelerator_commands.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_commands_aura.h" | 7 #include "ash/accelerators/accelerator_commands_aura.h" |
| 8 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
| 9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/wm/window_state_aura.h" | 11 #include "ash/wm/window_state_aura.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/apps/app_browsertest_util.h" | 15 #include "chrome/browser/apps/app_browsertest_util.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_commands.h" | 17 #include "chrome/browser/ui/browser_commands.h" |
| 18 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "extensions/browser/app_window/app_window.h" | 22 #include "extensions/browser/app_window/app_window.h" |
| 23 #include "extensions/browser/app_window/native_app_window.h" | 23 #include "extensions/browser/app_window/native_app_window.h" |
| 24 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
| 25 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
| 26 #include "ui/views/widget/widget_delegate.h" | 27 #include "ui/views/widget/widget_delegate.h" |
| 27 | 28 |
| 28 using testing::Combine; | 29 using testing::Combine; |
| 29 using testing::Values; | 30 using testing::Values; |
| 30 using testing::WithParamInterface; | 31 using testing::WithParamInterface; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 // WidgetDelegateView which allows the widget to be maximized. | 35 // WidgetDelegateView which allows the widget to be maximized. |
| 35 class MaximizableWidgetDelegate : public views::WidgetDelegateView { | 36 class MaximizableWidgetDelegate : public views::WidgetDelegateView { |
| 36 public: | 37 public: |
| 37 MaximizableWidgetDelegate() { | 38 MaximizableWidgetDelegate() {} |
| 38 } | |
| 39 ~MaximizableWidgetDelegate() override {} | 39 ~MaximizableWidgetDelegate() override {} |
| 40 | 40 |
| 41 bool CanMaximize() const override { return true; } | 41 bool CanMaximize() const override { return true; } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(MaximizableWidgetDelegate); | 44 DISALLOW_COPY_AND_ASSIGN(MaximizableWidgetDelegate); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Returns true if |window_state|'s window is in immersive fullscreen. Infer | 47 // Returns true if |window_state|'s window is in immersive fullscreen. Infer |
| 48 // whether the window is in immersive fullscreen based on whether the shelf is | 48 // whether the window is in immersive fullscreen based on whether the shelf is |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ash::accelerators::ToggleFullscreen(); | 134 ash::accelerators::ToggleFullscreen(); |
| 135 EXPECT_TRUE(window_state->IsFullscreen()); | 135 EXPECT_TRUE(window_state->IsFullscreen()); |
| 136 EXPECT_TRUE(IsInImmersiveFullscreen(window_state)); | 136 EXPECT_TRUE(IsInImmersiveFullscreen(window_state)); |
| 137 | 137 |
| 138 ash::accelerators::ToggleFullscreen(); | 138 ash::accelerators::ToggleFullscreen(); |
| 139 EXPECT_TRUE(IsInitialShowState(window_state)); | 139 EXPECT_TRUE(IsInitialShowState(window_state)); |
| 140 | 140 |
| 141 // 2) ToggleFullscreen() should have no effect on windows which cannot be | 141 // 2) ToggleFullscreen() should have no effect on windows which cannot be |
| 142 // maximized. | 142 // maximized. |
| 143 ash::WmWindowAura::GetAuraWindow(window_state->window()) | 143 ash::WmWindowAura::GetAuraWindow(window_state->window()) |
| 144 ->SetProperty(aura::client::kCanMaximizeKey, false); | 144 ->SetProperty(aura::client::kResizeBehaviorKey, |
| 145 ui::mojom::kResizeBehaviorNone); |
| 145 ash::accelerators::ToggleFullscreen(); | 146 ash::accelerators::ToggleFullscreen(); |
| 146 EXPECT_TRUE(IsInitialShowState(window_state)); | 147 EXPECT_TRUE(IsInitialShowState(window_state)); |
| 147 | 148 |
| 148 // 3) Hosted apps. | 149 // 3) Hosted apps. |
| 149 Browser::CreateParams browser_create_params( | 150 Browser::CreateParams browser_create_params( |
| 150 Browser::CreateParams::CreateForApp("Test", true /* trusted_source */, | 151 Browser::CreateParams::CreateForApp("Test", true /* trusted_source */, |
| 151 gfx::Rect(), browser()->profile())); | 152 gfx::Rect(), browser()->profile())); |
| 152 | 153 |
| 153 Browser* app_host_browser = new Browser(browser_create_params); | 154 Browser* app_host_browser = new Browser(browser_create_params); |
| 154 ASSERT_TRUE(app_host_browser->is_app()); | 155 ASSERT_TRUE(app_host_browser->is_app()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 CloseAppWindow(app_window); | 307 CloseAppWindow(app_window); |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 | 310 |
| 310 INSTANTIATE_TEST_CASE_P(InitiallyRestored, | 311 INSTANTIATE_TEST_CASE_P(InitiallyRestored, |
| 311 AcceleratorCommandsPlatformAppFullscreenBrowserTest, | 312 AcceleratorCommandsPlatformAppFullscreenBrowserTest, |
| 312 Values(ui::SHOW_STATE_NORMAL)); | 313 Values(ui::SHOW_STATE_NORMAL)); |
| 313 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, | 314 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, |
| 314 AcceleratorCommandsPlatformAppFullscreenBrowserTest, | 315 AcceleratorCommandsPlatformAppFullscreenBrowserTest, |
| 315 Values(ui::SHOW_STATE_MAXIMIZED)); | 316 Values(ui::SHOW_STATE_MAXIMIZED)); |
| OLD | NEW |