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

Side by Side Diff: components/mus/ws/window_tree_unittest.cc

Issue 1818333002: Reland: mus: Enable system modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased after fixing the crash Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/mus/ws/window_tree.h" 5 #include "components/mus/ws/window_tree.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 EXPECT_EQ(w3, GetCaptureWindow(display)); 849 EXPECT_EQ(w3, GetCaptureWindow(display));
850 AckPreviousEvent(); 850 AckPreviousEvent();
851 851
852 // Set |w2| modal to |w1|. This should not release the capture as the capture 852 // Set |w2| modal to |w1|. This should not release the capture as the capture
853 // is not set to a descendant of the modal parent. 853 // is not set to a descendant of the modal parent.
854 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); 854 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id));
855 ASSERT_TRUE(tree->SetModal(w2_id)); 855 ASSERT_TRUE(tree->SetModal(w2_id));
856 EXPECT_EQ(w3, GetCaptureWindow(display)); 856 EXPECT_EQ(w3, GetCaptureWindow(display));
857 } 857 }
858 858
859 // Tests that showing a system modal window releases the capture.
860 TEST_F(WindowTreeTest, ShowSystemModalWindowWithCapture) {
861 TestWindowTreeClient* embed_connection = nullptr;
862 WindowTree* tree = nullptr;
863 ServerWindow* w1 = nullptr;
864 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1));
865
866 w1->SetBounds(gfx::Rect(10, 10, 10, 10));
867 const ServerWindow* root_window = *tree->roots().begin();
868 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window);
869 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1);
870 Display* display = tree->GetDisplay(w1);
871
872 // Create a system modal window |w2| as a child of |root_window| and leave it
873 // hidden.
874 ClientWindowId w2_id = BuildClientWindowId(tree, 2);
875 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties()));
876 ServerWindow* w2 = tree->GetWindowByClientId(w2_id);
877 w2->SetBounds(gfx::Rect(30, 10, 10, 10));
878 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id));
879 ASSERT_TRUE(tree->SetModal(w2_id));
880
881 // Set capture to |w1|.
882 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15));
883 ASSERT_TRUE(tree->SetCapture(w1_id));
884 EXPECT_EQ(w1, GetCaptureWindow(display));
885 AckPreviousEvent();
886
887 // Make |w2| visible. This should release capture as it is system modal
888 // window.
889 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true));
890 EXPECT_EQ(nullptr, GetCaptureWindow(display));
891 }
892
893 // Tests that setting a visible window as modal to system releases the capture.
894 TEST_F(WindowTreeTest, VisibleWindowToSystemModalWithCapture) {
895 TestWindowTreeClient* embed_connection = nullptr;
896 WindowTree* tree = nullptr;
897 ServerWindow* w1 = nullptr;
898 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1));
899
900 w1->SetBounds(gfx::Rect(10, 10, 10, 10));
901 const ServerWindow* root_window = *tree->roots().begin();
902 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window);
903 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1);
904 Display* display = tree->GetDisplay(w1);
905
906 // Create |w2| as a child of |root_window| and make it visible.
907 ClientWindowId w2_id = BuildClientWindowId(tree, 2);
908 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties()));
909 ServerWindow* w2 = tree->GetWindowByClientId(w2_id);
910 w2->SetBounds(gfx::Rect(30, 10, 10, 10));
911 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id));
912 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true));
913
914 // Set capture to |w1|.
915 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15));
916 ASSERT_TRUE(tree->SetCapture(w1_id));
917 EXPECT_EQ(w1, GetCaptureWindow(display));
918 AckPreviousEvent();
919
920 // Make |w2| modal to system. This should release capture.
921 ASSERT_TRUE(tree->SetModal(w2_id));
922 EXPECT_EQ(nullptr, GetCaptureWindow(display));
923 }
924
859 // Tests that moving the capture window to a modal parent releases the capture 925 // Tests that moving the capture window to a modal parent releases the capture
860 // as capture cannot be blocked by a modal window. 926 // as capture cannot be blocked by a modal window.
861 TEST_F(WindowTreeTest, MoveCaptureWindowToModalParent) { 927 TEST_F(WindowTreeTest, MoveCaptureWindowToModalParent) {
862 TestWindowTreeClient* embed_connection = nullptr; 928 TestWindowTreeClient* embed_connection = nullptr;
863 WindowTree* tree = nullptr; 929 WindowTree* tree = nullptr;
864 ServerWindow* w1 = nullptr; 930 ServerWindow* w1 = nullptr;
865 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1)); 931 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1));
866 932
867 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 933 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
868 const ServerWindow* root_window = *tree->roots().begin(); 934 const ServerWindow* root_window = *tree->roots().begin();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 ASSERT_NE(new_opacity, unknown_window.opacity()); 1001 ASSERT_NE(new_opacity, unknown_window.opacity());
936 1002
937 EXPECT_FALSE(tree->SetWindowOpacity( 1003 EXPECT_FALSE(tree->SetWindowOpacity(
938 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity)); 1004 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity));
939 EXPECT_NE(new_opacity, unknown_window.opacity()); 1005 EXPECT_NE(new_opacity, unknown_window.opacity());
940 } 1006 }
941 1007
942 } // namespace test 1008 } // namespace test
943 } // namespace ws 1009 } // namespace ws
944 } // namespace mus 1010 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree.cc ('k') | mash/example/window_type_launcher/window_type_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698