blob: 741287b7c38fffbda334b8233af3e7fb2b72eae5 [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"
20#include "ui/aura/focus_manager.h"
21#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:
92 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
93 return ui::ER_UNHANDLED;
94 }
95
96 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
97 if (event->type() == ui::ET_MOUSE_RELEASED) {
98 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
99 DCHECK_LT(1u, root_windows.size());
100 root_windows[1]->AddChild(target_);
101 }
102 return ui::ER_UNHANDLED;
103 }
104
105 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE {
106 return ui::ER_UNHANDLED;
107 }
108
109 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
110 return ui::ER_UNHANDLED;
111 }
112
113 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
114 return ui::ER_UNHANDLED;
115 }
116
117 aura::Window* target_;
118 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventFilter);
119};
120
[email protected]c39be8f2012-06-15 22:58:36121} // namespace
122
[email protected]3e4351b2012-08-09 04:04:16123typedef test::AshTestBase ExtendedDesktopTest;
[email protected]c39be8f2012-06-15 22:58:36124
125// Test conditions that root windows in extended desktop mode
126// must satisfy.
127TEST_F(ExtendedDesktopTest, Basic) {
[email protected]f634dd32012-07-23 22:49:07128 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36129 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
130
131 // All root windows must have the root window controller.
132 ASSERT_EQ(2U, root_windows.size());
133 for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
134 iter != root_windows.end(); ++iter) {
[email protected]7ae525002012-07-26 23:55:10135 EXPECT_TRUE(GetRootWindowController(*iter) != NULL);
[email protected]c39be8f2012-06-15 22:58:36136 }
137 // Make sure root windows share the same controllers.
138 EXPECT_EQ(root_windows[0]->GetFocusManager(),
139 root_windows[1]->GetFocusManager());
140 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]),
141 aura::client::GetActivationClient(root_windows[1]));
142 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]),
143 aura::client::GetCaptureClient(root_windows[1]));
144}
145
146TEST_F(ExtendedDesktopTest, Activation) {
[email protected]f634dd32012-07-23 22:49:07147 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36148 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
149
[email protected]c39be8f2012-06-15 22:58:36150 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
[email protected]f634dd32012-07-23 22:49:07151 views::Widget* widget_on_2nd =
152 CreateTestWidget(gfx::Rect(1200, 10, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36153 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
[email protected]f634dd32012-07-23 22:49:07154 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow());
[email protected]c39be8f2012-06-15 22:58:36155
156 EXPECT_EQ(widget_on_2nd->GetNativeView(),
157 root_windows[0]->GetFocusManager()->GetFocusedWindow());
158 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
159
[email protected]f634dd32012-07-23 22:49:07160 aura::test::EventGenerator generator_1st(root_windows[0]);
161 aura::test::EventGenerator generator_2nd(root_windows[1]);
162
163 // Clicking a window changes the active window and active root window.
[email protected]c39be8f2012-06-15 22:58:36164 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
165 generator_1st.ClickLeftButton();
166
167 EXPECT_EQ(widget_on_1st->GetNativeView(),
168 root_windows[0]->GetFocusManager()->GetFocusedWindow());
169 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
[email protected]f634dd32012-07-23 22:49:07170
171 generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView());
172 generator_2nd.ClickLeftButton();
173
174 EXPECT_EQ(widget_on_2nd->GetNativeView(),
175 root_windows[0]->GetFocusManager()->GetFocusedWindow());
176 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
[email protected]c39be8f2012-06-15 22:58:36177}
178
179TEST_F(ExtendedDesktopTest, SystemModal) {
[email protected]f634dd32012-07-23 22:49:07180 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36181 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]c39be8f2012-06-15 22:58:36182
183 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36184 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
[email protected]492533b32012-09-21 19:06:14185 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
[email protected]c39be8f2012-06-15 22:58:36186 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
187
[email protected]c39be8f2012-06-15 22:58:36188 // Open system modal. Make sure it's on 2nd root window and active.
[email protected]f634dd32012-07-23 22:49:07189 views::Widget* modal_widget = views::Widget::CreateWindowWithBounds(
190 new ModalWidgetDelegate(), gfx::Rect(1200, 100, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36191 modal_widget->Show();
192 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView()));
193 EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow());
194 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow());
195
[email protected]2e236a52012-06-27 22:21:47196 // Clicking a widget on widget_on_1st display should not change activation.
[email protected]c39be8f2012-06-15 22:58:36197 aura::test::EventGenerator generator_1st(root_windows[0]);
198 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
199 generator_1st.ClickLeftButton();
200 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView()));
201 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow());
202
203 // Close system modal and so clicking a widget should work now.
204 modal_widget->Close();
205 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
206 generator_1st.ClickLeftButton();
207 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
208 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
209}
210
211TEST_F(ExtendedDesktopTest, TestCursor) {
[email protected]f634dd32012-07-23 22:49:07212 UpdateDisplay("1000x600,600x400");
[email protected]c39be8f2012-06-15 22:58:36213 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]c39be8f2012-06-15 22:58:36214 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type());
215 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type());
[email protected]151ffdff2012-09-11 20:18:35216 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy);
[email protected]c39be8f2012-06-15 22:58:36217 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type());
218 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type());
219}
220
[email protected]718b26c2012-07-24 20:53:23221TEST_F(ExtendedDesktopTest, TestCursorLocation) {
222 UpdateDisplay("0+0-1000x600,1001+0-600x400");
223 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
224 aura::Window::TestApi root_window0_test_api(root_windows[0]);
225 aura::Window::TestApi root_window1_test_api(root_windows[1]);
226
227 root_windows[0]->MoveCursorTo(gfx::Point(10, 10));
[email protected]ffabb1e2012-10-12 19:51:17228 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
[email protected]718b26c2012-07-24 20:53:23229 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
230 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
231 root_windows[1]->MoveCursorTo(gfx::Point(10, 20));
[email protected]ffabb1e2012-10-12 19:51:17232 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString());
[email protected]718b26c2012-07-24 20:53:23233 EXPECT_FALSE(root_window0_test_api.ContainsMouse());
234 EXPECT_TRUE(root_window1_test_api.ContainsMouse());
235 root_windows[0]->MoveCursorTo(gfx::Point(20, 10));
[email protected]ffabb1e2012-10-12 19:51:17236 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
[email protected]718b26c2012-07-24 20:53:23237 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
238 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
239}
240
[email protected]0f81f442012-06-22 06:20:27241TEST_F(ExtendedDesktopTest, CycleWindows) {
[email protected]f634dd32012-07-23 22:49:07242 UpdateDisplay("700x500,500x500");
[email protected]0f81f442012-06-22 06:20:27243 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24244
[email protected]0f81f442012-06-22 06:20:27245 WindowCycleController* controller =
246 Shell::GetInstance()->window_cycle_controller();
247
[email protected]0f81f442012-06-22 06:20:27248 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
249 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
[email protected]20c59762012-06-23 01:10:24250 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
[email protected]0f81f442012-06-22 06:20:27251 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
252 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
253
254 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
255 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
256 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
257 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
258 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
259 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
260 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
261 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
262
263 // Cycle through all windows across root windows.
[email protected]20c59762012-06-23 01:10:24264 views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100));
[email protected]0f81f442012-06-22 06:20:27265 EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow());
[email protected]20c59762012-06-23 01:10:24266 views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100));
[email protected]0f81f442012-06-22 06:20:27267 EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow());
268
269 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
[email protected]0f81f442012-06-22 06:20:27270 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
271 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
[email protected]8fef7432012-08-06 15:34:25272 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
273 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
[email protected]0f81f442012-06-22 06:20:27274 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
275 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
276 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
277
278 // Backwards
279 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
280 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
281 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
[email protected]0f81f442012-06-22 06:20:27282 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
283 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
[email protected]8fef7432012-08-06 15:34:25284 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
285 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
[email protected]0f81f442012-06-22 06:20:27286 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
[email protected]20c59762012-06-23 01:10:24287}
288
289TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
[email protected]f634dd32012-07-23 22:49:07290 UpdateDisplay("700x500,500x500");
[email protected]edbfb8d2012-09-03 08:33:43291 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
[email protected]20c59762012-06-23 01:10:24292 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24293
[email protected]7203a5e2012-08-06 18:27:46294 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100)));
295 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100)));
296 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300)));
297 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300)));
[email protected]20c59762012-06-23 01:10:24298
299 // Zero origin.
[email protected]7203a5e2012-08-06 18:27:46300 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0)));
[email protected]20c59762012-06-23 01:10:24301
302 // Out of range point should return the primary root window
[email protected]7203a5e2012-08-06 18:27:46303 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0)));
304 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100)));
[email protected]20c59762012-06-23 01:10:24305}
306
307TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
[email protected]f634dd32012-07-23 22:49:07308 UpdateDisplay("700x500,500x500");
[email protected]edbfb8d2012-09-03 08:33:43309 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
[email protected]66b05eac2012-06-27 23:53:10310
[email protected]20c59762012-06-23 01:10:24311 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24312
313 // Containing rect.
314 EXPECT_EQ(root_windows[1],
[email protected]7203a5e2012-08-06 18:27:46315 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
[email protected]20c59762012-06-23 01:10:24316 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46317 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
[email protected]20c59762012-06-23 01:10:24318
319 // Intersecting rect.
320 EXPECT_EQ(root_windows[1],
[email protected]7203a5e2012-08-06 18:27:46321 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
[email protected]20c59762012-06-23 01:10:24322 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46323 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)));
[email protected]20c59762012-06-23 01:10:24324
325 // Zero origin.
[email protected]66b05eac2012-06-27 23:53:10326 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46327 wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)));
[email protected]66b05eac2012-06-27 23:53:10328 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46329 wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)));
[email protected]20c59762012-06-23 01:10:24330
331 // Empty rect.
332 EXPECT_EQ(root_windows[1],
[email protected]7203a5e2012-08-06 18:27:46333 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)));
[email protected]20c59762012-06-23 01:10:24334 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46335 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)));
[email protected]20c59762012-06-23 01:10:24336
337 // Out of range rect should return the primary root window.
338 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46339 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
[email protected]20c59762012-06-23 01:10:24340 EXPECT_EQ(root_windows[0],
[email protected]7203a5e2012-08-06 18:27:46341 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
[email protected]0f81f442012-06-22 06:20:27342}
343
[email protected]7f502eb2012-09-20 09:17:12344#if defined(OS_WIN)
345// TODO(mazda): Re-enable this (http://crbug.com/150986).
346#define MAYBE_Capture DISABLED_Capture
347#else
348#define MAYBE_Capture Capture
349#endif
350
351TEST_F(ExtendedDesktopTest, MAYBE_Capture) {
[email protected]f634dd32012-07-23 22:49:07352 UpdateDisplay("1000x600,600x400");
[email protected]a5e71c92012-06-22 22:09:08353 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
354
355 aura::test::EventCountDelegate r1_d1;
356 aura::test::EventCountDelegate r1_d2;
357 aura::test::EventCountDelegate r2_d1;
358
359 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
360 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
361 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
362 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
363 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
364 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
[email protected]f634dd32012-07-23 22:49:07365
[email protected]a5e71c92012-06-22 22:09:08366 r1_w1->SetCapture();
367
368 EXPECT_EQ(r1_w1.get(),
369 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
370 aura::test::EventGenerator generator2(root_windows[1]);
371 generator2.MoveMouseToCenterOf(r2_w1.get());
372 generator2.ClickLeftButton();
373 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
374 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
[email protected]b19ba4adf2012-09-07 16:13:29375 // The mouse is outside. On chromeos, the mouse is warped to the
376 // dest root window, but it's not implemented on Win yet, so
377 // no mouse move event on Win.
378#if defined(OS_WIN)
379 EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset());
380#else
[email protected]7495e5032012-09-07 15:31:45381 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
[email protected]b19ba4adf2012-09-07 16:13:29382#endif
[email protected]a5e71c92012-06-22 22:09:08383 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset());
[email protected]f634dd32012-07-23 22:49:07384 // (15,15) on 1st display is (-985,15) on 2nd display.
385 generator2.MoveMouseTo(-985, 15);
386 EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset());
[email protected]a5e71c92012-06-22 22:09:08387
388 r1_w2->SetCapture();
389 EXPECT_EQ(r1_w2.get(),
390 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
391 generator2.MoveMouseBy(10, 10);
392 generator2.ClickLeftButton();
393 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
394 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
395 // mouse is already entered.
396 EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset());
397 EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset());
398
399 r1_w2->ReleaseCapture();
[email protected]36f566532012-09-19 04:07:24400 EXPECT_EQ(NULL, aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
[email protected]f634dd32012-07-23 22:49:07401 generator2.MoveMouseTo(15, 15);
[email protected]a5e71c92012-06-22 22:09:08402 generator2.ClickLeftButton();
403 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset());
404 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset());
405 // Make sure the mouse_moved_handler_ is properly reset.
406 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
407 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
408}
409
[email protected]f059c6942012-07-21 14:27:57410TEST_F(ExtendedDesktopTest, MoveWindow) {
[email protected]f634dd32012-07-23 22:49:07411 UpdateDisplay("1000x600,600x400");
[email protected]f059c6942012-07-21 14:27:57412 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
413 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
414
415 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
416
417 d1->SetBounds(gfx::Rect(1010, 10, 100, 100));
418 EXPECT_EQ("1010,10 100x100",
419 d1->GetWindowBoundsInScreen().ToString());
420
421 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
422
423 d1->SetBounds(gfx::Rect(10, 10, 100, 100));
424 EXPECT_EQ("10,10 100x100",
425 d1->GetWindowBoundsInScreen().ToString());
426
427 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
428
429 // Make sure the bounds which doesn't fit to the root window
430 // works correctly.
431 d1->SetBounds(gfx::Rect(1560, 30, 100, 100));
432 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
433 EXPECT_EQ("1560,30 100x100",
434 d1->GetWindowBoundsInScreen().ToString());
435
436 // Setting outside of root windows will be moved to primary root window.
437 // TODO(oshima): This one probably should pick the closest root window.
438 d1->SetBounds(gfx::Rect(200, 10, 100, 100));
439 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
[email protected]f059c6942012-07-21 14:27:57440}
441
[email protected]2e98aaf72012-11-08 06:30:59442// Verifies if the mouse event arrives to the window even when the window
443// moves to another root in a pre-target handler. See: crbug.com/157583
444TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
445 UpdateDisplay("1000x600,600x400");
446
447 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
448 aura::test::EventCountDelegate delegate;
449 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
450 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
451 MoveWindowByClickEventFilter event_filter(window.get());
452 window->AddPreTargetHandler(&event_filter);
453 aura::test::EventGenerator generator(root_windows[0], window.get());
454 generator.ClickLeftButton();
455 // Both mouse pressed and released arrive at the window and its delegate.
456 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
457 // Also event_filter moves the window to another root at mouse release.
458 EXPECT_EQ(root_windows[1], window->GetRootWindow());
459}
460
[email protected]608f02f2012-10-25 05:53:33461// This test fails on the "Win Aura" bot: <http://crbug.com/157817>.
462#if defined(OS_WIN)
463#define MAYBE_MoveWindowToDisplay DISABLED_MoveWindowToDisplay
464#else
465#define MAYBE_MoveWindowToDisplay MoveWindowToDisplay
466#endif
467TEST_F(ExtendedDesktopTest, MAYBE_MoveWindowToDisplay) {
[email protected]e79f26e2012-08-09 07:12:48468 UpdateDisplay("1000x1000,1000x1000");
469 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
470
[email protected]ffabb1e2012-10-12 19:51:17471 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching(
472 root_windows[0]->GetBoundsInScreen());
473 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching(
474 root_windows[1]->GetBoundsInScreen());
[email protected]e79f26e2012-08-09 07:12:48475 EXPECT_NE(display0.id(), display1.id());
476
477 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100));
478 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
479
480 // Move the window where the window spans both root windows. Since the second
481 // parameter is |display1|, the window should be shown on the secondary root.
482 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
483 display1);
484 EXPECT_EQ("500,10 1000x100",
485 d1->GetWindowBoundsInScreen().ToString());
486 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
487
488 // Move to the primary root.
489 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
490 display0);
491 EXPECT_EQ("500,10 1000x100",
492 d1->GetWindowBoundsInScreen().ToString());
493 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
494}
495
[email protected]f059c6942012-07-21 14:27:57496TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
[email protected]f634dd32012-07-23 22:49:07497 UpdateDisplay("1000x600,600x400");
[email protected]f059c6942012-07-21 14:27:57498 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
499 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
500 views::Widget* w1_t1 = CreateTestWidgetWithParent(
501 w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
502 // Transient child of the transient child.
503 views::Widget* w1_t11 = CreateTestWidgetWithParent(
504 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
505
506 views::Widget* w11 = CreateTestWidgetWithParent(
507 w1, gfx::Rect(10, 10, 40, 40), true /* child */);
508 views::Widget* w11_t1 = CreateTestWidgetWithParent(
509 w1, gfx::Rect(1300, 100, 80, 80), false /* transient */);
510
511 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
512 EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow());
513 EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow());
514 EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow());
515 EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow());
516 EXPECT_EQ("50,50 50x50",
517 w1_t1->GetWindowBoundsInScreen().ToString());
518 EXPECT_EQ("1200,70 30x30",
519 w1_t11->GetWindowBoundsInScreen().ToString());
520 EXPECT_EQ("20,20 40x40",
521 w11->GetWindowBoundsInScreen().ToString());
522 EXPECT_EQ("1300,100 80x80",
523 w11_t1->GetWindowBoundsInScreen().ToString());
524
525 w1->SetBounds(gfx::Rect(1100,10,100,100));
526
527 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
528 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
529 EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow());
530 EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow());
531 EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow());
532
533 EXPECT_EQ("1110,20 40x40",
534 w11->GetWindowBoundsInScreen().ToString());
535 // Transient window's screen bounds stays the same.
536 EXPECT_EQ("50,50 50x50",
537 w1_t1->GetWindowBoundsInScreen().ToString());
538 EXPECT_EQ("1200,70 30x30",
539 w1_t11->GetWindowBoundsInScreen().ToString());
540 EXPECT_EQ("1300,100 80x80",
541 w11_t1->GetWindowBoundsInScreen().ToString());
542
543 // Transient window doesn't move between root window unless
544 // its transient parent moves.
545 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50));
546 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
547 EXPECT_EQ("10,50 50x50",
548 w1_t1->GetWindowBoundsInScreen().ToString());
[email protected]f059c6942012-07-21 14:27:57549}
550
[email protected]a5e71c92012-06-22 22:09:08551namespace internal {
[email protected]ca7060982012-08-08 18:05:25552// Test if the Window::ConvertPointToTarget works across root windows.
[email protected]a5e71c92012-06-22 22:09:08553// TODO(oshima): Move multiple display suport and this test to aura.
554TEST_F(ExtendedDesktopTest, ConvertPoint) {
[email protected]f634dd32012-07-23 22:49:07555 UpdateDisplay("1000x600,600x400");
[email protected]a5e71c92012-06-22 22:09:08556 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
557 gfx::Display& display_1 =
[email protected]3e4351b2012-08-09 04:04:16558 GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]);
[email protected]a5e71c92012-06-22 22:09:08559 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
560 gfx::Display& display_2 =
[email protected]3e4351b2012-08-09 04:04:16561 GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]f634dd32012-07-23 22:49:07562 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString());
563
[email protected]a5e71c92012-06-22 22:09:08564 aura::Window* d1 =
565 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
[email protected]a5e71c92012-06-22 22:09:08566 aura::Window* d2 =
[email protected]f634dd32012-07-23 22:49:07567 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView();
568 EXPECT_EQ(root_windows[0], d1->GetRootWindow());
569 EXPECT_EQ(root_windows[1], d2->GetRootWindow());
[email protected]a5e71c92012-06-22 22:09:08570
[email protected]a5e71c92012-06-22 22:09:08571 // Convert point in the Root2's window to the Root1's window Coord.
572 gfx::Point p(0, 0);
[email protected]ca7060982012-08-08 18:05:25573 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p);
[email protected]f634dd32012-07-23 22:49:07574 EXPECT_EQ("1000,0", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08575 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25576 aura::Window::ConvertPointToTarget(d2, d1, &p);
[email protected]f634dd32012-07-23 22:49:07577 EXPECT_EQ("1010,10", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08578
579 // Convert point in the Root1's window to the Root2's window Coord.
580 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25581 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p);
[email protected]f634dd32012-07-23 22:49:07582 EXPECT_EQ("-1000,0", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08583 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25584 aura::Window::ConvertPointToTarget(d1, d2, &p);
[email protected]f634dd32012-07-23 22:49:07585 EXPECT_EQ("-1010,-10", p.ToString());
586
587 // Move the 2nd display to the bottom and test again.
[email protected]edbfb8d2012-09-03 08:33:43588 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
[email protected]f634dd32012-07-23 22:49:07589
[email protected]3e4351b2012-08-09 04:04:16590 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]f634dd32012-07-23 22:49:07591 EXPECT_EQ("0,600", display_2.bounds().origin().ToString());
592
593 // Convert point in Root2's window to Root1's window Coord.
594 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25595 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p);
[email protected]f634dd32012-07-23 22:49:07596 EXPECT_EQ("0,600", p.ToString());
597 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25598 aura::Window::ConvertPointToTarget(d2, d1, &p);
[email protected]f634dd32012-07-23 22:49:07599 EXPECT_EQ("10,610", p.ToString());
600
601 // Convert point in Root1's window to Root2's window Coord.
602 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25603 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p);
[email protected]f634dd32012-07-23 22:49:07604 EXPECT_EQ("0,-600", p.ToString());
605 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25606 aura::Window::ConvertPointToTarget(d1, d2, &p);
[email protected]f634dd32012-07-23 22:49:07607 EXPECT_EQ("-10,-610", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08608}
[email protected]f634dd32012-07-23 22:49:07609
[email protected]263898a2012-09-17 17:20:07610TEST_F(ExtendedDesktopTest, OpenSystemTray) {
[email protected]596c61c2012-10-29 17:29:43611 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07612 SystemTray* tray = ash::Shell::GetInstance()->system_tray();
613 ASSERT_FALSE(tray->HasSystemBubble());
614
615 // Opens the tray by a dummy click event and makes sure that adding/removing
616 // displays doesn't break anything.
617 aura::test::EventGenerator event_generator(
618 ash::Shell::GetInstance()->GetPrimaryRootWindow(),
619 tray->GetWidget()->GetNativeWindow());
620 event_generator.ClickLeftButton();
621 EXPECT_TRUE(tray->HasSystemBubble());
622
[email protected]596c61c2012-10-29 17:29:43623 UpdateDisplay("500x600");
[email protected]263898a2012-09-17 17:20:07624 EXPECT_TRUE(tray->HasSystemBubble());
[email protected]596c61c2012-10-29 17:29:43625 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07626 EXPECT_TRUE(tray->HasSystemBubble());
627
628 // Closes the tray and again makes sure that adding/removing displays doesn't
629 // break anything.
630 event_generator.ClickLeftButton();
631 RunAllPendingInMessageLoop();
632
633 EXPECT_FALSE(tray->HasSystemBubble());
634
[email protected]596c61c2012-10-29 17:29:43635 UpdateDisplay("500x600");
[email protected]263898a2012-09-17 17:20:07636 EXPECT_FALSE(tray->HasSystemBubble());
[email protected]596c61c2012-10-29 17:29:43637 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07638 EXPECT_FALSE(tray->HasSystemBubble());
639}
640
[email protected]578048512012-09-19 20:01:24641TEST_F(ExtendedDesktopTest, StayInSameRootWindow) {
642 UpdateDisplay("100x100,200x200");
643 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
644 views::Widget* w1 = CreateTestWidgetWithParent(
645 NULL, gfx::Rect(10, 10, 50, 50), false);
646 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
647 w1->SetBounds(gfx::Rect(150, 10, 50, 50));
648 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
649
650 // The widget stays in the same root if kStayInSameRootWindowKey is set to
651 // true.
652 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true);
653 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
654 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
655
656 // The widget should now move to the 1st root window without the property.
657 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey);
658 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
659 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
660}
661
[email protected]e67291f12012-10-10 05:52:38662TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
663 UpdateDisplay("100x100,200x200");
664 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
665
666 // Create normal windows on both displays.
667 views::Widget* widget1 = CreateTestWidget(
[email protected]ffabb1e2012-10-12 19:51:17668 Shell::GetScreen()->GetPrimaryDisplay().bounds());
[email protected]e67291f12012-10-10 05:52:38669 widget1->Show();
670 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
671 views::Widget* widget2 = CreateTestWidget(
672 ScreenAsh::GetSecondaryDisplay().bounds());
673 widget2->Show();
674 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
675
676 // Create a LockScreen window.
677 views::Widget* lock_widget = CreateTestWidget(
[email protected]ffabb1e2012-10-12 19:51:17678 Shell::GetScreen()->GetPrimaryDisplay().bounds());
[email protected]e67291f12012-10-10 05:52:38679 views::Textfield* textfield = new views::Textfield;
680 lock_widget->SetContentsView(textfield);
681
682 ash::Shell::GetContainer(
683 Shell::GetPrimaryRootWindow(),
684 ash::internal::kShellWindowId_LockScreenContainer)->
685 AddChild(lock_widget->GetNativeView());
686 lock_widget->Show();
687 textfield->RequestFocus();
688
689 aura::FocusManager* focus_manager = root_windows[0]->GetFocusManager();
690 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
691
692 // The lock window should get events on both root windows.
693 aura::test::EventGenerator generator1(root_windows[0]);
694 generator1.PressKey(ui::VKEY_A, 0);
695 generator1.ReleaseKey(ui::VKEY_A, 0);
696 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
697 EXPECT_EQ("a", UTF16ToASCII(textfield->text()));
698
699 aura::test::EventGenerator generator2(root_windows[1]);
700 generator2.PressKey(ui::VKEY_B, 0);
701 generator2.ReleaseKey(ui::VKEY_B, 0);
702 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
703 EXPECT_EQ("ab", UTF16ToASCII(textfield->text()));
704
705 // Deleting 2nd display. The lock window still should get the events.
706 UpdateDisplay("100x100");
707 generator2.PressKey(ui::VKEY_C, 0);
708 generator2.ReleaseKey(ui::VKEY_C, 0);
709 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
710 EXPECT_EQ("abc", UTF16ToASCII(textfield->text()));
711
712 // Creating 2nd display again, and lock window still should get events
713 // on both root windows.
714 UpdateDisplay("100x100,200x200");
715 root_windows = Shell::GetAllRootWindows();
716 generator1.PressKey(ui::VKEY_D, 0);
717 generator1.ReleaseKey(ui::VKEY_D, 0);
718 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
719 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text()));
720
721 aura::test::EventGenerator generator22(root_windows[1]);
722 generator22.PressKey(ui::VKEY_E, 0);
723 generator22.ReleaseKey(ui::VKEY_E, 0);
724 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow());
725 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text()));
726}
727
[email protected]a5e71c92012-06-22 22:09:08728} // namespace internal
[email protected]c39be8f2012-06-15 22:58:36729} // namespace ash