system_modal_container_layout_manager_unittest.cc 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/wm/system_modal_container_layout_manager.h"
  5. #include <memory>
  6. #include "ash/keyboard/keyboard_controller_impl.h"
  7. #include "ash/keyboard/ui/keyboard_ui.h"
  8. #include "ash/keyboard/ui/keyboard_ui_controller.h"
  9. #include "ash/keyboard/ui/test/keyboard_test_util.h"
  10. #include "ash/public/cpp/keyboard/keyboard_switches.h"
  11. #include "ash/public/cpp/shelf_config.h"
  12. #include "ash/public/cpp/shell_window_ids.h"
  13. #include "ash/root_window_controller.h"
  14. #include "ash/shell.h"
  15. #include "ash/test/ash_test_base.h"
  16. #include "ash/wm/container_finder.h"
  17. #include "ash/wm/window_util.h"
  18. #include "base/command_line.h"
  19. #include "base/compiler_specific.h"
  20. #include "base/run_loop.h"
  21. #include "components/session_manager/session_manager_types.h"
  22. #include "ui/aura/client/aura_constants.h"
  23. #include "ui/aura/test/test_window_delegate.h"
  24. #include "ui/aura/window.h"
  25. #include "ui/aura/window_event_dispatcher.h"
  26. #include "ui/base/hit_test.h"
  27. #include "ui/compositor/layer.h"
  28. #include "ui/compositor/scoped_animation_duration_scale_mode.h"
  29. #include "ui/compositor/test/layer_animator_test_controller.h"
  30. #include "ui/events/test/event_generator.h"
  31. #include "ui/views/test/capture_tracking_view.h"
  32. #include "ui/views/widget/widget.h"
  33. #include "ui/views/widget/widget_delegate.h"
  34. #include "ui/wm/core/window_util.h"
  35. namespace ash {
  36. namespace {
  37. aura::Window* GetModalContainer() {
  38. return Shell::GetPrimaryRootWindowController()->GetContainer(
  39. ash::kShellWindowId_SystemModalContainer);
  40. }
  41. bool AllRootWindowsHaveModalBackgroundsForContainer(int container_id) {
  42. aura::Window::Windows containers =
  43. GetContainersForAllRootWindows(container_id);
  44. bool has_modal_screen = !containers.empty();
  45. for (aura::Window* container : containers) {
  46. has_modal_screen &= static_cast<SystemModalContainerLayoutManager*>(
  47. container->layout_manager())
  48. ->has_window_dimmer();
  49. }
  50. return has_modal_screen;
  51. }
  52. bool AllRootWindowsHaveLockedModalBackgrounds() {
  53. return AllRootWindowsHaveModalBackgroundsForContainer(
  54. kShellWindowId_LockSystemModalContainer);
  55. }
  56. bool AllRootWindowsHaveModalBackgrounds() {
  57. return AllRootWindowsHaveModalBackgroundsForContainer(
  58. kShellWindowId_SystemModalContainer);
  59. }
  60. class TestWindow : public views::WidgetDelegateView {
  61. public:
  62. explicit TestWindow(bool modal) {
  63. SetModalType(modal ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE);
  64. SetPreferredSize(gfx::Size(50, 50));
  65. }
  66. TestWindow(const TestWindow&) = delete;
  67. TestWindow& operator=(const TestWindow&) = delete;
  68. ~TestWindow() override = default;
  69. // The window needs be closed from widget in order for
  70. // aura::client::kModalKey property to be reset.
  71. static void CloseTestWindow(aura::Window* window) {
  72. views::Widget::GetWidgetForNativeWindow(window)->Close();
  73. }
  74. };
  75. class EventTestWindow : public TestWindow {
  76. public:
  77. explicit EventTestWindow(bool modal) : TestWindow(modal), mouse_presses_(0) {}
  78. EventTestWindow(const EventTestWindow&) = delete;
  79. EventTestWindow& operator=(const EventTestWindow&) = delete;
  80. ~EventTestWindow() override = default;
  81. aura::Window* ShowTestWindowWithContext(aura::Window* context) {
  82. views::Widget* widget =
  83. views::Widget::CreateWindowWithContext(this, context);
  84. widget->Show();
  85. return widget->GetNativeView();
  86. }
  87. aura::Window* ShowTestWindowWithParent(aura::Window* parent) {
  88. DCHECK(parent);
  89. views::Widget* widget = views::Widget::CreateWindowWithParent(this, parent);
  90. widget->Show();
  91. return widget->GetNativeView();
  92. }
  93. // Overridden from views::View:
  94. bool OnMousePressed(const ui::MouseEvent& event) override {
  95. mouse_presses_++;
  96. return false;
  97. }
  98. int mouse_presses() const { return mouse_presses_; }
  99. private:
  100. int mouse_presses_;
  101. };
  102. class TransientWindowObserver : public aura::WindowObserver {
  103. public:
  104. TransientWindowObserver() : destroyed_(false) {}
  105. TransientWindowObserver(const TransientWindowObserver&) = delete;
  106. TransientWindowObserver& operator=(const TransientWindowObserver&) = delete;
  107. ~TransientWindowObserver() override = default;
  108. bool destroyed() const { return destroyed_; }
  109. // Overridden from aura::WindowObserver:
  110. void OnWindowDestroyed(aura::Window* window) override { destroyed_ = true; }
  111. private:
  112. bool destroyed_;
  113. };
  114. } // namespace
  115. class SystemModalContainerLayoutManagerTest : public AshTestBase {
  116. public:
  117. void SetUp() override {
  118. // Allow a virtual keyboard (and initialize it per default).
  119. base::CommandLine::ForCurrentProcess()->AppendSwitch(
  120. keyboard::switches::kEnableVirtualKeyboard);
  121. AshTestBase::SetUp();
  122. }
  123. aura::Window* ShowToplevelTestWindow(bool modal) {
  124. views::Widget* widget = views::Widget::CreateWindowWithContext(
  125. new TestWindow(modal), GetContext());
  126. widget->Show();
  127. return widget->GetNativeView();
  128. }
  129. aura::Window* ShowTestWindowWithParent(aura::Window* parent, bool modal) {
  130. views::Widget* widget =
  131. views::Widget::CreateWindowWithParent(new TestWindow(modal), parent);
  132. widget->Show();
  133. return widget->GetNativeView();
  134. }
  135. // Show or hide the keyboard.
  136. void ShowKeyboard(bool show) {
  137. auto* keyboard = keyboard::KeyboardUIController::Get();
  138. ASSERT_TRUE(keyboard->IsEnabled());
  139. if (show == keyboard->IsKeyboardVisible())
  140. return;
  141. if (show) {
  142. keyboard->ShowKeyboard(true /* lock */);
  143. ASSERT_TRUE(keyboard::WaitUntilShown());
  144. } else {
  145. keyboard->HideKeyboardByUser();
  146. }
  147. DCHECK_EQ(show, keyboard->IsKeyboardVisible());
  148. }
  149. };
  150. TEST_F(SystemModalContainerLayoutManagerTest, NonModalTransient) {
  151. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  152. aura::Window* transient = ShowTestWindowWithParent(parent.get(), false);
  153. TransientWindowObserver destruction_observer;
  154. transient->AddObserver(&destruction_observer);
  155. EXPECT_EQ(parent.get(), ::wm::GetTransientParent(transient));
  156. EXPECT_EQ(parent->parent(), transient->parent());
  157. // The transient should be destroyed with its parent.
  158. parent.reset();
  159. EXPECT_TRUE(destruction_observer.destroyed());
  160. }
  161. TEST_F(SystemModalContainerLayoutManagerTest, ModalTransient) {
  162. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  163. // parent should be active.
  164. EXPECT_TRUE(wm::IsActiveWindow(parent.get()));
  165. aura::Window* t1 = ShowTestWindowWithParent(parent.get(), true);
  166. TransientWindowObserver do1;
  167. t1->AddObserver(&do1);
  168. EXPECT_EQ(parent.get(), ::wm::GetTransientParent(t1));
  169. EXPECT_EQ(GetModalContainer(), t1->parent());
  170. // t1 should now be active.
  171. EXPECT_TRUE(wm::IsActiveWindow(t1));
  172. // Attempting to click the parent should result in no activation change.
  173. ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), parent.get());
  174. e1.ClickLeftButton();
  175. EXPECT_TRUE(wm::IsActiveWindow(t1));
  176. // Now open another modal transient parented to the original modal transient.
  177. aura::Window* t2 = ShowTestWindowWithParent(t1, true);
  178. TransientWindowObserver do2;
  179. t2->AddObserver(&do2);
  180. EXPECT_TRUE(wm::IsActiveWindow(t2));
  181. EXPECT_EQ(t1, ::wm::GetTransientParent(t2));
  182. EXPECT_EQ(GetModalContainer(), t2->parent());
  183. // t2 should still be active, even after clicking on t1.
  184. ui::test::EventGenerator e2(Shell::GetPrimaryRootWindow(), t1);
  185. e2.ClickLeftButton();
  186. EXPECT_TRUE(wm::IsActiveWindow(t2));
  187. // Both transients should be destroyed with parent.
  188. parent.reset();
  189. EXPECT_TRUE(do1.destroyed());
  190. EXPECT_TRUE(do2.destroyed());
  191. }
  192. TEST_F(SystemModalContainerLayoutManagerTest, ModalNonTransient) {
  193. std::unique_ptr<aura::Window> t1(ShowToplevelTestWindow(true));
  194. // parent should be active.
  195. EXPECT_TRUE(wm::IsActiveWindow(t1.get()));
  196. TransientWindowObserver do1;
  197. t1->AddObserver(&do1);
  198. EXPECT_EQ(NULL, ::wm::GetTransientParent(t1.get()));
  199. EXPECT_EQ(GetModalContainer(), t1->parent());
  200. // t1 should now be active.
  201. EXPECT_TRUE(wm::IsActiveWindow(t1.get()));
  202. // Attempting to click the parent should result in no activation change.
  203. ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(),
  204. Shell::GetPrimaryRootWindow());
  205. e1.ClickLeftButton();
  206. EXPECT_TRUE(wm::IsActiveWindow(t1.get()));
  207. // Now open another modal transient parented to the original modal transient.
  208. aura::Window* t2 = ShowTestWindowWithParent(t1.get(), true);
  209. TransientWindowObserver do2;
  210. t2->AddObserver(&do2);
  211. EXPECT_TRUE(wm::IsActiveWindow(t2));
  212. EXPECT_EQ(t1.get(), ::wm::GetTransientParent(t2));
  213. EXPECT_EQ(GetModalContainer(), t2->parent());
  214. // t2 should still be active, even after clicking on t1.
  215. ui::test::EventGenerator e2(Shell::GetPrimaryRootWindow(), t1.get());
  216. e2.ClickLeftButton();
  217. EXPECT_TRUE(wm::IsActiveWindow(t2));
  218. // Both transients should be destroyed with parent.
  219. t1.reset();
  220. EXPECT_TRUE(do1.destroyed());
  221. EXPECT_TRUE(do2.destroyed());
  222. }
  223. // Tests that we can activate an unrelated window after a modal window is closed
  224. // for a window.
  225. TEST_F(SystemModalContainerLayoutManagerTest, CanActivateAfterEndModalSession) {
  226. std::unique_ptr<aura::Window> unrelated(ShowToplevelTestWindow(false));
  227. unrelated->SetBounds(gfx::Rect(100, 100, 50, 50));
  228. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  229. // parent should be active.
  230. EXPECT_TRUE(wm::IsActiveWindow(parent.get()));
  231. std::unique_ptr<aura::Window> transient(
  232. ShowTestWindowWithParent(parent.get(), true));
  233. // t1 should now be active.
  234. EXPECT_TRUE(wm::IsActiveWindow(transient.get()));
  235. // Attempting to click the parent should result in no activation change.
  236. ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), parent.get());
  237. e1.ClickLeftButton();
  238. EXPECT_TRUE(wm::IsActiveWindow(transient.get()));
  239. // Now close the transient.
  240. transient->Hide();
  241. TestWindow::CloseTestWindow(transient.release());
  242. base::RunLoop().RunUntilIdle();
  243. // parent should now be active again.
  244. EXPECT_TRUE(wm::IsActiveWindow(parent.get()));
  245. // Attempting to click unrelated should activate it.
  246. ui::test::EventGenerator e2(Shell::GetPrimaryRootWindow(), unrelated.get());
  247. e2.ClickLeftButton();
  248. EXPECT_TRUE(wm::IsActiveWindow(unrelated.get()));
  249. }
  250. TEST_F(SystemModalContainerLayoutManagerTest, EventFocusContainers) {
  251. // Create a normal window and attempt to receive a click event.
  252. EventTestWindow* main_delegate = new EventTestWindow(false);
  253. std::unique_ptr<aura::Window> main(
  254. main_delegate->ShowTestWindowWithContext(GetContext()));
  255. EXPECT_TRUE(wm::IsActiveWindow(main.get()));
  256. ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), main.get());
  257. e1.ClickLeftButton();
  258. EXPECT_EQ(1, main_delegate->mouse_presses());
  259. EventTestWindow* status_delegate = new EventTestWindow(false);
  260. std::unique_ptr<aura::Window> status_control(
  261. status_delegate->ShowTestWindowWithParent(
  262. Shell::GetPrimaryRootWindowController()->GetContainer(
  263. kShellWindowId_ShelfContainer)));
  264. status_control->SetBounds(main->bounds());
  265. // Make sure that status window can receive event.
  266. e1.ClickLeftButton();
  267. EXPECT_EQ(1, status_delegate->mouse_presses());
  268. // Create a modal window for the main window and verify that the main window
  269. // no longer receives mouse events.
  270. EventTestWindow* transient_delegate = new EventTestWindow(true);
  271. aura::Window* transient =
  272. transient_delegate->ShowTestWindowWithParent(main.get());
  273. EXPECT_TRUE(wm::IsActiveWindow(transient));
  274. e1.ClickLeftButton();
  275. EXPECT_EQ(0, transient_delegate->mouse_presses());
  276. EXPECT_EQ(1, status_delegate->mouse_presses());
  277. status_control->Hide();
  278. e1.ClickLeftButton();
  279. EXPECT_EQ(1, transient_delegate->mouse_presses());
  280. EXPECT_EQ(1, status_delegate->mouse_presses());
  281. for (int block_reason = FIRST_BLOCK_REASON;
  282. block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) {
  283. // Create a window in the lock screen container and ensure that it receives
  284. // the mouse event instead of the modal window (crbug.com/110920).
  285. BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
  286. EventTestWindow* lock_delegate = new EventTestWindow(false);
  287. std::unique_ptr<aura::Window> lock(lock_delegate->ShowTestWindowWithParent(
  288. Shell::GetPrimaryRootWindowController()->GetContainer(
  289. kShellWindowId_LockScreenContainer)));
  290. // BlockUserSession could change the workspace size. Make sure |lock| has
  291. // the same bounds as |main| so that |lock| gets the generated mouse events.
  292. lock->SetBounds(main->bounds());
  293. EXPECT_TRUE(wm::IsActiveWindow(lock.get()));
  294. e1.ClickLeftButton();
  295. EXPECT_EQ(1, lock_delegate->mouse_presses());
  296. EXPECT_EQ(1, status_delegate->mouse_presses());
  297. // Make sure that a modal container created by the lock screen can still
  298. // receive mouse events.
  299. EventTestWindow* lock_modal_delegate = new EventTestWindow(true);
  300. aura::Window* lock_modal =
  301. lock_modal_delegate->ShowTestWindowWithParent(lock.get());
  302. EXPECT_TRUE(wm::IsActiveWindow(lock_modal));
  303. e1.ClickLeftButton();
  304. // Verify that none of the other containers received any more mouse presses.
  305. EXPECT_EQ(1, lock_modal_delegate->mouse_presses());
  306. EXPECT_EQ(1, lock_delegate->mouse_presses());
  307. EXPECT_EQ(1, status_delegate->mouse_presses());
  308. EXPECT_EQ(1, main_delegate->mouse_presses());
  309. EXPECT_EQ(1, transient_delegate->mouse_presses());
  310. // Showing status will block events.
  311. status_control->Show();
  312. e1.ClickLeftButton();
  313. // Verify that none of the other containers received any more mouse presses.
  314. EXPECT_EQ(1, lock_modal_delegate->mouse_presses());
  315. EXPECT_EQ(1, lock_delegate->mouse_presses());
  316. EXPECT_EQ(1, status_delegate->mouse_presses());
  317. EXPECT_EQ(1, main_delegate->mouse_presses());
  318. EXPECT_EQ(1, transient_delegate->mouse_presses());
  319. status_control->Hide();
  320. // Close |lock| before unlocking so that Shell::OnLockStateChanged does
  321. // not DCHECK on finding a system modal in Lock layer when unlocked.
  322. lock.reset();
  323. UnblockUserSession();
  324. }
  325. }
  326. // Test if a user can still click the status area in lock screen
  327. // even if the user session has system modal dialog.
  328. TEST_F(SystemModalContainerLayoutManagerTest,
  329. ClickStatusWithModalDialogInLockedState) {
  330. // Create a normal window and attempt to receive a click event.
  331. EventTestWindow* main_delegate = new EventTestWindow(false);
  332. std::unique_ptr<aura::Window> main(
  333. main_delegate->ShowTestWindowWithContext(GetContext()));
  334. ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), main.get());
  335. // A window for status area to test if it could receive an event
  336. // under each condition.
  337. EventTestWindow* status_delegate = new EventTestWindow(false);
  338. std::unique_ptr<aura::Window> status_control(
  339. status_delegate->ShowTestWindowWithParent(
  340. Shell::GetPrimaryRootWindowController()->GetContainer(
  341. kShellWindowId_ShelfContainer)));
  342. status_control->SetBounds(main->bounds());
  343. status_control->SetName("Status Control");
  344. // Events are blocked on all windows because status window is above the modal
  345. // window.
  346. EventTestWindow* modal_delegate = new EventTestWindow(true);
  347. aura::Window* modal = modal_delegate->ShowTestWindowWithParent(main.get());
  348. modal->SetName("Modal Window");
  349. EXPECT_TRUE(wm::IsActiveWindow(modal));
  350. generator.ClickLeftButton();
  351. EXPECT_EQ(0, main_delegate->mouse_presses());
  352. EXPECT_EQ(0, modal_delegate->mouse_presses());
  353. EXPECT_EQ(0, status_delegate->mouse_presses());
  354. BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
  355. // In lock screen, a window in status area container should be able to receive
  356. // the event even with a system modal dialog in the user session.
  357. generator.ClickLeftButton();
  358. EXPECT_EQ(0, main_delegate->mouse_presses());
  359. EXPECT_EQ(0, modal_delegate->mouse_presses());
  360. EXPECT_EQ(1, status_delegate->mouse_presses());
  361. }
  362. TEST_F(SystemModalContainerLayoutManagerTest, ModalTransientChildEvents) {
  363. // Create a normal window and attempt to receive a click event.
  364. EventTestWindow* main_delegate = new EventTestWindow(false);
  365. std::unique_ptr<aura::Window> main(
  366. main_delegate->ShowTestWindowWithContext(GetContext()));
  367. EXPECT_TRUE(wm::IsActiveWindow(main.get()));
  368. ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), main.get());
  369. e1.ClickLeftButton();
  370. EXPECT_EQ(1, main_delegate->mouse_presses());
  371. // Create a modal window for the main window and verify that the main window
  372. // no longer receives mouse events.
  373. EventTestWindow* modal1_delegate = new EventTestWindow(true);
  374. aura::Window* modal1 = modal1_delegate->ShowTestWindowWithParent(main.get());
  375. EXPECT_TRUE(wm::IsActiveWindow(modal1));
  376. e1.ClickLeftButton();
  377. EXPECT_EQ(1, modal1_delegate->mouse_presses());
  378. EXPECT_EQ(1, main_delegate->mouse_presses());
  379. // Create a non-modal transient child of modal1 and verify it receives mouse
  380. // events instead of main and modal1.
  381. EventTestWindow* modal1_transient_delegate = new EventTestWindow(false);
  382. aura::Window* modal1_transient =
  383. modal1_transient_delegate->ShowTestWindowWithParent(modal1);
  384. EXPECT_TRUE(wm::IsActiveWindow(modal1_transient));
  385. e1.ClickLeftButton();
  386. EXPECT_EQ(1, modal1_transient_delegate->mouse_presses());
  387. EXPECT_EQ(1, modal1_delegate->mouse_presses());
  388. EXPECT_EQ(1, main_delegate->mouse_presses());
  389. // Create a child control for modal1_transient and it receives mouse events.
  390. aura::test::EventCountDelegate control_delegate;
  391. control_delegate.set_window_component(HTCLIENT);
  392. std::unique_ptr<aura::Window> child =
  393. std::make_unique<aura::Window>(&control_delegate);
  394. child->SetType(aura::client::WINDOW_TYPE_CONTROL);
  395. child->Init(ui::LAYER_TEXTURED);
  396. modal1_transient->AddChild(child.get());
  397. child->SetBounds(gfx::Rect(100, 100));
  398. child->Show();
  399. e1.ClickLeftButton();
  400. EXPECT_EQ("1 1", control_delegate.GetMouseButtonCountsAndReset());
  401. EXPECT_EQ(1, modal1_transient_delegate->mouse_presses());
  402. EXPECT_EQ(1, modal1_delegate->mouse_presses());
  403. EXPECT_EQ(1, main_delegate->mouse_presses());
  404. // Create another modal window for the main window and it receives mouse
  405. // events instead of all others.
  406. EventTestWindow* modal2_delegate = new EventTestWindow(true);
  407. aura::Window* modal2 = modal2_delegate->ShowTestWindowWithParent(main.get());
  408. EXPECT_TRUE(wm::IsActiveWindow(modal2));
  409. e1.ClickLeftButton();
  410. EXPECT_EQ(1, modal2_delegate->mouse_presses());
  411. EXPECT_EQ("0 0", control_delegate.GetMouseButtonCountsAndReset());
  412. EXPECT_EQ(1, modal1_transient_delegate->mouse_presses());
  413. EXPECT_EQ(1, modal1_delegate->mouse_presses());
  414. EXPECT_EQ(1, main_delegate->mouse_presses());
  415. // Create a non-modal transient child of modal2 and it receives events.
  416. EventTestWindow* modal2_transient_delegate = new EventTestWindow(false);
  417. aura::Window* modal2_transient =
  418. modal2_transient_delegate->ShowTestWindowWithParent(modal2);
  419. EXPECT_TRUE(wm::IsActiveWindow(modal2_transient));
  420. e1.ClickLeftButton();
  421. EXPECT_EQ(1, modal2_transient_delegate->mouse_presses());
  422. EXPECT_EQ(1, modal2_delegate->mouse_presses());
  423. EXPECT_EQ("0 0", control_delegate.GetMouseButtonCountsAndReset());
  424. EXPECT_EQ(1, modal1_transient_delegate->mouse_presses());
  425. EXPECT_EQ(1, modal1_delegate->mouse_presses());
  426. EXPECT_EQ(1, main_delegate->mouse_presses());
  427. // Create a non-modal transient grandchild of modal2 and it receives events.
  428. EventTestWindow* modal2_transient_grandchild_delegate =
  429. new EventTestWindow(false);
  430. aura::Window* modal2_transient_grandchild =
  431. modal2_transient_grandchild_delegate->ShowTestWindowWithParent(
  432. modal2_transient);
  433. EXPECT_TRUE(wm::IsActiveWindow(modal2_transient_grandchild));
  434. e1.ClickLeftButton();
  435. EXPECT_EQ(1, modal2_transient_grandchild_delegate->mouse_presses());
  436. EXPECT_EQ(1, modal2_transient_delegate->mouse_presses());
  437. EXPECT_EQ(1, modal2_delegate->mouse_presses());
  438. EXPECT_EQ("0 0", control_delegate.GetMouseButtonCountsAndReset());
  439. EXPECT_EQ(1, modal1_transient_delegate->mouse_presses());
  440. EXPECT_EQ(1, modal1_delegate->mouse_presses());
  441. EXPECT_EQ(1, main_delegate->mouse_presses());
  442. }
  443. // Makes sure we don't crash if a modal window is shown while the parent window
  444. // is hidden.
  445. TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) {
  446. // Hide the lock screen.
  447. Shell::GetPrimaryRootWindowController()
  448. ->GetContainer(kShellWindowId_SystemModalContainer)
  449. ->layer()
  450. ->SetOpacity(0);
  451. // Create a modal window.
  452. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  453. std::unique_ptr<aura::Window> modal_window(
  454. ShowTestWindowWithParent(parent.get(), true));
  455. }
  456. // Verifies we generate a capture lost when showing a modal window.
  457. TEST_F(SystemModalContainerLayoutManagerTest, ChangeCapture) {
  458. std::unique_ptr<aura::Window> widget_window(ShowToplevelTestWindow(false));
  459. views::test::CaptureTrackingView* view = new views::test::CaptureTrackingView;
  460. views::View* client_view =
  461. views::Widget::GetWidgetForNativeView(widget_window.get())
  462. ->non_client_view()
  463. ->client_view();
  464. client_view->AddChildView(view);
  465. view->SetBoundsRect(client_view->bounds());
  466. gfx::Point center(view->width() / 2, view->height() / 2);
  467. views::View::ConvertPointToScreen(view, &center);
  468. ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), center);
  469. generator.PressLeftButton();
  470. EXPECT_TRUE(view->got_press());
  471. std::unique_ptr<aura::Window> modal_window(
  472. ShowTestWindowWithParent(widget_window.get(), true));
  473. EXPECT_TRUE(view->got_capture_lost());
  474. }
  475. // Verifies that the window gets moved into the visible screen area upon screen
  476. // resize.
  477. TEST_F(SystemModalContainerLayoutManagerTest, KeepVisible) {
  478. GetModalContainer()->SetBounds(gfx::Rect(0, 0, 1024, 768));
  479. std::unique_ptr<aura::Window> main(
  480. ShowTestWindowWithParent(GetModalContainer(), true));
  481. const int shelf_height = ShelfConfig::Get()->shelf_size();
  482. main->SetBounds(gfx::Rect(924, 668 - shelf_height, 100, 100));
  483. // We set now the bounds of the root window to something new which will
  484. // Then trigger the repos operation.
  485. GetModalContainer()->SetBounds(gfx::Rect(0, 0, 800, 600));
  486. gfx::Rect bounds = main->bounds();
  487. EXPECT_EQ(bounds, gfx::Rect(700, 500 - shelf_height, 100, 100));
  488. }
  489. // Verifies that centered windows will remain centered after the visible screen
  490. // area changed.
  491. TEST_F(SystemModalContainerLayoutManagerTest, KeepCentered) {
  492. GetModalContainer()->SetBounds(gfx::Rect(0, 0, 800, 600));
  493. std::unique_ptr<aura::Window> main(
  494. ShowTestWindowWithParent(GetModalContainer(), true));
  495. // Center the window.
  496. main->SetBounds(gfx::Rect((800 - 512) / 2, (600 - 256) / 2, 512, 256));
  497. // We set now the bounds of the root window to something new which will
  498. // Then trigger the reposition operation.
  499. GetModalContainer()->SetBounds(gfx::Rect(0, 0, 600, 400));
  500. // The window should still be centered.
  501. gfx::Rect bounds = main->bounds();
  502. EXPECT_EQ(bounds.ToString(),
  503. gfx::Rect((600 - 512) / 2, (400 - 256) / 2, 512, 256).ToString());
  504. }
  505. // Verifies that centered windows will remain centered in the secondary screen
  506. // with correct global position in screen coordinate system and local position
  507. // relative to root window.
  508. TEST_F(SystemModalContainerLayoutManagerTest, KeepCenteredSecondaryScreen) {
  509. UpdateDisplay("800x600,800+0-800x600");
  510. // Create a lock modal window in a lock state.
  511. GetSessionControllerClient()->SetSessionState(
  512. session_manager::SessionState::OOBE);
  513. aura::Window::Windows root_windows = Shell::GetAllRootWindows();
  514. aura::Window* secondary_display_modal_container = Shell::GetContainer(
  515. root_windows[1], kShellWindowId_LockSystemModalContainer);
  516. secondary_display_modal_container->SetBounds(gfx::Rect(0, 0, 800, 600));
  517. std::unique_ptr<aura::Window> modal(
  518. ShowTestWindowWithParent(secondary_display_modal_container, true));
  519. // Center the window.
  520. modal->SetBounds(gfx::Rect((800 - 512) / 2, (600 - 256) / 2, 512, 256));
  521. // We set now the bounds of the root window to something new which will
  522. // Then trigger the reposition operation.
  523. secondary_display_modal_container->SetBounds(gfx::Rect(0, 0, 600, 400));
  524. // The window should still be centered with global and local coordinates.
  525. gfx::Rect modal_bounds_in_screen = modal->GetBoundsInScreen();
  526. EXPECT_EQ(
  527. modal_bounds_in_screen.ToString(),
  528. gfx::Rect(800 + (600 - 512) / 2, (400 - 256) / 2, 512, 256).ToString());
  529. gfx::Rect modal_bounds_in_root = modal->bounds();
  530. EXPECT_EQ(modal_bounds_in_root.ToString(),
  531. gfx::Rect((600 - 512) / 2, (400 - 256) / 2, 512, 256).ToString());
  532. }
  533. TEST_F(SystemModalContainerLayoutManagerTest, ShowNormalBackgroundOrLocked) {
  534. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  535. std::unique_ptr<aura::Window> modal_window(
  536. ShowTestWindowWithParent(parent.get(), true));
  537. // Normal system modal window. Shows normal system modal background and not
  538. // locked.
  539. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  540. EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
  541. TestWindow::CloseTestWindow(modal_window.release());
  542. EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
  543. EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
  544. for (int block_reason = FIRST_BLOCK_REASON;
  545. block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) {
  546. // Normal system modal window while blocked. Shows blocked system modal
  547. // background.
  548. BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
  549. std::unique_ptr<aura::Window> lock_parent(ShowTestWindowWithParent(
  550. Shell::GetPrimaryRootWindowController()->GetContainer(
  551. kShellWindowId_LockScreenContainer),
  552. false));
  553. std::unique_ptr<aura::Window> lock_modal_window(
  554. ShowTestWindowWithParent(lock_parent.get(), true));
  555. EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
  556. EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds());
  557. TestWindow::CloseTestWindow(lock_modal_window.release());
  558. // Normal system modal window while blocked, but it belongs to the normal
  559. // window. Shouldn't show blocked system modal background, but normal.
  560. std::unique_ptr<aura::Window> modal_window(
  561. ShowTestWindowWithParent(parent.get(), true));
  562. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  563. EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
  564. TestWindow::CloseTestWindow(modal_window.release());
  565. // Close |lock_parent| before unlocking so that Shell::OnLockStateChanged
  566. // does not DCHECK on finding a system modal in Lock layer when unlocked.
  567. lock_parent.reset();
  568. UnblockUserSession();
  569. // Here we should check the behavior of the locked system modal dialog when
  570. // unlocked, but such case isn't handled very well right now.
  571. // See crbug.com/157660
  572. // TODO(mukai): add the test case when the bug is fixed.
  573. }
  574. }
  575. TEST_F(SystemModalContainerLayoutManagerTest, MultiDisplays) {
  576. UpdateDisplay("600x500,600x500");
  577. std::unique_ptr<aura::Window> normal(ShowToplevelTestWindow(false));
  578. normal->SetBounds(gfx::Rect(100, 100, 50, 50));
  579. aura::Window::Windows root_windows = Shell::GetAllRootWindows();
  580. EXPECT_EQ(2U, root_windows.size());
  581. aura::Window* container1 =
  582. Shell::GetContainer(root_windows[0], kShellWindowId_SystemModalContainer);
  583. aura::Window* container2 =
  584. Shell::GetContainer(root_windows[1], kShellWindowId_SystemModalContainer);
  585. std::unique_ptr<aura::Window> modal1(
  586. ShowTestWindowWithParent(container1, true));
  587. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  588. EXPECT_TRUE(wm::IsActiveWindow(modal1.get()));
  589. std::unique_ptr<aura::Window> modal11(
  590. ShowTestWindowWithParent(container1, true));
  591. EXPECT_TRUE(wm::IsActiveWindow(modal11.get()));
  592. std::unique_ptr<aura::Window> modal2(
  593. ShowTestWindowWithParent(container2, true));
  594. EXPECT_TRUE(wm::IsActiveWindow(modal2.get()));
  595. // Sanity check if they're on the correct containers.
  596. EXPECT_EQ(container1, modal1->parent());
  597. EXPECT_EQ(container1, modal11->parent());
  598. EXPECT_EQ(container2, modal2->parent());
  599. TestWindow::CloseTestWindow(modal2.release());
  600. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  601. EXPECT_TRUE(wm::IsActiveWindow(modal11.get()));
  602. TestWindow::CloseTestWindow(modal11.release());
  603. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  604. EXPECT_TRUE(wm::IsActiveWindow(modal1.get()));
  605. UpdateDisplay("600x500");
  606. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  607. EXPECT_TRUE(wm::IsActiveWindow(modal1.get()));
  608. UpdateDisplay("600x500,700x600");
  609. EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
  610. EXPECT_TRUE(wm::IsActiveWindow(modal1.get()));
  611. // No more modal screen.
  612. modal1->Hide();
  613. TestWindow::CloseTestWindow(modal1.release());
  614. EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
  615. EXPECT_TRUE(wm::IsActiveWindow(normal.get()));
  616. }
  617. // Test that with the visible keyboard, an existing system modal dialog gets
  618. // positioned into the visible area.
  619. TEST_F(SystemModalContainerLayoutManagerTest,
  620. SystemModalDialogGetPushedFromKeyboard) {
  621. const gfx::Rect& container_bounds = GetModalContainer()->bounds();
  622. // Place the window at the bottom of the screen.
  623. gfx::Size modal_size(100, 100);
  624. gfx::Point modal_origin = gfx::Point(
  625. (container_bounds.right() - modal_size.width()) / 2, // X centered
  626. container_bounds.bottom() - modal_size.height()); // at bottom
  627. gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size);
  628. // Create a modal window.
  629. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  630. std::unique_ptr<aura::Window> modal_window(
  631. ShowTestWindowWithParent(parent.get(), true));
  632. modal_window->SetBounds(modal_bounds);
  633. EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString());
  634. // The keyboard gets shown and the dialog should get pushed.
  635. ShowKeyboard(true);
  636. EXPECT_NE(modal_bounds.ToString(), modal_window->bounds().ToString());
  637. EXPECT_GT(modal_bounds.y(), modal_window->bounds().y());
  638. EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
  639. EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
  640. // After the keyboard is gone, the window will remain where it was.
  641. ShowKeyboard(false);
  642. EXPECT_NE(modal_bounds.ToString(), modal_window->bounds().ToString());
  643. EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
  644. EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
  645. }
  646. // Test that windows will not get cropped through the visible virtual keyboard -
  647. // if centered.
  648. TEST_F(SystemModalContainerLayoutManagerTest,
  649. SystemModalDialogGetPushedButNotCroppedFromKeyboard) {
  650. const gfx::Rect& container_bounds = GetModalContainer()->bounds();
  651. const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size();
  652. // Place the window at the bottom of the screen.
  653. gfx::Size modal_size(100, screen_size.height() - 70);
  654. gfx::Point modal_origin = gfx::Point(
  655. (container_bounds.right() - modal_size.width()) / 2, // X centered
  656. container_bounds.bottom() - modal_size.height()); // at bottom
  657. gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size);
  658. // Create a modal window.
  659. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  660. std::unique_ptr<aura::Window> modal_window(
  661. ShowTestWindowWithParent(parent.get(), true));
  662. modal_window->SetBounds(modal_bounds);
  663. EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString());
  664. // The keyboard gets shown and the dialog should get pushed up, but not get
  665. // cropped (and aligned to the top).
  666. ShowKeyboard(true);
  667. EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
  668. EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
  669. EXPECT_EQ(0, modal_window->bounds().y());
  670. ShowKeyboard(false);
  671. }
  672. // Test that windows will not get cropped through the visible virtual keyboard -
  673. // if not centered.
  674. TEST_F(SystemModalContainerLayoutManagerTest,
  675. SystemModalDialogGetPushedButNotCroppedFromKeyboardIfNotCentered) {
  676. const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size();
  677. // Place the window at the bottom of the screen.
  678. gfx::Size modal_size(100, screen_size.height() - 70);
  679. gfx::Point modal_origin = gfx::Point(10, 20);
  680. gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size);
  681. // Create a modal window.
  682. std::unique_ptr<aura::Window> parent(ShowToplevelTestWindow(false));
  683. std::unique_ptr<aura::Window> modal_window(
  684. ShowTestWindowWithParent(parent.get(), true));
  685. modal_window->SetBounds(modal_bounds);
  686. EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString());
  687. // The keyboard gets shown and the dialog should get pushed up, but not get
  688. // cropped (and aligned to the top).
  689. ShowKeyboard(true);
  690. EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
  691. EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
  692. EXPECT_EQ(0, modal_window->bounds().y());
  693. ShowKeyboard(false);
  694. }
  695. TEST_F(SystemModalContainerLayoutManagerTest, UpdateModalType) {
  696. aura::Window* modal_container = Shell::GetContainer(
  697. Shell::GetPrimaryRootWindow(), kShellWindowId_SystemModalContainer);
  698. aura::Window* window = ShowTestWindowWithParent(modal_container, false);
  699. EXPECT_FALSE(Shell::IsSystemModalWindowOpen());
  700. window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
  701. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  702. // Setting twice should not cause error.
  703. window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
  704. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  705. window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_NONE);
  706. EXPECT_FALSE(Shell::IsSystemModalWindowOpen());
  707. window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
  708. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  709. window_util::CloseWidgetForWindow(window);
  710. EXPECT_FALSE(Shell::IsSystemModalWindowOpen());
  711. }
  712. TEST_F(SystemModalContainerLayoutManagerTest, VisibilityChange) {
  713. std::unique_ptr<aura::Window> window(ShowToplevelTestWindow(false));
  714. std::unique_ptr<aura::Window> modal_window(
  715. views::Widget::CreateWindowWithContext(new TestWindow(true), GetContext())
  716. ->GetNativeWindow());
  717. SystemModalContainerLayoutManager* layout_manager =
  718. Shell::GetPrimaryRootWindowController()->GetSystemModalLayoutManager(
  719. modal_window.get());
  720. EXPECT_FALSE(Shell::IsSystemModalWindowOpen());
  721. EXPECT_FALSE(layout_manager->has_window_dimmer());
  722. modal_window->Show();
  723. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  724. EXPECT_TRUE(layout_manager->has_window_dimmer());
  725. // Make sure that a child visibility change should not cause
  726. // inconsistent state.
  727. std::unique_ptr<aura::Window> child = std::make_unique<aura::Window>(nullptr);
  728. child->SetType(aura::client::WINDOW_TYPE_CONTROL);
  729. child->Init(ui::LAYER_TEXTURED);
  730. modal_window->AddChild(child.get());
  731. child->Show();
  732. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  733. EXPECT_TRUE(layout_manager->has_window_dimmer());
  734. modal_window->Hide();
  735. EXPECT_FALSE(Shell::IsSystemModalWindowOpen());
  736. EXPECT_FALSE(layout_manager->has_window_dimmer());
  737. modal_window->Show();
  738. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  739. EXPECT_TRUE(layout_manager->has_window_dimmer());
  740. }
  741. namespace {
  742. class InputTestDelegate : public aura::test::TestWindowDelegate {
  743. public:
  744. InputTestDelegate() = default;
  745. InputTestDelegate(const InputTestDelegate&) = delete;
  746. InputTestDelegate& operator=(const InputTestDelegate&) = delete;
  747. ~InputTestDelegate() override = default;
  748. void RunTest(AshTestBase* test_base) {
  749. std::unique_ptr<aura::Window> window(
  750. test_base->CreateTestWindowInShellWithDelegate(
  751. this, 0, gfx::Rect(0, 0, 100, 100)));
  752. window->Show();
  753. GenerateEvents(window.get());
  754. EXPECT_EQ(2, mouse_event_count_);
  755. EXPECT_EQ(3, scroll_event_count_);
  756. EXPECT_EQ(4, touch_event_count_);
  757. EXPECT_EQ(10, gesture_event_count_);
  758. Reset();
  759. views::Widget* widget = views::Widget::CreateWindowWithContext(
  760. new TestWindow(true), Shell::GetPrimaryRootWindow(),
  761. gfx::Rect(200, 200, 100, 100));
  762. widget->Show();
  763. EXPECT_TRUE(Shell::IsSystemModalWindowOpen());
  764. // Events should be blocked.
  765. GenerateEvents(window.get());
  766. EXPECT_EQ(0, mouse_event_count_);
  767. EXPECT_EQ(0, scroll_event_count_);
  768. EXPECT_EQ(0, touch_event_count_);
  769. EXPECT_EQ(0, gesture_event_count_);
  770. Reset();
  771. widget->Close();
  772. EXPECT_FALSE(Shell::IsSystemModalWindowOpen());
  773. GenerateEvents(window.get());
  774. EXPECT_EQ(2, mouse_event_count_);
  775. EXPECT_EQ(3, scroll_event_count_);
  776. EXPECT_EQ(4, touch_event_count_);
  777. EXPECT_EQ(10, gesture_event_count_);
  778. }
  779. private:
  780. // ui::EventHandler:
  781. void OnMouseEvent(ui::MouseEvent* event) override { mouse_event_count_++; }
  782. void OnScrollEvent(ui::ScrollEvent* event) override { scroll_event_count_++; }
  783. void OnTouchEvent(ui::TouchEvent* event) override { touch_event_count_++; }
  784. void OnGestureEvent(ui::GestureEvent* event) override {
  785. gesture_event_count_++;
  786. }
  787. void GenerateEvents(aura::Window* window) {
  788. ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow(),
  789. window);
  790. event_generator.ClickLeftButton();
  791. event_generator.ScrollSequence(window->bounds().CenterPoint(),
  792. base::TimeDelta(), 0, 10, 1, 2);
  793. event_generator.PressTouch();
  794. event_generator.ReleaseTouch();
  795. event_generator.GestureTapAt(window->bounds().CenterPoint());
  796. }
  797. void Reset() {
  798. mouse_event_count_ = 0;
  799. scroll_event_count_ = 0;
  800. touch_event_count_ = 0;
  801. gesture_event_count_ = 0;
  802. }
  803. int mouse_event_count_ = 0;
  804. int scroll_event_count_ = 0;
  805. int touch_event_count_ = 0;
  806. int gesture_event_count_ = 0;
  807. };
  808. } // namespace
  809. TEST_F(SystemModalContainerLayoutManagerTest, BlockAllEvents) {
  810. InputTestDelegate delegate;
  811. delegate.RunTest(this);
  812. }
  813. // Make sure that events are properly blocked in multi displays environment.
  814. TEST_F(SystemModalContainerLayoutManagerTest, BlockEventsInMultiDisplays) {
  815. UpdateDisplay("600x500, 600x500");
  816. InputTestDelegate delegate;
  817. delegate.RunTest(this);
  818. }
  819. } // namespace ash