blob: 1d2b49ed56bca3dd43151a199cd3fed8ea6f6a49 [file] [log] [blame]
[email protected]c39be8f2012-06-15 22:58:361// 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
[email protected]2e236a52012-06-27 22:21:475#include "ash/display/display_controller.h"
[email protected]6bdf7952012-11-14 10:10:586#include "ash/display/display_manager.h"
[email protected]e67291f12012-10-10 05:52:387#include "ash/screen_ash.h"
[email protected]c39be8f2012-06-15 22:58:368#include "ash/shell.h"
[email protected]e67291f12012-10-10 05:52:389#include "ash/shell_window_ids.h"
[email protected]263898a2012-09-17 17:20:0710#include "ash/system/tray/system_tray.h"
[email protected]c39be8f2012-06-15 22:58:3611#include "ash/test/ash_test_base.h"
[email protected]7203a5e2012-08-06 18:27:4612#include "ash/wm/coordinate_conversion.h"
[email protected]7ae525002012-07-26 23:55:1013#include "ash/wm/property_util.h"
[email protected]0f81f442012-06-22 06:20:2714#include "ash/wm/window_cycle_controller.h"
[email protected]578048512012-09-19 20:01:2415#include "ash/wm/window_properties.h"
[email protected]c39be8f2012-06-15 22:58:3616#include "ash/wm/window_util.h"
[email protected]e67291f12012-10-10 05:52:3817#include "base/string_util.h"
[email protected]c39be8f2012-06-15 22:58:3618#include "ui/aura/client/activation_client.h"
19#include "ui/aura/client/capture_client.h"
[email protected]8cfb6722012-11-28 03:28:4620#include "ui/aura/client/focus_client.h"
[email protected]c39be8f2012-06-15 22:58:3621#include "ui/aura/root_window.h"
22#include "ui/aura/test/event_generator.h"
[email protected]a5e71c92012-06-22 22:09:0823#include "ui/aura/test/test_windows.h"
[email protected]c39be8f2012-06-15 22:58:3624#include "ui/aura/window.h"
25#include "ui/base/cursor/cursor.h"
[email protected]2e98aaf72012-11-08 06:30:5926#include "ui/base/events/event_handler.h"
[email protected]a5e71c92012-06-22 22:09:0827#include "ui/gfx/display.h"
[email protected]718b26c2012-07-24 20:53:2328#include "ui/gfx/screen.h"
[email protected]e67291f12012-10-10 05:52:3829#include "ui/views/controls/textfield/textfield.h"
[email protected]c39be8f2012-06-15 22:58:3630#include "ui/views/widget/widget.h"
31#include "ui/views/widget/widget_delegate.h"
32
33namespace ash {
34namespace {
35
[email protected]f059c6942012-07-21 14:27:5736views::Widget* CreateTestWidgetWithParent(views::Widget* parent,
37 const gfx::Rect& bounds,
38 bool child) {
[email protected]c39be8f2012-06-15 22:58:3639 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
[email protected]f059c6942012-07-21 14:27:5740 params.parent_widget = parent;
[email protected]c39be8f2012-06-15 22:58:3641 params.bounds = bounds;
[email protected]f059c6942012-07-21 14:27:5742 params.child = child;
[email protected]c39be8f2012-06-15 22:58:3643 views::Widget* widget = new views::Widget;
44 widget->Init(params);
[email protected]0f81f442012-06-22 06:20:2745 widget->Show();
[email protected]c39be8f2012-06-15 22:58:3646 return widget;
47}
48
[email protected]f059c6942012-07-21 14:27:5749views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
50 return CreateTestWidgetWithParent(NULL, bounds, false);
51}
52
[email protected]edbfb8d2012-09-03 08:33:4353void SetSecondaryDisplayLayout(DisplayLayout::Position position) {
54 DisplayController* display_controller =
55 Shell::GetInstance()->display_controller();
56 DisplayLayout layout = display_controller->default_display_layout();
57 layout.position = position;
58 display_controller->SetDefaultDisplayLayout(layout);
59}
60
[email protected]c39be8f2012-06-15 22:58:3661class ModalWidgetDelegate : public views::WidgetDelegateView {
62 public:
63 ModalWidgetDelegate() {}
64 virtual ~ModalWidgetDelegate() {}
65
66 // Overridden from views::WidgetDelegate:
67 virtual views::View* GetContentsView() OVERRIDE {
68 return this;
69 }
70 virtual ui::ModalType GetModalType() const OVERRIDE {
71 return ui::MODAL_TYPE_SYSTEM;
72 }
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate);
76};
77
[email protected]6bdf7952012-11-14 10:10:5878internal::DisplayManager* GetDisplayManager() {
79 return Shell::GetInstance()->display_manager();
[email protected]3e4351b2012-08-09 04:04:1680}
81
[email protected]2e98aaf72012-11-08 06:30:5982// An event filter which moves the target window to the secondary root window
83// at pre-handle phase of a mouse release event.
84class MoveWindowByClickEventFilter : public ui::EventHandler {
85 public:
86 explicit MoveWindowByClickEventFilter(aura::Window* target)
87 : target_(target) {}
88 virtual ~MoveWindowByClickEventFilter() {}
89
90 private:
91 // ui::EventHandler overrides:
[email protected]2e98aaf72012-11-08 06:30:5992 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
93 if (event->type() == ui::ET_MOUSE_RELEASED) {
94 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
95 DCHECK_LT(1u, root_windows.size());
96 root_windows[1]->AddChild(target_);
97 }
98 return ui::ER_UNHANDLED;
99 }
100
[email protected]2e98aaf72012-11-08 06:30:59101 aura::Window* target_;
102 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventFilter);
103};
104
[email protected]c39be8f2012-06-15 22:58:36105} // namespace
106
[email protected]3e4351b2012-08-09 04:04:16107typedef test::AshTestBase ExtendedDesktopTest;
[email protected]c39be8f2012-06-15 22:58:36108
109// Test conditions that root windows in extended desktop mode
110// must satisfy.
111TEST_F(ExtendedDesktopTest, Basic) {
[email protected]f634dd32012-07-23 22:49:07112 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36113 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
114
115 // All root windows must have the root window controller.
116 ASSERT_EQ(2U, root_windows.size());
117 for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
118 iter != root_windows.end(); ++iter) {
[email protected]7ae525002012-07-26 23:55:10119 EXPECT_TRUE(GetRootWindowController(*iter) != NULL);
[email protected]c39be8f2012-06-15 22:58:36120 }
121 // Make sure root windows share the same controllers.
[email protected]8cfb6722012-11-28 03:28:46122 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]),
123 aura::client::GetFocusClient(root_windows[1]));
[email protected]c39be8f2012-06-15 22:58:36124 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]),
125 aura::client::GetActivationClient(root_windows[1]));
126 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]),
127 aura::client::GetCaptureClient(root_windows[1]));
128}
129
130TEST_F(ExtendedDesktopTest, Activation) {
[email protected]f634dd32012-07-23 22:49:07131 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36132 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
133
[email protected]c39be8f2012-06-15 22:58:36134 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
[email protected]f634dd32012-07-23 22:49:07135 views::Widget* widget_on_2nd =
136 CreateTestWidget(gfx::Rect(1200, 10, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36137 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
[email protected]f634dd32012-07-23 22:49:07138 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow());
[email protected]c39be8f2012-06-15 22:58:36139
140 EXPECT_EQ(widget_on_2nd->GetNativeView(),
[email protected]8cfb6722012-11-28 03:28:46141 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
[email protected]c39be8f2012-06-15 22:58:36142 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
143
[email protected]f634dd32012-07-23 22:49:07144 aura::test::EventGenerator generator_1st(root_windows[0]);
145 aura::test::EventGenerator generator_2nd(root_windows[1]);
146
147 // Clicking a window changes the active window and active root window.
[email protected]c39be8f2012-06-15 22:58:36148 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
149 generator_1st.ClickLeftButton();
150
151 EXPECT_EQ(widget_on_1st->GetNativeView(),
[email protected]8cfb6722012-11-28 03:28:46152 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
[email protected]c39be8f2012-06-15 22:58:36153 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
[email protected]f634dd32012-07-23 22:49:07154
155 generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView());
156 generator_2nd.ClickLeftButton();
157
158 EXPECT_EQ(widget_on_2nd->GetNativeView(),
[email protected]8cfb6722012-11-28 03:28:46159 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
[email protected]f634dd32012-07-23 22:49:07160 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
[email protected]c39be8f2012-06-15 22:58:36161}
162
163TEST_F(ExtendedDesktopTest, SystemModal) {
[email protected]f634dd32012-07-23 22:49:07164 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36165 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]c39be8f2012-06-15 22:58:36166
167 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36168 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
[email protected]492533b32012-09-21 19:06:14169 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
[email protected]c39be8f2012-06-15 22:58:36170 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
171
[email protected]c39be8f2012-06-15 22:58:36172 // Open system modal. Make sure it's on 2nd root window and active.
[email protected]f634dd32012-07-23 22:49:07173 views::Widget* modal_widget = views::Widget::CreateWindowWithBounds(
174 new ModalWidgetDelegate(), gfx::Rect(1200, 100, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36175 modal_widget->Show();
176 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView()));
177 EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow());
178 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow());
179
[email protected]2e236a52012-06-27 22:21:47180 // Clicking a widget on widget_on_1st display should not change activation.
[email protected]c39be8f2012-06-15 22:58:36181 aura::test::EventGenerator generator_1st(root_windows[0]);
182 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
183 generator_1st.ClickLeftButton();
184 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView()));
185 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow());
186
187 // Close system modal and so clicking a widget should work now.
188 modal_widget->Close();
189 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
190 generator_1st.ClickLeftButton();
191 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
192 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
193}
194
195TEST_F(ExtendedDesktopTest, TestCursor) {
[email protected]f634dd32012-07-23 22:49:07196 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36197 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]c39be8f2012-06-15 22:58:36198 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type());
199 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type());
[email protected]151ffdff2012-09-11 20:18:35200 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy);
[email protected]c39be8f2012-06-15 22:58:36201 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type());
202 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type());
203}
204
[email protected]718b26c2012-07-24 20:53:23205TEST_F(ExtendedDesktopTest, TestCursorLocation) {
206 UpdateDisplay("0+0-1000x600,1001+0-600x400");
207 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
208 aura::Window::TestApi root_window0_test_api(root_windows[0]);
209 aura::Window::TestApi root_window1_test_api(root_windows[1]);
210
211 root_windows[0]->MoveCursorTo(gfx::Point(10, 10));
[email protected]ffabb1e2012-10-12 19:51:17212 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
[email protected]718b26c2012-07-24 20:53:23213 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
214 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
215 root_windows[1]->MoveCursorTo(gfx::Point(10, 20));
[email protected]ffabb1e2012-10-12 19:51:17216 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString());
[email protected]718b26c2012-07-24 20:53:23217 EXPECT_FALSE(root_window0_test_api.ContainsMouse());
218 EXPECT_TRUE(root_window1_test_api.ContainsMouse());
219 root_windows[0]->MoveCursorTo(gfx::Point(20, 10));
[email protected]ffabb1e2012-10-12 19:51:17220 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
[email protected]718b26c2012-07-24 20:53:23221 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
222 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
223}
224
[email protected]0f81f442012-06-22 06:20:27225TEST_F(ExtendedDesktopTest, CycleWindows) {
[email protected]f634dd32012-07-23 22:49:07226 UpdateDisplay("700x500,500x500");
[email protected]0f81f442012-06-22 06:20:27227 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24228
[email protected]0f81f442012-06-22 06:20:27229 WindowCycleController* controller =
230 Shell::GetInstance()->window_cycle_controller();
231
[email protected]0f81f442012-06-22 06:20:27232 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
233 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
[email protected]20c59762012-06-23 01:10:24234 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
[email protected]0f81f442012-06-22 06:20:27235 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
236 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
237
238 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
239 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
240 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
241 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
242 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
243 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
244 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
245 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
246
247 // Cycle through all windows across root windows.
[email protected]20c59762012-06-23 01:10:24248 views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100));
[email protected]0f81f442012-06-22 06:20:27249 EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow());
[email protected]20c59762012-06-23 01:10:24250 views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100));
[email protected]0f81f442012-06-22 06:20:27251 EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow());
252
253 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
[email protected]0f81f442012-06-22 06:20:27254 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
255 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
[email protected]8fef7432012-08-06 15:34:25256 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
257 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
[email protected]0f81f442012-06-22 06:20:27258 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
259 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
260 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
261
262 // Backwards
263 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
264 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
265 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
[email protected]0f81f442012-06-22 06:20:27266 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
267 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
[email protected]8fef7432012-08-06 15:34:25268 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
269 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
[email protected]0f81f442012-06-22 06:20:27270 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
[email protected]20c59762012-06-23 01:10:24271}
272
273TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
[email protected]f634dd32012-07-23 22:49:07274 UpdateDisplay("700x500,500x500");
[email protected]edbfb8d2012-09-03 08:33:43275 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
[email protected]20c59762012-06-23 01:10:24276 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24277
[email protected]7203a5e2012-08-06 18:27:46278 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100)));
279 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100)));
280 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300)));
281 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300)));
[email protected]20c59762012-06-23 01:10:24282
283 // Zero origin.
[email protected]7203a5e2012-08-06 18:27:46284 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0)));
[email protected]20c59762012-06-23 01:10:24285
286 // Out of range point should return the primary root window
[email protected]7203a5e2012-08-06 18:27:46287 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0)));
288 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100)));
[email protected]20c59762012-06-23 01:10:24289}
290
291TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
[email protected]f634dd32012-07-23 22:49:07292 UpdateDisplay("700x500,500x500");
[email protected]edbfb8d2012-09-03 08:33:43293 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
[email protected]66b05eac2012-06-27 23:53:10294
[email protected]20c59762012-06-23 01:10:24295 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24296
297 // Containing rect.
298 EXPECT_EQ(root_windows[1],
[email protected]7203a5e2012-08-06 18:27:46299 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
[email protected]20c59762012-06-23 01:10:24300 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46301 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
[email protected]20c59762012-06-23 01:10:24302
303 // Intersecting rect.
304 EXPECT_EQ(root_windows[1],
[email protected]7203a5e2012-08-06 18:27:46305 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
[email protected]20c59762012-06-23 01:10:24306 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46307 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)));
[email protected]20c59762012-06-23 01:10:24308
309 // Zero origin.
[email protected]66b05eac2012-06-27 23:53:10310 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46311 wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)));
[email protected]66b05eac2012-06-27 23:53:10312 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46313 wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)));
[email protected]20c59762012-06-23 01:10:24314
315 // Empty rect.
316 EXPECT_EQ(root_windows[1],
[email protected]7203a5e2012-08-06 18:27:46317 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)));
[email protected]20c59762012-06-23 01:10:24318 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46319 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)));
[email protected]20c59762012-06-23 01:10:24320
321 // Out of range rect should return the primary root window.
322 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46323 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
[email protected]20c59762012-06-23 01:10:24324 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46325 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
[email protected]0f81f442012-06-22 06:20:27326}
327
[email protected]7f502eb2012-09-20 09:17:12328#if defined(OS_WIN)
329// TODO(mazda): Re-enable this (http://crbug.com/150986).
330#define MAYBE_Capture DISABLED_Capture
331#else
332#define MAYBE_Capture Capture
333#endif
334
335TEST_F(ExtendedDesktopTest, MAYBE_Capture) {
[email protected]f634dd32012-07-23 22:49:07336 UpdateDisplay("1000x600,600x400");
[email protected]a5e71c92012-06-22 22:09:08337 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
338
339 aura::test::EventCountDelegate r1_d1;
340 aura::test::EventCountDelegate r1_d2;
341 aura::test::EventCountDelegate r2_d1;
342
343 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
344 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
345 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
346 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
347 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
348 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
[email protected]f634dd32012-07-23 22:49:07349
[email protected]a5e71c92012-06-22 22:09:08350 r1_w1->SetCapture();
351
352 EXPECT_EQ(r1_w1.get(),
353 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
354 aura::test::EventGenerator generator2(root_windows[1]);
355 generator2.MoveMouseToCenterOf(r2_w1.get());
356 generator2.ClickLeftButton();
357 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
358 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
[email protected]b19ba4adf2012-09-07 16:13:29359 // The mouse is outside. On chromeos, the mouse is warped to the
360 // dest root window, but it's not implemented on Win yet, so
361 // no mouse move event on Win.
362#if defined(OS_WIN)
363 EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset());
364#else
[email protected]7495e5032012-09-07 15:31:45365 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
[email protected]b19ba4adf2012-09-07 16:13:29366#endif
[email protected]a5e71c92012-06-22 22:09:08367 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset());
[email protected]f634dd32012-07-23 22:49:07368 // (15,15) on 1st display is (-985,15) on 2nd display.
369 generator2.MoveMouseTo(-985, 15);
370 EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset());
[email protected]a5e71c92012-06-22 22:09:08371
372 r1_w2->SetCapture();
373 EXPECT_EQ(r1_w2.get(),
374 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
375 generator2.MoveMouseBy(10, 10);
376 generator2.ClickLeftButton();
377 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
378 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
379 // mouse is already entered.
380 EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset());
381 EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset());
382
383 r1_w2->ReleaseCapture();
[email protected]36f566532012-09-19 04:07:24384 EXPECT_EQ(NULL, aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
[email protected]f634dd32012-07-23 22:49:07385 generator2.MoveMouseTo(15, 15);
[email protected]a5e71c92012-06-22 22:09:08386 generator2.ClickLeftButton();
387 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset());
388 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset());
389 // Make sure the mouse_moved_handler_ is properly reset.
390 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
391 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
392}
393
[email protected]f059c6942012-07-21 14:27:57394TEST_F(ExtendedDesktopTest, MoveWindow) {
[email protected]f634dd32012-07-23 22:49:07395 UpdateDisplay("1000x600,600x400");
[email protected]f059c6942012-07-21 14:27:57396 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
397 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
398
399 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
400
401 d1->SetBounds(gfx::Rect(1010, 10, 100, 100));
402 EXPECT_EQ("1010,10 100x100",
403 d1->GetWindowBoundsInScreen().ToString());
404
405 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
406
407 d1->SetBounds(gfx::Rect(10, 10, 100, 100));
408 EXPECT_EQ("10,10 100x100",
409 d1->GetWindowBoundsInScreen().ToString());
410
411 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
412
413 // Make sure the bounds which doesn't fit to the root window
414 // works correctly.
415 d1->SetBounds(gfx::Rect(1560, 30, 100, 100));
416 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
417 EXPECT_EQ("1560,30 100x100",
418 d1->GetWindowBoundsInScreen().ToString());
419
420 // Setting outside of root windows will be moved to primary root window.
421 // TODO(oshima): This one probably should pick the closest root window.
422 d1->SetBounds(gfx::Rect(200, 10, 100, 100));
423 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
[email protected]f059c6942012-07-21 14:27:57424}
425
[email protected]2e98aaf72012-11-08 06:30:59426// Verifies if the mouse event arrives to the window even when the window
427// moves to another root in a pre-target handler. See: crbug.com/157583
428TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
429 UpdateDisplay("1000x600,600x400");
430
431 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
432 aura::test::EventCountDelegate delegate;
433 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
434 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
435 MoveWindowByClickEventFilter event_filter(window.get());
436 window->AddPreTargetHandler(&event_filter);
437 aura::test::EventGenerator generator(root_windows[0], window.get());
438 generator.ClickLeftButton();
439 // Both mouse pressed and released arrive at the window and its delegate.
440 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
441 // Also event_filter moves the window to another root at mouse release.
442 EXPECT_EQ(root_windows[1], window->GetRootWindow());
443}
444
[email protected]608f02f2012-10-25 05:53:33445// This test fails on the "Win Aura" bot: <http://crbug.com/157817>.
446#if defined(OS_WIN)
447#define MAYBE_MoveWindowToDisplay DISABLED_MoveWindowToDisplay
448#else
449#define MAYBE_MoveWindowToDisplay MoveWindowToDisplay
450#endif
451TEST_F(ExtendedDesktopTest, MAYBE_MoveWindowToDisplay) {
[email protected]e79f26e2012-08-09 07:12:48452 UpdateDisplay("1000x1000,1000x1000");
453 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
454
[email protected]ffabb1e2012-10-12 19:51:17455 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching(
456 root_windows[0]->GetBoundsInScreen());
457 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching(
458 root_windows[1]->GetBoundsInScreen());
[email protected]e79f26e2012-08-09 07:12:48459 EXPECT_NE(display0.id(), display1.id());
460
461 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100));
462 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
463
464 // Move the window where the window spans both root windows. Since the second
465 // parameter is |display1|, the window should be shown on the secondary root.
466 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
467 display1);
468 EXPECT_EQ("500,10 1000x100",
469 d1->GetWindowBoundsInScreen().ToString());
470 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
471
472 // Move to the primary root.
473 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
474 display0);
475 EXPECT_EQ("500,10 1000x100",
476 d1->GetWindowBoundsInScreen().ToString());
477 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
478}
479
[email protected]f059c6942012-07-21 14:27:57480TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
[email protected]f634dd32012-07-23 22:49:07481 UpdateDisplay("1000x600,600x400");
[email protected]f059c6942012-07-21 14:27:57482 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
483 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
484 views::Widget* w1_t1 = CreateTestWidgetWithParent(
485 w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
486 // Transient child of the transient child.
487 views::Widget* w1_t11 = CreateTestWidgetWithParent(
488 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
489
490 views::Widget* w11 = CreateTestWidgetWithParent(
491 w1, gfx::Rect(10, 10, 40, 40), true /* child */);
492 views::Widget* w11_t1 = CreateTestWidgetWithParent(
493 w1, gfx::Rect(1300, 100, 80, 80), false /* transient */);
494
495 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
496 EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow());
497 EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow());
498 EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow());
499 EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow());
500 EXPECT_EQ("50,50 50x50",
501 w1_t1->GetWindowBoundsInScreen().ToString());
502 EXPECT_EQ("1200,70 30x30",
503 w1_t11->GetWindowBoundsInScreen().ToString());
504 EXPECT_EQ("20,20 40x40",
505 w11->GetWindowBoundsInScreen().ToString());
506 EXPECT_EQ("1300,100 80x80",
507 w11_t1->GetWindowBoundsInScreen().ToString());
508
509 w1->SetBounds(gfx::Rect(1100,10,100,100));
510
511 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
512 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
513 EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow());
514 EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow());
515 EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow());
516
517 EXPECT_EQ("1110,20 40x40",
518 w11->GetWindowBoundsInScreen().ToString());
519 // Transient window's screen bounds stays the same.
520 EXPECT_EQ("50,50 50x50",
521 w1_t1->GetWindowBoundsInScreen().ToString());
522 EXPECT_EQ("1200,70 30x30",
523 w1_t11->GetWindowBoundsInScreen().ToString());
524 EXPECT_EQ("1300,100 80x80",
525 w11_t1->GetWindowBoundsInScreen().ToString());
526
527 // Transient window doesn't move between root window unless
528 // its transient parent moves.
529 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50));
530 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
531 EXPECT_EQ("10,50 50x50",
532 w1_t1->GetWindowBoundsInScreen().ToString());
[email protected]f059c6942012-07-21 14:27:57533}
534
[email protected]a5e71c92012-06-22 22:09:08535namespace internal {
[email protected]ca7060982012-08-08 18:05:25536// Test if the Window::ConvertPointToTarget works across root windows.
[email protected]a5e71c92012-06-22 22:09:08537// TODO(oshima): Move multiple display suport and this test to aura.
538TEST_F(ExtendedDesktopTest, ConvertPoint) {
[email protected]f634dd32012-07-23 22:49:07539 UpdateDisplay("1000x600,600x400");
[email protected]a5e71c92012-06-22 22:09:08540 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
541 gfx::Display& display_1 =
[email protected]3e4351b2012-08-09 04:04:16542 GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]);
[email protected]a5e71c92012-06-22 22:09:08543 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
544 gfx::Display& display_2 =
[email protected]3e4351b2012-08-09 04:04:16545 GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]f634dd32012-07-23 22:49:07546 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString());
547
[email protected]a5e71c92012-06-22 22:09:08548 aura::Window* d1 =
549 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
[email protected]a5e71c92012-06-22 22:09:08550 aura::Window* d2 =
[email protected]f634dd32012-07-23 22:49:07551 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView();
552 EXPECT_EQ(root_windows[0], d1->GetRootWindow());
553 EXPECT_EQ(root_windows[1], d2->GetRootWindow());
[email protected]a5e71c92012-06-22 22:09:08554
[email protected]a5e71c92012-06-22 22:09:08555 // Convert point in the Root2's window to the Root1's window Coord.
556 gfx::Point p(0, 0);
[email protected]ca7060982012-08-08 18:05:25557 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p);
[email protected]f634dd32012-07-23 22:49:07558 EXPECT_EQ("1000,0", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08559 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25560 aura::Window::ConvertPointToTarget(d2, d1, &p);
[email protected]f634dd32012-07-23 22:49:07561 EXPECT_EQ("1010,10", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08562
563 // Convert point in the Root1's window to the Root2's window Coord.
564 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25565 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p);
[email protected]f634dd32012-07-23 22:49:07566 EXPECT_EQ("-1000,0", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08567 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25568 aura::Window::ConvertPointToTarget(d1, d2, &p);
[email protected]f634dd32012-07-23 22:49:07569 EXPECT_EQ("-1010,-10", p.ToString());
570
571 // Move the 2nd display to the bottom and test again.
[email protected]edbfb8d2012-09-03 08:33:43572 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
[email protected]f634dd32012-07-23 22:49:07573
[email protected]3e4351b2012-08-09 04:04:16574 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]f634dd32012-07-23 22:49:07575 EXPECT_EQ("0,600", display_2.bounds().origin().ToString());
576
577 // Convert point in Root2's window to Root1's window Coord.
578 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25579 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p);
[email protected]f634dd32012-07-23 22:49:07580 EXPECT_EQ("0,600", p.ToString());
581 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25582 aura::Window::ConvertPointToTarget(d2, d1, &p);
[email protected]f634dd32012-07-23 22:49:07583 EXPECT_EQ("10,610", p.ToString());
584
585 // Convert point in Root1's window to Root2's window Coord.
586 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25587 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p);
[email protected]f634dd32012-07-23 22:49:07588 EXPECT_EQ("0,-600", p.ToString());
589 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25590 aura::Window::ConvertPointToTarget(d1, d2, &p);
[email protected]f634dd32012-07-23 22:49:07591 EXPECT_EQ("-10,-610", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08592}
[email protected]f634dd32012-07-23 22:49:07593
[email protected]263898a2012-09-17 17:20:07594TEST_F(ExtendedDesktopTest, OpenSystemTray) {
[email protected]596c61c2012-10-29 17:29:43595 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07596 SystemTray* tray = ash::Shell::GetInstance()->system_tray();
597 ASSERT_FALSE(tray->HasSystemBubble());
598
599 // Opens the tray by a dummy click event and makes sure that adding/removing
600 // displays doesn't break anything.
601 aura::test::EventGenerator event_generator(
602 ash::Shell::GetInstance()->GetPrimaryRootWindow(),
603 tray->GetWidget()->GetNativeWindow());
604 event_generator.ClickLeftButton();
605 EXPECT_TRUE(tray->HasSystemBubble());
606
[email protected]596c61c2012-10-29 17:29:43607 UpdateDisplay("500x600");
[email protected]263898a2012-09-17 17:20:07608 EXPECT_TRUE(tray->HasSystemBubble());
[email protected]596c61c2012-10-29 17:29:43609 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07610 EXPECT_TRUE(tray->HasSystemBubble());
611
612 // Closes the tray and again makes sure that adding/removing displays doesn't
613 // break anything.
614 event_generator.ClickLeftButton();
615 RunAllPendingInMessageLoop();
616
617 EXPECT_FALSE(tray->HasSystemBubble());
618
[email protected]596c61c2012-10-29 17:29:43619 UpdateDisplay("500x600");
[email protected]263898a2012-09-17 17:20:07620 EXPECT_FALSE(tray->HasSystemBubble());
[email protected]596c61c2012-10-29 17:29:43621 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07622 EXPECT_FALSE(tray->HasSystemBubble());
623}
624
[email protected]578048512012-09-19 20:01:24625TEST_F(ExtendedDesktopTest, StayInSameRootWindow) {
626 UpdateDisplay("100x100,200x200");
627 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
628 views::Widget* w1 = CreateTestWidgetWithParent(
629 NULL, gfx::Rect(10, 10, 50, 50), false);
630 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
631 w1->SetBounds(gfx::Rect(150, 10, 50, 50));
632 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
633
634 // The widget stays in the same root if kStayInSameRootWindowKey is set to
635 // true.
636 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true);
637 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
638 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
639
640 // The widget should now move to the 1st root window without the property.
641 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey);
642 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
643 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
644}
645
[email protected]e67291f12012-10-10 05:52:38646TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
647 UpdateDisplay("100x100,200x200");
648 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
649
650 // Create normal windows on both displays.
651 views::Widget* widget1 = CreateTestWidget(
[email protected]ffabb1e2012-10-12 19:51:17652 Shell::GetScreen()->GetPrimaryDisplay().bounds());
[email protected]e67291f12012-10-10 05:52:38653 widget1->Show();
654 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
655 views::Widget* widget2 = CreateTestWidget(
656 ScreenAsh::GetSecondaryDisplay().bounds());
657 widget2->Show();
658 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
659
660 // Create a LockScreen window.
661 views::Widget* lock_widget = CreateTestWidget(
[email protected]ffabb1e2012-10-12 19:51:17662 Shell::GetScreen()->GetPrimaryDisplay().bounds());
[email protected]e67291f12012-10-10 05:52:38663 views::Textfield* textfield = new views::Textfield;
664 lock_widget->SetContentsView(textfield);
665
666 ash::Shell::GetContainer(
667 Shell::GetPrimaryRootWindow(),
668 ash::internal::kShellWindowId_LockScreenContainer)->
669 AddChild(lock_widget->GetNativeView());
670 lock_widget->Show();
671 textfield->RequestFocus();
672
[email protected]8cfb6722012-11-28 03:28:46673 aura::client::FocusClient* focus_client =
674 aura::client::GetFocusClient(root_windows[0]);
675 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38676
677 // The lock window should get events on both root windows.
678 aura::test::EventGenerator generator1(root_windows[0]);
679 generator1.PressKey(ui::VKEY_A, 0);
680 generator1.ReleaseKey(ui::VKEY_A, 0);
[email protected]8cfb6722012-11-28 03:28:46681 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38682 EXPECT_EQ("a", UTF16ToASCII(textfield->text()));
683
684 aura::test::EventGenerator generator2(root_windows[1]);
685 generator2.PressKey(ui::VKEY_B, 0);
686 generator2.ReleaseKey(ui::VKEY_B, 0);
[email protected]8cfb6722012-11-28 03:28:46687 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38688 EXPECT_EQ("ab", UTF16ToASCII(textfield->text()));
689
690 // Deleting 2nd display. The lock window still should get the events.
691 UpdateDisplay("100x100");
692 generator2.PressKey(ui::VKEY_C, 0);
693 generator2.ReleaseKey(ui::VKEY_C, 0);
[email protected]8cfb6722012-11-28 03:28:46694 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38695 EXPECT_EQ("abc", UTF16ToASCII(textfield->text()));
696
697 // Creating 2nd display again, and lock window still should get events
698 // on both root windows.
699 UpdateDisplay("100x100,200x200");
700 root_windows = Shell::GetAllRootWindows();
701 generator1.PressKey(ui::VKEY_D, 0);
702 generator1.ReleaseKey(ui::VKEY_D, 0);
[email protected]8cfb6722012-11-28 03:28:46703 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38704 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text()));
705
706 aura::test::EventGenerator generator22(root_windows[1]);
707 generator22.PressKey(ui::VKEY_E, 0);
708 generator22.ReleaseKey(ui::VKEY_E, 0);
[email protected]8cfb6722012-11-28 03:28:46709 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38710 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text()));
711}
712
[email protected]a5e71c92012-06-22 22:09:08713} // namespace internal
[email protected]c39be8f2012-06-15 22:58:36714} // namespace ash