| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 return w; | 88 return w; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void MoveCursorTo(const gfx::Point& p) { | 91 void MoveCursorTo(const gfx::Point& p) { |
| 92 DisplayManager* display_manager = window_server()->display_manager(); | 92 DisplayManager* display_manager = window_server()->display_manager(); |
| 93 ASSERT_EQ(1u, display_manager->displays().size()); | 93 ASSERT_EQ(1u, display_manager->displays().size()); |
| 94 Display* display = *display_manager->displays().begin(); | 94 Display* display = *display_manager->displays().begin(); |
| 95 WindowManagerDisplayRoot* active_display_root = | 95 WindowManagerDisplayRoot* active_display_root = |
| 96 display->GetActiveWindowManagerDisplayRoot(); | 96 display->GetActiveWindowManagerDisplayRoot(); |
| 97 ASSERT_TRUE(active_display_root); | 97 ASSERT_TRUE(active_display_root); |
| 98 static_cast<PlatformDisplayDelegate*>(display)->OnEvent(ui::PointerEvent( | 98 static_cast<PlatformDisplayDelegate*>(display)->OnEvent(PointerEvent( |
| 99 ui::MouseEvent(ui::ET_MOUSE_MOVED, p, p, base::TimeTicks(), 0, 0))); | 99 MouseEvent(ET_MOUSE_MOVED, p, p, base::TimeTicks(), 0, 0))); |
| 100 WindowManagerState* wms = active_display_root->window_manager_state(); | 100 WindowManagerState* wms = active_display_root->window_manager_state(); |
| 101 wms->OnEventAck(wms->window_tree(), mojom::EventResult::HANDLED); | 101 wms->OnEventAck(wms->window_tree(), mojom::EventResult::HANDLED); |
| 102 } | 102 } |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 WindowServerTestHelper ws_test_helper_; | 105 WindowServerTestHelper ws_test_helper_; |
| 106 TestScreenManager screen_manager_; | 106 TestScreenManager screen_manager_; |
| 107 DISALLOW_COPY_AND_ASSIGN(CursorTest); | 107 DISALLOW_COPY_AND_ASSIGN(CursorTest); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 TEST_F(CursorTest, ChangeByMouseMove) { | 110 TEST_F(CursorTest, ChangeByMouseMove) { |
| 111 ServerWindow* win = BuildServerWindow(); | 111 ServerWindow* win = BuildServerWindow(); |
| 112 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 112 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 113 win->parent()->SetPredefinedCursor(mojom::Cursor::CELL); |
| 113 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 114 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 114 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 115 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 115 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 116 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 116 | 117 |
| 117 // Non client area | 118 // Non client area |
| 118 MoveCursorTo(gfx::Point(15, 15)); | 119 MoveCursorTo(gfx::Point(15, 15)); |
| 119 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 120 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 120 | 121 |
| 121 // Client area | 122 // Client area, which comes from win->parent(). |
| 122 MoveCursorTo(gfx::Point(25, 25)); | 123 MoveCursorTo(gfx::Point(25, 25)); |
| 123 EXPECT_EQ(mojom::Cursor::IBEAM, cursor()); | 124 EXPECT_EQ(mojom::Cursor::CELL, cursor()); |
| 124 } | 125 } |
| 125 | 126 |
| 126 TEST_F(CursorTest, ChangeByClientAreaChange) { | 127 TEST_F(CursorTest, ChangeByClientAreaChange) { |
| 127 ServerWindow* win = BuildServerWindow(); | 128 ServerWindow* win = BuildServerWindow(); |
| 129 win->parent()->SetPredefinedCursor(mojom::Cursor::CROSS); |
| 128 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 130 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 129 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 131 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); |
| 130 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 132 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 131 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 133 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 132 | 134 |
| 133 // Non client area before we move. | 135 // Non client area before we move. |
| 134 MoveCursorTo(gfx::Point(15, 15)); | 136 MoveCursorTo(gfx::Point(15, 15)); |
| 135 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 137 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 136 | 138 |
| 137 // Changing the client area should cause a change. | 139 // Changing the client area should cause a change. The cursor for the client |
| 140 // area comes from root ancestor, which is win->parent(). |
| 138 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); | 141 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); |
| 139 EXPECT_EQ(mojom::Cursor::IBEAM, cursor()); | 142 EXPECT_EQ(mojom::Cursor::CROSS, cursor()); |
| 140 } | 143 } |
| 141 | 144 |
| 142 TEST_F(CursorTest, NonClientCursorChange) { | 145 TEST_F(CursorTest, NonClientCursorChange) { |
| 143 ServerWindow* win = BuildServerWindow(); | 146 ServerWindow* win = BuildServerWindow(); |
| 144 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 147 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 145 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 148 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 146 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 149 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 147 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 150 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 148 | 151 |
| 149 MoveCursorTo(gfx::Point(15, 15)); | 152 MoveCursorTo(gfx::Point(15, 15)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 162 | 165 |
| 163 MoveCursorTo(gfx::Point(15, 15)); | 166 MoveCursorTo(gfx::Point(15, 15)); |
| 164 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 167 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 165 | 168 |
| 166 win->SetPredefinedCursor(mojom::Cursor::HELP); | 169 win->SetPredefinedCursor(mojom::Cursor::HELP); |
| 167 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 170 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 168 } | 171 } |
| 169 | 172 |
| 170 TEST_F(CursorTest, NonClientToClientByBoundsChange) { | 173 TEST_F(CursorTest, NonClientToClientByBoundsChange) { |
| 171 ServerWindow* win = BuildServerWindow(); | 174 ServerWindow* win = BuildServerWindow(); |
| 175 win->parent()->SetPredefinedCursor(mojom::Cursor::COPY); |
| 172 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 176 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 173 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 177 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 174 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 178 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 175 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 179 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 176 | 180 |
| 177 // Non client area before we move. | 181 // Non client area before we move. |
| 178 MoveCursorTo(gfx::Point(15, 15)); | 182 MoveCursorTo(gfx::Point(15, 15)); |
| 179 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 183 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 180 | 184 |
| 181 win->SetBounds(gfx::Rect(0, 0, 30, 30)); | 185 win->SetBounds(gfx::Rect(0, 0, 30, 30)); |
| 182 EXPECT_EQ(mojom::Cursor::IBEAM, cursor()); | 186 EXPECT_EQ(mojom::Cursor::COPY, cursor()); |
| 183 } | 187 } |
| 184 | 188 |
| 185 } // namespace test | 189 } // namespace test |
| 186 } // namespace ws | 190 } // namespace ws |
| 187 } // namespace ui | 191 } // namespace ui |
| OLD | NEW |