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

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

Issue 1949603002: Revert of mus: Enable system modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 EXPECT_EQ(w3, GetCaptureWindow(display)); 905 EXPECT_EQ(w3, GetCaptureWindow(display));
906 AckPreviousEvent(); 906 AckPreviousEvent();
907 907
908 // Set |w2| modal to |w1|. This should not release the capture as the capture 908 // Set |w2| modal to |w1|. This should not release the capture as the capture
909 // is not set to a descendant of the modal parent. 909 // is not set to a descendant of the modal parent.
910 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id)); 910 ASSERT_TRUE(tree->AddTransientWindow(w1_id, w2_id));
911 ASSERT_TRUE(tree->SetModal(w2_id)); 911 ASSERT_TRUE(tree->SetModal(w2_id));
912 EXPECT_EQ(w3, GetCaptureWindow(display)); 912 EXPECT_EQ(w3, GetCaptureWindow(display));
913 } 913 }
914 914
915 // Tests that showing a system modal window releases the capture.
916 TEST_F(WindowTreeTest, ShowSystemModalWindowWithCapture) {
917 TestWindowTreeClient* embed_connection = nullptr;
918 WindowTree* tree = nullptr;
919 ServerWindow* w1 = nullptr;
920 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1));
921
922 w1->SetBounds(gfx::Rect(10, 10, 10, 10));
923 const ServerWindow* root_window = *tree->roots().begin();
924 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window);
925 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1);
926 Display* display = tree->GetDisplay(w1);
927
928 // Create a system modal window |w2| as a child of |root_window| and leave it
929 // hidden.
930 ClientWindowId w2_id = BuildClientWindowId(tree, 2);
931 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties()));
932 ServerWindow* w2 = tree->GetWindowByClientId(w2_id);
933 w2->SetBounds(gfx::Rect(30, 10, 10, 10));
934 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id));
935 ASSERT_TRUE(tree->SetModal(w2_id));
936
937 // Set capture to |w1|.
938 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15));
939 ASSERT_TRUE(tree->SetCapture(w1_id));
940 EXPECT_EQ(w1, GetCaptureWindow(display));
941 AckPreviousEvent();
942
943 // Make |w2| visible. This should release capture as it is system modal
944 // window.
945 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true));
946 EXPECT_EQ(nullptr, GetCaptureWindow(display));
947 }
948
949 // Tests that setting a visible window as modal to system releases the capture.
950 TEST_F(WindowTreeTest, VisibleWindowToSystemModalWithCapture) {
951 TestWindowTreeClient* embed_connection = nullptr;
952 WindowTree* tree = nullptr;
953 ServerWindow* w1 = nullptr;
954 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1));
955
956 w1->SetBounds(gfx::Rect(10, 10, 10, 10));
957 const ServerWindow* root_window = *tree->roots().begin();
958 ClientWindowId root_window_id = ClientWindowIdForWindow(tree, root_window);
959 ClientWindowId w1_id = ClientWindowIdForWindow(tree, w1);
960 Display* display = tree->GetDisplay(w1);
961
962 // Create |w2| as a child of |root_window| and make it visible.
963 ClientWindowId w2_id = BuildClientWindowId(tree, 2);
964 ASSERT_TRUE(tree->NewWindow(w2_id, ServerWindow::Properties()));
965 ServerWindow* w2 = tree->GetWindowByClientId(w2_id);
966 w2->SetBounds(gfx::Rect(30, 10, 10, 10));
967 ASSERT_TRUE(tree->AddWindow(root_window_id, w2_id));
968 ASSERT_TRUE(tree->SetWindowVisibility(w2_id, true));
969
970 // Set capture to |w1|.
971 DispatchEventWithoutAck(CreatePointerDownEvent(15, 15));
972 ASSERT_TRUE(tree->SetCapture(w1_id));
973 EXPECT_EQ(w1, GetCaptureWindow(display));
974 AckPreviousEvent();
975
976 // Make |w2| modal to system. This should release capture.
977 ASSERT_TRUE(tree->SetModal(w2_id));
978 EXPECT_EQ(nullptr, GetCaptureWindow(display));
979 }
980
981 // Tests that moving the capture window to a modal parent releases the capture 915 // Tests that moving the capture window to a modal parent releases the capture
982 // as capture cannot be blocked by a modal window. 916 // as capture cannot be blocked by a modal window.
983 TEST_F(WindowTreeTest, MoveCaptureWindowToModalParent) { 917 TEST_F(WindowTreeTest, MoveCaptureWindowToModalParent) {
984 TestWindowTreeClient* embed_connection = nullptr; 918 TestWindowTreeClient* embed_connection = nullptr;
985 WindowTree* tree = nullptr; 919 WindowTree* tree = nullptr;
986 ServerWindow* w1 = nullptr; 920 ServerWindow* w1 = nullptr;
987 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1)); 921 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_connection, &tree, &w1));
988 922
989 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 923 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
990 const ServerWindow* root_window = *tree->roots().begin(); 924 const ServerWindow* root_window = *tree->roots().begin();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 ASSERT_NE(new_opacity, unknown_window.opacity()); 991 ASSERT_NE(new_opacity, unknown_window.opacity());
1058 992
1059 EXPECT_FALSE(tree->SetWindowOpacity( 993 EXPECT_FALSE(tree->SetWindowOpacity(
1060 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity)); 994 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity));
1061 EXPECT_NE(new_opacity, unknown_window.opacity()); 995 EXPECT_NE(new_opacity, unknown_window.opacity());
1062 } 996 }
1063 997
1064 } // namespace test 998 } // namespace test
1065 } // namespace ws 999 } // namespace ws
1066 } // namespace mus 1000 } // 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