| 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/aura/wm_window_aura.h" |
| 6 #include "ash/common/accessibility_delegate.h" | 6 #include "ash/common/accessibility_delegate.h" |
| 7 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/common/wm/wm_event.h" | 9 #include "ash/common/wm/wm_event.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 bool resizing, | 43 bool resizing, |
| 44 bool activated) { | 44 bool activated) { |
| 45 EXPECT_EQ(ash::wm::WINDOW_STATE_TYPE_FULLSCREEN, state_type); | 45 EXPECT_EQ(ash::wm::WINDOW_STATE_TYPE_FULLSCREEN, state_type); |
| 46 return serial; | 46 return serial; |
| 47 } | 47 } |
| 48 | 48 |
| 49 TEST_F(ShellSurfaceTest, AcknowledgeConfigure) { | 49 TEST_F(ShellSurfaceTest, AcknowledgeConfigure) { |
| 50 gfx::Size buffer_size(32, 32); | 50 gfx::Size buffer_size(32, 32); |
| 51 std::unique_ptr<Buffer> buffer( | 51 std::unique_ptr<Buffer> buffer( |
| 52 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 52 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 53 const Display display; |
| 53 std::unique_ptr<Surface> surface(new Surface); | 54 std::unique_ptr<Surface> surface(new Surface); |
| 54 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 55 std::unique_ptr<ShellSurface> shell_surface( |
| 56 new ShellSurface(display, surface.get())); |
| 55 | 57 |
| 56 surface->Attach(buffer.get()); | 58 surface->Attach(buffer.get()); |
| 57 surface->Commit(); | 59 surface->Commit(); |
| 58 | 60 |
| 59 gfx::Point origin(100, 100); | 61 gfx::Point origin(100, 100); |
| 60 shell_surface->GetWidget()->SetBounds(gfx::Rect(origin, buffer_size)); | 62 shell_surface->GetWidget()->SetBounds(gfx::Rect(origin, buffer_size)); |
| 61 EXPECT_EQ(origin.ToString(), | 63 EXPECT_EQ(origin.ToString(), |
| 62 surface->window()->GetBoundsInRootWindow().origin().ToString()); | 64 surface->window()->GetBoundsInRootWindow().origin().ToString()); |
| 63 | 65 |
| 64 const uint32_t kSerial = 1; | 66 const uint32_t kSerial = 1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 surface->Commit(); | 80 surface->Commit(); |
| 79 | 81 |
| 80 EXPECT_EQ(gfx::Point().ToString(), | 82 EXPECT_EQ(gfx::Point().ToString(), |
| 81 surface->window()->GetBoundsInRootWindow().origin().ToString()); | 83 surface->window()->GetBoundsInRootWindow().origin().ToString()); |
| 82 } | 84 } |
| 83 | 85 |
| 84 TEST_F(ShellSurfaceTest, SetParent) { | 86 TEST_F(ShellSurfaceTest, SetParent) { |
| 85 gfx::Size buffer_size(256, 256); | 87 gfx::Size buffer_size(256, 256); |
| 86 std::unique_ptr<Buffer> parent_buffer( | 88 std::unique_ptr<Buffer> parent_buffer( |
| 87 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 89 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 90 const Display display; |
| 88 std::unique_ptr<Surface> parent_surface(new Surface); | 91 std::unique_ptr<Surface> parent_surface(new Surface); |
| 89 std::unique_ptr<ShellSurface> parent_shell_surface( | 92 std::unique_ptr<ShellSurface> parent_shell_surface( |
| 90 new ShellSurface(parent_surface.get())); | 93 new ShellSurface(display, parent_surface.get())); |
| 91 | 94 |
| 92 parent_surface->Attach(parent_buffer.get()); | 95 parent_surface->Attach(parent_buffer.get()); |
| 93 parent_surface->Commit(); | 96 parent_surface->Commit(); |
| 94 | 97 |
| 95 std::unique_ptr<Buffer> buffer( | 98 std::unique_ptr<Buffer> buffer( |
| 96 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 99 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 97 std::unique_ptr<Surface> surface(new Surface); | 100 std::unique_ptr<Surface> surface(new Surface); |
| 98 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 101 std::unique_ptr<ShellSurface> shell_surface( |
| 102 new ShellSurface(display, surface.get())); |
| 99 shell_surface->SetParent(parent_shell_surface.get()); | 103 shell_surface->SetParent(parent_shell_surface.get()); |
| 100 | 104 |
| 101 surface->Attach(buffer.get()); | 105 surface->Attach(buffer.get()); |
| 102 surface->Commit(); | 106 surface->Commit(); |
| 103 EXPECT_EQ( | 107 EXPECT_EQ( |
| 104 parent_shell_surface->GetWidget()->GetNativeWindow(), | 108 parent_shell_surface->GetWidget()->GetNativeWindow(), |
| 105 wm::GetTransientParent(shell_surface->GetWidget()->GetNativeWindow())); | 109 wm::GetTransientParent(shell_surface->GetWidget()->GetNativeWindow())); |
| 106 } | 110 } |
| 107 | 111 |
| 108 TEST_F(ShellSurfaceTest, Maximize) { | 112 TEST_F(ShellSurfaceTest, Maximize) { |
| 109 gfx::Size buffer_size(256, 256); | 113 gfx::Size buffer_size(256, 256); |
| 110 std::unique_ptr<Buffer> buffer( | 114 std::unique_ptr<Buffer> buffer( |
| 111 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 115 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 116 const Display display; |
| 112 std::unique_ptr<Surface> surface(new Surface); | 117 std::unique_ptr<Surface> surface(new Surface); |
| 113 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 118 std::unique_ptr<ShellSurface> shell_surface( |
| 119 new ShellSurface(display, surface.get())); |
| 114 | 120 |
| 115 surface->Attach(buffer.get()); | 121 surface->Attach(buffer.get()); |
| 116 shell_surface->Maximize(); | 122 shell_surface->Maximize(); |
| 117 surface->Commit(); | 123 surface->Commit(); |
| 118 EXPECT_EQ(CurrentContext()->bounds().width(), | 124 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 119 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); | 125 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| 120 } | 126 } |
| 121 | 127 |
| 122 TEST_F(ShellSurfaceTest, Minimize) { | 128 TEST_F(ShellSurfaceTest, Minimize) { |
| 123 gfx::Size buffer_size(256, 256); | 129 gfx::Size buffer_size(256, 256); |
| 124 std::unique_ptr<Buffer> buffer( | 130 std::unique_ptr<Buffer> buffer( |
| 125 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 131 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 132 const Display display; |
| 126 std::unique_ptr<Surface> surface(new Surface); | 133 std::unique_ptr<Surface> surface(new Surface); |
| 127 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 134 std::unique_ptr<ShellSurface> shell_surface( |
| 135 new ShellSurface(display, surface.get())); |
| 128 | 136 |
| 129 surface->Attach(buffer.get()); | 137 surface->Attach(buffer.get()); |
| 130 surface->Commit(); | 138 surface->Commit(); |
| 131 shell_surface->Minimize(); | 139 shell_surface->Minimize(); |
| 132 EXPECT_TRUE(shell_surface->GetWidget()->IsMinimized()); | 140 EXPECT_TRUE(shell_surface->GetWidget()->IsMinimized()); |
| 133 } | 141 } |
| 134 | 142 |
| 135 TEST_F(ShellSurfaceTest, Restore) { | 143 TEST_F(ShellSurfaceTest, Restore) { |
| 136 gfx::Size buffer_size(256, 256); | 144 gfx::Size buffer_size(256, 256); |
| 137 std::unique_ptr<Buffer> buffer( | 145 std::unique_ptr<Buffer> buffer( |
| 138 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 146 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 147 const Display display; |
| 139 std::unique_ptr<Surface> surface(new Surface); | 148 std::unique_ptr<Surface> surface(new Surface); |
| 140 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 149 std::unique_ptr<ShellSurface> shell_surface( |
| 150 new ShellSurface(display, surface.get())); |
| 141 | 151 |
| 142 surface->Attach(buffer.get()); | 152 surface->Attach(buffer.get()); |
| 143 surface->Commit(); | 153 surface->Commit(); |
| 144 // Note: Remove contents to avoid issues with maximize animations in tests. | 154 // Note: Remove contents to avoid issues with maximize animations in tests. |
| 145 shell_surface->Maximize(); | 155 shell_surface->Maximize(); |
| 146 shell_surface->Restore(); | 156 shell_surface->Restore(); |
| 147 EXPECT_EQ( | 157 EXPECT_EQ( |
| 148 buffer_size.ToString(), | 158 buffer_size.ToString(), |
| 149 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 159 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
| 150 } | 160 } |
| 151 | 161 |
| 152 TEST_F(ShellSurfaceTest, SetFullscreen) { | 162 TEST_F(ShellSurfaceTest, SetFullscreen) { |
| 153 gfx::Size buffer_size(256, 256); | 163 gfx::Size buffer_size(256, 256); |
| 154 std::unique_ptr<Buffer> buffer( | 164 std::unique_ptr<Buffer> buffer( |
| 155 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 165 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 166 const Display display; |
| 156 std::unique_ptr<Surface> surface(new Surface); | 167 std::unique_ptr<Surface> surface(new Surface); |
| 157 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 168 std::unique_ptr<ShellSurface> shell_surface( |
| 169 new ShellSurface(display, surface.get())); |
| 158 | 170 |
| 159 shell_surface->SetFullscreen(true); | 171 shell_surface->SetFullscreen(true); |
| 160 surface->Attach(buffer.get()); | 172 surface->Attach(buffer.get()); |
| 161 surface->Commit(); | 173 surface->Commit(); |
| 162 EXPECT_EQ(CurrentContext()->bounds().ToString(), | 174 EXPECT_EQ(CurrentContext()->bounds().ToString(), |
| 163 shell_surface->GetWidget()->GetWindowBoundsInScreen().ToString()); | 175 shell_surface->GetWidget()->GetWindowBoundsInScreen().ToString()); |
| 164 } | 176 } |
| 165 | 177 |
| 166 TEST_F(ShellSurfaceTest, SetPinned) { | 178 TEST_F(ShellSurfaceTest, SetPinned) { |
| 167 gfx::Size buffer_size(256, 256); | 179 gfx::Size buffer_size(256, 256); |
| 168 std::unique_ptr<Buffer> buffer( | 180 std::unique_ptr<Buffer> buffer( |
| 169 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 181 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 182 const Display display; |
| 170 std::unique_ptr<Surface> surface(new Surface); | 183 std::unique_ptr<Surface> surface(new Surface); |
| 171 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 184 std::unique_ptr<ShellSurface> shell_surface( |
| 185 new ShellSurface(display, surface.get())); |
| 172 | 186 |
| 173 shell_surface->SetPinned(true, /* trusted */ true); | 187 shell_surface->SetPinned(true, /* trusted */ true); |
| 174 EXPECT_TRUE( | 188 EXPECT_TRUE( |
| 175 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | 189 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) |
| 176 ->IsPinned()); | 190 ->IsPinned()); |
| 177 | 191 |
| 178 shell_surface->SetPinned(false, /* trusted */ true); | 192 shell_surface->SetPinned(false, /* trusted */ true); |
| 179 EXPECT_FALSE( | 193 EXPECT_FALSE( |
| 180 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | 194 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) |
| 181 ->IsPinned()); | 195 ->IsPinned()); |
| 182 | 196 |
| 183 shell_surface->SetPinned(true, /* trusted */ false); | 197 shell_surface->SetPinned(true, /* trusted */ false); |
| 184 EXPECT_TRUE( | 198 EXPECT_TRUE( |
| 185 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | 199 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) |
| 186 ->IsPinned()); | 200 ->IsPinned()); |
| 187 | 201 |
| 188 shell_surface->SetPinned(false, /* trusted */ false); | 202 shell_surface->SetPinned(false, /* trusted */ false); |
| 189 EXPECT_FALSE( | 203 EXPECT_FALSE( |
| 190 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) | 204 ash::wm::GetWindowState(shell_surface->GetWidget()->GetNativeWindow()) |
| 191 ->IsPinned()); | 205 ->IsPinned()); |
| 192 } | 206 } |
| 193 | 207 |
| 194 TEST_F(ShellSurfaceTest, SetTitle) { | 208 TEST_F(ShellSurfaceTest, SetTitle) { |
| 209 const Display display; |
| 195 std::unique_ptr<Surface> surface(new Surface); | 210 std::unique_ptr<Surface> surface(new Surface); |
| 196 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 211 std::unique_ptr<ShellSurface> shell_surface( |
| 212 new ShellSurface(display, surface.get())); |
| 197 | 213 |
| 198 shell_surface->SetTitle(base::string16(base::ASCIIToUTF16("test"))); | 214 shell_surface->SetTitle(base::string16(base::ASCIIToUTF16("test"))); |
| 199 surface->Commit(); | 215 surface->Commit(); |
| 200 } | 216 } |
| 201 | 217 |
| 202 TEST_F(ShellSurfaceTest, SetApplicationId) { | 218 TEST_F(ShellSurfaceTest, SetApplicationId) { |
| 219 const Display display; |
| 203 std::unique_ptr<Surface> surface(new Surface); | 220 std::unique_ptr<Surface> surface(new Surface); |
| 204 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 221 std::unique_ptr<ShellSurface> shell_surface( |
| 222 new ShellSurface(display, surface.get())); |
| 205 | 223 |
| 206 surface->Commit(); | 224 surface->Commit(); |
| 207 EXPECT_EQ("", ShellSurface::GetApplicationId( | 225 EXPECT_EQ("", ShellSurface::GetApplicationId( |
| 208 shell_surface->GetWidget()->GetNativeWindow())); | 226 shell_surface->GetWidget()->GetNativeWindow())); |
| 209 shell_surface->SetApplicationId("test"); | 227 shell_surface->SetApplicationId("test"); |
| 210 EXPECT_EQ("test", ShellSurface::GetApplicationId( | 228 EXPECT_EQ("test", ShellSurface::GetApplicationId( |
| 211 shell_surface->GetWidget()->GetNativeWindow())); | 229 shell_surface->GetWidget()->GetNativeWindow())); |
| 212 } | 230 } |
| 213 | 231 |
| 214 TEST_F(ShellSurfaceTest, Move) { | 232 TEST_F(ShellSurfaceTest, Move) { |
| 233 const Display display; |
| 215 std::unique_ptr<Surface> surface(new Surface); | 234 std::unique_ptr<Surface> surface(new Surface); |
| 216 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 235 std::unique_ptr<ShellSurface> shell_surface( |
| 236 new ShellSurface(display, surface.get())); |
| 217 | 237 |
| 218 // Map shell surface. | 238 // Map shell surface. |
| 219 surface->Commit(); | 239 surface->Commit(); |
| 220 | 240 |
| 221 // The interactive move should end when surface is destroyed. | 241 // The interactive move should end when surface is destroyed. |
| 222 shell_surface->Move(); | 242 shell_surface->Move(); |
| 223 | 243 |
| 224 // Test that destroying the shell surface before move ends is OK. | 244 // Test that destroying the shell surface before move ends is OK. |
| 225 shell_surface.reset(); | 245 shell_surface.reset(); |
| 226 } | 246 } |
| 227 | 247 |
| 228 TEST_F(ShellSurfaceTest, Resize) { | 248 TEST_F(ShellSurfaceTest, Resize) { |
| 249 const Display display; |
| 229 std::unique_ptr<Surface> surface(new Surface); | 250 std::unique_ptr<Surface> surface(new Surface); |
| 230 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 251 std::unique_ptr<ShellSurface> shell_surface( |
| 252 new ShellSurface(display, surface.get())); |
| 231 | 253 |
| 232 // Map shell surface. | 254 // Map shell surface. |
| 233 surface->Commit(); | 255 surface->Commit(); |
| 234 | 256 |
| 235 // The interactive resize should end when surface is destroyed. | 257 // The interactive resize should end when surface is destroyed. |
| 236 shell_surface->Resize(HTBOTTOMRIGHT); | 258 shell_surface->Resize(HTBOTTOMRIGHT); |
| 237 | 259 |
| 238 // Test that destroying the surface before resize ends is OK. | 260 // Test that destroying the surface before resize ends is OK. |
| 239 surface.reset(); | 261 surface.reset(); |
| 240 } | 262 } |
| 241 | 263 |
| 242 TEST_F(ShellSurfaceTest, SetGeometry) { | 264 TEST_F(ShellSurfaceTest, SetGeometry) { |
| 243 gfx::Size buffer_size(64, 64); | 265 gfx::Size buffer_size(64, 64); |
| 244 std::unique_ptr<Buffer> buffer( | 266 std::unique_ptr<Buffer> buffer( |
| 245 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 267 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 268 const Display display; |
| 246 std::unique_ptr<Surface> surface(new Surface); | 269 std::unique_ptr<Surface> surface(new Surface); |
| 247 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 270 std::unique_ptr<ShellSurface> shell_surface( |
| 271 new ShellSurface(display, surface.get())); |
| 248 | 272 |
| 249 gfx::Rect geometry(16, 16, 32, 32); | 273 gfx::Rect geometry(16, 16, 32, 32); |
| 250 shell_surface->SetGeometry(geometry); | 274 shell_surface->SetGeometry(geometry); |
| 251 surface->Attach(buffer.get()); | 275 surface->Attach(buffer.get()); |
| 252 surface->Commit(); | 276 surface->Commit(); |
| 253 EXPECT_EQ( | 277 EXPECT_EQ( |
| 254 geometry.size().ToString(), | 278 geometry.size().ToString(), |
| 255 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 279 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
| 256 EXPECT_EQ(gfx::Rect(gfx::Point() - geometry.OffsetFromOrigin(), buffer_size) | 280 EXPECT_EQ(gfx::Rect(gfx::Point() - geometry.OffsetFromOrigin(), buffer_size) |
| 257 .ToString(), | 281 .ToString(), |
| 258 surface->window()->bounds().ToString()); | 282 surface->window()->bounds().ToString()); |
| 259 } | 283 } |
| 260 | 284 |
| 261 TEST_F(ShellSurfaceTest, SetScale) { | 285 TEST_F(ShellSurfaceTest, SetScale) { |
| 262 gfx::Size buffer_size(64, 64); | 286 gfx::Size buffer_size(64, 64); |
| 263 std::unique_ptr<Buffer> buffer( | 287 std::unique_ptr<Buffer> buffer( |
| 264 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 288 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 289 const Display display; |
| 265 std::unique_ptr<Surface> surface(new Surface); | 290 std::unique_ptr<Surface> surface(new Surface); |
| 266 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 291 std::unique_ptr<ShellSurface> shell_surface( |
| 292 new ShellSurface(display, surface.get())); |
| 267 | 293 |
| 268 double scale = 1.5; | 294 double scale = 1.5; |
| 269 shell_surface->SetScale(scale); | 295 shell_surface->SetScale(scale); |
| 270 surface->Attach(buffer.get()); | 296 surface->Attach(buffer.get()); |
| 271 surface->Commit(); | 297 surface->Commit(); |
| 272 | 298 |
| 273 gfx::Transform transform; | 299 gfx::Transform transform; |
| 274 transform.Scale(1.0 / scale, 1.0 / scale); | 300 transform.Scale(1.0 / scale, 1.0 / scale); |
| 275 EXPECT_EQ(transform.ToString(), | 301 EXPECT_EQ(transform.ToString(), |
| 276 surface->window()->layer()->GetTargetTransform().ToString()); | 302 surface->window()->layer()->GetTargetTransform().ToString()); |
| 277 } | 303 } |
| 278 | 304 |
| 279 TEST_F(ShellSurfaceTest, SetTopInset) { | 305 TEST_F(ShellSurfaceTest, SetTopInset) { |
| 280 gfx::Size buffer_size(64, 64); | 306 gfx::Size buffer_size(64, 64); |
| 281 std::unique_ptr<Buffer> buffer( | 307 std::unique_ptr<Buffer> buffer( |
| 282 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 308 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 309 const Display display; |
| 283 std::unique_ptr<Surface> surface(new Surface); | 310 std::unique_ptr<Surface> surface(new Surface); |
| 284 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 311 std::unique_ptr<ShellSurface> shell_surface( |
| 312 new ShellSurface(display, surface.get())); |
| 285 | 313 |
| 286 surface->Attach(buffer.get()); | 314 surface->Attach(buffer.get()); |
| 287 surface->Commit(); | 315 surface->Commit(); |
| 288 | 316 |
| 289 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); | 317 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 290 ASSERT_TRUE(window); | 318 ASSERT_TRUE(window); |
| 291 EXPECT_EQ(0, window->GetProperty(aura::client::kTopViewInset)); | 319 EXPECT_EQ(0, window->GetProperty(aura::client::kTopViewInset)); |
| 292 int top_inset_height = 20; | 320 int top_inset_height = 20; |
| 293 shell_surface->SetTopInset(top_inset_height); | 321 shell_surface->SetTopInset(top_inset_height); |
| 294 surface->Commit(); | 322 surface->Commit(); |
| 295 EXPECT_EQ(top_inset_height, window->GetProperty(aura::client::kTopViewInset)); | 323 EXPECT_EQ(top_inset_height, window->GetProperty(aura::client::kTopViewInset)); |
| 296 } | 324 } |
| 297 | 325 |
| 298 void Close(int* close_call_count) { | 326 void Close(int* close_call_count) { |
| 299 (*close_call_count)++; | 327 (*close_call_count)++; |
| 300 } | 328 } |
| 301 | 329 |
| 302 TEST_F(ShellSurfaceTest, CloseCallback) { | 330 TEST_F(ShellSurfaceTest, CloseCallback) { |
| 331 const Display display; |
| 303 std::unique_ptr<Surface> surface(new Surface); | 332 std::unique_ptr<Surface> surface(new Surface); |
| 304 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 333 std::unique_ptr<ShellSurface> shell_surface( |
| 334 new ShellSurface(display, surface.get())); |
| 305 | 335 |
| 306 int close_call_count = 0; | 336 int close_call_count = 0; |
| 307 shell_surface->set_close_callback( | 337 shell_surface->set_close_callback( |
| 308 base::Bind(&Close, base::Unretained(&close_call_count))); | 338 base::Bind(&Close, base::Unretained(&close_call_count))); |
| 309 | 339 |
| 310 surface->Commit(); | 340 surface->Commit(); |
| 311 | 341 |
| 312 EXPECT_EQ(0, close_call_count); | 342 EXPECT_EQ(0, close_call_count); |
| 313 shell_surface->GetWidget()->Close(); | 343 shell_surface->GetWidget()->Close(); |
| 314 EXPECT_EQ(1, close_call_count); | 344 EXPECT_EQ(1, close_call_count); |
| 315 | 345 |
| 316 ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 346 ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 317 shell_surface->GetWidget()->OnKeyEvent(&event); | 347 shell_surface->GetWidget()->OnKeyEvent(&event); |
| 318 EXPECT_EQ(2, close_call_count); | 348 EXPECT_EQ(2, close_call_count); |
| 319 } | 349 } |
| 320 | 350 |
| 321 void DestroyShellSurface(std::unique_ptr<ShellSurface>* shell_surface) { | 351 void DestroyShellSurface(std::unique_ptr<ShellSurface>* shell_surface) { |
| 322 shell_surface->reset(); | 352 shell_surface->reset(); |
| 323 } | 353 } |
| 324 | 354 |
| 325 TEST_F(ShellSurfaceTest, SurfaceDestroyedCallback) { | 355 TEST_F(ShellSurfaceTest, SurfaceDestroyedCallback) { |
| 356 const Display display; |
| 326 std::unique_ptr<Surface> surface(new Surface); | 357 std::unique_ptr<Surface> surface(new Surface); |
| 327 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 358 std::unique_ptr<ShellSurface> shell_surface( |
| 359 new ShellSurface(display, surface.get())); |
| 328 | 360 |
| 329 shell_surface->set_surface_destroyed_callback( | 361 shell_surface->set_surface_destroyed_callback( |
| 330 base::Bind(&DestroyShellSurface, base::Unretained(&shell_surface))); | 362 base::Bind(&DestroyShellSurface, base::Unretained(&shell_surface))); |
| 331 | 363 |
| 332 surface->Commit(); | 364 surface->Commit(); |
| 333 | 365 |
| 334 EXPECT_TRUE(shell_surface.get()); | 366 EXPECT_TRUE(shell_surface.get()); |
| 335 surface.reset(); | 367 surface.reset(); |
| 336 EXPECT_FALSE(shell_surface.get()); | 368 EXPECT_FALSE(shell_surface.get()); |
| 337 } | 369 } |
| 338 | 370 |
| 339 uint32_t Configure(gfx::Size* suggested_size, | 371 uint32_t Configure(gfx::Size* suggested_size, |
| 340 ash::wm::WindowStateType* has_state_type, | 372 ash::wm::WindowStateType* has_state_type, |
| 341 bool* is_resizing, | 373 bool* is_resizing, |
| 342 bool* is_active, | 374 bool* is_active, |
| 343 const gfx::Size& size, | 375 const gfx::Size& size, |
| 344 ash::wm::WindowStateType state_type, | 376 ash::wm::WindowStateType state_type, |
| 345 bool resizing, | 377 bool resizing, |
| 346 bool activated) { | 378 bool activated) { |
| 347 *suggested_size = size; | 379 *suggested_size = size; |
| 348 *has_state_type = state_type; | 380 *has_state_type = state_type; |
| 349 *is_resizing = resizing; | 381 *is_resizing = resizing; |
| 350 *is_active = activated; | 382 *is_active = activated; |
| 351 return 0; | 383 return 0; |
| 352 } | 384 } |
| 353 | 385 |
| 354 TEST_F(ShellSurfaceTest, ConfigureCallback) { | 386 TEST_F(ShellSurfaceTest, ConfigureCallback) { |
| 387 const Display display; |
| 355 std::unique_ptr<Surface> surface(new Surface); | 388 std::unique_ptr<Surface> surface(new Surface); |
| 356 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 389 std::unique_ptr<ShellSurface> shell_surface( |
| 390 new ShellSurface(display, surface.get())); |
| 357 | 391 |
| 358 gfx::Size suggested_size; | 392 gfx::Size suggested_size; |
| 359 ash::wm::WindowStateType has_state_type = ash::wm::WINDOW_STATE_TYPE_NORMAL; | 393 ash::wm::WindowStateType has_state_type = ash::wm::WINDOW_STATE_TYPE_NORMAL; |
| 360 bool is_resizing = false; | 394 bool is_resizing = false; |
| 361 bool is_active = false; | 395 bool is_active = false; |
| 362 shell_surface->set_configure_callback( | 396 shell_surface->set_configure_callback( |
| 363 base::Bind(&Configure, base::Unretained(&suggested_size), | 397 base::Bind(&Configure, base::Unretained(&suggested_size), |
| 364 base::Unretained(&has_state_type), | 398 base::Unretained(&has_state_type), |
| 365 base::Unretained(&is_resizing), base::Unretained(&is_active))); | 399 base::Unretained(&is_resizing), base::Unretained(&is_active))); |
| 366 shell_surface->Maximize(); | 400 shell_surface->Maximize(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 390 shell_surface->AcknowledgeConfigure(0); | 424 shell_surface->AcknowledgeConfigure(0); |
| 391 EXPECT_FALSE(is_active); | 425 EXPECT_FALSE(is_active); |
| 392 | 426 |
| 393 EXPECT_FALSE(is_resizing); | 427 EXPECT_FALSE(is_resizing); |
| 394 shell_surface->Resize(HTBOTTOMRIGHT); | 428 shell_surface->Resize(HTBOTTOMRIGHT); |
| 395 shell_surface->AcknowledgeConfigure(0); | 429 shell_surface->AcknowledgeConfigure(0); |
| 396 EXPECT_TRUE(is_resizing); | 430 EXPECT_TRUE(is_resizing); |
| 397 } | 431 } |
| 398 | 432 |
| 399 TEST_F(ShellSurfaceTest, ModalWindow) { | 433 TEST_F(ShellSurfaceTest, ModalWindow) { |
| 434 Display display; |
| 400 std::unique_ptr<Surface> surface(new Surface); | 435 std::unique_ptr<Surface> surface(new Surface); |
| 401 std::unique_ptr<ShellSurface> shell_surface( | 436 std::unique_ptr<ShellSurface> shell_surface( |
| 402 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, | 437 new ShellSurface(display, surface.get(), nullptr, gfx::Rect(), true, |
| 403 ash::kShellWindowId_SystemModalContainer)); | 438 ash::kShellWindowId_SystemModalContainer)); |
| 404 gfx::Size desktop_size(640, 480); | 439 gfx::Size desktop_size(640, 480); |
| 405 std::unique_ptr<Buffer> desktop_buffer( | 440 std::unique_ptr<Buffer> desktop_buffer( |
| 406 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size))); | 441 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size))); |
| 407 surface->Attach(desktop_buffer.get()); | 442 surface->Attach(desktop_buffer.get()); |
| 408 surface->SetInputRegion(SkRegion()); | 443 surface->SetInputRegion(SkRegion()); |
| 409 surface->Commit(); | 444 surface->Commit(); |
| 410 | 445 |
| 411 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 446 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 412 | 447 |
| 413 // Creating a surface without input region should not make it modal. | 448 // Creating a surface without input region should not make it modal. |
| 414 std::unique_ptr<Display> display(new Display); | 449 std::unique_ptr<Surface> child = display.CreateSurface(); |
| 415 std::unique_ptr<Surface> child = display->CreateSurface(); | |
| 416 gfx::Size buffer_size(128, 128); | 450 gfx::Size buffer_size(128, 128); |
| 417 std::unique_ptr<Buffer> child_buffer( | 451 std::unique_ptr<Buffer> child_buffer( |
| 418 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 452 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 419 child->Attach(child_buffer.get()); | 453 child->Attach(child_buffer.get()); |
| 420 std::unique_ptr<SubSurface> sub_surface( | 454 std::unique_ptr<SubSurface> sub_surface( |
| 421 display->CreateSubSurface(child.get(), surface.get())); | 455 display.CreateSubSurface(child.get(), surface.get())); |
| 422 surface->SetSubSurfacePosition(child.get(), gfx::Point(10, 10)); | 456 surface->SetSubSurfacePosition(child.get(), gfx::Point(10, 10)); |
| 423 child->Commit(); | 457 child->Commit(); |
| 424 surface->Commit(); | 458 surface->Commit(); |
| 425 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 459 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 426 | 460 |
| 427 // Making the surface opaque shouldn't make it modal either. | 461 // Making the surface opaque shouldn't make it modal either. |
| 428 child->SetBlendMode(SkXfermode::kSrc_Mode); | 462 child->SetBlendMode(SkXfermode::kSrc_Mode); |
| 429 child->Commit(); | 463 child->Commit(); |
| 430 surface->Commit(); | 464 surface->Commit(); |
| 431 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 465 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 432 | 466 |
| 433 // Setting input regions won't make it modal either. | 467 // Setting input regions won't make it modal either. |
| 434 surface->SetInputRegion( | 468 surface->SetInputRegion( |
| 435 SkRegion(gfx::RectToSkIRect(gfx::Rect(10, 10, 100, 100)))); | 469 SkRegion(gfx::RectToSkIRect(gfx::Rect(10, 10, 100, 100)))); |
| 436 surface->Commit(); | 470 surface->Commit(); |
| 437 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 471 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 438 | 472 |
| 439 // Only SetSystemModal changes modality. | 473 // Only SetSystemModal changes modality. |
| 440 shell_surface->SetSystemModal(true); | 474 shell_surface->SetSystemModal(true); |
| 441 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 475 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 442 | 476 |
| 443 shell_surface->SetSystemModal(false); | 477 shell_surface->SetSystemModal(false); |
| 444 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 478 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 445 } | 479 } |
| 446 | 480 |
| 447 TEST_F(ShellSurfaceTest, Shadow) { | 481 TEST_F(ShellSurfaceTest, Shadow) { |
| 482 Display display; |
| 448 std::unique_ptr<Surface> surface(new Surface); | 483 std::unique_ptr<Surface> surface(new Surface); |
| 449 std::unique_ptr<ShellSurface> shell_surface( | 484 std::unique_ptr<ShellSurface> shell_surface( |
| 450 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, | 485 new ShellSurface(display, surface.get(), nullptr, gfx::Rect(), true, |
| 451 ash::kShellWindowId_DefaultContainer)); | 486 ash::kShellWindowId_DefaultContainer)); |
| 452 surface->Commit(); | 487 surface->Commit(); |
| 453 | 488 |
| 454 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); | 489 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 455 | 490 |
| 456 // 1) Initial state, no shadow. | 491 // 1) Initial state, no shadow. |
| 457 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 492 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 458 ASSERT_TRUE(shadow); | 493 ASSERT_TRUE(shadow); |
| 459 EXPECT_FALSE(shadow->layer()->visible()); | 494 EXPECT_FALSE(shadow->layer()->visible()); |
| 460 | 495 |
| 461 std::unique_ptr<Display> display(new Display); | |
| 462 | |
| 463 // 2) Just creating a sub surface won't create a shadow. | 496 // 2) Just creating a sub surface won't create a shadow. |
| 464 std::unique_ptr<Surface> child = display->CreateSurface(); | 497 std::unique_ptr<Surface> child = display.CreateSurface(); |
| 465 gfx::Size buffer_size(128, 128); | 498 gfx::Size buffer_size(128, 128); |
| 466 std::unique_ptr<Buffer> child_buffer( | 499 std::unique_ptr<Buffer> child_buffer( |
| 467 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 500 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 468 child->Attach(child_buffer.get()); | 501 child->Attach(child_buffer.get()); |
| 469 std::unique_ptr<SubSurface> sub_surface( | 502 std::unique_ptr<SubSurface> sub_surface( |
| 470 display->CreateSubSurface(child.get(), surface.get())); | 503 display.CreateSubSurface(child.get(), surface.get())); |
| 471 surface->Commit(); | 504 surface->Commit(); |
| 472 | 505 |
| 473 EXPECT_FALSE(shadow->layer()->visible()); | 506 EXPECT_FALSE(shadow->layer()->visible()); |
| 474 | 507 |
| 475 // 3) Create a shadow. | 508 // 3) Create a shadow. |
| 476 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); | 509 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); |
| 477 surface->Commit(); | 510 surface->Commit(); |
| 478 EXPECT_TRUE(shadow->layer()->visible()); | 511 EXPECT_TRUE(shadow->layer()->visible()); |
| 479 | 512 |
| 480 gfx::Rect before = shadow->layer()->bounds(); | 513 gfx::Rect before = shadow->layer()->bounds(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 502 | 535 |
| 503 // 6) Setting non empty content bounds should enable shadow. | 536 // 6) Setting non empty content bounds should enable shadow. |
| 504 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); | 537 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); |
| 505 surface->Commit(); | 538 surface->Commit(); |
| 506 | 539 |
| 507 EXPECT_EQ(wm::SHADOW_TYPE_RECTANGULAR, wm::GetShadowType(window)); | 540 EXPECT_EQ(wm::SHADOW_TYPE_RECTANGULAR, wm::GetShadowType(window)); |
| 508 EXPECT_TRUE(shadow->layer()->visible()); | 541 EXPECT_TRUE(shadow->layer()->visible()); |
| 509 } | 542 } |
| 510 | 543 |
| 511 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { | 544 TEST_F(ShellSurfaceTest, ShadowWithStateChange) { |
| 545 const Display display; |
| 512 std::unique_ptr<Surface> surface(new Surface); | 546 std::unique_ptr<Surface> surface(new Surface); |
| 513 // Set the bounds to disable auto managed mode. | 547 // Set the bounds to disable auto managed mode. |
| 514 std::unique_ptr<ShellSurface> shell_surface( | 548 std::unique_ptr<ShellSurface> shell_surface( |
| 515 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, | 549 new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 480), |
| 516 ash::kShellWindowId_DefaultContainer)); | 550 true, ash::kShellWindowId_DefaultContainer)); |
| 517 | 551 |
| 518 // Postion the widget at 10,10 so that we get non zero offset. | 552 // Postion the widget at 10,10 so that we get non zero offset. |
| 519 const gfx::Size content_size(100, 100); | 553 const gfx::Size content_size(100, 100); |
| 520 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size); | 554 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size); |
| 521 shell_surface->SetGeometry(original_bounds); | 555 shell_surface->SetGeometry(original_bounds); |
| 522 surface->Commit(); | 556 surface->Commit(); |
| 523 | 557 |
| 524 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). | 558 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). |
| 525 const gfx::Rect shadow_bounds(content_size); | 559 const gfx::Rect shadow_bounds(content_size); |
| 526 | 560 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); | 594 const gfx::Rect shadow_in_maximized(expected_shadow_origin, work_area.size()); |
| 561 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); | 595 EXPECT_EQ(shadow_in_maximized, shadow->layer()->parent()->bounds()); |
| 562 | 596 |
| 563 // The bounds is updated. | 597 // The bounds is updated. |
| 564 shell_surface->SetRectangularShadow(shadow_bounds); | 598 shell_surface->SetRectangularShadow(shadow_bounds); |
| 565 surface->Commit(); | 599 surface->Commit(); |
| 566 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); | 600 EXPECT_EQ(expected_shadow_bounds, shadow->layer()->parent()->bounds()); |
| 567 } | 601 } |
| 568 | 602 |
| 569 TEST_F(ShellSurfaceTest, ShadowWithTransform) { | 603 TEST_F(ShellSurfaceTest, ShadowWithTransform) { |
| 604 const Display display; |
| 570 std::unique_ptr<Surface> surface(new Surface); | 605 std::unique_ptr<Surface> surface(new Surface); |
| 571 // Set the bounds to disable auto managed mode. | 606 // Set the bounds to disable auto managed mode. |
| 572 std::unique_ptr<ShellSurface> shell_surface( | 607 std::unique_ptr<ShellSurface> shell_surface( |
| 573 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 400), true, | 608 new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 400), |
| 574 ash::kShellWindowId_DefaultContainer)); | 609 true, ash::kShellWindowId_DefaultContainer)); |
| 575 | 610 |
| 576 // Postion the widget at 10,10 so that we get non zero offset. | 611 // Postion the widget at 10,10 so that we get non zero offset. |
| 577 const gfx::Size content_size(100, 100); | 612 const gfx::Size content_size(100, 100); |
| 578 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size); | 613 const gfx::Rect original_bounds(gfx::Point(10, 10), content_size); |
| 579 shell_surface->SetGeometry(original_bounds); | 614 shell_surface->SetGeometry(original_bounds); |
| 580 surface->Commit(); | 615 surface->Commit(); |
| 581 | 616 |
| 582 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); | 617 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); |
| 583 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 618 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 584 | 619 |
| 585 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). | 620 // Placing a shadow at screen origin will make the shadow's origin (-10, -10). |
| 586 const gfx::Rect shadow_bounds(content_size); | 621 const gfx::Rect shadow_bounds(content_size); |
| 587 | 622 |
| 588 // Shadow bounds relative to its parent should not be affected by a transform. | 623 // Shadow bounds relative to its parent should not be affected by a transform. |
| 589 gfx::Transform transform; | 624 gfx::Transform transform; |
| 590 transform.Translate(50, 50); | 625 transform.Translate(50, 50); |
| 591 window->SetTransform(transform); | 626 window->SetTransform(transform); |
| 592 shell_surface->SetRectangularShadow(shadow_bounds); | 627 shell_surface->SetRectangularShadow(shadow_bounds); |
| 593 surface->Commit(); | 628 surface->Commit(); |
| 594 EXPECT_TRUE(shadow->layer()->visible()); | 629 EXPECT_TRUE(shadow->layer()->visible()); |
| 595 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); | 630 EXPECT_EQ(gfx::Rect(-10, -10, 100, 100), shadow->layer()->parent()->bounds()); |
| 596 } | 631 } |
| 597 | 632 |
| 598 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { | 633 TEST_F(ShellSurfaceTest, ShadowStartMaximized) { |
| 634 const Display display; |
| 599 std::unique_ptr<Surface> surface(new Surface); | 635 std::unique_ptr<Surface> surface(new Surface); |
| 600 std::unique_ptr<ShellSurface> shell_surface( | 636 std::unique_ptr<ShellSurface> shell_surface( |
| 601 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, | 637 new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 480), |
| 602 ash::kShellWindowId_DefaultContainer)); | 638 true, ash::kShellWindowId_DefaultContainer)); |
| 603 shell_surface->Maximize(); | 639 shell_surface->Maximize(); |
| 604 views::Widget* widget = shell_surface->GetWidget(); | 640 views::Widget* widget = shell_surface->GetWidget(); |
| 605 aura::Window* window = widget->GetNativeWindow(); | 641 aura::Window* window = widget->GetNativeWindow(); |
| 606 | 642 |
| 607 // There is no shadow when started in maximized state. | 643 // There is no shadow when started in maximized state. |
| 608 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 644 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 609 | 645 |
| 610 // Sending a shadow bounds in maximized state won't create a shaodw. | 646 // Sending a shadow bounds in maximized state won't create a shaodw. |
| 611 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); | 647 shell_surface->SetRectangularShadow(gfx::Rect(10, 10, 100, 100)); |
| 612 surface->Commit(); | 648 surface->Commit(); |
| 613 | 649 |
| 614 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); | 650 EXPECT_FALSE(wm::ShadowController::GetShadowForWindow(window)); |
| 615 // Underlay should be created even without shadow. | 651 // Underlay should be created even without shadow. |
| 616 ASSERT_TRUE(shell_surface->shadow_underlay()); | 652 ASSERT_TRUE(shell_surface->shadow_underlay()); |
| 617 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 653 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 618 | 654 |
| 619 // Restore the window and make sure the shadow is created, visible and | 655 // Restore the window and make sure the shadow is created, visible and |
| 620 // has the latest bounds. | 656 // has the latest bounds. |
| 621 widget->Restore(); | 657 widget->Restore(); |
| 622 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 658 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
| 623 ASSERT_TRUE(shadow); | 659 ASSERT_TRUE(shadow); |
| 624 EXPECT_TRUE(shadow->layer()->visible()); | 660 EXPECT_TRUE(shadow->layer()->visible()); |
| 625 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); | 661 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), shadow->layer()->parent()->bounds()); |
| 626 } | 662 } |
| 627 | 663 |
| 628 TEST_F(ShellSurfaceTest, ToggleFullscreen) { | 664 TEST_F(ShellSurfaceTest, ToggleFullscreen) { |
| 629 gfx::Size buffer_size(256, 256); | 665 gfx::Size buffer_size(256, 256); |
| 630 std::unique_ptr<Buffer> buffer( | 666 std::unique_ptr<Buffer> buffer( |
| 631 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 667 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 668 const Display display; |
| 632 std::unique_ptr<Surface> surface(new Surface); | 669 std::unique_ptr<Surface> surface(new Surface); |
| 633 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); | 670 std::unique_ptr<ShellSurface> shell_surface( |
| 671 new ShellSurface(display, surface.get())); |
| 634 | 672 |
| 635 surface->Attach(buffer.get()); | 673 surface->Attach(buffer.get()); |
| 636 surface->Commit(); | 674 surface->Commit(); |
| 637 EXPECT_EQ( | 675 EXPECT_EQ( |
| 638 buffer_size.ToString(), | 676 buffer_size.ToString(), |
| 639 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 677 shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
| 640 | 678 |
| 641 shell_surface->Maximize(); | 679 shell_surface->Maximize(); |
| 642 EXPECT_EQ(CurrentContext()->bounds().width(), | 680 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 643 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); | 681 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 657 | 695 |
| 658 // Check that shell surface is maximized. | 696 // Check that shell surface is maximized. |
| 659 EXPECT_EQ(CurrentContext()->bounds().width(), | 697 EXPECT_EQ(CurrentContext()->bounds().width(), |
| 660 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); | 698 shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); |
| 661 } | 699 } |
| 662 | 700 |
| 663 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { | 701 TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) { |
| 664 gfx::Size buffer_size(256, 256); | 702 gfx::Size buffer_size(256, 256); |
| 665 std::unique_ptr<Buffer> buffer( | 703 std::unique_ptr<Buffer> buffer( |
| 666 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); | 704 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); |
| 705 const Display display; |
| 667 std::unique_ptr<Surface> surface(new Surface); | 706 std::unique_ptr<Surface> surface(new Surface); |
| 668 std::unique_ptr<ShellSurface> shell_surface( | 707 std::unique_ptr<ShellSurface> shell_surface( |
| 669 new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true, | 708 new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 480), |
| 670 ash::kShellWindowId_DefaultContainer)); | 709 true, ash::kShellWindowId_DefaultContainer)); |
| 671 | 710 |
| 672 surface->Attach(buffer.get()); | 711 surface->Attach(buffer.get()); |
| 673 | 712 |
| 674 gfx::Rect shadow_bounds(10, 10, 100, 100); | 713 gfx::Rect shadow_bounds(10, 10, 100, 100); |
| 675 shell_surface->SetRectangularShadow(shadow_bounds); | 714 shell_surface->SetRectangularShadow(shadow_bounds); |
| 676 surface->Commit(); | 715 surface->Commit(); |
| 677 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); | 716 ASSERT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 678 | 717 |
| 679 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); | 718 ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 680 ash::WmWindow* window = | 719 ash::WmWindow* window = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 692 | 731 |
| 693 // Leave fullscreen mode. Shadow underlay is restored. | 732 // Leave fullscreen mode. Shadow underlay is restored. |
| 694 window->GetWindowState()->OnWMEvent(&event); | 733 window->GetWindowState()->OnWMEvent(&event); |
| 695 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); | 734 EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible()); |
| 696 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); | 735 EXPECT_EQ(shadow_bounds, shell_surface->shadow_underlay()->bounds()); |
| 697 } | 736 } |
| 698 | 737 |
| 699 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { | 738 TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) { |
| 700 gfx::Size buffer_size(256, 256); | 739 gfx::Size buffer_size(256, 256); |
| 701 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | 740 Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); |
| 741 const Display display; |
| 702 Surface surface; | 742 Surface surface; |
| 703 ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true, | 743 ShellSurface shell_surface(display, &surface, nullptr, gfx::Rect(640, 480), |
| 704 ash::kShellWindowId_DefaultContainer); | 744 true, ash::kShellWindowId_DefaultContainer); |
| 705 | 745 |
| 706 surface.Attach(&buffer); | 746 surface.Attach(&buffer); |
| 707 | 747 |
| 708 gfx::Rect shadow_bounds(10, 10, 100, 100); | 748 gfx::Rect shadow_bounds(10, 10, 100, 100); |
| 709 shell_surface.SetRectangularShadow(shadow_bounds); | 749 shell_surface.SetRectangularShadow(shadow_bounds); |
| 710 surface.Commit(); | 750 surface.Commit(); |
| 711 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 751 ASSERT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 712 | 752 |
| 713 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); | 753 aura::Window* shell_window = shell_surface.GetWidget()->GetNativeWindow(); |
| 714 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( | 754 aura::WindowTargeter* targeter = static_cast<aura::WindowTargeter*>( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 739 EXPECT_EQ(shell_surface.shadow_underlay(), | 779 EXPECT_EQ(shell_surface.shadow_underlay(), |
| 740 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | 780 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( |
| 741 shell_window, &ev_out)); | 781 shell_window, &ev_out)); |
| 742 EXPECT_NE(shell_surface.shadow_underlay(), | 782 EXPECT_NE(shell_surface.shadow_underlay(), |
| 743 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( | 783 static_cast<ui::EventTargeter*>(targeter)->FindTargetForEvent( |
| 744 shell_window, &ev_in)); | 784 shell_window, &ev_in)); |
| 745 | 785 |
| 746 // Create a new surface | 786 // Create a new surface |
| 747 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); | 787 Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)); |
| 748 Surface surface2; | 788 Surface surface2; |
| 749 ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true, | 789 ShellSurface shell_surface2(display, &surface2, nullptr, gfx::Rect(640, 480), |
| 750 ash::kShellWindowId_DefaultContainer); | 790 true, ash::kShellWindowId_DefaultContainer); |
| 751 surface2.Attach(&buffer2); | 791 surface2.Attach(&buffer2); |
| 752 shell_surface2.SetRectangularShadow(shadow_bounds); | 792 shell_surface2.SetRectangularShadow(shadow_bounds); |
| 753 surface2.Commit(); | 793 surface2.Commit(); |
| 754 | 794 |
| 755 // spoken-feedback was already on, so underlay should fill screen | 795 // spoken-feedback was already on, so underlay should fill screen |
| 756 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), | 796 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().bounds(), |
| 757 shell_surface2.shadow_underlay()->bounds()); | 797 shell_surface2.shadow_underlay()->bounds()); |
| 758 | 798 |
| 759 // De-activated shell-surface should NOT have fullscreen underlay | 799 // De-activated shell-surface should NOT have fullscreen underlay |
| 760 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 800 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 761 | 801 |
| 762 // Disable spoken feedback. Shadow underlay is restored. | 802 // Disable spoken feedback. Shadow underlay is restored. |
| 763 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 803 ash::WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
| 764 ash::A11Y_NOTIFICATION_NONE); | 804 ash::A11Y_NOTIFICATION_NONE); |
| 765 shell_surface.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); | 805 shell_surface.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); |
| 766 shell_surface2.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); | 806 shell_surface2.OnAccessibilityModeChanged(ash::A11Y_NOTIFICATION_NONE); |
| 767 | 807 |
| 768 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); | 808 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); |
| 769 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); | 809 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); |
| 770 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); | 810 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); |
| 771 } | 811 } |
| 772 | 812 |
| 773 } // namespace | 813 } // namespace |
| 774 } // namespace exo | 814 } // namespace exo |
| OLD | NEW |