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