blob: d4cce054474101e1f742ef6210ff3e9203d75a74 [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"
6#include "ash/display/multi_display_manager.h"
[email protected]c39be8f2012-06-15 22:58:367#include "ash/shell.h"
8#include "ash/test/ash_test_base.h"
[email protected]0f81f442012-06-22 06:20:279#include "ash/wm/window_cycle_controller.h"
[email protected]c39be8f2012-06-15 22:58:3610#include "ash/wm/window_util.h"
11#include "ui/aura/client/activation_client.h"
12#include "ui/aura/client/capture_client.h"
[email protected]a5e71c92012-06-22 22:09:0813#include "ui/aura/env.h"
[email protected]c39be8f2012-06-15 22:58:3614#include "ui/aura/focus_manager.h"
15#include "ui/aura/root_window.h"
16#include "ui/aura/test/event_generator.h"
[email protected]a5e71c92012-06-22 22:09:0817#include "ui/aura/test/test_windows.h"
[email protected]c39be8f2012-06-15 22:58:3618#include "ui/aura/window.h"
19#include "ui/base/cursor/cursor.h"
[email protected]a5e71c92012-06-22 22:09:0820#include "ui/gfx/display.h"
[email protected]c39be8f2012-06-15 22:58:3621#include "ui/views/widget/widget.h"
22#include "ui/views/widget/widget_delegate.h"
23
24namespace ash {
25namespace {
26
27views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
28 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
29 params.bounds = bounds;
30 views::Widget* widget = new views::Widget;
31 widget->Init(params);
[email protected]0f81f442012-06-22 06:20:2732 widget->Show();
[email protected]c39be8f2012-06-15 22:58:3633 return widget;
34}
35
36class ModalWidgetDelegate : public views::WidgetDelegateView {
37 public:
38 ModalWidgetDelegate() {}
39 virtual ~ModalWidgetDelegate() {}
40
41 // Overridden from views::WidgetDelegate:
42 virtual views::View* GetContentsView() OVERRIDE {
43 return this;
44 }
45 virtual ui::ModalType GetModalType() const OVERRIDE {
46 return ui::MODAL_TYPE_SYSTEM;
47 }
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate);
51};
52
53} // namespace
54
55class ExtendedDesktopTest : public test::AshTestBase {
56 public:
57 ExtendedDesktopTest() {}
58 virtual ~ExtendedDesktopTest() {}
59
60 virtual void SetUp() OVERRIDE {
[email protected]2e236a52012-06-27 22:21:4761 internal::DisplayController::SetExtendedDesktopEnabled(true);
[email protected]c39be8f2012-06-15 22:58:3662 AshTestBase::SetUp();
63 }
64
65 virtual void TearDown() OVERRIDE {
66 AshTestBase::TearDown();
[email protected]2e236a52012-06-27 22:21:4767 internal::DisplayController::SetExtendedDesktopEnabled(false);
[email protected]c39be8f2012-06-15 22:58:3668 }
69
[email protected]a5e71c92012-06-22 22:09:0870 protected:
[email protected]2e236a52012-06-27 22:21:4771 internal::MultiDisplayManager* display_manager() {
72 return static_cast<internal::MultiDisplayManager*>(
73 aura::Env::GetInstance()->display_manager());
[email protected]a5e71c92012-06-22 22:09:0874 }
75
[email protected]c39be8f2012-06-15 22:58:3676 private:
77 DISALLOW_COPY_AND_ASSIGN(ExtendedDesktopTest);
78};
79
80// Test conditions that root windows in extended desktop mode
81// must satisfy.
82TEST_F(ExtendedDesktopTest, Basic) {
[email protected]2e236a52012-06-27 22:21:4783 UpdateDisplay("0+0-1000x600,1001+0-600x400");
[email protected]c39be8f2012-06-15 22:58:3684 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
85
86 // All root windows must have the root window controller.
87 ASSERT_EQ(2U, root_windows.size());
88 for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
89 iter != root_windows.end(); ++iter) {
90 EXPECT_TRUE(wm::GetRootWindowController(*iter) != NULL);
91 }
92 // Make sure root windows share the same controllers.
93 EXPECT_EQ(root_windows[0]->GetFocusManager(),
94 root_windows[1]->GetFocusManager());
95 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]),
96 aura::client::GetActivationClient(root_windows[1]));
97 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]),
98 aura::client::GetCaptureClient(root_windows[1]));
99}
100
101TEST_F(ExtendedDesktopTest, Activation) {
[email protected]2e236a52012-06-27 22:21:47102 UpdateDisplay("0+0-1000x600,1001+0-600x400");
[email protected]c39be8f2012-06-15 22:58:36103 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
104
105 // Move the active root window to the secondary.
106 Shell::GetInstance()->set_active_root_window(root_windows[1]);
107
108 views::Widget* widget_on_2nd = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
109 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow());
[email protected]c39be8f2012-06-15 22:58:36110
111 // Move the active root window back to the primary.
112 Shell::GetInstance()->set_active_root_window(root_windows[0]);
113
114 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
115 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
[email protected]c39be8f2012-06-15 22:58:36116
117 aura::test::EventGenerator generator_1st(root_windows[0]);
118 aura::test::EventGenerator generator_2nd(root_windows[1]);
119
120 // Clicking a window changes the active window and active root window.
121 generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView());
122 generator_2nd.ClickLeftButton();
123
124 EXPECT_EQ(widget_on_2nd->GetNativeView(),
125 root_windows[0]->GetFocusManager()->GetFocusedWindow());
126 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
127
128 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
129 generator_1st.ClickLeftButton();
130
131 EXPECT_EQ(widget_on_1st->GetNativeView(),
132 root_windows[0]->GetFocusManager()->GetFocusedWindow());
133 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
134}
135
136TEST_F(ExtendedDesktopTest, SystemModal) {
[email protected]2e236a52012-06-27 22:21:47137 UpdateDisplay("0+0-1000x600,1001+0-600x400");
[email protected]c39be8f2012-06-15 22:58:36138 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
139 Shell::GetInstance()->set_active_root_window(root_windows[0]);
140
141 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
[email protected]c39be8f2012-06-15 22:58:36142 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
143 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
144
145 // Change the active root window to 2nd.
146 Shell::GetInstance()->set_active_root_window(root_windows[1]);
147
148 // Open system modal. Make sure it's on 2nd root window and active.
149 views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
150 new ModalWidgetDelegate(), NULL);
151 modal_widget->Show();
152 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView()));
153 EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow());
154 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow());
155
[email protected]2e236a52012-06-27 22:21:47156 // Clicking a widget on widget_on_1st display should not change activation.
[email protected]c39be8f2012-06-15 22:58:36157 aura::test::EventGenerator generator_1st(root_windows[0]);
158 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
159 generator_1st.ClickLeftButton();
160 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView()));
161 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow());
162
163 // Close system modal and so clicking a widget should work now.
164 modal_widget->Close();
165 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView());
166 generator_1st.ClickLeftButton();
167 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
168 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
169}
170
171TEST_F(ExtendedDesktopTest, TestCursor) {
[email protected]2e236a52012-06-27 22:21:47172 UpdateDisplay("0+0-1000x600,1001+0-600x400");
[email protected]c39be8f2012-06-15 22:58:36173 Shell::GetInstance()->ShowCursor(false);
174 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
175 EXPECT_FALSE(root_windows[0]->cursor_shown());
176 EXPECT_FALSE(root_windows[1]->cursor_shown());
177 Shell::GetInstance()->ShowCursor(true);
178 EXPECT_TRUE(root_windows[0]->cursor_shown());
179 EXPECT_TRUE(root_windows[1]->cursor_shown());
180
181 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type());
182 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type());
183 Shell::GetInstance()->SetCursor(ui::kCursorCopy);
184 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type());
185 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type());
186}
187
[email protected]0f81f442012-06-22 06:20:27188TEST_F(ExtendedDesktopTest, CycleWindows) {
[email protected]2e236a52012-06-27 22:21:47189 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
190 UpdateDisplay("0+0-700x500,0+0-500x500");
[email protected]0f81f442012-06-22 06:20:27191 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24192
[email protected]0f81f442012-06-22 06:20:27193 WindowCycleController* controller =
194 Shell::GetInstance()->window_cycle_controller();
195
[email protected]0f81f442012-06-22 06:20:27196 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
197 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
[email protected]20c59762012-06-23 01:10:24198 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
[email protected]0f81f442012-06-22 06:20:27199 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
200 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
201
202 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
203 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
204 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
205 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
206 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
207 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
208 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
209 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
210
211 // Cycle through all windows across root windows.
[email protected]20c59762012-06-23 01:10:24212 views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100));
[email protected]0f81f442012-06-22 06:20:27213 EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow());
[email protected]20c59762012-06-23 01:10:24214 views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100));
[email protected]0f81f442012-06-22 06:20:27215 EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow());
216
217 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
218 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
219 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
220 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
221 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
222 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
223 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
224 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
225
226 // Backwards
227 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
228 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
229 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
230 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
231 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
232 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
233 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
234 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
[email protected]2e236a52012-06-27 22:21:47235 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
[email protected]20c59762012-06-23 01:10:24236}
237
238TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
[email protected]2e236a52012-06-27 22:21:47239 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
240 UpdateDisplay("0+0-700x500,0+0-500x500");
[email protected]66b05eac2012-06-27 23:53:10241 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
242 internal::DisplayController::LEFT);
[email protected]20c59762012-06-23 01:10:24243 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24244
[email protected]66b05eac2012-06-27 23:53:10245 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-400, 100)));
246 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-1, 100)));
247 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 300)));
248 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(700,300)));
[email protected]20c59762012-06-23 01:10:24249
250 // Zero origin.
[email protected]66b05eac2012-06-27 23:53:10251 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 0)));
[email protected]20c59762012-06-23 01:10:24252
253 // Out of range point should return the primary root window
[email protected]66b05eac2012-06-27 23:53:10254 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-600, 0)));
255 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(701, 100)));
[email protected]2e236a52012-06-27 22:21:47256 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
[email protected]20c59762012-06-23 01:10:24257}
258
259TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
[email protected]2e236a52012-06-27 22:21:47260 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
261 UpdateDisplay("0+0-700x500,0+0-500x500");
[email protected]66b05eac2012-06-27 23:53:10262 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
263 internal::DisplayController::LEFT);
264
[email protected]20c59762012-06-23 01:10:24265 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
[email protected]20c59762012-06-23 01:10:24266
267 // Containing rect.
268 EXPECT_EQ(root_windows[1],
[email protected]66b05eac2012-06-27 23:53:10269 Shell::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
[email protected]20c59762012-06-23 01:10:24270 EXPECT_EQ(root_windows[0],
[email protected]66b05eac2012-06-27 23:53:10271 Shell::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
[email protected]20c59762012-06-23 01:10:24272
273 // Intersecting rect.
274 EXPECT_EQ(root_windows[1],
[email protected]66b05eac2012-06-27 23:53:10275 Shell::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
[email protected]20c59762012-06-23 01:10:24276 EXPECT_EQ(root_windows[0],
[email protected]66b05eac2012-06-27 23:53:10277 Shell::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)));
[email protected]20c59762012-06-23 01:10:24278
279 // Zero origin.
[email protected]66b05eac2012-06-27 23:53:10280 EXPECT_EQ(root_windows[0],
[email protected]20c59762012-06-23 01:10:24281 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)));
[email protected]66b05eac2012-06-27 23:53:10282 EXPECT_EQ(root_windows[0],
[email protected]20c59762012-06-23 01:10:24283 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)));
284
285 // Empty rect.
286 EXPECT_EQ(root_windows[1],
[email protected]66b05eac2012-06-27 23:53:10287 Shell::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)));
[email protected]20c59762012-06-23 01:10:24288 EXPECT_EQ(root_windows[0],
[email protected]66b05eac2012-06-27 23:53:10289 Shell::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)));
[email protected]20c59762012-06-23 01:10:24290
291 // Out of range rect should return the primary root window.
292 EXPECT_EQ(root_windows[0],
[email protected]66b05eac2012-06-27 23:53:10293 Shell::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
[email protected]20c59762012-06-23 01:10:24294 EXPECT_EQ(root_windows[0],
[email protected]66b05eac2012-06-27 23:53:10295 Shell::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
[email protected]2e236a52012-06-27 22:21:47296 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
[email protected]0f81f442012-06-22 06:20:27297}
298
[email protected]a5e71c92012-06-22 22:09:08299TEST_F(ExtendedDesktopTest, Capture) {
[email protected]2e236a52012-06-27 22:21:47300 UpdateDisplay("0+0-1000x600,1001+0-600x400");
[email protected]a5e71c92012-06-22 22:09:08301 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
302
303 aura::test::EventCountDelegate r1_d1;
304 aura::test::EventCountDelegate r1_d2;
305 aura::test::EventCountDelegate r2_d1;
306
307 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
308 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
309 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
310 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
311 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
312 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1]));
313 r1_w1->SetCapture();
314
315 EXPECT_EQ(r1_w1.get(),
316 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
317 aura::test::EventGenerator generator2(root_windows[1]);
318 generator2.MoveMouseToCenterOf(r2_w1.get());
319 generator2.ClickLeftButton();
320 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
321 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
322 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
323 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset());
324
325 r1_w2->SetCapture();
326 EXPECT_EQ(r1_w2.get(),
327 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
328 generator2.MoveMouseBy(10, 10);
329 generator2.ClickLeftButton();
330 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset());
331 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset());
332 // mouse is already entered.
333 EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset());
334 EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset());
335
336 r1_w2->ReleaseCapture();
337 EXPECT_EQ(NULL,
338 aura::client::GetCaptureWindow(r2_w1->GetRootWindow()));
339 generator2.MoveMouseBy(-10, -10);
340 generator2.ClickLeftButton();
341 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset());
342 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset());
343 // Make sure the mouse_moved_handler_ is properly reset.
344 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
345 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
346}
347
348namespace internal {
349// Test if the Window::ConvertPointToWindow works across root windows.
350// TODO(oshima): Move multiple display suport and this test to aura.
351TEST_F(ExtendedDesktopTest, ConvertPoint) {
[email protected]2e236a52012-06-27 22:21:47352 UpdateDisplay("0+0-1000x600,1001+0-600x400");
[email protected]a5e71c92012-06-22 22:09:08353 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
354 gfx::Display& display_1 =
[email protected]2e236a52012-06-27 22:21:47355 display_manager()->FindDisplayForRootWindow(root_windows[0]);
[email protected]a5e71c92012-06-22 22:09:08356 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
357 gfx::Display& display_2 =
[email protected]2e236a52012-06-27 22:21:47358 display_manager()->FindDisplayForRootWindow(root_windows[1]);
[email protected]a5e71c92012-06-22 22:09:08359 Shell::GetInstance()->set_active_root_window(root_windows[0]);
360 aura::Window* d1 =
361 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
362 Shell::GetInstance()->set_active_root_window(root_windows[1]);
363 aura::Window* d2 =
364 CreateTestWidget(gfx::Rect(20, 20, 100, 100))->GetNativeView();
365
366 // TODO(oshima):
367 // This is a hack to emulate virtual screen coordinates. Cleanup this
368 // when the virtual screen coordinates is implemented.a
369 gfx::Rect bounds = display_2.bounds();
370 bounds.set_origin(gfx::Point(500, 500));
371 display_2.set_bounds(bounds);
372 // Convert point in the Root2's window to the Root1's window Coord.
373 gfx::Point p(0, 0);
374 aura::Window::ConvertPointToWindow(root_windows[1], root_windows[0], &p);
375 EXPECT_EQ("500,500", p.ToString());
376 p.SetPoint(0, 0);
377 aura::Window::ConvertPointToWindow(d2, d1, &p);
378 EXPECT_EQ("510,510", p.ToString());
379
380 // Convert point in the Root1's window to the Root2's window Coord.
381 p.SetPoint(0, 0);
382 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p);
383 EXPECT_EQ("-500,-500", p.ToString());
384 p.SetPoint(0, 0);
385 aura::Window::ConvertPointToWindow(d1, d2, &p);
386 EXPECT_EQ("-510,-510", p.ToString());
387}
388} // namespace internal
[email protected]c39be8f2012-06-15 22:58:36389} // namespace ash