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

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

Issue 2743053002: arc: Fix race condition in applying modal state. (Closed)
Patch Set: unit_test added + refactored apply logic 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
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 "ash/common/accessibility_delegate.h" 5 #include "ash/common/accessibility_delegate.h"
6 #include "ash/common/wm/window_state.h" 6 #include "ash/common/wm/window_state.h"
7 #include "ash/common/wm/wm_event.h" 7 #include "ash/common/wm/wm_event.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 463 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
464 464
465 // Only SetSystemModal changes modality. 465 // Only SetSystemModal changes modality.
466 shell_surface->SetSystemModal(true); 466 shell_surface->SetSystemModal(true);
467 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 467 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
468 468
469 shell_surface->SetSystemModal(false); 469 shell_surface->SetSystemModal(false);
470 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 470 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
471 } 471 }
472 472
473 TEST_F(ShellSurfaceTest, ModalWindowInitializedBeforeCommit) {
reveman 2017/03/11 00:45:09 nit: s/Initialized/SetSystemModal/
khmel 2017/03/11 01:33:32 Done.
474 std::unique_ptr<Surface> surface(new Surface);
475 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(
476 surface.get(), nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(),
477 true, false, ash::kShellWindowId_SystemModalContainer));
478 gfx::Size desktop_size(640, 480);
479 std::unique_ptr<Buffer> desktop_buffer(
480 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(desktop_size)));
481 surface->Attach(desktop_buffer.get());
482 surface->SetInputRegion(SkRegion());
483
484 // Set SetSystemModal before any commit happens. Widget is not created at
485 // this time.
486 EXPECT_FALSE(shell_surface->GetWidget());
487 shell_surface->SetSystemModal(true);
488
489 surface->Commit();
490
491 // It is expected that modal window is shown.
492 EXPECT_TRUE(shell_surface->GetWidget());
493 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
494
495 // Now widget is created and setting modal state should be applied
496 // immediately.
497 shell_surface->SetSystemModal(false);
498 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
499 }
500
473 TEST_F(ShellSurfaceTest, PopupWindow) { 501 TEST_F(ShellSurfaceTest, PopupWindow) {
474 Surface parent_surface; 502 Surface parent_surface;
475 ShellSurface parent(&parent_surface); 503 ShellSurface parent(&parent_surface);
476 const gfx::Rect parent_bounds(100, 100, 300, 300); 504 const gfx::Rect parent_bounds(100, 100, 300, 300);
477 505
478 Buffer parent_buffer( 506 Buffer parent_buffer(
479 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size())); 507 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size()));
480 parent_surface.Attach(&parent_buffer); 508 parent_surface.Attach(&parent_buffer);
481 parent_surface.Commit(); 509 parent_surface.Commit();
482 510
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 shell_surface.OnAccessibilityModeChanged(); 971 shell_surface.OnAccessibilityModeChanged();
944 shell_surface2.OnAccessibilityModeChanged(); 972 shell_surface2.OnAccessibilityModeChanged();
945 973
946 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); 974 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
947 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 975 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
948 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); 976 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
949 } 977 }
950 978
951 } // namespace 979 } // namespace
952 } // namespace exo 980 } // namespace exo
OLDNEW
« components/exo/shell_surface.cc ('K') | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698