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

Unified Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2710023007: Make WindowTree::SetModal() take the type. (Closed)
Patch Set: address feedback. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client_unittest.cc
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc
index b4f7db246ccb772238beaeeb7b0faf319a7c3f64..ea3e765101710ea95ea7239dccd1f166597ab0f4 100644
--- a/ui/aura/mus/window_tree_client_unittest.cc
+++ b/ui/aura/mus/window_tree_client_unittest.cc
@@ -1746,7 +1746,7 @@ TEST_F(WindowTreeClientClientTest, TwoWindowTreesRequestCapture) {
capture_client.reset();
}
-TEST_F(WindowTreeClientClientTest, ModalFail) {
+TEST_F(WindowTreeClientClientTest, ModalTypeWindowFail) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW);
@@ -1756,19 +1756,51 @@ TEST_F(WindowTreeClientClientTest, ModalFail) {
// Type should be back to MODAL_TYPE_NONE as the server didn't accept the
// change.
EXPECT_EQ(ui::MODAL_TYPE_NONE, window.GetProperty(client::kModalKey));
- // There should be no more modal changes.
- EXPECT_FALSE(
- window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false));
+ // Server is told that the type is set back to MODAL_TYPE_NONE.
+ EXPECT_TRUE(
+ window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true));
+ // Type should still remain MODAL_TYPE_NONE.
+ EXPECT_EQ(ui::MODAL_TYPE_NONE, window.GetProperty(client::kModalKey));
}
-TEST_F(WindowTreeClientClientTest, ModalSuccess) {
+TEST_F(WindowTreeClientClientTest, ModalTypeNoneFail) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
+ // First, set modality type to window sucessfully.
window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW);
- // Ack change as succeeding.
ASSERT_TRUE(
window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true));
EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey));
+ // Now, set type to MODAL_TYPE_NONE, and have the server say it failed.
+ window.SetProperty(client::kModalKey, ui::MODAL_TYPE_NONE);
+ ASSERT_TRUE(
+ window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false));
+ // Type should be back to MODAL_TYPE_WINDOW as the server didn't accept the
+ // change.
+ EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey));
+ // Server is told that the type is set back to MODAL_TYPE_WINDOW.
+ EXPECT_TRUE(
+ window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true));
+ // Type should still remain MODAL_TYPE_WINDOW.
+ EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey));
+}
+
+TEST_F(WindowTreeClientClientTest, ModalTypeSuccess) {
+ Window window(nullptr);
+ window.Init(ui::LAYER_NOT_DRAWN);
+
+ // Set modality type to MODAL_TYPE_WINDOW, MODAL_TYPE_SYSTEM, and then back to
+ // MODAL_TYPE_NONE, and make sure it succeeds each time.
+ ui::ModalType kModalTypes[] = {ui::MODAL_TYPE_WINDOW, ui::MODAL_TYPE_SYSTEM,
+ ui::MODAL_TYPE_NONE};
+ for (size_t i = 0; i < arraysize(kModalTypes); i++) {
+ window.SetProperty(client::kModalKey, kModalTypes[i]);
+ // Ack change as succeeding.
+ ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
+ WindowTreeChangeType::MODAL, true));
+ EXPECT_EQ(kModalTypes[i], window.GetProperty(client::kModalKey));
+ }
+
// There should be no more modal changes.
EXPECT_FALSE(
window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false));
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698