OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/aura/wm_window_aura.h" |
5 #include "ash/common/shell_window_ids.h" | 6 #include "ash/common/shell_window_ids.h" |
6 #include "ash/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm/wm_event.h" |
7 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
8 #include "ash/wm/window_state_aura.h" | 10 #include "ash/wm/window_state_aura.h" |
9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
11 #include "components/exo/buffer.h" | 13 #include "components/exo/buffer.h" |
12 #include "components/exo/display.h" | 14 #include "components/exo/display.h" |
13 #include "components/exo/shell_surface.h" | 15 #include "components/exo/shell_surface.h" |
14 #include "components/exo/sub_surface.h" | 16 #include "components/exo/sub_surface.h" |
15 #include "components/exo/surface.h" | 17 #include "components/exo/surface.h" |
16 #include "components/exo/test/exo_test_base.h" | 18 #include "components/exo/test/exo_test_base.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 602 |
601 // Restore the window and make sure the shadow is created, visible and | 603 // Restore the window and make sure the shadow is created, visible and |
602 // has the latest bounds. | 604 // has the latest bounds. |
603 widget->Restore(); | 605 widget->Restore(); |
604 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 606 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
605 ASSERT_TRUE(shadow); | 607 ASSERT_TRUE(shadow); |
606 EXPECT_TRUE(shadow->layer()->visible()); | 608 EXPECT_TRUE(shadow->layer()->visible()); |
607 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); | 609 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); |
608 } | 610 } |
609 | 611 |
| 612 TEST_F(ShellSurfaceTest, ToggleFullscreen) { |
| 613 gfx::Size buffer_size(256, 256); |
| 614 std::unique_ptr<Buffer> buffer( |
| 615 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 616 std::unique_ptr<Surface> surface(new Surface); |
| 617 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 618 |
| 619 surface->Attach(buffer.get()); |
| 620 surface->Commit(); |
| 621 EXPECT_EQ( |
| 622 buffer_size.ToString(), |
| 623 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
| 624 |
| 625 shell_surface->Maximize(); |
| 626 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 627 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| 628 |
| 629 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 630 ash::WmWindow* window = |
| 631 ash::WmWindowAura::Get(shell_surface->GetWidget()->GetNativeWindow()); |
| 632 |
| 633 // Enter fullscreen mode. |
| 634 window->GetWindowState()->OnWMEvent(&event); |
| 635 |
| 636 EXPECT_EQ(CurrentContext()->bounds().ToString(), |
| 637 shell_surface->GetWidget()->GetWindowBoundsInScreen().ToString()); |
| 638 |
| 639 // Leave fullscreen mode. |
| 640 window->GetWindowState()->OnWMEvent(&event); |
| 641 |
| 642 // Check that shell surface is maximized. |
| 643 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 644 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| 645 } |
| 646 |
610 } // namespace | 647 } // namespace |
611 } // namespace exo | 648 } // namespace exo |
OLD | NEW |