OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 received_mouse_exit_ = false; | 207 received_mouse_exit_ = false; |
208 last_touch_event_type_ = 0; | 208 last_touch_event_type_ = 0; |
209 last_touch_event_was_handled_ = false; | 209 last_touch_event_was_handled_ = false; |
210 last_gesture_event_type_ = 0; | 210 last_gesture_event_type_ = 0; |
211 last_gesture_event_was_handled_ = false; | 211 last_gesture_event_was_handled_ = false; |
212 last_clip_.setEmpty(); | 212 last_clip_.setEmpty(); |
213 accelerator_count_map_.clear(); | 213 accelerator_count_map_.clear(); |
214 } | 214 } |
215 | 215 |
216 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 216 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
217 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | 217 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
218 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; | 218 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
219 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; | 219 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
220 virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; | 220 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
221 virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; | 221 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
222 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; | 222 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; |
223 // Ignores GestureEvent by default. | 223 // Ignores GestureEvent by default. |
224 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; | 224 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; |
225 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; | 225 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; |
226 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; | 226 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; |
227 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 227 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
228 | 228 |
229 // OnBoundsChanged. | 229 // OnBoundsChanged. |
230 bool did_change_bounds_; | 230 bool did_change_bounds_; |
231 gfx::Rect new_bounds_; | 231 gfx::Rect new_bounds_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 335 |
336 EXPECT_EQ(v.did_change_bounds_, true); | 336 EXPECT_EQ(v.did_change_bounds_, true); |
337 EXPECT_EQ(v.new_bounds_, new_rect); | 337 EXPECT_EQ(v.new_bounds_, new_rect); |
338 EXPECT_EQ(v.bounds(), new_rect); | 338 EXPECT_EQ(v.bounds(), new_rect); |
339 } | 339 } |
340 | 340 |
341 //////////////////////////////////////////////////////////////////////////////// | 341 //////////////////////////////////////////////////////////////////////////////// |
342 // MouseEvent | 342 // MouseEvent |
343 //////////////////////////////////////////////////////////////////////////////// | 343 //////////////////////////////////////////////////////////////////////////////// |
344 | 344 |
345 bool TestView::OnMousePressed(const MouseEvent& event) { | 345 bool TestView::OnMousePressed(const ui::MouseEvent& event) { |
346 last_mouse_event_type_ = event.type(); | 346 last_mouse_event_type_ = event.type(); |
347 location_.SetPoint(event.x(), event.y()); | 347 location_.SetPoint(event.x(), event.y()); |
348 if (delete_on_pressed_) | 348 if (delete_on_pressed_) |
349 delete this; | 349 delete this; |
350 return true; | 350 return true; |
351 } | 351 } |
352 | 352 |
353 bool TestView::OnMouseDragged(const MouseEvent& event) { | 353 bool TestView::OnMouseDragged(const ui::MouseEvent& event) { |
354 last_mouse_event_type_ = event.type(); | 354 last_mouse_event_type_ = event.type(); |
355 location_.SetPoint(event.x(), event.y()); | 355 location_.SetPoint(event.x(), event.y()); |
356 return true; | 356 return true; |
357 } | 357 } |
358 | 358 |
359 void TestView::OnMouseReleased(const MouseEvent& event) { | 359 void TestView::OnMouseReleased(const ui::MouseEvent& event) { |
360 last_mouse_event_type_ = event.type(); | 360 last_mouse_event_type_ = event.type(); |
361 location_.SetPoint(event.x(), event.y()); | 361 location_.SetPoint(event.x(), event.y()); |
362 } | 362 } |
363 | 363 |
364 void TestView::OnMouseEntered(const MouseEvent& event) { | 364 void TestView::OnMouseEntered(const ui::MouseEvent& event) { |
365 received_mouse_enter_ = true; | 365 received_mouse_enter_ = true; |
366 } | 366 } |
367 | 367 |
368 void TestView::OnMouseExited(const MouseEvent& event) { | 368 void TestView::OnMouseExited(const ui::MouseEvent& event) { |
369 received_mouse_exit_ = true; | 369 received_mouse_exit_ = true; |
370 } | 370 } |
371 | 371 |
372 TEST_F(ViewTest, MouseEvent) { | 372 TEST_F(ViewTest, MouseEvent) { |
373 TestView* v1 = new TestView(); | 373 TestView* v1 = new TestView(); |
374 v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300)); | 374 v1->SetBoundsRect(gfx::Rect(0, 0, 300, 300)); |
375 | 375 |
376 TestView* v2 = new TestView(); | 376 TestView* v2 = new TestView(); |
377 v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100)); | 377 v2->SetBoundsRect(gfx::Rect(100, 100, 100, 100)); |
378 | 378 |
379 scoped_ptr<Widget> widget(new Widget); | 379 scoped_ptr<Widget> widget(new Widget); |
380 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 380 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
381 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 381 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
382 params.bounds = gfx::Rect(50, 50, 650, 650); | 382 params.bounds = gfx::Rect(50, 50, 650, 650); |
383 widget->Init(params); | 383 widget->Init(params); |
384 View* root = widget->GetRootView(); | 384 View* root = widget->GetRootView(); |
385 | 385 |
386 root->AddChildView(v1); | 386 root->AddChildView(v1); |
387 v1->AddChildView(v2); | 387 v1->AddChildView(v2); |
388 | 388 |
389 v1->Reset(); | 389 v1->Reset(); |
390 v2->Reset(); | 390 v2->Reset(); |
391 | 391 |
392 MouseEvent pressed(ui::ET_MOUSE_PRESSED, | 392 gfx::Point p1(110, 120); |
393 110, | 393 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, |
394 120, | 394 ui::EF_LEFT_MOUSE_BUTTON); |
395 ui::EF_LEFT_MOUSE_BUTTON); | |
396 root->OnMousePressed(pressed); | 395 root->OnMousePressed(pressed); |
397 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED); | 396 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED); |
398 EXPECT_EQ(v2->location_.x(), 10); | 397 EXPECT_EQ(v2->location_.x(), 10); |
399 EXPECT_EQ(v2->location_.y(), 20); | 398 EXPECT_EQ(v2->location_.y(), 20); |
400 // Make sure v1 did not receive the event | 399 // Make sure v1 did not receive the event |
401 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 400 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
402 | 401 |
403 // Drag event out of bounds. Should still go to v2 | 402 // Drag event out of bounds. Should still go to v2 |
404 v1->Reset(); | 403 v1->Reset(); |
405 v2->Reset(); | 404 v2->Reset(); |
406 MouseEvent dragged(ui::ET_MOUSE_DRAGGED, | 405 gfx::Point p2(50, 40); |
407 50, | 406 ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2, |
408 40, | 407 ui::EF_LEFT_MOUSE_BUTTON); |
409 ui::EF_LEFT_MOUSE_BUTTON); | |
410 root->OnMouseDragged(dragged); | 408 root->OnMouseDragged(dragged); |
411 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED); | 409 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED); |
412 EXPECT_EQ(v2->location_.x(), -50); | 410 EXPECT_EQ(v2->location_.x(), -50); |
413 EXPECT_EQ(v2->location_.y(), -60); | 411 EXPECT_EQ(v2->location_.y(), -60); |
414 // Make sure v1 did not receive the event | 412 // Make sure v1 did not receive the event |
415 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 413 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
416 | 414 |
417 // Releasted event out of bounds. Should still go to v2 | 415 // Releasted event out of bounds. Should still go to v2 |
418 v1->Reset(); | 416 v1->Reset(); |
419 v2->Reset(); | 417 v2->Reset(); |
420 MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0); | 418 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0); |
421 root->OnMouseDragged(released); | 419 root->OnMouseDragged(released); |
422 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED); | 420 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED); |
423 EXPECT_EQ(v2->location_.x(), -100); | 421 EXPECT_EQ(v2->location_.x(), -100); |
424 EXPECT_EQ(v2->location_.y(), -100); | 422 EXPECT_EQ(v2->location_.y(), -100); |
425 // Make sure v1 did not receive the event | 423 // Make sure v1 did not receive the event |
426 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 424 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
427 | 425 |
428 widget->CloseNow(); | 426 widget->CloseNow(); |
429 } | 427 } |
430 | 428 |
(...skipping 12 matching lines...) Expand all Loading... |
443 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 441 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
444 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 442 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
445 params.bounds = gfx::Rect(50, 50, 650, 650); | 443 params.bounds = gfx::Rect(50, 50, 650, 650); |
446 widget->Init(params); | 444 widget->Init(params); |
447 View* root = widget->GetRootView(); | 445 View* root = widget->GetRootView(); |
448 | 446 |
449 root->AddChildView(v1); | 447 root->AddChildView(v1); |
450 v1->AddChildView(v2); | 448 v1->AddChildView(v2); |
451 | 449 |
452 v2->delete_on_pressed_ = true; | 450 v2->delete_on_pressed_ = true; |
453 MouseEvent pressed(ui::ET_MOUSE_PRESSED, | 451 gfx::Point point(110, 120); |
454 110, | 452 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, |
455 120, | 453 ui::EF_LEFT_MOUSE_BUTTON); |
456 ui::EF_LEFT_MOUSE_BUTTON); | |
457 root->OnMousePressed(pressed); | 454 root->OnMousePressed(pressed); |
458 EXPECT_EQ(0, v1->child_count()); | 455 EXPECT_EQ(0, v1->child_count()); |
459 | 456 |
460 widget->CloseNow(); | 457 widget->CloseNow(); |
461 } | 458 } |
462 | 459 |
463 //////////////////////////////////////////////////////////////////////////////// | 460 //////////////////////////////////////////////////////////////////////////////// |
464 // TouchEvent | 461 // TouchEvent |
465 //////////////////////////////////////////////////////////////////////////////// | 462 //////////////////////////////////////////////////////////////////////////////// |
466 ui::TouchStatus TestView::OnTouchEvent(const TouchEvent& event) { | 463 ui::TouchStatus TestView::OnTouchEvent(const TouchEvent& event) { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 | 1064 |
1068 v1->Reset(); | 1065 v1->Reset(); |
1069 v11->Reset(); | 1066 v11->Reset(); |
1070 v111->Reset(); | 1067 v111->Reset(); |
1071 v12->Reset(); | 1068 v12->Reset(); |
1072 v121->Reset(); | 1069 v121->Reset(); |
1073 v2->Reset(); | 1070 v2->Reset(); |
1074 v21->Reset(); | 1071 v21->Reset(); |
1075 | 1072 |
1076 // Move the mouse in v111. | 1073 // Move the mouse in v111. |
1077 MouseEvent move1(ui::ET_MOUSE_MOVED, 6, 6, 0); | 1074 gfx::Point p1(6, 6); |
| 1075 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, 0); |
1078 root_view->OnMouseMoved(move1); | 1076 root_view->OnMouseMoved(move1); |
1079 EXPECT_TRUE(v111->received_mouse_enter_); | 1077 EXPECT_TRUE(v111->received_mouse_enter_); |
1080 EXPECT_FALSE(v11->last_mouse_event_type_); | 1078 EXPECT_FALSE(v11->last_mouse_event_type_); |
1081 EXPECT_TRUE(v1->received_mouse_enter_); | 1079 EXPECT_TRUE(v1->received_mouse_enter_); |
1082 | 1080 |
1083 v111->Reset(); | 1081 v111->Reset(); |
1084 v1->Reset(); | 1082 v1->Reset(); |
1085 | 1083 |
1086 // Now, move into v121. | 1084 // Now, move into v121. |
1087 MouseEvent move2(ui::ET_MOUSE_MOVED, 65, 21, 0); | 1085 gfx::Point p2(65, 21); |
| 1086 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, 0); |
1088 root_view->OnMouseMoved(move2); | 1087 root_view->OnMouseMoved(move2); |
1089 EXPECT_TRUE(v111->received_mouse_exit_); | 1088 EXPECT_TRUE(v111->received_mouse_exit_); |
1090 EXPECT_TRUE(v121->received_mouse_enter_); | 1089 EXPECT_TRUE(v121->received_mouse_enter_); |
1091 EXPECT_FALSE(v1->last_mouse_event_type_); | 1090 EXPECT_FALSE(v1->last_mouse_event_type_); |
1092 | 1091 |
1093 v111->Reset(); | 1092 v111->Reset(); |
1094 v121->Reset(); | 1093 v121->Reset(); |
1095 | 1094 |
1096 // Now, move into v11. | 1095 // Now, move into v11. |
1097 MouseEvent move3(ui::ET_MOUSE_MOVED, 1, 1, 0); | 1096 gfx::Point p3(1, 1); |
| 1097 ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, 0); |
1098 root_view->OnMouseMoved(move3); | 1098 root_view->OnMouseMoved(move3); |
1099 EXPECT_TRUE(v121->received_mouse_exit_); | 1099 EXPECT_TRUE(v121->received_mouse_exit_); |
1100 EXPECT_TRUE(v11->received_mouse_enter_); | 1100 EXPECT_TRUE(v11->received_mouse_enter_); |
1101 EXPECT_FALSE(v1->last_mouse_event_type_); | 1101 EXPECT_FALSE(v1->last_mouse_event_type_); |
1102 | 1102 |
1103 v121->Reset(); | 1103 v121->Reset(); |
1104 v11->Reset(); | 1104 v11->Reset(); |
1105 | 1105 |
1106 // Move to v21. | 1106 // Move to v21. |
1107 MouseEvent move4(ui::ET_MOUSE_MOVED, 121, 15, 0); | 1107 gfx::Point p4(121, 15); |
| 1108 ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, 0); |
1108 root_view->OnMouseMoved(move4); | 1109 root_view->OnMouseMoved(move4); |
1109 EXPECT_TRUE(v21->received_mouse_enter_); | 1110 EXPECT_TRUE(v21->received_mouse_enter_); |
1110 EXPECT_FALSE(v2->last_mouse_event_type_); | 1111 EXPECT_FALSE(v2->last_mouse_event_type_); |
1111 EXPECT_TRUE(v11->received_mouse_exit_); | 1112 EXPECT_TRUE(v11->received_mouse_exit_); |
1112 EXPECT_TRUE(v1->received_mouse_exit_); | 1113 EXPECT_TRUE(v1->received_mouse_exit_); |
1113 | 1114 |
1114 v21->Reset(); | 1115 v21->Reset(); |
1115 v11->Reset(); | 1116 v11->Reset(); |
1116 v1->Reset(); | 1117 v1->Reset(); |
1117 | 1118 |
1118 // Move to v1. | 1119 // Move to v1. |
1119 MouseEvent move5(ui::ET_MOUSE_MOVED, 21, 0, 0); | 1120 gfx::Point p5(21, 0); |
| 1121 ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, 0); |
1120 root_view->OnMouseMoved(move5); | 1122 root_view->OnMouseMoved(move5); |
1121 EXPECT_TRUE(v21->received_mouse_exit_); | 1123 EXPECT_TRUE(v21->received_mouse_exit_); |
1122 EXPECT_TRUE(v1->received_mouse_enter_); | 1124 EXPECT_TRUE(v1->received_mouse_enter_); |
1123 | 1125 |
1124 v21->Reset(); | 1126 v21->Reset(); |
1125 v1->Reset(); | 1127 v1->Reset(); |
1126 | 1128 |
1127 // Now, move into v11. | 1129 // Now, move into v11. |
1128 MouseEvent mouse6(ui::ET_MOUSE_MOVED, 15, 15, 0); | 1130 gfx::Point p6(15, 15); |
| 1131 ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, 0); |
1129 root_view->OnMouseMoved(mouse6); | 1132 root_view->OnMouseMoved(mouse6); |
1130 EXPECT_TRUE(v11->received_mouse_enter_); | 1133 EXPECT_TRUE(v11->received_mouse_enter_); |
1131 EXPECT_FALSE(v1->last_mouse_event_type_); | 1134 EXPECT_FALSE(v1->last_mouse_event_type_); |
1132 | 1135 |
1133 v11->Reset(); | 1136 v11->Reset(); |
1134 v1->Reset(); | 1137 v1->Reset(); |
1135 | 1138 |
1136 // Move back into v1. Although |v1| had already received an ENTER for mouse6, | 1139 // Move back into v1. Although |v1| had already received an ENTER for mouse6, |
1137 // and the mouse remains inside |v1| the whole time, it receives another ENTER | 1140 // and the mouse remains inside |v1| the whole time, it receives another ENTER |
1138 // when the mouse leaves v11. | 1141 // when the mouse leaves v11. |
1139 MouseEvent mouse7(ui::ET_MOUSE_MOVED, 21, 0, 0); | 1142 gfx::Point p7(21, 0); |
| 1143 ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, 0); |
1140 root_view->OnMouseMoved(mouse7); | 1144 root_view->OnMouseMoved(mouse7); |
1141 EXPECT_TRUE(v11->received_mouse_exit_); | 1145 EXPECT_TRUE(v11->received_mouse_exit_); |
1142 EXPECT_FALSE(v1->received_mouse_enter_); | 1146 EXPECT_FALSE(v1->received_mouse_enter_); |
1143 | 1147 |
1144 widget->CloseNow(); | 1148 widget->CloseNow(); |
1145 } | 1149 } |
1146 | 1150 |
1147 TEST_F(ViewTest, Textfield) { | 1151 TEST_F(ViewTest, Textfield) { |
1148 const string16 kText = ASCIIToUTF16("Reality is that which, when you stop " | 1152 const string16 kText = ASCIIToUTF16("Reality is that which, when you stop " |
1149 "believing it, doesn't go away."); | 1153 "believing it, doesn't go away."); |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 // This is owned by test_dialog_. | 1811 // This is owned by test_dialog_. |
1808 View* button_as_view_; | 1812 View* button_as_view_; |
1809 | 1813 |
1810 private: | 1814 private: |
1811 DISALLOW_COPY_AND_ASSIGN(ButtonDropDownTest); | 1815 DISALLOW_COPY_AND_ASSIGN(ButtonDropDownTest); |
1812 }; | 1816 }; |
1813 | 1817 |
1814 // Ensure that regular clicks on the drop down button still work. (i.e. - the | 1818 // Ensure that regular clicks on the drop down button still work. (i.e. - the |
1815 // click events are processed and the listener gets the click) | 1819 // click events are processed and the listener gets the click) |
1816 TEST_F(ButtonDropDownTest, RegularClickTest) { | 1820 TEST_F(ButtonDropDownTest, RegularClickTest) { |
1817 MouseEvent press_event(ui::ET_MOUSE_PRESSED, 1, 1, ui::EF_LEFT_MOUSE_BUTTON); | 1821 gfx::Point point(1, 1); |
1818 MouseEvent release_event(ui::ET_MOUSE_RELEASED, 1, 1, | 1822 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, point, point, |
1819 ui::EF_LEFT_MOUSE_BUTTON); | 1823 ui::EF_LEFT_MOUSE_BUTTON); |
| 1824 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, point, point, |
| 1825 ui::EF_LEFT_MOUSE_BUTTON); |
1820 button_as_view_->OnMousePressed(press_event); | 1826 button_as_view_->OnMousePressed(press_event); |
1821 button_as_view_->OnMouseReleased(release_event); | 1827 button_as_view_->OnMouseReleased(release_event); |
1822 EXPECT_EQ(test_dialog_->last_pressed_button_, test_dialog_->button_drop_); | 1828 EXPECT_EQ(test_dialog_->last_pressed_button_, test_dialog_->button_drop_); |
1823 } | 1829 } |
1824 | 1830 |
1825 //////////////////////////////////////////////////////////////////////////////// | 1831 //////////////////////////////////////////////////////////////////////////////// |
1826 // View hierarchy / Visibility changes | 1832 // View hierarchy / Visibility changes |
1827 //////////////////////////////////////////////////////////////////////////////// | 1833 //////////////////////////////////////////////////////////////////////////////// |
1828 /* | 1834 /* |
1829 TEST_F(ViewTest, ChangeVisibility) { | 1835 TEST_F(ViewTest, ChangeVisibility) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 // Rotate |v1| counter-clockwise. | 2071 // Rotate |v1| counter-clockwise. |
2066 ui::Transform transform(v1->GetTransform()); | 2072 ui::Transform transform(v1->GetTransform()); |
2067 RotateCounterclockwise(&transform); | 2073 RotateCounterclockwise(&transform); |
2068 transform.SetTranslateY(500.0f); | 2074 transform.SetTranslateY(500.0f); |
2069 v1->SetTransform(transform); | 2075 v1->SetTransform(transform); |
2070 | 2076 |
2071 // |v2| now occupies (100, 200) to (200, 400) in |root|. | 2077 // |v2| now occupies (100, 200) to (200, 400) in |root|. |
2072 v1->Reset(); | 2078 v1->Reset(); |
2073 v2->Reset(); | 2079 v2->Reset(); |
2074 | 2080 |
2075 MouseEvent pressed(ui::ET_MOUSE_PRESSED, | 2081 gfx::Point p1(110, 210); |
2076 110, 210, | 2082 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, |
2077 ui::EF_LEFT_MOUSE_BUTTON); | 2083 ui::EF_LEFT_MOUSE_BUTTON); |
2078 root->OnMousePressed(pressed); | 2084 root->OnMousePressed(pressed); |
2079 EXPECT_EQ(0, v1->last_mouse_event_type_); | 2085 EXPECT_EQ(0, v1->last_mouse_event_type_); |
2080 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); | 2086 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); |
2081 EXPECT_EQ(190, v2->location_.x()); | 2087 EXPECT_EQ(190, v2->location_.x()); |
2082 EXPECT_EQ(10, v2->location_.y()); | 2088 EXPECT_EQ(10, v2->location_.y()); |
2083 | 2089 |
2084 MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0); | 2090 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 0); |
2085 root->OnMouseReleased(released); | 2091 root->OnMouseReleased(released); |
2086 | 2092 |
2087 // Now rotate |v2| inside |v1| clockwise. | 2093 // Now rotate |v2| inside |v1| clockwise. |
2088 transform = v2->GetTransform(); | 2094 transform = v2->GetTransform(); |
2089 RotateClockwise(&transform); | 2095 RotateClockwise(&transform); |
2090 transform.SetTranslateX(100.0f); | 2096 transform.SetTranslateX(100.0f); |
2091 v2->SetTransform(transform); | 2097 v2->SetTransform(transform); |
2092 | 2098 |
2093 // Now, |v2| occupies (100, 100) to (200, 300) in |v1|, and (100, 300) to | 2099 // Now, |v2| occupies (100, 100) to (200, 300) in |v1|, and (100, 300) to |
2094 // (300, 400) in |root|. | 2100 // (300, 400) in |root|. |
2095 | 2101 |
2096 v1->Reset(); | 2102 v1->Reset(); |
2097 v2->Reset(); | 2103 v2->Reset(); |
2098 | 2104 |
2099 MouseEvent p2(ui::ET_MOUSE_PRESSED, | 2105 gfx::Point point2(110, 320); |
2100 110, 320, | 2106 ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2, |
2101 ui::EF_LEFT_MOUSE_BUTTON); | 2107 ui::EF_LEFT_MOUSE_BUTTON); |
2102 root->OnMousePressed(p2); | 2108 root->OnMousePressed(p2); |
2103 EXPECT_EQ(0, v1->last_mouse_event_type_); | 2109 EXPECT_EQ(0, v1->last_mouse_event_type_); |
2104 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); | 2110 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); |
2105 EXPECT_EQ(10, v2->location_.x()); | 2111 EXPECT_EQ(10, v2->location_.x()); |
2106 EXPECT_EQ(20, v2->location_.y()); | 2112 EXPECT_EQ(20, v2->location_.y()); |
2107 | 2113 |
2108 root->OnMouseReleased(released); | 2114 root->OnMouseReleased(released); |
2109 | 2115 |
2110 v1->SetTransform(ui::Transform()); | 2116 v1->SetTransform(ui::Transform()); |
2111 v2->SetTransform(ui::Transform()); | 2117 v2->SetTransform(ui::Transform()); |
(...skipping 12 matching lines...) Expand all Loading... |
2124 transform = v2->GetTransform(); | 2130 transform = v2->GetTransform(); |
2125 transform.SetScale(0.8f, 0.5f); | 2131 transform.SetScale(0.8f, 0.5f); |
2126 v2->SetTransform(transform); | 2132 v2->SetTransform(transform); |
2127 | 2133 |
2128 // |v3| occupies (108, 105) to (132, 115) in |root|. | 2134 // |v3| occupies (108, 105) to (132, 115) in |root|. |
2129 | 2135 |
2130 v1->Reset(); | 2136 v1->Reset(); |
2131 v2->Reset(); | 2137 v2->Reset(); |
2132 v3->Reset(); | 2138 v3->Reset(); |
2133 | 2139 |
2134 MouseEvent p3(ui::ET_MOUSE_PRESSED, | 2140 gfx::Point point(112, 110); |
2135 112, 110, | 2141 ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point, |
2136 ui::EF_LEFT_MOUSE_BUTTON); | 2142 ui::EF_LEFT_MOUSE_BUTTON); |
2137 root->OnMousePressed(p3); | 2143 root->OnMousePressed(p3); |
2138 | 2144 |
2139 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); | 2145 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); |
2140 EXPECT_EQ(10, v3->location_.x()); | 2146 EXPECT_EQ(10, v3->location_.x()); |
2141 EXPECT_EQ(25, v3->location_.y()); | 2147 EXPECT_EQ(25, v3->location_.y()); |
2142 | 2148 |
2143 root->OnMouseReleased(released); | 2149 root->OnMouseReleased(released); |
2144 | 2150 |
2145 v1->SetTransform(ui::Transform()); | 2151 v1->SetTransform(ui::Transform()); |
2146 v2->SetTransform(ui::Transform()); | 2152 v2->SetTransform(ui::Transform()); |
(...skipping 13 matching lines...) Expand all Loading... |
2160 transform.ConcatScale(0.8f, 0.5f); | 2166 transform.ConcatScale(0.8f, 0.5f); |
2161 v3->SetTransform(transform); | 2167 v3->SetTransform(transform); |
2162 | 2168 |
2163 // Translate |v2| with respect to |v1|. | 2169 // Translate |v2| with respect to |v1|. |
2164 transform = v2->GetTransform(); | 2170 transform = v2->GetTransform(); |
2165 transform.SetTranslate(10, 10); | 2171 transform.SetTranslate(10, 10); |
2166 v2->SetTransform(transform); | 2172 v2->SetTransform(transform); |
2167 | 2173 |
2168 // |v3| now occupies (120, 120) to (144, 130) in |root|. | 2174 // |v3| now occupies (120, 120) to (144, 130) in |root|. |
2169 | 2175 |
2170 MouseEvent p4(ui::ET_MOUSE_PRESSED, | 2176 gfx::Point point3(124, 125); |
2171 124, 125, | 2177 ui::MouseEvent p4(ui::ET_MOUSE_PRESSED, point3, point3, |
2172 ui::EF_LEFT_MOUSE_BUTTON); | 2178 ui::EF_LEFT_MOUSE_BUTTON); |
2173 root->OnMousePressed(p4); | 2179 root->OnMousePressed(p4); |
2174 | 2180 |
2175 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); | 2181 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); |
2176 EXPECT_EQ(10, v3->location_.x()); | 2182 EXPECT_EQ(10, v3->location_.x()); |
2177 EXPECT_EQ(25, v3->location_.y()); | 2183 EXPECT_EQ(25, v3->location_.y()); |
2178 | 2184 |
2179 root->OnMouseReleased(released); | 2185 root->OnMouseReleased(released); |
2180 | 2186 |
2181 widget->CloseNow(); | 2187 widget->CloseNow(); |
2182 } | 2188 } |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3361 // Set to non default value. | 3367 // Set to non default value. |
3362 v->layer()->set_scale_content(false); | 3368 v->layer()->set_scale_content(false); |
3363 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); | 3369 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); |
3364 ui::Layer* new_layer = v->layer(); | 3370 ui::Layer* new_layer = v->layer(); |
3365 EXPECT_FALSE(new_layer->scale_content()); | 3371 EXPECT_FALSE(new_layer->scale_content()); |
3366 } | 3372 } |
3367 | 3373 |
3368 #endif // USE_AURA | 3374 #endif // USE_AURA |
3369 | 3375 |
3370 } // namespace views | 3376 } // namespace views |
OLD | NEW |