blob: d43fe021c078ce182cfe2224ae8691d0b9f931e1 [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]1a015382012-12-01 19:44:59328TEST_F(ExtendedDesktopTest, Capture) {
[email protected]f634dd32012-07-23 22:49:07329 UpdateDisplay("1000x600,600x400");
[email protected]a5e71c92012-06-22 22:09:08330 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
331
332 aura::test::EventCountDelegate r1_d1;
333 aura::test::EventCountDelegate r1_d2;
334 aura::test::EventCountDelegate r2_d1;
335
336 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
337 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
338 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
339 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
340 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
341 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
[email protected]f634dd32012-07-23 22:49:07342
[email protected]a5e71c92012-06-22 22:09:08343 r1_w1->SetCapture();
344
345 EXPECT_EQ(r1_w1.get(),
346 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
347 aura::test::EventGenerator generator2(root_windows[1]);
348 generator2.MoveMouseToCenterOf(r2_w1.get());
349 generator2.ClickLeftButton();
350 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
351 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
[email protected]b19ba4adf2012-09-07 16:13:29352 // The mouse is outside. On chromeos, the mouse is warped to the
353 // dest root window, but it's not implemented on Win yet, so
354 // no mouse move event on Win.
[email protected]7495e5032012-09-07 15:31:45355 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
[email protected]a5e71c92012-06-22 22:09:08356 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset());
[email protected]f634dd32012-07-23 22:49:07357 // (15,15) on 1st display is (-985,15) on 2nd display.
358 generator2.MoveMouseTo(-985, 15);
359 EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset());
[email protected]a5e71c92012-06-22 22:09:08360
361 r1_w2->SetCapture();
362 EXPECT_EQ(r1_w2.get(),
363 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
364 generator2.MoveMouseBy(10, 10);
365 generator2.ClickLeftButton();
366 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
367 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
368 // mouse is already entered.
369 EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset());
370 EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset());
371
372 r1_w2->ReleaseCapture();
[email protected]36f566532012-09-19 04:07:24373 EXPECT_EQ(NULL, aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
[email protected]f634dd32012-07-23 22:49:07374 generator2.MoveMouseTo(15, 15);
[email protected]a5e71c92012-06-22 22:09:08375 generator2.ClickLeftButton();
376 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset());
377 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset());
378 // Make sure the mouse_moved_handler_ is properly reset.
379 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
380 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
381}
382
[email protected]f059c6942012-07-21 14:27:57383TEST_F(ExtendedDesktopTest, MoveWindow) {
[email protected]f634dd32012-07-23 22:49:07384 UpdateDisplay("1000x600,600x400");
[email protected]f059c6942012-07-21 14:27:57385 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
386 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
387
388 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
389
390 d1->SetBounds(gfx::Rect(1010, 10, 100, 100));
391 EXPECT_EQ("1010,10 100x100",
392 d1->GetWindowBoundsInScreen().ToString());
393
394 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
395
396 d1->SetBounds(gfx::Rect(10, 10, 100, 100));
397 EXPECT_EQ("10,10 100x100",
398 d1->GetWindowBoundsInScreen().ToString());
399
400 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
401
402 // Make sure the bounds which doesn't fit to the root window
403 // works correctly.
404 d1->SetBounds(gfx::Rect(1560, 30, 100, 100));
405 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
406 EXPECT_EQ("1560,30 100x100",
407 d1->GetWindowBoundsInScreen().ToString());
408
409 // Setting outside of root windows will be moved to primary root window.
410 // TODO(oshima): This one probably should pick the closest root window.
411 d1->SetBounds(gfx::Rect(200, 10, 100, 100));
412 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
[email protected]f059c6942012-07-21 14:27:57413}
414
[email protected]2e98aaf72012-11-08 06:30:59415// Verifies if the mouse event arrives to the window even when the window
416// moves to another root in a pre-target handler. See: crbug.com/157583
417TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
418 UpdateDisplay("1000x600,600x400");
419
420 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
421 aura::test::EventCountDelegate delegate;
422 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
423 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
424 MoveWindowByClickEventFilter event_filter(window.get());
425 window->AddPreTargetHandler(&event_filter);
426 aura::test::EventGenerator generator(root_windows[0], window.get());
427 generator.ClickLeftButton();
428 // Both mouse pressed and released arrive at the window and its delegate.
429 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
430 // Also event_filter moves the window to another root at mouse release.
431 EXPECT_EQ(root_windows[1], window->GetRootWindow());
432}
433
[email protected]1a015382012-12-01 19:44:59434TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) {
[email protected]e79f26e2012-08-09 07:12:48435 UpdateDisplay("1000x1000,1000x1000");
436 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
437
[email protected]ffabb1e2012-10-12 19:51:17438 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching(
439 root_windows[0]->GetBoundsInScreen());
440 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching(
441 root_windows[1]->GetBoundsInScreen());
[email protected]e79f26e2012-08-09 07:12:48442 EXPECT_NE(display0.id(), display1.id());
443
444 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100));
445 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
446
447 // Move the window where the window spans both root windows. Since the second
448 // parameter is |display1|, the window should be shown on the secondary root.
449 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
450 display1);
451 EXPECT_EQ("500,10 1000x100",
452 d1->GetWindowBoundsInScreen().ToString());
453 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
454
455 // Move to the primary root.
456 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
457 display0);
458 EXPECT_EQ("500,10 1000x100",
459 d1->GetWindowBoundsInScreen().ToString());
460 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
461}
462
[email protected]f059c6942012-07-21 14:27:57463TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
[email protected]f634dd32012-07-23 22:49:07464 UpdateDisplay("1000x600,600x400");
[email protected]f059c6942012-07-21 14:27:57465 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
466 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
467 views::Widget* w1_t1 = CreateTestWidgetWithParent(
468 w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
469 // Transient child of the transient child.
470 views::Widget* w1_t11 = CreateTestWidgetWithParent(
471 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
472
473 views::Widget* w11 = CreateTestWidgetWithParent(
474 w1, gfx::Rect(10, 10, 40, 40), true /* child */);
475 views::Widget* w11_t1 = CreateTestWidgetWithParent(
476 w1, gfx::Rect(1300, 100, 80, 80), false /* transient */);
477
478 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
479 EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow());
480 EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow());
481 EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow());
482 EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow());
483 EXPECT_EQ("50,50 50x50",
484 w1_t1->GetWindowBoundsInScreen().ToString());
485 EXPECT_EQ("1200,70 30x30",
486 w1_t11->GetWindowBoundsInScreen().ToString());
487 EXPECT_EQ("20,20 40x40",
488 w11->GetWindowBoundsInScreen().ToString());
489 EXPECT_EQ("1300,100 80x80",
490 w11_t1->GetWindowBoundsInScreen().ToString());
491
492 w1->SetBounds(gfx::Rect(1100,10,100,100));
493
494 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
495 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
496 EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow());
497 EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow());
498 EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow());
499
500 EXPECT_EQ("1110,20 40x40",
501 w11->GetWindowBoundsInScreen().ToString());
502 // Transient window's screen bounds stays the same.
503 EXPECT_EQ("50,50 50x50",
504 w1_t1->GetWindowBoundsInScreen().ToString());
505 EXPECT_EQ("1200,70 30x30",
506 w1_t11->GetWindowBoundsInScreen().ToString());
507 EXPECT_EQ("1300,100 80x80",
508 w11_t1->GetWindowBoundsInScreen().ToString());
509
510 // Transient window doesn't move between root window unless
511 // its transient parent moves.
512 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50));
513 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
514 EXPECT_EQ("10,50 50x50",
515 w1_t1->GetWindowBoundsInScreen().ToString());
[email protected]f059c6942012-07-21 14:27:57516}
517
[email protected]a5e71c92012-06-22 22:09:08518namespace internal {
[email protected]ca7060982012-08-08 18:05:25519// Test if the Window::ConvertPointToTarget works across root windows.
[email protected]a5e71c92012-06-22 22:09:08520// TODO(oshima): Move multiple display suport and this test to aura.
521TEST_F(ExtendedDesktopTest, ConvertPoint) {
[email protected]f634dd32012-07-23 22:49:07522 UpdateDisplay("1000x600,600x400");
[email protected]a5e71c92012-06-22 22:09:08523 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
524 gfx::Display& display_1 =
[email protected]3e4351b2012-08-09 04:04:16525 GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]);
[email protected]a5e71c92012-06-22 22:09:08526 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
527 gfx::Display& display_2 =
[email protected]3e4351b2012-08-09 04:04:16528 GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]f634dd32012-07-23 22:49:07529 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString());
530
[email protected]a5e71c92012-06-22 22:09:08531 aura::Window* d1 =
532 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
[email protected]a5e71c92012-06-22 22:09:08533 aura::Window* d2 =
[email protected]f634dd32012-07-23 22:49:07534 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView();
535 EXPECT_EQ(root_windows[0], d1->GetRootWindow());
536 EXPECT_EQ(root_windows[1], d2->GetRootWindow());
[email protected]a5e71c92012-06-22 22:09:08537
[email protected]a5e71c92012-06-22 22:09:08538 // Convert point in the Root2's window to the Root1's window Coord.
539 gfx::Point p(0, 0);
[email protected]ca7060982012-08-08 18:05:25540 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p);
[email protected]f634dd32012-07-23 22:49:07541 EXPECT_EQ("1000,0", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08542 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25543 aura::Window::ConvertPointToTarget(d2, d1, &p);
[email protected]f634dd32012-07-23 22:49:07544 EXPECT_EQ("1010,10", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08545
546 // Convert point in the Root1's window to the Root2's window Coord.
547 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25548 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p);
[email protected]f634dd32012-07-23 22:49:07549 EXPECT_EQ("-1000,0", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08550 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25551 aura::Window::ConvertPointToTarget(d1, d2, &p);
[email protected]f634dd32012-07-23 22:49:07552 EXPECT_EQ("-1010,-10", p.ToString());
553
554 // Move the 2nd display to the bottom and test again.
[email protected]edbfb8d2012-09-03 08:33:43555 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
[email protected]f634dd32012-07-23 22:49:07556
[email protected]3e4351b2012-08-09 04:04:16557 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]f634dd32012-07-23 22:49:07558 EXPECT_EQ("0,600", display_2.bounds().origin().ToString());
559
560 // Convert point in Root2's window to Root1's window Coord.
561 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25562 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p);
[email protected]f634dd32012-07-23 22:49:07563 EXPECT_EQ("0,600", p.ToString());
564 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25565 aura::Window::ConvertPointToTarget(d2, d1, &p);
[email protected]f634dd32012-07-23 22:49:07566 EXPECT_EQ("10,610", p.ToString());
567
568 // Convert point in Root1's window to Root2's window Coord.
569 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25570 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p);
[email protected]f634dd32012-07-23 22:49:07571 EXPECT_EQ("0,-600", p.ToString());
572 p.SetPoint(0, 0);
[email protected]ca7060982012-08-08 18:05:25573 aura::Window::ConvertPointToTarget(d1, d2, &p);
[email protected]f634dd32012-07-23 22:49:07574 EXPECT_EQ("-10,-610", p.ToString());
[email protected]a5e71c92012-06-22 22:09:08575}
[email protected]f634dd32012-07-23 22:49:07576
[email protected]263898a2012-09-17 17:20:07577TEST_F(ExtendedDesktopTest, OpenSystemTray) {
[email protected]596c61c2012-10-29 17:29:43578 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07579 SystemTray* tray = ash::Shell::GetInstance()->system_tray();
580 ASSERT_FALSE(tray->HasSystemBubble());
581
582 // Opens the tray by a dummy click event and makes sure that adding/removing
583 // displays doesn't break anything.
584 aura::test::EventGenerator event_generator(
585 ash::Shell::GetInstance()->GetPrimaryRootWindow(),
586 tray->GetWidget()->GetNativeWindow());
587 event_generator.ClickLeftButton();
588 EXPECT_TRUE(tray->HasSystemBubble());
589
[email protected]596c61c2012-10-29 17:29:43590 UpdateDisplay("500x600");
[email protected]263898a2012-09-17 17:20:07591 EXPECT_TRUE(tray->HasSystemBubble());
[email protected]596c61c2012-10-29 17:29:43592 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07593 EXPECT_TRUE(tray->HasSystemBubble());
594
595 // Closes the tray and again makes sure that adding/removing displays doesn't
596 // break anything.
597 event_generator.ClickLeftButton();
598 RunAllPendingInMessageLoop();
599
600 EXPECT_FALSE(tray->HasSystemBubble());
601
[email protected]596c61c2012-10-29 17:29:43602 UpdateDisplay("500x600");
[email protected]263898a2012-09-17 17:20:07603 EXPECT_FALSE(tray->HasSystemBubble());
[email protected]596c61c2012-10-29 17:29:43604 UpdateDisplay("500x600,600x400");
[email protected]263898a2012-09-17 17:20:07605 EXPECT_FALSE(tray->HasSystemBubble());
606}
607
[email protected]578048512012-09-19 20:01:24608TEST_F(ExtendedDesktopTest, StayInSameRootWindow) {
609 UpdateDisplay("100x100,200x200");
610 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
611 views::Widget* w1 = CreateTestWidgetWithParent(
612 NULL, gfx::Rect(10, 10, 50, 50), false);
613 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
614 w1->SetBounds(gfx::Rect(150, 10, 50, 50));
615 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
616
617 // The widget stays in the same root if kStayInSameRootWindowKey is set to
618 // true.
619 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true);
620 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
621 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
622
623 // The widget should now move to the 1st root window without the property.
624 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey);
625 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
626 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
627}
628
[email protected]e67291f12012-10-10 05:52:38629TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
630 UpdateDisplay("100x100,200x200");
631 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
632
633 // Create normal windows on both displays.
634 views::Widget* widget1 = CreateTestWidget(
[email protected]ffabb1e2012-10-12 19:51:17635 Shell::GetScreen()->GetPrimaryDisplay().bounds());
[email protected]e67291f12012-10-10 05:52:38636 widget1->Show();
637 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
638 views::Widget* widget2 = CreateTestWidget(
639 ScreenAsh::GetSecondaryDisplay().bounds());
640 widget2->Show();
641 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
642
643 // Create a LockScreen window.
644 views::Widget* lock_widget = CreateTestWidget(
[email protected]ffabb1e2012-10-12 19:51:17645 Shell::GetScreen()->GetPrimaryDisplay().bounds());
[email protected]e67291f12012-10-10 05:52:38646 views::Textfield* textfield = new views::Textfield;
647 lock_widget->SetContentsView(textfield);
648
649 ash::Shell::GetContainer(
650 Shell::GetPrimaryRootWindow(),
651 ash::internal::kShellWindowId_LockScreenContainer)->
652 AddChild(lock_widget->GetNativeView());
653 lock_widget->Show();
654 textfield->RequestFocus();
655
[email protected]8cfb6722012-11-28 03:28:46656 aura::client::FocusClient* focus_client =
657 aura::client::GetFocusClient(root_windows[0]);
658 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38659
660 // The lock window should get events on both root windows.
661 aura::test::EventGenerator generator1(root_windows[0]);
662 generator1.PressKey(ui::VKEY_A, 0);
663 generator1.ReleaseKey(ui::VKEY_A, 0);
[email protected]8cfb6722012-11-28 03:28:46664 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38665 EXPECT_EQ("a", UTF16ToASCII(textfield->text()));
666
667 aura::test::EventGenerator generator2(root_windows[1]);
668 generator2.PressKey(ui::VKEY_B, 0);
669 generator2.ReleaseKey(ui::VKEY_B, 0);
[email protected]8cfb6722012-11-28 03:28:46670 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38671 EXPECT_EQ("ab", UTF16ToASCII(textfield->text()));
672
673 // Deleting 2nd display. The lock window still should get the events.
674 UpdateDisplay("100x100");
675 generator2.PressKey(ui::VKEY_C, 0);
676 generator2.ReleaseKey(ui::VKEY_C, 0);
[email protected]8cfb6722012-11-28 03:28:46677 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38678 EXPECT_EQ("abc", UTF16ToASCII(textfield->text()));
679
680 // Creating 2nd display again, and lock window still should get events
681 // on both root windows.
682 UpdateDisplay("100x100,200x200");
683 root_windows = Shell::GetAllRootWindows();
684 generator1.PressKey(ui::VKEY_D, 0);
685 generator1.ReleaseKey(ui::VKEY_D, 0);
[email protected]8cfb6722012-11-28 03:28:46686 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38687 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text()));
688
689 aura::test::EventGenerator generator22(root_windows[1]);
690 generator22.PressKey(ui::VKEY_E, 0);
691 generator22.ReleaseKey(ui::VKEY_E, 0);
[email protected]8cfb6722012-11-28 03:28:46692 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
[email protected]e67291f12012-10-10 05:52:38693 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text()));
694}
695
[email protected]a5e71c92012-06-22 22:09:08696} // namespace internal
[email protected]c39be8f2012-06-15 22:58:36697} // namespace ash