[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 1 | // 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] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 5 | #include "ash/display/display_controller.h" |
| 6 | #include "ash/display/multi_display_manager.h" |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 7 | #include "ash/shell.h" |
[email protected] | 263898a | 2012-09-17 17:20:07 | [diff] [blame^] | 8 | #include "ash/system/tray/system_tray.h" |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 9 | #include "ash/test/ash_test_base.h" |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 10 | #include "ash/wm/coordinate_conversion.h" |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 11 | #include "ash/wm/property_util.h" |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 12 | #include "ash/wm/window_cycle_controller.h" |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 13 | #include "ash/wm/window_util.h" |
| 14 | #include "ui/aura/client/activation_client.h" |
| 15 | #include "ui/aura/client/capture_client.h" |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 16 | #include "ui/aura/env.h" |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 17 | #include "ui/aura/focus_manager.h" |
| 18 | #include "ui/aura/root_window.h" |
| 19 | #include "ui/aura/test/event_generator.h" |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 20 | #include "ui/aura/test/test_windows.h" |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 21 | #include "ui/aura/window.h" |
| 22 | #include "ui/base/cursor/cursor.h" |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 23 | #include "ui/gfx/display.h" |
[email protected] | 718b26c | 2012-07-24 20:53:23 | [diff] [blame] | 24 | #include "ui/gfx/screen.h" |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 25 | #include "ui/views/widget/widget.h" |
| 26 | #include "ui/views/widget/widget_delegate.h" |
| 27 | |
| 28 | namespace ash { |
| 29 | namespace { |
| 30 | |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 31 | views::Widget* CreateTestWidgetWithParent(views::Widget* parent, |
| 32 | const gfx::Rect& bounds, |
| 33 | bool child) { |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 34 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 35 | params.parent_widget = parent; |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 36 | params.bounds = bounds; |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 37 | params.child = child; |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 38 | views::Widget* widget = new views::Widget; |
| 39 | widget->Init(params); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 40 | widget->Show(); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 41 | return widget; |
| 42 | } |
| 43 | |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 44 | views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
| 45 | return CreateTestWidgetWithParent(NULL, bounds, false); |
| 46 | } |
| 47 | |
[email protected] | edbfb8d | 2012-09-03 08:33:43 | [diff] [blame] | 48 | void SetSecondaryDisplayLayout(DisplayLayout::Position position) { |
| 49 | DisplayController* display_controller = |
| 50 | Shell::GetInstance()->display_controller(); |
| 51 | DisplayLayout layout = display_controller->default_display_layout(); |
| 52 | layout.position = position; |
| 53 | display_controller->SetDefaultDisplayLayout(layout); |
| 54 | } |
| 55 | |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 56 | class ModalWidgetDelegate : public views::WidgetDelegateView { |
| 57 | public: |
| 58 | ModalWidgetDelegate() {} |
| 59 | virtual ~ModalWidgetDelegate() {} |
| 60 | |
| 61 | // Overridden from views::WidgetDelegate: |
| 62 | virtual views::View* GetContentsView() OVERRIDE { |
| 63 | return this; |
| 64 | } |
| 65 | virtual ui::ModalType GetModalType() const OVERRIDE { |
| 66 | return ui::MODAL_TYPE_SYSTEM; |
| 67 | } |
| 68 | |
| 69 | private: |
| 70 | DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 71 | }; |
| 72 | |
[email protected] | 3e4351b | 2012-08-09 04:04:16 | [diff] [blame] | 73 | internal::MultiDisplayManager* GetDisplayManager() { |
| 74 | return static_cast<internal::MultiDisplayManager*>( |
| 75 | aura::Env::GetInstance()->display_manager()); |
| 76 | } |
| 77 | |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 78 | } // namespace |
| 79 | |
[email protected] | 3e4351b | 2012-08-09 04:04:16 | [diff] [blame] | 80 | typedef test::AshTestBase ExtendedDesktopTest; |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 81 | |
| 82 | // Test conditions that root windows in extended desktop mode |
| 83 | // must satisfy. |
| 84 | TEST_F(ExtendedDesktopTest, Basic) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 85 | UpdateDisplay("1000x600,600x400"); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 86 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 87 | |
| 88 | // All root windows must have the root window controller. |
| 89 | ASSERT_EQ(2U, root_windows.size()); |
| 90 | for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
| 91 | iter != root_windows.end(); ++iter) { |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 92 | EXPECT_TRUE(GetRootWindowController(*iter) != NULL); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 93 | } |
| 94 | // Make sure root windows share the same controllers. |
| 95 | EXPECT_EQ(root_windows[0]->GetFocusManager(), |
| 96 | root_windows[1]->GetFocusManager()); |
| 97 | EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), |
| 98 | aura::client::GetActivationClient(root_windows[1])); |
| 99 | EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), |
| 100 | aura::client::GetCaptureClient(root_windows[1])); |
| 101 | } |
| 102 | |
| 103 | TEST_F(ExtendedDesktopTest, Activation) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 104 | UpdateDisplay("1000x600,600x400"); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 105 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 106 | |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 107 | views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 108 | views::Widget* widget_on_2nd = |
| 109 | CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 110 | EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 111 | EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 112 | |
| 113 | EXPECT_EQ(widget_on_2nd->GetNativeView(), |
| 114 | root_windows[0]->GetFocusManager()->GetFocusedWindow()); |
| 115 | EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); |
| 116 | |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 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. |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 121 | generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); |
| 122 | generator_1st.ClickLeftButton(); |
| 123 | |
| 124 | EXPECT_EQ(widget_on_1st->GetNativeView(), |
| 125 | root_windows[0]->GetFocusManager()->GetFocusedWindow()); |
| 126 | EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 127 | |
| 128 | generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); |
| 129 | generator_2nd.ClickLeftButton(); |
| 130 | |
| 131 | EXPECT_EQ(widget_on_2nd->GetNativeView(), |
| 132 | root_windows[0]->GetFocusManager()->GetFocusedWindow()); |
| 133 | EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | TEST_F(ExtendedDesktopTest, SystemModal) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 137 | UpdateDisplay("1000x600,600x400"); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 138 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 139 | |
| 140 | views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 141 | EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
| 142 | EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); |
| 143 | |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 144 | // Open system modal. Make sure it's on 2nd root window and active. |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 145 | views::Widget* modal_widget = views::Widget::CreateWindowWithBounds( |
| 146 | new ModalWidgetDelegate(), gfx::Rect(1200, 100, 100, 100)); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 147 | modal_widget->Show(); |
| 148 | EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); |
| 149 | EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow()); |
| 150 | EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); |
| 151 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 152 | // Clicking a widget on widget_on_1st display should not change activation. |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 153 | aura::test::EventGenerator generator_1st(root_windows[0]); |
| 154 | generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); |
| 155 | generator_1st.ClickLeftButton(); |
| 156 | EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); |
| 157 | EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); |
| 158 | |
| 159 | // Close system modal and so clicking a widget should work now. |
| 160 | modal_widget->Close(); |
| 161 | generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); |
| 162 | generator_1st.ClickLeftButton(); |
| 163 | EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
| 164 | EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); |
| 165 | } |
| 166 | |
| 167 | TEST_F(ExtendedDesktopTest, TestCursor) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 168 | UpdateDisplay("1000x600,600x400"); |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 169 | Shell::GetInstance()->cursor_manager()->ShowCursor(false); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 170 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 171 | EXPECT_FALSE(root_windows[0]->cursor_shown()); |
| 172 | EXPECT_FALSE(root_windows[1]->cursor_shown()); |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 173 | Shell::GetInstance()->cursor_manager()->ShowCursor(true); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 174 | EXPECT_TRUE(root_windows[0]->cursor_shown()); |
| 175 | EXPECT_TRUE(root_windows[1]->cursor_shown()); |
| 176 | |
| 177 | EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type()); |
| 178 | EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 179 | Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy); |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 180 | EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); |
| 181 | EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); |
| 182 | } |
| 183 | |
[email protected] | 718b26c | 2012-07-24 20:53:23 | [diff] [blame] | 184 | TEST_F(ExtendedDesktopTest, TestCursorLocation) { |
| 185 | UpdateDisplay("0+0-1000x600,1001+0-600x400"); |
| 186 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 187 | aura::Window::TestApi root_window0_test_api(root_windows[0]); |
| 188 | aura::Window::TestApi root_window1_test_api(root_windows[1]); |
| 189 | |
| 190 | root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); |
| 191 | EXPECT_EQ("10,10", gfx::Screen::GetCursorScreenPoint().ToString()); |
| 192 | EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 193 | EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 194 | root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
| 195 | EXPECT_EQ("1010,20", gfx::Screen::GetCursorScreenPoint().ToString()); |
| 196 | EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
| 197 | EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
| 198 | root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
| 199 | EXPECT_EQ("20,10", gfx::Screen::GetCursorScreenPoint().ToString()); |
| 200 | EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 201 | EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 202 | } |
| 203 | |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 204 | TEST_F(ExtendedDesktopTest, CycleWindows) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 205 | UpdateDisplay("700x500,500x500"); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 206 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 207 | |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 208 | WindowCycleController* controller = |
| 209 | Shell::GetInstance()->window_cycle_controller(); |
| 210 | |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 211 | views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 212 | EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 213 | views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 214 | EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); |
| 215 | EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 216 | |
| 217 | controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
| 218 | EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); |
| 219 | controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
| 220 | EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 221 | controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); |
| 222 | EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); |
| 223 | controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); |
| 224 | EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 225 | |
| 226 | // Cycle through all windows across root windows. |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 227 | views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100)); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 228 | EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow()); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 229 | views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100)); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 230 | EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow()); |
| 231 | |
| 232 | controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 233 | EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); |
| 234 | controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 235 | EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 236 | controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 237 | EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); |
| 238 | controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
| 239 | EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
| 240 | |
| 241 | // Backwards |
| 242 | controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 243 | EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); |
| 244 | controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 245 | EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 246 | controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 247 | EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); |
| 248 | controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 249 | EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 253 | UpdateDisplay("700x500,500x500"); |
[email protected] | edbfb8d | 2012-09-03 08:33:43 | [diff] [blame] | 254 | SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 255 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 256 | |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 257 | EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
| 258 | EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
| 259 | EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); |
| 260 | EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 261 | |
| 262 | // Zero origin. |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 263 | EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 264 | |
| 265 | // Out of range point should return the primary root window |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 266 | EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); |
| 267 | EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 271 | UpdateDisplay("700x500,500x500"); |
[email protected] | edbfb8d | 2012-09-03 08:33:43 | [diff] [blame] | 272 | SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
[email protected] | 66b05eac | 2012-06-27 23:53:10 | [diff] [blame] | 273 | |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 274 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 275 | |
| 276 | // Containing rect. |
| 277 | EXPECT_EQ(root_windows[1], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 278 | wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 279 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 280 | wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 281 | |
| 282 | // Intersecting rect. |
| 283 | EXPECT_EQ(root_windows[1], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 284 | wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 285 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 286 | wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 287 | |
| 288 | // Zero origin. |
[email protected] | 66b05eac | 2012-06-27 23:53:10 | [diff] [blame] | 289 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 290 | wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))); |
[email protected] | 66b05eac | 2012-06-27 23:53:10 | [diff] [blame] | 291 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 292 | wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 293 | |
| 294 | // Empty rect. |
| 295 | EXPECT_EQ(root_windows[1], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 296 | wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 297 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 298 | wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 299 | |
| 300 | // Out of range rect should return the primary root window. |
| 301 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 302 | wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 303 | EXPECT_EQ(root_windows[0], |
[email protected] | 7203a5e | 2012-08-06 18:27:46 | [diff] [blame] | 304 | wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); |
[email protected] | 0f81f44 | 2012-06-22 06:20:27 | [diff] [blame] | 305 | } |
| 306 | |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 307 | TEST_F(ExtendedDesktopTest, Capture) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 308 | UpdateDisplay("1000x600,600x400"); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 309 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 310 | |
| 311 | aura::test::EventCountDelegate r1_d1; |
| 312 | aura::test::EventCountDelegate r1_d2; |
| 313 | aura::test::EventCountDelegate r2_d1; |
| 314 | |
| 315 | scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( |
| 316 | &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); |
| 317 | scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( |
| 318 | &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); |
| 319 | scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( |
| 320 | &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 321 | |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 322 | r1_w1->SetCapture(); |
| 323 | |
| 324 | EXPECT_EQ(r1_w1.get(), |
| 325 | aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
| 326 | aura::test::EventGenerator generator2(root_windows[1]); |
| 327 | generator2.MoveMouseToCenterOf(r2_w1.get()); |
| 328 | generator2.ClickLeftButton(); |
| 329 | EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 330 | EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); |
[email protected] | b19ba4adf | 2012-09-07 16:13:29 | [diff] [blame] | 331 | // The mouse is outside. On chromeos, the mouse is warped to the |
| 332 | // dest root window, but it's not implemented on Win yet, so |
| 333 | // no mouse move event on Win. |
| 334 | #if defined(OS_WIN) |
| 335 | EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset()); |
| 336 | #else |
[email protected] | 7495e503 | 2012-09-07 15:31:45 | [diff] [blame] | 337 | EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset()); |
[email protected] | b19ba4adf | 2012-09-07 16:13:29 | [diff] [blame] | 338 | #endif |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 339 | EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset()); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 340 | // (15,15) on 1st display is (-985,15) on 2nd display. |
| 341 | generator2.MoveMouseTo(-985, 15); |
| 342 | EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset()); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 343 | |
| 344 | r1_w2->SetCapture(); |
| 345 | EXPECT_EQ(r1_w2.get(), |
| 346 | aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
| 347 | generator2.MoveMouseBy(10, 10); |
| 348 | generator2.ClickLeftButton(); |
| 349 | EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 350 | EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); |
| 351 | // mouse is already entered. |
| 352 | EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset()); |
| 353 | EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset()); |
| 354 | |
| 355 | r1_w2->ReleaseCapture(); |
| 356 | EXPECT_EQ(NULL, |
| 357 | aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 358 | generator2.MoveMouseTo(15, 15); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 359 | generator2.ClickLeftButton(); |
| 360 | EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 361 | EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset()); |
| 362 | // Make sure the mouse_moved_handler_ is properly reset. |
| 363 | EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); |
| 364 | EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); |
| 365 | } |
| 366 | |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 367 | TEST_F(ExtendedDesktopTest, MoveWindow) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 368 | UpdateDisplay("1000x600,600x400"); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 369 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 370 | views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 371 | |
| 372 | EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 373 | |
| 374 | d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); |
| 375 | EXPECT_EQ("1010,10 100x100", |
| 376 | d1->GetWindowBoundsInScreen().ToString()); |
| 377 | |
| 378 | EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); |
| 379 | |
| 380 | d1->SetBounds(gfx::Rect(10, 10, 100, 100)); |
| 381 | EXPECT_EQ("10,10 100x100", |
| 382 | d1->GetWindowBoundsInScreen().ToString()); |
| 383 | |
| 384 | EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 385 | |
| 386 | // Make sure the bounds which doesn't fit to the root window |
| 387 | // works correctly. |
| 388 | d1->SetBounds(gfx::Rect(1560, 30, 100, 100)); |
| 389 | EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); |
| 390 | EXPECT_EQ("1560,30 100x100", |
| 391 | d1->GetWindowBoundsInScreen().ToString()); |
| 392 | |
| 393 | // Setting outside of root windows will be moved to primary root window. |
| 394 | // TODO(oshima): This one probably should pick the closest root window. |
| 395 | d1->SetBounds(gfx::Rect(200, 10, 100, 100)); |
| 396 | EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 397 | } |
| 398 | |
[email protected] | e79f26e | 2012-08-09 07:12:48 | [diff] [blame] | 399 | TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { |
| 400 | UpdateDisplay("1000x1000,1000x1000"); |
| 401 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 402 | |
| 403 | gfx::Display display0 = |
| 404 | gfx::Screen::GetDisplayMatching(root_windows[0]->GetBoundsInScreen()); |
| 405 | gfx::Display display1 = |
| 406 | gfx::Screen::GetDisplayMatching(root_windows[1]->GetBoundsInScreen()); |
| 407 | EXPECT_NE(display0.id(), display1.id()); |
| 408 | |
| 409 | views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); |
| 410 | EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 411 | |
| 412 | // Move the window where the window spans both root windows. Since the second |
| 413 | // parameter is |display1|, the window should be shown on the secondary root. |
| 414 | d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
| 415 | display1); |
| 416 | EXPECT_EQ("500,10 1000x100", |
| 417 | d1->GetWindowBoundsInScreen().ToString()); |
| 418 | EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); |
| 419 | |
| 420 | // Move to the primary root. |
| 421 | d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
| 422 | display0); |
| 423 | EXPECT_EQ("500,10 1000x100", |
| 424 | d1->GetWindowBoundsInScreen().ToString()); |
| 425 | EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 426 | } |
| 427 | |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 428 | TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 429 | UpdateDisplay("1000x600,600x400"); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 430 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 431 | views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 432 | views::Widget* w1_t1 = CreateTestWidgetWithParent( |
| 433 | w1, gfx::Rect(50, 50, 50, 50), false /* transient */); |
| 434 | // Transient child of the transient child. |
| 435 | views::Widget* w1_t11 = CreateTestWidgetWithParent( |
| 436 | w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); |
| 437 | |
| 438 | views::Widget* w11 = CreateTestWidgetWithParent( |
| 439 | w1, gfx::Rect(10, 10, 40, 40), true /* child */); |
| 440 | views::Widget* w11_t1 = CreateTestWidgetWithParent( |
| 441 | w1, gfx::Rect(1300, 100, 80, 80), false /* transient */); |
| 442 | |
| 443 | EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); |
| 444 | EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow()); |
| 445 | EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow()); |
| 446 | EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow()); |
| 447 | EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow()); |
| 448 | EXPECT_EQ("50,50 50x50", |
| 449 | w1_t1->GetWindowBoundsInScreen().ToString()); |
| 450 | EXPECT_EQ("1200,70 30x30", |
| 451 | w1_t11->GetWindowBoundsInScreen().ToString()); |
| 452 | EXPECT_EQ("20,20 40x40", |
| 453 | w11->GetWindowBoundsInScreen().ToString()); |
| 454 | EXPECT_EQ("1300,100 80x80", |
| 455 | w11_t1->GetWindowBoundsInScreen().ToString()); |
| 456 | |
| 457 | w1->SetBounds(gfx::Rect(1100,10,100,100)); |
| 458 | |
| 459 | EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 460 | EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 461 | EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow()); |
| 462 | EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow()); |
| 463 | EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow()); |
| 464 | |
| 465 | EXPECT_EQ("1110,20 40x40", |
| 466 | w11->GetWindowBoundsInScreen().ToString()); |
| 467 | // Transient window's screen bounds stays the same. |
| 468 | EXPECT_EQ("50,50 50x50", |
| 469 | w1_t1->GetWindowBoundsInScreen().ToString()); |
| 470 | EXPECT_EQ("1200,70 30x30", |
| 471 | w1_t11->GetWindowBoundsInScreen().ToString()); |
| 472 | EXPECT_EQ("1300,100 80x80", |
| 473 | w11_t1->GetWindowBoundsInScreen().ToString()); |
| 474 | |
| 475 | // Transient window doesn't move between root window unless |
| 476 | // its transient parent moves. |
| 477 | w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); |
| 478 | EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 479 | EXPECT_EQ("10,50 50x50", |
| 480 | w1_t1->GetWindowBoundsInScreen().ToString()); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 481 | } |
| 482 | |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 483 | namespace internal { |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 484 | // Test if the Window::ConvertPointToTarget works across root windows. |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 485 | // TODO(oshima): Move multiple display suport and this test to aura. |
| 486 | TEST_F(ExtendedDesktopTest, ConvertPoint) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 487 | UpdateDisplay("1000x600,600x400"); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 488 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 489 | gfx::Display& display_1 = |
[email protected] | 3e4351b | 2012-08-09 04:04:16 | [diff] [blame] | 490 | GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 491 | EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); |
| 492 | gfx::Display& display_2 = |
[email protected] | 3e4351b | 2012-08-09 04:04:16 | [diff] [blame] | 493 | GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 494 | EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); |
| 495 | |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 496 | aura::Window* d1 = |
| 497 | CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 498 | aura::Window* d2 = |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 499 | CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); |
| 500 | EXPECT_EQ(root_windows[0], d1->GetRootWindow()); |
| 501 | EXPECT_EQ(root_windows[1], d2->GetRootWindow()); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 502 | |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 503 | // Convert point in the Root2's window to the Root1's window Coord. |
| 504 | gfx::Point p(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 505 | aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 506 | EXPECT_EQ("1000,0", p.ToString()); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 507 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 508 | aura::Window::ConvertPointToTarget(d2, d1, &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 509 | EXPECT_EQ("1010,10", p.ToString()); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 510 | |
| 511 | // Convert point in the Root1's window to the Root2's window Coord. |
| 512 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 513 | aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 514 | EXPECT_EQ("-1000,0", p.ToString()); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 515 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 516 | aura::Window::ConvertPointToTarget(d1, d2, &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 517 | EXPECT_EQ("-1010,-10", p.ToString()); |
| 518 | |
| 519 | // Move the 2nd display to the bottom and test again. |
[email protected] | edbfb8d | 2012-09-03 08:33:43 | [diff] [blame] | 520 | SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 521 | |
[email protected] | 3e4351b | 2012-08-09 04:04:16 | [diff] [blame] | 522 | display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 523 | EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); |
| 524 | |
| 525 | // Convert point in Root2's window to Root1's window Coord. |
| 526 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 527 | aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 528 | EXPECT_EQ("0,600", p.ToString()); |
| 529 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 530 | aura::Window::ConvertPointToTarget(d2, d1, &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 531 | EXPECT_EQ("10,610", p.ToString()); |
| 532 | |
| 533 | // Convert point in Root1's window to Root2's window Coord. |
| 534 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 535 | aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 536 | EXPECT_EQ("0,-600", p.ToString()); |
| 537 | p.SetPoint(0, 0); |
[email protected] | ca706098 | 2012-08-08 18:05:25 | [diff] [blame] | 538 | aura::Window::ConvertPointToTarget(d1, d2, &p); |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 539 | EXPECT_EQ("-10,-610", p.ToString()); |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 540 | } |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 541 | |
[email protected] | 263898a | 2012-09-17 17:20:07 | [diff] [blame^] | 542 | TEST_F(ExtendedDesktopTest, OpenSystemTray) { |
| 543 | UpdateDisplay("1000x600,600x400"); |
| 544 | SystemTray* tray = ash::Shell::GetInstance()->system_tray(); |
| 545 | ASSERT_FALSE(tray->HasSystemBubble()); |
| 546 | |
| 547 | // Opens the tray by a dummy click event and makes sure that adding/removing |
| 548 | // displays doesn't break anything. |
| 549 | aura::test::EventGenerator event_generator( |
| 550 | ash::Shell::GetInstance()->GetPrimaryRootWindow(), |
| 551 | tray->GetWidget()->GetNativeWindow()); |
| 552 | event_generator.ClickLeftButton(); |
| 553 | EXPECT_TRUE(tray->HasSystemBubble()); |
| 554 | |
| 555 | UpdateDisplay("100x600"); |
| 556 | EXPECT_TRUE(tray->HasSystemBubble()); |
| 557 | UpdateDisplay("100x600,600x400"); |
| 558 | EXPECT_TRUE(tray->HasSystemBubble()); |
| 559 | |
| 560 | // Closes the tray and again makes sure that adding/removing displays doesn't |
| 561 | // break anything. |
| 562 | event_generator.ClickLeftButton(); |
| 563 | RunAllPendingInMessageLoop(); |
| 564 | |
| 565 | EXPECT_FALSE(tray->HasSystemBubble()); |
| 566 | |
| 567 | UpdateDisplay("100x600"); |
| 568 | EXPECT_FALSE(tray->HasSystemBubble()); |
| 569 | UpdateDisplay("100x600,600x400"); |
| 570 | EXPECT_FALSE(tray->HasSystemBubble()); |
| 571 | } |
| 572 | |
[email protected] | a5e71c9 | 2012-06-22 22:09:08 | [diff] [blame] | 573 | } // namespace internal |
[email protected] | c39be8f | 2012-06-15 22:58:36 | [diff] [blame] | 574 | } // namespace ash |