Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: components/exo/shell_surface_unittest.cc

Issue 2743053002: arc: Fix race condition in applying modal state. (Closed)
Patch Set: forgotten nit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 464 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
465 465
466 // Only SetSystemModal changes modality. 466 // Only SetSystemModal changes modality.
467 shell_surface->SetSystemModal(true); 467 shell_surface->SetSystemModal(true);
468 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 468 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
469 469
470 shell_surface->SetSystemModal(false); 470 shell_surface->SetSystemModal(false);
471 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 471 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
472 } 472 }
473 473
474 TEST_F(ShellSurfaceTest, ModalWindowSetSystemModalBeforeCommit) {
475 std::unique_ptr<Surface> surface(new Surface);
476 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(
477 surface.get(), nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(),
478 true, false, ash::kShellWindowId_SystemModalContainer));
479 gfx::Size desktop_size(640, 480);
480 std::unique_ptr<Buffer> desktop_buffer(
481 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size)));
482 surface->Attach(desktop_buffer.get());
483 surface->SetInputRegion(SkRegion());
484
485 // Set SetSystemModal before any commit happens. Widget is not created at
486 // this time.
487 EXPECT_FALSE(shell_surface->GetWidget());
488 shell_surface->SetSystemModal(true);
489
490 surface->Commit();
491
492 // It is expected that modal window is shown.
493 EXPECT_TRUE(shell_surface->GetWidget());
494 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
495
496 // Now widget is created and setting modal state should be applied
497 // immediately.
498 shell_surface->SetSystemModal(false);
499 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
500 }
501
474 TEST_F(ShellSurfaceTest, PopupWindow) { 502 TEST_F(ShellSurfaceTest, PopupWindow) {
475 Surface parent_surface; 503 Surface parent_surface;
476 ShellSurface parent(&parent_surface); 504 ShellSurface parent(&parent_surface);
477 const gfx::Rect parent_bounds(100, 100, 300, 300); 505 const gfx::Rect parent_bounds(100, 100, 300, 300);
478 506
479 Buffer parent_buffer( 507 Buffer parent_buffer(
480 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size())); 508 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size()));
481 parent_surface.Attach(&parent_buffer); 509 parent_surface.Attach(&parent_buffer);
482 parent_surface.Commit(); 510 parent_surface.Commit();
483 511
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 shell_surface.OnAccessibilityModeChanged(); 972 shell_surface.OnAccessibilityModeChanged();
945 shell_surface2.OnAccessibilityModeChanged(); 973 shell_surface2.OnAccessibilityModeChanged();
946 974
947 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); 975 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
948 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 976 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
949 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); 977 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
950 } 978 }
951 979
952 } // namespace 980 } // namespace
953 } // namespace exo 981 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698