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

Side by Side Diff: login/login_controller_test.cc

Issue 6902072: wm: Update a lot of code to use structs from geometry.h. (Closed) Base URL: ssh://gitrw.chromium.org:9222/window_manager.git@master
Patch Set: move override-redirect stacking and visibility into Window Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium OS 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 <vector> 5 #include <vector>
6 6
7 #include <gflags/gflags.h> 7 #include <gflags/gflags.h>
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 9
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 // Create the set of windows expected by LoginController. 80 // Create the set of windows expected by LoginController.
81 void CreateLoginWindows(int num_entries, 81 void CreateLoginWindows(int num_entries,
82 bool background_is_ready, 82 bool background_is_ready,
83 bool entry_pixmaps_are_ready, 83 bool entry_pixmaps_are_ready,
84 bool create_wizard_window) { 84 bool create_wizard_window) {
85 CHECK(num_entries == 0 || num_entries >= 2); 85 CHECK(num_entries == 0 || num_entries >= 2);
86 86
87 if (!background_xid_) { 87 if (!background_xid_) {
88 background_xid_ = CreateBasicWindow(0, 0, wm_->width(), wm_->height()); 88 background_xid_ = CreateBasicWindow(wm_->root_bounds());
89 vector<int> background_params; 89 vector<int> background_params;
90 background_params.push_back(background_is_ready ? 1 : 0); 90 background_params.push_back(background_is_ready ? 1 : 0);
91 wm_->wm_ipc()->SetWindowType(background_xid_, 91 wm_->wm_ipc()->SetWindowType(background_xid_,
92 chromeos::WM_IPC_WINDOW_LOGIN_BACKGROUND, 92 chromeos::WM_IPC_WINDOW_LOGIN_BACKGROUND,
93 &background_params); 93 &background_params);
94 SendInitialEventsForWindow(background_xid_); 94 SendInitialEventsForWindow(background_xid_);
95 } 95 }
96 96
97 for (int i = 0; i < num_entries; ++i) { 97 for (int i = 0; i < num_entries; ++i) {
98 entries_.push_back(CreateLoginEntry(num_entries, i)); 98 entries_.push_back(CreateLoginEntry(num_entries, i));
99 } 99 }
100 100
101 // The wizard window needs to be mapped after the entries. Otherwise, when 101 // The wizard window needs to be mapped after the entries. Otherwise, when
102 // LoginController sees the wizard window get mapped, it won't know whether 102 // LoginController sees the wizard window get mapped, it won't know whether
103 // it should display it immediately or wait for entries to show up. 103 // it should display it immediately or wait for entries to show up.
104 if (create_wizard_window) { 104 if (create_wizard_window) {
105 wizard_xid_ = CreateBasicWindow(0, 0, 105 wizard_xid_ =
106 wm_->width() / 2, wm_->height() / 2); 106 CreateBasicWindow(Rect(0, 0, wm_->width() / 2, wm_->height() / 2));
107 wm_->wm_ipc()->SetWindowType(wizard_xid_, 107 wm_->wm_ipc()->SetWindowType(wizard_xid_,
108 chromeos::WM_IPC_WINDOW_LOGIN_GUEST, 108 chromeos::WM_IPC_WINDOW_LOGIN_GUEST,
109 NULL); 109 NULL);
110 SendInitialEventsForWindow(wizard_xid_); 110 SendInitialEventsForWindow(wizard_xid_);
111 } 111 }
112 112
113 if (entry_pixmaps_are_ready) { 113 if (entry_pixmaps_are_ready) {
114 for (int i = 0; i < num_entries; ++i) 114 for (int i = 0; i < num_entries; ++i)
115 SendInitialPixmapEventForEntry(i); 115 SendInitialPixmapEventForEntry(i);
116 // LoginController registers a timeout to call this, so we need to call 116 // LoginController registers a timeout to call this, so we need to call
117 // it manually. 117 // it manually.
118 // TODO: It'd be better to make it so that tests can manually run 118 // TODO: It'd be better to make it so that tests can manually run
119 // timeouts that have been posted to EventLoop. 119 // timeouts that have been posted to EventLoop.
120 if (num_entries > 0) 120 if (num_entries > 0)
121 login_controller_->InitialShow(); 121 login_controller_->InitialShow();
122 } 122 }
123 } 123 }
124 124
125 EntryWindows CreateLoginEntry(int num_entries, int i) { 125 EntryWindows CreateLoginEntry(int num_entries, int i) {
126 EntryWindows entry; 126 EntryWindows entry;
127 entry.border_xid = CreateBasicWindow(0, 0, 127 entry.border_xid =
128 kImageSize + 2 * kGapBetweenImageAndControls, 128 CreateBasicWindow(
129 kImageSize + kControlsSize + 3 * kGapBetweenImageAndControls); 129 Rect(0, 0,
130 entry.image_xid = CreateBasicWindow(0, 0, kImageSize, kImageSize); 130 kImageSize + 2 * kGapBetweenImageAndControls,
131 entry.controls_xid = CreateBasicWindow(0, 0, kImageSize, kControlsSize); 131 kImageSize + kControlsSize + 3 * kGapBetweenImageAndControls));
132 entry.label_xid = CreateBasicWindow(0, 0, kImageSize, kControlsSize); 132 entry.image_xid =
133 entry.unselected_label_xid = CreateBasicWindow(0, 0, kImageSize, 133 CreateBasicWindow(Rect(0, 0, kImageSize, kImageSize));
134 kControlsSize); 134 entry.controls_xid =
135 CreateBasicWindow(Rect(0, 0, kImageSize, kControlsSize));
136 entry.label_xid =
137 CreateBasicWindow(Rect(0, 0, kImageSize, kControlsSize));
138 entry.unselected_label_xid =
139 CreateBasicWindow(Rect(0, 0, kImageSize, kControlsSize));
135 140
136 vector<int> params; 141 vector<int> params;
137 params.push_back(i); // entry index 142 params.push_back(i); // entry index
138 wm_->wm_ipc()->SetWindowType( 143 wm_->wm_ipc()->SetWindowType(
139 entry.image_xid, 144 entry.image_xid,
140 chromeos::WM_IPC_WINDOW_LOGIN_IMAGE, 145 chromeos::WM_IPC_WINDOW_LOGIN_IMAGE,
141 &params); 146 &params);
142 wm_->wm_ipc()->SetWindowType( 147 wm_->wm_ipc()->SetWindowType(
143 entry.controls_xid, 148 entry.controls_xid,
144 chromeos::WM_IPC_WINDOW_LOGIN_CONTROLS, 149 chromeos::WM_IPC_WINDOW_LOGIN_CONTROLS,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 EXPECT_TRUE(wm_->GetWindowOrDie(background_xid_)->shadow() == NULL); 340 EXPECT_TRUE(wm_->GetWindowOrDie(background_xid_)->shadow() == NULL);
336 } 341 }
337 342
338 // Check that LoginController does some half-baked handling of transient 343 // Check that LoginController does some half-baked handling of transient
339 // windows that get mapped before Chrome is in a logged-in state. 344 // windows that get mapped before Chrome is in a logged-in state.
340 TEST_F(LoginControllerTest, OtherWindows) { 345 TEST_F(LoginControllerTest, OtherWindows) {
341 CreateLoginWindows(2, true, true, true); 346 CreateLoginWindows(2, true, true, true);
342 347
343 const int initial_width = 300; 348 const int initial_width = 300;
344 const int initial_height = 200; 349 const int initial_height = 200;
345 const XWindow xid = CreateBasicWindow(0, 0, initial_width, initial_height); 350 const XWindow xid =
351 CreateBasicWindow(Rect(0, 0, initial_width, initial_height));
346 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); 352 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid);
347 info->transient_for = background_xid_; 353 info->transient_for = background_xid_;
348 ASSERT_FALSE(info->mapped); 354 ASSERT_FALSE(info->mapped);
349 355
350 XEvent event; 356 XEvent event;
351 xconn_->InitCreateWindowEvent(&event, xid); 357 xconn_->InitCreateWindowEvent(&event, xid);
352 wm_->HandleEvent(&event); 358 wm_->HandleEvent(&event);
353 Window* win = wm_->GetWindowOrDie(xid); 359 Window* win = wm_->GetWindowOrDie(xid);
354 MockCompositor::Actor* actor = GetMockActorForWindow(win); 360 MockCompositor::Actor* actor = GetMockActorForWindow(win);
355 361
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 TEST_F(LoginControllerTest, HideAfterLogin) { 615 TEST_F(LoginControllerTest, HideAfterLogin) {
610 // We should show the windows after they're mapped. 616 // We should show the windows after they're mapped.
611 CreateLoginWindows(2, true, true, false); 617 CreateLoginWindows(2, true, true, false);
612 EXPECT_FALSE(WindowIsOffscreen(background_xid_)); 618 EXPECT_FALSE(WindowIsOffscreen(background_xid_));
613 619
614 // They should still be shown even after the user logs in. 620 // They should still be shown even after the user logs in.
615 SetLoggedInState(true); 621 SetLoggedInState(true);
616 EXPECT_FALSE(WindowIsOffscreen(background_xid_)); 622 EXPECT_FALSE(WindowIsOffscreen(background_xid_));
617 623
618 // But we should hide them after the first Chrome window is created. 624 // But we should hide them after the first Chrome window is created.
619 XWindow xid = CreateToplevelWindow(1, 0, // tab_count, selected_tab 625 XWindow xid = CreateToplevelWindow(1, 0, Rect(0, 0, 200, 200));
620 0, 0, 200, 200); // position and size
621 SendInitialEventsForWindow(xid); 626 SendInitialEventsForWindow(xid);
622 EXPECT_TRUE(WindowIsOffscreen(background_xid_)); 627 EXPECT_TRUE(WindowIsOffscreen(background_xid_));
623 } 628 }
624 629
625 TEST_F(LoginControllerTest, ShowDestroyedWindows) { 630 TEST_F(LoginControllerTest, ShowDestroyedWindows) {
626 // Create some login windows and then tell the window manager that the 631 // Create some login windows and then tell the window manager that the
627 // user has logged in. 632 // user has logged in.
628 CreateLoginWindows(2, true, true, false); 633 CreateLoginWindows(2, true, true, false);
629 MockCompositor::TexturePixmapActor* background_actor = 634 MockCompositor::TexturePixmapActor* background_actor =
630 GetMockActorForWindow(wm_->GetWindowOrDie(background_xid_)); 635 GetMockActorForWindow(wm_->GetWindowOrDie(background_xid_));
(...skipping 10 matching lines...) Expand all
641 xconn_->InitDestroyWindowEvent(&event, background_xid_); 646 xconn_->InitDestroyWindowEvent(&event, background_xid_);
642 wm_->HandleEvent(&event); 647 wm_->HandleEvent(&event);
643 648
644 // Even though the background window has been destroyed, its actor should 649 // Even though the background window has been destroyed, its actor should
645 // still be displayed. 650 // still be displayed.
646 EXPECT_TRUE(wm_->GetWindow(background_xid_) == NULL); 651 EXPECT_TRUE(wm_->GetWindow(background_xid_) == NULL);
647 EXPECT_TRUE(stage->stacked_children()->Contains(background_actor)); 652 EXPECT_TRUE(stage->stacked_children()->Contains(background_actor));
648 653
649 // After the initial browser window gets mapped (but not yet painted), we 654 // After the initial browser window gets mapped (but not yet painted), we
650 // should still show the background. 655 // should still show the background.
651 XWindow xid = CreateToplevelWindow(1, 0, // tab_count, selected_tab 656 XWindow xid = CreateToplevelWindow(1, 0, Rect(0, 0, 200, 200));
652 0, 0, 200, 200); // position and size
653 ConfigureWindowForSyncRequestProtocol(xid); 657 ConfigureWindowForSyncRequestProtocol(xid);
654 SendInitialEventsForWindow(xid); 658 SendInitialEventsForWindow(xid);
655 EXPECT_TRUE(stage->stacked_children()->Contains(background_actor)); 659 EXPECT_TRUE(stage->stacked_children()->Contains(background_actor));
656 660
657 // After it's painted, the login actors should be destroyed. 661 // After it's painted, the login actors should be destroyed.
658 SendSyncRequestProtocolAlarm(xid); 662 SendSyncRequestProtocolAlarm(xid);
659 EXPECT_FALSE(stage->stacked_children()->Contains(background_actor)); 663 EXPECT_FALSE(stage->stacked_children()->Contains(background_actor));
660 } 664 }
661 665
662 TEST_F(LoginControllerTest, SelectGuest) { 666 TEST_F(LoginControllerTest, SelectGuest) {
(...skipping 19 matching lines...) Expand all
682 EXPECT_EQ(entries_[0].controls_xid, GetActiveWindowProperty()); 686 EXPECT_EQ(entries_[0].controls_xid, GetActiveWindowProperty());
683 687
684 // Click on the entry for the guest window again. 688 // Click on the entry for the guest window again.
685 SelectEntry(1); 689 SelectEntry(1);
686 690
687 // The guest entry should be focused. 691 // The guest entry should be focused.
688 EXPECT_EQ(entries_[1].controls_xid, xconn_->focused_xid()); 692 EXPECT_EQ(entries_[1].controls_xid, xconn_->focused_xid());
689 EXPECT_EQ(entries_[1].controls_xid, GetActiveWindowProperty()); 693 EXPECT_EQ(entries_[1].controls_xid, GetActiveWindowProperty());
690 694
691 // Create wizard window. 695 // Create wizard window.
692 wizard_xid_ = CreateBasicWindow(0, 0, wm_->width() / 2, wm_->height() / 2); 696 wizard_xid_ =
697 CreateBasicWindow(Rect(0, 0, wm_->width() / 2, wm_->height() / 2));
693 wm_->wm_ipc()->SetWindowType(wizard_xid_, 698 wm_->wm_ipc()->SetWindowType(wizard_xid_,
694 chromeos::WM_IPC_WINDOW_LOGIN_GUEST, 699 chromeos::WM_IPC_WINDOW_LOGIN_GUEST,
695 NULL); 700 NULL);
696 SendInitialEventsForWindow(wizard_xid_); 701 SendInitialEventsForWindow(wizard_xid_);
697 702
698 // The wizard window should be focused. 703 // The wizard window should be focused.
699 EXPECT_EQ(wizard_xid_, xconn_->focused_xid()); 704 EXPECT_EQ(wizard_xid_, xconn_->focused_xid());
700 EXPECT_EQ(wizard_xid_, GetActiveWindowProperty()); 705 EXPECT_EQ(wizard_xid_, GetActiveWindowProperty());
701 } 706 }
702 707
703 TEST_F(LoginControllerTest, RemoveUser) { 708 TEST_F(LoginControllerTest, RemoveUser) {
704 // Create 3 entries for new Chrome. 709 // Create 3 entries for new Chrome.
705 CreateLoginWindows(3, true, true, false); 710 CreateLoginWindows(3, true, true, false);
706 SelectEntry(1); 711 SelectEntry(1);
707 EXPECT_EQ(entries_[1].controls_xid, xconn_->focused_xid()); 712 EXPECT_EQ(entries_[1].controls_xid, xconn_->focused_xid());
708 EXPECT_EQ(entries_[1].controls_xid, GetActiveWindowProperty()); 713 EXPECT_EQ(entries_[1].controls_xid, GetActiveWindowProperty());
709 714
710 UnmapLoginEntry(1); 715 UnmapLoginEntry(1);
711 // Entry 1 was removed from the vector. Focus moved to 0 because 1 is Guest. 716 // Entry 1 was removed from the vector. Focus moved to 0 because 1 is Guest.
712 EXPECT_EQ(entries_[0].controls_xid, xconn_->focused_xid()); 717 EXPECT_EQ(entries_[0].controls_xid, xconn_->focused_xid());
713 EXPECT_EQ(entries_[0].controls_xid, GetActiveWindowProperty()); 718 EXPECT_EQ(entries_[0].controls_xid, GetActiveWindowProperty());
714 719
715 UnmapLoginEntry(0); 720 UnmapLoginEntry(0);
716 EXPECT_EQ(entries_[0].controls_xid, xconn_->focused_xid()); 721 EXPECT_EQ(entries_[0].controls_xid, xconn_->focused_xid());
717 EXPECT_EQ(entries_[0].controls_xid, GetActiveWindowProperty()); 722 EXPECT_EQ(entries_[0].controls_xid, GetActiveWindowProperty());
718 723
719 // Create wizard window. 724 // Create wizard window.
720 wizard_xid_ = CreateBasicWindow(0, 0, wm_->width() / 2, wm_->height() / 2); 725 wizard_xid_ =
726 CreateBasicWindow(Rect(0, 0, wm_->width() / 2, wm_->height() / 2));
721 wm_->wm_ipc()->SetWindowType(wizard_xid_, 727 wm_->wm_ipc()->SetWindowType(wizard_xid_,
722 chromeos::WM_IPC_WINDOW_LOGIN_GUEST, 728 chromeos::WM_IPC_WINDOW_LOGIN_GUEST,
723 NULL); 729 NULL);
724 SendInitialEventsForWindow(wizard_xid_); 730 SendInitialEventsForWindow(wizard_xid_);
725 UnmapLoginEntry(0); 731 UnmapLoginEntry(0);
726 732
727 // The wizard window should be focused. 733 // The wizard window should be focused.
728 EXPECT_EQ(wizard_xid_, xconn_->focused_xid()); 734 EXPECT_EQ(wizard_xid_, xconn_->focused_xid());
729 EXPECT_EQ(wizard_xid_, GetActiveWindowProperty()); 735 EXPECT_EQ(wizard_xid_, GetActiveWindowProperty());
730 } 736 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 856
851 EXPECT_TRUE(WindowIsOffscreen(entries_[0].border_xid)); 857 EXPECT_TRUE(WindowIsOffscreen(entries_[0].border_xid));
852 EXPECT_FALSE(WindowIsOffscreen(entries_[0].image_xid)); 858 EXPECT_FALSE(WindowIsOffscreen(entries_[0].image_xid));
853 EXPECT_TRUE(WindowIsOffscreen(entries_[0].controls_xid)); 859 EXPECT_TRUE(WindowIsOffscreen(entries_[0].controls_xid));
854 EXPECT_TRUE(WindowIsOffscreen(entries_[0].label_xid)); 860 EXPECT_TRUE(WindowIsOffscreen(entries_[0].label_xid));
855 EXPECT_FALSE(WindowIsOffscreen(entries_[0].unselected_label_xid)); 861 EXPECT_FALSE(WindowIsOffscreen(entries_[0].unselected_label_xid));
856 862
857 // Now check that for both entries windows are hidden when login succeeded 863 // Now check that for both entries windows are hidden when login succeeded
858 // and the first Chrome window is shown. 864 // and the first Chrome window is shown.
859 SetLoggedInState(true); 865 SetLoggedInState(true);
860 XWindow xid = CreateToplevelWindow(1, 0, // tab_count, selected_tab 866 XWindow xid = CreateToplevelWindow(1, 0, Rect(0, 0, 200, 200));
861 0, 0, 200, 200); // position and size
862 SendInitialEventsForWindow(xid); 867 SendInitialEventsForWindow(xid);
863 868
864 EXPECT_TRUE(WindowIsOffscreen(entries_[0].border_xid)); 869 EXPECT_TRUE(WindowIsOffscreen(entries_[0].border_xid));
865 EXPECT_TRUE(WindowIsOffscreen(entries_[0].image_xid)); 870 EXPECT_TRUE(WindowIsOffscreen(entries_[0].image_xid));
866 EXPECT_TRUE(WindowIsOffscreen(entries_[0].controls_xid)); 871 EXPECT_TRUE(WindowIsOffscreen(entries_[0].controls_xid));
867 EXPECT_TRUE(WindowIsOffscreen(entries_[0].label_xid)); 872 EXPECT_TRUE(WindowIsOffscreen(entries_[0].label_xid));
868 EXPECT_TRUE(WindowIsOffscreen(entries_[0].unselected_label_xid)); 873 EXPECT_TRUE(WindowIsOffscreen(entries_[0].unselected_label_xid));
869 874
870 EXPECT_TRUE(WindowIsOffscreen(entries_[1].border_xid)); 875 EXPECT_TRUE(WindowIsOffscreen(entries_[1].border_xid));
871 EXPECT_TRUE(WindowIsOffscreen(entries_[1].image_xid)); 876 EXPECT_TRUE(WindowIsOffscreen(entries_[1].image_xid));
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1218
1214 } 1219 }
1215 1220
1216 // Test that we focus the first controls window as soon as we map it. 1221 // Test that we focus the first controls window as soon as we map it.
1217 TEST_F(LoginControllerTest, FocusFirstControlsWindowImmediately) { 1222 TEST_F(LoginControllerTest, FocusFirstControlsWindowImmediately) {
1218 // Create just a background window. 1223 // Create just a background window.
1219 CreateLoginWindows(0, true, false, false); 1224 CreateLoginWindows(0, true, false, false);
1220 1225
1221 // Create a border window for the first entry. 1226 // Create a border window for the first entry.
1222 XWindow border_xid = 1227 XWindow border_xid =
1223 CreateBasicWindow(0, 0, 1228 CreateBasicWindow(
1224 kImageSize + 2 * kGapBetweenImageAndControls, 1229 Rect(0, 0,
1225 kImageSize + kControlsSize + 3 * kGapBetweenImageAndControls); 1230 kImageSize + 2 * kGapBetweenImageAndControls,
1231 kImageSize + kControlsSize + 3 * kGapBetweenImageAndControls));
1226 vector<int> params; 1232 vector<int> params;
1227 params.push_back(0); // entry index 1233 params.push_back(0); // entry index
1228 params.push_back(1); // num entries 1234 params.push_back(1); // num entries
1229 params.push_back(kUnselectedImageSize); 1235 params.push_back(kUnselectedImageSize);
1230 params.push_back(kGapBetweenImageAndControls); 1236 params.push_back(kGapBetweenImageAndControls);
1231 wm_->wm_ipc()->SetWindowType( 1237 wm_->wm_ipc()->SetWindowType(
1232 border_xid, 1238 border_xid,
1233 chromeos::WM_IPC_WINDOW_LOGIN_BORDER, 1239 chromeos::WM_IPC_WINDOW_LOGIN_BORDER,
1234 &params); 1240 &params);
1235 SendInitialEventsForWindow(border_xid); 1241 SendInitialEventsForWindow(border_xid);
1236 1242
1237 // Now create a controls window for the entry. Don't map it yet. 1243 // Now create a controls window for the entry. Don't map it yet.
1238 XWindow controls_xid = CreateBasicWindow(0, 0, kImageSize, kControlsSize); 1244 XWindow controls_xid =
1245 CreateBasicWindow(Rect(0, 0, kImageSize, kControlsSize));
1239 ConfigureWindowForSyncRequestProtocol(controls_xid); 1246 ConfigureWindowForSyncRequestProtocol(controls_xid);
1240 params.clear(); 1247 params.clear();
1241 params.push_back(0); // entry index 1248 params.push_back(0); // entry index
1242 wm_->wm_ipc()->SetWindowType( 1249 wm_->wm_ipc()->SetWindowType(
1243 controls_xid, 1250 controls_xid,
1244 chromeos::WM_IPC_WINDOW_LOGIN_CONTROLS, 1251 chromeos::WM_IPC_WINDOW_LOGIN_CONTROLS,
1245 &params); 1252 &params);
1246 XEvent event; 1253 XEvent event;
1247 xconn_->InitCreateWindowEvent(&event, controls_xid); 1254 xconn_->InitCreateWindowEvent(&event, controls_xid);
1248 wm_->HandleEvent(&event); 1255 wm_->HandleEvent(&event);
1249 1256
1250 // As soon as we send a map request, the controls window should be focused. 1257 // As soon as we send a map request, the controls window should be focused.
1251 EXPECT_EQ(0, xconn_->focused_xid()); 1258 EXPECT_EQ(0, xconn_->focused_xid());
1252 xconn_->InitMapRequestEvent(&event, controls_xid); 1259 xconn_->InitMapRequestEvent(&event, controls_xid);
1253 wm_->HandleEvent(&event); 1260 wm_->HandleEvent(&event);
1254 EXPECT_EQ(controls_xid, xconn_->focused_xid()); 1261 EXPECT_EQ(controls_xid, xconn_->focused_xid());
1255 EXPECT_EQ(controls_xid, GetActiveWindowProperty()); 1262 EXPECT_EQ(controls_xid, GetActiveWindowProperty());
1256 } 1263 }
1257 1264
1258 #ifndef TOUCH_UI 1265 #ifndef TOUCH_UI
1259 TEST_F(LoginControllerTest, UnhideCursorOnLeave) { 1266 TEST_F(LoginControllerTest, UnhideCursorOnLeave) {
1260 // At startup, we should hide the cursor and map a fullscreen input window. 1267 // At startup, we should hide the cursor and map a fullscreen input window.
1261 EXPECT_FALSE(xconn_->cursor_shown()); 1268 EXPECT_FALSE(xconn_->cursor_shown());
1262 XWindow hide_mouse_cursor_xid = login_controller_->hide_mouse_cursor_xid_; 1269 XWindow hide_mouse_cursor_xid = login_controller_->hide_mouse_cursor_xid_;
1263 ASSERT_TRUE(hide_mouse_cursor_xid != 0); 1270 ASSERT_TRUE(hide_mouse_cursor_xid != 0);
1264 MockXConnection::WindowInfo* info = 1271 MockXConnection::WindowInfo* info =
1265 xconn_->GetWindowInfoOrDie(hide_mouse_cursor_xid); 1272 xconn_->GetWindowInfoOrDie(hide_mouse_cursor_xid);
1266 EXPECT_EQ(wm_->bounds(), info->bounds); 1273 EXPECT_EQ(wm_->root_bounds(), info->bounds);
1267 EXPECT_TRUE(info->input_only); 1274 EXPECT_TRUE(info->input_only);
1268 EXPECT_TRUE(info->mapped); 1275 EXPECT_TRUE(info->mapped);
1269 1276
1270 // The window should be destroyed and the cursor shown as soon as the mouse 1277 // The window should be destroyed and the cursor shown as soon as the mouse
1271 // moves. 1278 // moves.
1272 XEvent event; 1279 XEvent event;
1273 xconn_->InitMotionNotifyEvent(&event, hide_mouse_cursor_xid, Point(0, 0)); 1280 xconn_->InitMotionNotifyEvent(&event, hide_mouse_cursor_xid, Point(0, 0));
1274 wm_->HandleEvent(&event); 1281 wm_->HandleEvent(&event);
1275 EXPECT_TRUE(xconn_->cursor_shown()); 1282 EXPECT_TRUE(xconn_->cursor_shown());
1276 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) == NULL); 1283 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) == NULL);
(...skipping 11 matching lines...) Expand all
1288 EXPECT_FALSE(xconn_->cursor_shown()); 1295 EXPECT_FALSE(xconn_->cursor_shown());
1289 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) != NULL); 1296 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) != NULL);
1290 1297
1291 // ... and after the user logs in... 1298 // ... and after the user logs in...
1292 SetLoggedInState(true); 1299 SetLoggedInState(true);
1293 EXPECT_FALSE(xconn_->cursor_shown()); 1300 EXPECT_FALSE(xconn_->cursor_shown());
1294 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) != NULL); 1301 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) != NULL);
1295 1302
1296 // ... and after the first browser window is mapped. 1303 // ... and after the first browser window is mapped.
1297 XWindow browser_xid = 1304 XWindow browser_xid =
1298 CreateToplevelWindow(1, 0, // tab_count, selected_tab 1305 CreateToplevelWindow(1, 0, Rect(0, 0, 200, 200));
1299 0, 0, 200, 200); // position and size
1300 ConfigureWindowForSyncRequestProtocol(browser_xid); 1306 ConfigureWindowForSyncRequestProtocol(browser_xid);
1301 SendInitialEventsForWindow(browser_xid); 1307 SendInitialEventsForWindow(browser_xid);
1302 EXPECT_FALSE(xconn_->cursor_shown()); 1308 EXPECT_FALSE(xconn_->cursor_shown());
1303 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) != NULL); 1309 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) != NULL);
1304 1310
1305 // Once the browser window is visible, it should be destroyed. 1311 // Once the browser window is visible, it should be destroyed.
1306 SendSyncRequestProtocolAlarm(browser_xid); 1312 SendSyncRequestProtocolAlarm(browser_xid);
1307 EXPECT_TRUE(xconn_->cursor_shown()); 1313 EXPECT_TRUE(xconn_->cursor_shown());
1308 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) == NULL); 1314 EXPECT_TRUE(xconn_->GetWindowInfo(hide_mouse_cursor_xid) == NULL);
1309 } 1315 }
(...skipping 12 matching lines...) Expand all
1322 1328
1323 xconn_->InitMapRequestEvent(&event, wizard_xid_); 1329 xconn_->InitMapRequestEvent(&event, wizard_xid_);
1324 wm_->HandleEvent(&event); 1330 wm_->HandleEvent(&event);
1325 } 1331 }
1326 1332
1327 } // namespace window_manager 1333 } // namespace window_manager
1328 1334
1329 int main(int argc, char** argv) { 1335 int main(int argc, char** argv) {
1330 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); 1336 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr);
1331 } 1337 }
OLDNEW
« no previous file with comments | « login/login_controller.cc ('k') | modality_handler.h » ('j') | window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698