Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/browser/ui/ash/accelerator_commands_browsertest.cc

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/accelerators/accelerator_commands.h" 5 #include "ash/accelerators/accelerator_commands.h"
6 6
7 #include "apps/app_window.h"
8 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
9 #include "ash/shell.h" 8 #include "ash/shell.h"
10 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "chrome/browser/apps/app_browsertest_util.h" 11 #include "chrome/browser/apps/app_browsertest_util.h"
13 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
18 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/test_switches.h" 18 #include "chrome/test/base/test_switches.h"
19 #include "extensions/browser/app_window/app_window.h"
20 #include "extensions/browser/app_window/native_app_window.h" 20 #include "extensions/browser/app_window/native_app_window.h"
21 #include "ui/aura/client/aura_constants.h" 21 #include "ui/aura/client/aura_constants.h"
22 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
23 #include "ui/views/widget/widget_delegate.h" 23 #include "ui/views/widget/widget_delegate.h"
24 24
25 using testing::Combine; 25 using testing::Combine;
26 using testing::Values; 26 using testing::Values;
27 using testing::WithParamInterface; 27 using testing::WithParamInterface;
28 28
29 namespace { 29 namespace {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 : public WithParamInterface<ui::WindowShowState>, 233 : public WithParamInterface<ui::WindowShowState>,
234 public extensions::PlatformAppBrowserTest { 234 public extensions::PlatformAppBrowserTest {
235 public: 235 public:
236 AcceleratorCommandsPlatformAppFullscreenBrowserTest() 236 AcceleratorCommandsPlatformAppFullscreenBrowserTest()
237 : initial_show_state_(GetParam()) { 237 : initial_show_state_(GetParam()) {
238 } 238 }
239 virtual ~AcceleratorCommandsPlatformAppFullscreenBrowserTest() { 239 virtual ~AcceleratorCommandsPlatformAppFullscreenBrowserTest() {
240 } 240 }
241 241
242 // Sets |app_window|'s show state to |initial_show_state_|. 242 // Sets |app_window|'s show state to |initial_show_state_|.
243 void SetToInitialShowState(apps::AppWindow* app_window) { 243 void SetToInitialShowState(extensions::AppWindow* app_window) {
244 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED) 244 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED)
245 app_window->Maximize(); 245 app_window->Maximize();
246 else 246 else
247 app_window->Restore(); 247 app_window->Restore();
248 } 248 }
249 249
250 // Returns true if |app_window|'s show state is |initial_show_state_|. 250 // Returns true if |app_window|'s show state is |initial_show_state_|.
251 bool IsInitialShowState(apps::AppWindow* app_window) const { 251 bool IsInitialShowState(extensions::AppWindow* app_window) const {
252 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED) 252 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED)
253 return app_window->GetBaseWindow()->IsMaximized(); 253 return app_window->GetBaseWindow()->IsMaximized();
254 else 254 else
255 return ui::BaseWindow::IsRestored(*app_window->GetBaseWindow()); 255 return ui::BaseWindow::IsRestored(*app_window->GetBaseWindow());
256 } 256 }
257 257
258 private: 258 private:
259 ui::WindowShowState initial_show_state_; 259 ui::WindowShowState initial_show_state_;
260 260
261 DISALLOW_COPY_AND_ASSIGN(AcceleratorCommandsPlatformAppFullscreenBrowserTest); 261 DISALLOW_COPY_AND_ASSIGN(AcceleratorCommandsPlatformAppFullscreenBrowserTest);
262 }; 262 };
263 263
264 // Test the behavior of platform apps when ToggleFullscreen() is called. 264 // Test the behavior of platform apps when ToggleFullscreen() is called.
265 IN_PROC_BROWSER_TEST_P(AcceleratorCommandsPlatformAppFullscreenBrowserTest, 265 IN_PROC_BROWSER_TEST_P(AcceleratorCommandsPlatformAppFullscreenBrowserTest,
266 ToggleFullscreen) { 266 ToggleFullscreen) {
267 #if defined(OS_WIN) 267 #if defined(OS_WIN)
268 // Run the test on Win Ash only. 268 // Run the test on Win Ash only.
269 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 269 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
270 return; 270 return;
271 #endif 271 #endif
272 272
273 ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance"; 273 ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance";
274 const extensions::Extension* extension = LoadAndLaunchPlatformApp("minimal", 274 const extensions::Extension* extension = LoadAndLaunchPlatformApp("minimal",
275 "Launched"); 275 "Launched");
276 276
277 { 277 {
278 // Test that ToggleFullscreen() toggles a platform's app's fullscreen 278 // Test that ToggleFullscreen() toggles a platform's app's fullscreen
279 // state and that it additionally puts the app into immersive fullscreen 279 // state and that it additionally puts the app into immersive fullscreen
280 // if put_all_windows_in_immersive() returns true. 280 // if put_all_windows_in_immersive() returns true.
281 apps::AppWindow::CreateParams params; 281 extensions::AppWindow::CreateParams params;
282 params.frame = apps::AppWindow::FRAME_CHROME; 282 params.frame = extensions::AppWindow::FRAME_CHROME;
283 apps::AppWindow* app_window = CreateAppWindowFromParams(extension, params); 283 extensions::AppWindow* app_window =
284 CreateAppWindowFromParams(extension, params);
284 extensions::NativeAppWindow* native_app_window = 285 extensions::NativeAppWindow* native_app_window =
285 app_window->GetBaseWindow(); 286 app_window->GetBaseWindow();
286 SetToInitialShowState(app_window); 287 SetToInitialShowState(app_window);
287 ASSERT_TRUE(app_window->GetBaseWindow()->IsActive()); 288 ASSERT_TRUE(app_window->GetBaseWindow()->IsActive());
288 EXPECT_TRUE(IsInitialShowState(app_window)); 289 EXPECT_TRUE(IsInitialShowState(app_window));
289 290
290 ash::accelerators::ToggleFullscreen(); 291 ash::accelerators::ToggleFullscreen();
291 EXPECT_TRUE(native_app_window->IsFullscreen()); 292 EXPECT_TRUE(native_app_window->IsFullscreen());
292 ash::wm::WindowState* window_state = 293 ash::wm::WindowState* window_state =
293 ash::wm::GetWindowState(native_app_window->GetNativeWindow()); 294 ash::wm::GetWindowState(native_app_window->GetNativeWindow());
294 EXPECT_TRUE(IsInImmersiveFullscreen(window_state)); 295 EXPECT_TRUE(IsInImmersiveFullscreen(window_state));
295 296
296 ash::accelerators::ToggleFullscreen(); 297 ash::accelerators::ToggleFullscreen();
297 EXPECT_TRUE(IsInitialShowState(app_window)); 298 EXPECT_TRUE(IsInitialShowState(app_window));
298 299
299 CloseAppWindow(app_window); 300 CloseAppWindow(app_window);
300 } 301 }
301 302
302 { 303 {
303 // Repeat the test, but make sure that frameless platform apps are never put 304 // Repeat the test, but make sure that frameless platform apps are never put
304 // into immersive fullscreen. 305 // into immersive fullscreen.
305 apps::AppWindow::CreateParams params; 306 extensions::AppWindow::CreateParams params;
306 params.frame = apps::AppWindow::FRAME_NONE; 307 params.frame = extensions::AppWindow::FRAME_NONE;
307 apps::AppWindow* app_window = CreateAppWindowFromParams(extension, params); 308 extensions::AppWindow* app_window =
309 CreateAppWindowFromParams(extension, params);
308 extensions::NativeAppWindow* native_app_window = 310 extensions::NativeAppWindow* native_app_window =
309 app_window->GetBaseWindow(); 311 app_window->GetBaseWindow();
310 ASSERT_TRUE(app_window->GetBaseWindow()->IsActive()); 312 ASSERT_TRUE(app_window->GetBaseWindow()->IsActive());
311 SetToInitialShowState(app_window); 313 SetToInitialShowState(app_window);
312 EXPECT_TRUE(IsInitialShowState(app_window)); 314 EXPECT_TRUE(IsInitialShowState(app_window));
313 315
314 ash::accelerators::ToggleFullscreen(); 316 ash::accelerators::ToggleFullscreen();
315 EXPECT_TRUE(native_app_window->IsFullscreen()); 317 EXPECT_TRUE(native_app_window->IsFullscreen());
316 ash::wm::WindowState* window_state = 318 ash::wm::WindowState* window_state =
317 ash::wm::GetWindowState(native_app_window->GetNativeWindow()); 319 ash::wm::GetWindowState(native_app_window->GetNativeWindow());
318 EXPECT_FALSE(IsInImmersiveFullscreen(window_state)); 320 EXPECT_FALSE(IsInImmersiveFullscreen(window_state));
319 321
320 ash::accelerators::ToggleFullscreen(); 322 ash::accelerators::ToggleFullscreen();
321 EXPECT_TRUE(IsInitialShowState(app_window)); 323 EXPECT_TRUE(IsInitialShowState(app_window));
322 324
323 CloseAppWindow(app_window); 325 CloseAppWindow(app_window);
324 } 326 }
325 } 327 }
326 328
327 INSTANTIATE_TEST_CASE_P(InitiallyRestored, 329 INSTANTIATE_TEST_CASE_P(InitiallyRestored,
328 AcceleratorCommandsPlatformAppFullscreenBrowserTest, 330 AcceleratorCommandsPlatformAppFullscreenBrowserTest,
329 Values(ui::SHOW_STATE_NORMAL)); 331 Values(ui::SHOW_STATE_NORMAL));
330 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, 332 INSTANTIATE_TEST_CASE_P(InitiallyMaximized,
331 AcceleratorCommandsPlatformAppFullscreenBrowserTest, 333 AcceleratorCommandsPlatformAppFullscreenBrowserTest,
332 Values(ui::SHOW_STATE_MAXIMIZED)); 334 Values(ui::SHOW_STATE_MAXIMIZED));
OLDNEW
« no previous file with comments | « chrome/browser/ui/apps/chrome_apps_client.cc ('k') | chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698