| 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 #include "ash/common/accessibility_delegate.h" | 6 #include "ash/common/accessibility_delegate.h" |
| 7 #include "ash/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm/wm_event.h" | 8 #include "ash/common/wm/wm_event.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| 11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
| 12 #include "ash/public/cpp/window_properties.h" |
| 13 #include "ash/public/interfaces/window_pin_type.mojom.h" |
| 12 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 13 #include "ash/wm/window_state_aura.h" | 15 #include "ash/wm/window_state_aura.h" |
| 14 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 16 #include "components/exo/buffer.h" | 18 #include "components/exo/buffer.h" |
| 17 #include "components/exo/display.h" | 19 #include "components/exo/display.h" |
| 18 #include "components/exo/sub_surface.h" | 20 #include "components/exo/sub_surface.h" |
| 19 #include "components/exo/surface.h" | 21 #include "components/exo/surface.h" |
| 20 #include "components/exo/test/exo_test_base.h" | 22 #include "components/exo/test/exo_test_base.h" |
| 21 #include "components/exo/test/exo_test_helper.h" | 23 #include "components/exo/test/exo_test_helper.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 bool activated, | 47 bool activated, |
| 46 const gfx::Vector2d& origin_offset) { | 48 const gfx::Vector2d& origin_offset) { |
| 47 EXPECT_EQ(ash::wm::WINDOW_STATE_TYPE_FULLSCREEN, state_type); | 49 EXPECT_EQ(ash::wm::WINDOW_STATE_TYPE_FULLSCREEN, state_type); |
| 48 return serial; | 50 return serial; |
| 49 } | 51 } |
| 50 | 52 |
| 51 wm::ShadowElevation GetShadowElevation(aura::Window* window) { | 53 wm::ShadowElevation GetShadowElevation(aura::Window* window) { |
| 52 return window->GetProperty(wm::kShadowElevationKey); | 54 return window->GetProperty(wm::kShadowElevationKey); |
| 53 } | 55 } |
| 54 | 56 |
| 57 bool IsWidgetPinned(views::Widget* widget) { |
| 58 ash::mojom::WindowPinType type = |
| 59 widget->GetNativeWindow()->GetProperty(ash::kWindowPinTypeKey); |
| 60 return type == ash::mojom::WindowPinType::PINNED || |
| 61 type == ash::mojom::WindowPinType::TRUSTED_PINNED; |
| 62 } |
| 63 |
| 55 TEST_F(ShellSurfaceTest, AcknowledgeConfigure) { | 64 TEST_F(ShellSurfaceTest, AcknowledgeConfigure) { |
| 56 gfx::Size buffer_size(32, 32); | 65 gfx::Size buffer_size(32, 32); |
| 57 std::unique_ptr<Buffer> buffer( | 66 std::unique_ptr<Buffer> buffer( |
| 58 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 67 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 59 std::unique_ptr<Surface> surface(new Surface); | 68 std::unique_ptr<Surface> surface(new Surface); |
| 60 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 69 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 61 | 70 |
| 62 surface->Attach(buffer.get()); | 71 surface->Attach(buffer.get()); |
| 63 surface->Commit(); | 72 surface->Commit(); |
| 64 | 73 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 shell_surface->GetWidget()->GetWindowBoundsInScreen().ToString()); | 188 shell_surface->GetWidget()->GetWindowBoundsInScreen().ToString()); |
| 180 } | 189 } |
| 181 | 190 |
| 182 TEST_F(ShellSurfaceTest, SetPinned) { | 191 TEST_F(ShellSurfaceTest, SetPinned) { |
| 183 gfx::Size buffer_size(256, 256); | 192 gfx::Size buffer_size(256, 256); |
| 184 std::unique_ptr<Buffer> buffer( | 193 std::unique_ptr<Buffer> buffer( |
| 185 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 194 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 186 std::unique_ptr<Surface> surface(new Surface); | 195 std::unique_ptr<Surface> surface(new Surface); |
| 187 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 196 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 188 | 197 |
| 189 shell_surface->SetPinned(true, /* trusted */ true); | 198 shell_surface->SetPinned(ash::mojom::WindowPinType::TRUSTED_PINNED); |
| 190 EXPECT_TRUE( | 199 EXPECT_TRUE(IsWidgetPinned(shell_surface->GetWidget())); |
| 191 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | |
| 192 ->IsPinned()); | |
| 193 | 200 |
| 194 shell_surface->SetPinned(false, /* trusted */ true); | 201 shell_surface->SetPinned(ash::mojom::WindowPinType::NONE); |
| 195 EXPECT_FALSE( | 202 EXPECT_FALSE(IsWidgetPinned(shell_surface->GetWidget())); |
| 196 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | |
| 197 ->IsPinned()); | |
| 198 | 203 |
| 199 shell_surface->SetPinned(true, /* trusted */ false); | 204 shell_surface->SetPinned(ash::mojom::WindowPinType::PINNED); |
| 200 EXPECT_TRUE( | 205 EXPECT_TRUE(IsWidgetPinned(shell_surface->GetWidget())); |
| 201 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | |
| 202 ->IsPinned()); | |
| 203 | 206 |
| 204 shell_surface->SetPinned(false, /* trusted */ false); | 207 shell_surface->SetPinned(ash::mojom::WindowPinType::NONE); |
| 205 EXPECT_FALSE( | 208 EXPECT_FALSE(IsWidgetPinned(shell_surface->GetWidget())); |
| 206 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | |
| 207 ->IsPinned()); | |
| 208 } | 209 } |
| 209 | 210 |
| 210 TEST_F(ShellSurfaceTest, SetSystemUiVisibility) { | 211 TEST_F(ShellSurfaceTest, SetSystemUiVisibility) { |
| 211 gfx::Size buffer_size(256, 256); | 212 gfx::Size buffer_size(256, 256); |
| 212 std::unique_ptr<Buffer> buffer( | 213 std::unique_ptr<Buffer> buffer( |
| 213 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 214 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 214 std::unique_ptr<Surface> surface(new Surface); | 215 std::unique_ptr<Surface> surface(new Surface); |
| 215 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 216 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 216 surface->Attach(buffer.get()); | 217 surface->Attach(buffer.get()); |
| 217 surface->Commit(); | 218 surface->Commit(); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 shell_surface.OnAccessibilityModeChanged(); | 1008 shell_surface.OnAccessibilityModeChanged(); |
| 1008 shell_surface2.OnAccessibilityModeChanged(); | 1009 shell_surface2.OnAccessibilityModeChanged(); |
| 1009 | 1010 |
| 1010 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 1011 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 1011 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 1012 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 1012 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); | 1013 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); |
| 1013 } | 1014 } |
| 1014 | 1015 |
| 1015 } // namespace | 1016 } // namespace |
| 1016 } // namespace exo | 1017 } // namespace exo |
| OLD | NEW |