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/accelerators/accelerator_commands.h" | 5 #include "ash/accelerators/accelerator_commands.h" |
6 | 6 |
7 #include "apps/shell_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/ui/native_app_window.h" | 8 #include "apps/ui/native_app_window.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/wm/window_state.h" | 11 #include "ash/wm/window_state.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "chrome/browser/apps/app_browsertest_util.h" | 13 #include "chrome/browser/apps/app_browsertest_util.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 #if defined(OS_CHROMEOS) | 281 #if defined(OS_CHROMEOS) |
282 : put_all_windows_in_immersive_(std::tr1::get<0>(GetParam())), | 282 : put_all_windows_in_immersive_(std::tr1::get<0>(GetParam())), |
283 #else | 283 #else |
284 : put_all_windows_in_immersive_(false), | 284 : put_all_windows_in_immersive_(false), |
285 #endif | 285 #endif |
286 initial_show_state_(std::tr1::get<1>(GetParam())) { | 286 initial_show_state_(std::tr1::get<1>(GetParam())) { |
287 } | 287 } |
288 virtual ~AcceleratorCommandsPlatformAppFullscreenBrowserTest() { | 288 virtual ~AcceleratorCommandsPlatformAppFullscreenBrowserTest() { |
289 } | 289 } |
290 | 290 |
291 // Sets |shell_window|'s show state to |initial_show_state_|. | 291 // Sets |app_window|'s show state to |initial_show_state_|. |
292 void SetToInitialShowState(apps::ShellWindow* shell_window) { | 292 void SetToInitialShowState(apps::AppWindow* app_window) { |
293 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED) | 293 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED) |
294 shell_window->Maximize(); | 294 app_window->Maximize(); |
295 else | 295 else |
296 shell_window->Restore(); | 296 app_window->Restore(); |
297 } | 297 } |
298 | 298 |
299 // Returns true if |shell_window|'s show state is |initial_show_state_|. | 299 // Returns true if |app_window|'s show state is |initial_show_state_|. |
300 bool IsInitialShowState(apps::ShellWindow* shell_window) const { | 300 bool IsInitialShowState(apps::AppWindow* app_window) const { |
301 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED) | 301 if (initial_show_state_ == ui::SHOW_STATE_MAXIMIZED) |
302 return shell_window->GetBaseWindow()->IsMaximized(); | 302 return app_window->GetBaseWindow()->IsMaximized(); |
303 else | 303 else |
304 return ui::BaseWindow::IsRestored(*shell_window->GetBaseWindow()); | 304 return ui::BaseWindow::IsRestored(*app_window->GetBaseWindow()); |
305 } | 305 } |
306 | 306 |
307 // content::BrowserTestBase override: | 307 // content::BrowserTestBase override: |
308 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 308 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
309 if (put_all_windows_in_immersive_) { | 309 if (put_all_windows_in_immersive_) { |
310 CommandLine::ForCurrentProcess()->AppendSwitch( | 310 CommandLine::ForCurrentProcess()->AppendSwitch( |
311 ash::switches::kAshEnableImmersiveFullscreenForAllWindows); | 311 ash::switches::kAshEnableImmersiveFullscreenForAllWindows); |
312 } else { | 312 } else { |
313 CommandLine::ForCurrentProcess()->AppendSwitch( | 313 CommandLine::ForCurrentProcess()->AppendSwitch( |
314 ash::switches::kAshEnableImmersiveFullscreenForBrowserOnly); | 314 ash::switches::kAshEnableImmersiveFullscreenForBrowserOnly); |
(...skipping 21 matching lines...) Expand all Loading... |
336 return; | 336 return; |
337 #endif | 337 #endif |
338 | 338 |
339 ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance"; | 339 ASSERT_TRUE(ash::Shell::HasInstance()) << "No Instance"; |
340 const extensions::Extension* extension = LoadAndLaunchPlatformApp("minimal"); | 340 const extensions::Extension* extension = LoadAndLaunchPlatformApp("minimal"); |
341 | 341 |
342 { | 342 { |
343 // Test that ToggleFullscreen() toggles a platform's app's fullscreen | 343 // Test that ToggleFullscreen() toggles a platform's app's fullscreen |
344 // state and that it additionally puts the app into immersive fullscreen | 344 // state and that it additionally puts the app into immersive fullscreen |
345 // if put_all_windows_in_immersive() returns true. | 345 // if put_all_windows_in_immersive() returns true. |
346 apps::ShellWindow::CreateParams params; | 346 apps::AppWindow::CreateParams params; |
347 params.frame = apps::ShellWindow::FRAME_CHROME; | 347 params.frame = apps::AppWindow::FRAME_CHROME; |
348 apps::ShellWindow* shell_window = CreateShellWindowFromParams( | 348 apps::AppWindow* app_window = CreateAppWindowFromParams(extension, params); |
349 extension, params); | 349 apps::NativeAppWindow* native_app_window = app_window->GetBaseWindow(); |
350 apps::NativeAppWindow* app_window = shell_window->GetBaseWindow(); | 350 SetToInitialShowState(app_window); |
351 SetToInitialShowState(shell_window); | 351 ASSERT_TRUE(app_window->GetBaseWindow()->IsActive()); |
352 ASSERT_TRUE(shell_window->GetBaseWindow()->IsActive()); | 352 EXPECT_TRUE(IsInitialShowState(app_window)); |
353 EXPECT_TRUE(IsInitialShowState(shell_window)); | |
354 | 353 |
355 ash::accelerators::ToggleFullscreen(); | 354 ash::accelerators::ToggleFullscreen(); |
356 EXPECT_TRUE(app_window->IsFullscreen()); | 355 EXPECT_TRUE(native_app_window->IsFullscreen()); |
357 ash::wm::WindowState* window_state = | 356 ash::wm::WindowState* window_state = |
358 ash::wm::GetWindowState(app_window->GetNativeWindow()); | 357 ash::wm::GetWindowState(native_app_window->GetNativeWindow()); |
359 EXPECT_EQ(put_all_windows_in_immersive(), | 358 EXPECT_EQ(put_all_windows_in_immersive(), |
360 IsInImmersiveFullscreen(window_state)); | 359 IsInImmersiveFullscreen(window_state)); |
361 | 360 |
362 ash::accelerators::ToggleFullscreen(); | 361 ash::accelerators::ToggleFullscreen(); |
363 EXPECT_TRUE(IsInitialShowState(shell_window)); | 362 EXPECT_TRUE(IsInitialShowState(app_window)); |
364 | 363 |
365 CloseShellWindow(shell_window); | 364 CloseAppWindow(app_window); |
366 } | 365 } |
367 | 366 |
368 { | 367 { |
369 // Repeat the test, but make sure that frameless platform apps are never put | 368 // Repeat the test, but make sure that frameless platform apps are never put |
370 // into immersive fullscreen. | 369 // into immersive fullscreen. |
371 apps::ShellWindow::CreateParams params; | 370 apps::AppWindow::CreateParams params; |
372 params.frame = apps::ShellWindow::FRAME_NONE; | 371 params.frame = apps::AppWindow::FRAME_NONE; |
373 apps::ShellWindow* shell_window = CreateShellWindowFromParams( | 372 apps::AppWindow* app_window = CreateAppWindowFromParams(extension, params); |
374 extension, params); | 373 apps::NativeAppWindow* native_app_window = app_window->GetBaseWindow(); |
375 apps::NativeAppWindow* app_window = shell_window->GetBaseWindow(); | 374 ASSERT_TRUE(app_window->GetBaseWindow()->IsActive()); |
376 ASSERT_TRUE(shell_window->GetBaseWindow()->IsActive()); | 375 SetToInitialShowState(app_window); |
377 SetToInitialShowState(shell_window); | 376 EXPECT_TRUE(IsInitialShowState(app_window)); |
378 EXPECT_TRUE(IsInitialShowState(shell_window)); | |
379 | 377 |
380 ash::accelerators::ToggleFullscreen(); | 378 ash::accelerators::ToggleFullscreen(); |
381 EXPECT_TRUE(app_window->IsFullscreen()); | 379 EXPECT_TRUE(native_app_window->IsFullscreen()); |
382 ash::wm::WindowState* window_state = | 380 ash::wm::WindowState* window_state = |
383 ash::wm::GetWindowState(app_window->GetNativeWindow()); | 381 ash::wm::GetWindowState(native_app_window->GetNativeWindow()); |
384 EXPECT_FALSE(IsInImmersiveFullscreen(window_state)); | 382 EXPECT_FALSE(IsInImmersiveFullscreen(window_state)); |
385 | 383 |
386 ash::accelerators::ToggleFullscreen(); | 384 ash::accelerators::ToggleFullscreen(); |
387 EXPECT_TRUE(IsInitialShowState(shell_window)); | 385 EXPECT_TRUE(IsInitialShowState(app_window)); |
388 | 386 |
389 CloseShellWindow(shell_window); | 387 CloseAppWindow(app_window); |
390 } | 388 } |
391 } | 389 } |
392 | 390 |
393 #if defined(OS_CHROMEOS) | 391 #if defined(OS_CHROMEOS) |
394 INSTANTIATE_TEST_CASE_P(InitiallyRestored, | 392 INSTANTIATE_TEST_CASE_P(InitiallyRestored, |
395 AcceleratorCommandsPlatformAppFullscreenBrowserTest, | 393 AcceleratorCommandsPlatformAppFullscreenBrowserTest, |
396 Combine(Values(false, true), | 394 Combine(Values(false, true), |
397 Values(ui::SHOW_STATE_NORMAL))); | 395 Values(ui::SHOW_STATE_NORMAL))); |
398 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, | 396 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, |
399 AcceleratorCommandsPlatformAppFullscreenBrowserTest, | 397 AcceleratorCommandsPlatformAppFullscreenBrowserTest, |
400 Combine(Values(false, true), | 398 Combine(Values(false, true), |
401 Values(ui::SHOW_STATE_MAXIMIZED))); | 399 Values(ui::SHOW_STATE_MAXIMIZED))); |
402 #else | 400 #else |
403 // The kAshEnableImmersiveFullscreenForAllWindows flag should have no effect on | 401 // The kAshEnableImmersiveFullscreenForAllWindows flag should have no effect on |
404 // Windows. Do not run the tests with and without the flag to spare some | 402 // Windows. Do not run the tests with and without the flag to spare some |
405 // cycles. | 403 // cycles. |
406 INSTANTIATE_TEST_CASE_P(InitiallyRestored, | 404 INSTANTIATE_TEST_CASE_P(InitiallyRestored, |
407 AcceleratorCommandsPlatformAppFullscreenBrowserTest, | 405 AcceleratorCommandsPlatformAppFullscreenBrowserTest, |
408 Combine(Values(false), | 406 Combine(Values(false), |
409 Values(ui::SHOW_STATE_NORMAL))); | 407 Values(ui::SHOW_STATE_NORMAL))); |
410 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, | 408 INSTANTIATE_TEST_CASE_P(InitiallyMaximized, |
411 AcceleratorCommandsPlatformAppFullscreenBrowserTest, | 409 AcceleratorCommandsPlatformAppFullscreenBrowserTest, |
412 Combine(Values(false), | 410 Combine(Values(false), |
413 Values(ui::SHOW_STATE_MAXIMIZED))); | 411 Values(ui::SHOW_STATE_MAXIMIZED))); |
414 #endif | 412 #endif |
OLD | NEW |