| 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 "components/exo/shell_surface.h" | 5 #include "components/exo/shell_surface.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/public/cpp/shell_window_ids.h" | 8 #include "ash/public/cpp/shell_window_ids.h" |
| 9 #include "ash/public/cpp/window_properties.h" | 9 #include "ash/public/cpp/window_properties.h" |
| 10 #include "ash/public/interfaces/window_pin_type.mojom.h" | 10 #include "ash/public/interfaces/window_pin_type.mojom.h" |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 | 825 |
| 826 // Sending a shadow bounds in maximized state won't create a shaodw. | 826 // Sending a shadow bounds in maximized state won't create a shaodw. |
| 827 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); | 827 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); |
| 828 surface->Commit(); | 828 surface->Commit(); |
| 829 | 829 |
| 830 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 830 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 831 // Underlay should be created even without shadow. | 831 // Underlay should be created even without shadow. |
| 832 ASSERT_TRUE(shell_surface->shadow_underlay()); | 832 ASSERT_TRUE(shell_surface->shadow_underlay()); |
| 833 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 833 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 834 | 834 |
| 835 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(0, 0, 0, 0)); |
| 836 // Underlay should be created even without shadow. |
| 837 ASSERT_TRUE(shell_surface->shadow_underlay()); |
| 838 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 839 shell_surface->SetRectangularShadowEnabled(false); |
| 840 surface->Commit(); |
| 841 // Underlay should be created even without shadow. |
| 842 ASSERT_TRUE(shell_surface->shadow_underlay()); |
| 843 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 844 |
| 845 shell_surface->SetRectangularShadowEnabled(true); |
| 846 shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100)); |
| 847 surface->Commit(); |
| 848 |
| 835 // Restore the window and make sure the shadow is created, visible and | 849 // Restore the window and make sure the shadow is created, visible and |
| 836 // has the latest bounds. | 850 // has the latest bounds. |
| 837 widget->Restore(); | 851 widget->Restore(); |
| 838 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 852 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 839 ASSERT_TRUE(shadow); | 853 ASSERT_TRUE(shadow); |
| 840 EXPECT_TRUE(shadow->layer()->visible()); | 854 EXPECT_TRUE(shadow->layer()->visible()); |
| 841 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); | 855 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); |
| 842 } | 856 } |
| 843 | 857 |
| 844 TEST_F(ShellSurfaceTest, ToggleFullscreen) { | 858 TEST_F(ShellSurfaceTest, ToggleFullscreen) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 ash::Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 1021 ash::Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
| 1008 ash::A11Y_NOTIFICATION_NONE); | 1022 ash::A11Y_NOTIFICATION_NONE); |
| 1009 shell_surface.OnAccessibilityModeChanged(); | 1023 shell_surface.OnAccessibilityModeChanged(); |
| 1010 shell_surface2.OnAccessibilityModeChanged(); | 1024 shell_surface2.OnAccessibilityModeChanged(); |
| 1011 | 1025 |
| 1012 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 1026 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 1013 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 1027 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 1014 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); | 1028 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); |
| 1015 } | 1029 } |
| 1016 | 1030 |
| 1031 // Make sure that a surface shell started in maximize creates deprecated |
| 1032 // shadow correctly. |
| 1033 TEST_F(ShellSurfaceTest, |
| 1034 StartMaximizedThenMinimizeWithSetRectangularShadow_DEPRECATED) { |
| 1035 const gfx::Size display_size = |
| 1036 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 1037 const gfx::Size buffer_size(display_size); |
| 1038 std::unique_ptr<Buffer> buffer( |
| 1039 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 1040 std::unique_ptr<Surface> surface(new Surface); |
| 1041 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface( |
| 1042 surface.get(), nullptr, ShellSurface::BoundsMode::CLIENT, gfx::Point(), |
| 1043 true, false, ash::kShellWindowId_DefaultContainer)); |
| 1044 |
| 1045 // Start in maximized. |
| 1046 shell_surface->Maximize(); |
| 1047 surface->Attach(buffer.get()); |
| 1048 surface->Commit(); |
| 1049 |
| 1050 gfx::Rect shadow_bounds = |
| 1051 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 1052 shell_surface->SetGeometry(shadow_bounds); |
| 1053 shell_surface->SetRectangularShadow_DEPRECATED(shadow_bounds); |
| 1054 surface->Commit(); |
| 1055 EXPECT_EQ(shadow_bounds, |
| 1056 shell_surface->GetWidget()->GetWindowBoundsInScreen()); |
| 1057 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 1058 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().size(), |
| 1059 shell_surface->surface_for_testing()->window()->bounds().size()); |
| 1060 |
| 1061 ash::wm::WMEvent minimize_event(ash::wm::WM_EVENT_MINIMIZE); |
| 1062 ash::WmWindow* window = |
| 1063 ash::WmWindow::Get(shell_surface->GetWidget()->GetNativeWindow()); |
| 1064 window->GetWindowState()->OnWMEvent(&minimize_event); |
| 1065 } |
| 1066 |
| 1017 } // namespace | 1067 } // namespace |
| 1018 } // namespace exo | 1068 } // namespace exo |
| OLD | NEW |