| 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 "ui/views/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 internal::RootView* root = | 396 internal::RootView* root = |
| 397 static_cast<internal::RootView*>(widget->GetRootView()); | 397 static_cast<internal::RootView*>(widget->GetRootView()); |
| 398 | 398 |
| 399 root->AddChildView(v1); | 399 root->AddChildView(v1); |
| 400 v1->AddChildView(v2); | 400 v1->AddChildView(v2); |
| 401 | 401 |
| 402 v1->Reset(); | 402 v1->Reset(); |
| 403 v2->Reset(); | 403 v2->Reset(); |
| 404 | 404 |
| 405 gfx::Point p1(110, 120); | 405 gfx::Point p1(110, 120); |
| 406 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), | 406 ui::MouseEvent pressed( |
| 407 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 407 ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), |
| 408 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 409 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 408 root->OnMousePressed(pressed); | 410 root->OnMousePressed(pressed); |
| 409 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED); | 411 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED); |
| 410 EXPECT_EQ(v2->location_.x(), 10); | 412 EXPECT_EQ(v2->location_.x(), 10); |
| 411 EXPECT_EQ(v2->location_.y(), 20); | 413 EXPECT_EQ(v2->location_.y(), 20); |
| 412 // Make sure v1 did not receive the event | 414 // Make sure v1 did not receive the event |
| 413 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 415 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
| 414 | 416 |
| 415 // Drag event out of bounds. Should still go to v2 | 417 // Drag event out of bounds. Should still go to v2 |
| 416 v1->Reset(); | 418 v1->Reset(); |
| 417 v2->Reset(); | 419 v2->Reset(); |
| 418 gfx::Point p2(50, 40); | 420 gfx::Point p2(50, 40); |
| 419 ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, p2, p2, ui::EventTimeForNow(), | 421 ui::MouseEvent dragged( |
| 420 ui::EF_LEFT_MOUSE_BUTTON, 0); | 422 ui::ET_MOUSE_DRAGGED, p2, p2, ui::EventTimeForNow(), |
| 423 ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 424 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 421 root->OnMouseDragged(dragged); | 425 root->OnMouseDragged(dragged); |
| 422 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED); | 426 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED); |
| 423 EXPECT_EQ(v2->location_.x(), -50); | 427 EXPECT_EQ(v2->location_.x(), -50); |
| 424 EXPECT_EQ(v2->location_.y(), -60); | 428 EXPECT_EQ(v2->location_.y(), -60); |
| 425 // Make sure v1 did not receive the event | 429 // Make sure v1 did not receive the event |
| 426 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 430 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
| 427 | 431 |
| 428 // Releasted event out of bounds. Should still go to v2 | 432 // Releasted event out of bounds. Should still go to v2 |
| 429 v1->Reset(); | 433 v1->Reset(); |
| 430 v2->Reset(); | 434 v2->Reset(); |
| 431 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), | 435 ui::MouseEvent released( |
| 432 ui::EventTimeForNow(), 0, 0); | 436 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 437 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 433 root->OnMouseDragged(released); | 438 root->OnMouseDragged(released); |
| 434 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED); | 439 EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED); |
| 435 EXPECT_EQ(v2->location_.x(), -100); | 440 EXPECT_EQ(v2->location_.x(), -100); |
| 436 EXPECT_EQ(v2->location_.y(), -100); | 441 EXPECT_EQ(v2->location_.y(), -100); |
| 437 // Make sure v1 did not receive the event | 442 // Make sure v1 did not receive the event |
| 438 EXPECT_EQ(v1->last_mouse_event_type_, 0); | 443 EXPECT_EQ(v1->last_mouse_event_type_, 0); |
| 439 | 444 |
| 440 widget->CloseNow(); | 445 widget->CloseNow(); |
| 441 } | 446 } |
| 442 | 447 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 456 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 461 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 457 params.bounds = gfx::Rect(50, 50, 650, 650); | 462 params.bounds = gfx::Rect(50, 50, 650, 650); |
| 458 widget->Init(params); | 463 widget->Init(params); |
| 459 View* root = widget->GetRootView(); | 464 View* root = widget->GetRootView(); |
| 460 | 465 |
| 461 root->AddChildView(v1); | 466 root->AddChildView(v1); |
| 462 v1->AddChildView(v2); | 467 v1->AddChildView(v2); |
| 463 | 468 |
| 464 v2->delete_on_pressed_ = true; | 469 v2->delete_on_pressed_ = true; |
| 465 gfx::Point point(110, 120); | 470 gfx::Point point(110, 120); |
| 466 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, | 471 ui::MouseEvent pressed( |
| 467 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 472 ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), |
| 468 ui::EF_LEFT_MOUSE_BUTTON); | 473 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 474 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 469 root->OnMousePressed(pressed); | 475 root->OnMousePressed(pressed); |
| 470 EXPECT_EQ(0, v1->child_count()); | 476 EXPECT_EQ(0, v1->child_count()); |
| 471 | 477 |
| 472 widget->CloseNow(); | 478 widget->CloseNow(); |
| 473 } | 479 } |
| 474 | 480 |
| 475 //////////////////////////////////////////////////////////////////////////////// | 481 //////////////////////////////////////////////////////////////////////////////// |
| 476 // Painting | 482 // Painting |
| 477 //////////////////////////////////////////////////////////////////////////////// | 483 //////////////////////////////////////////////////////////////////////////////// |
| 478 | 484 |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 v1->Reset(); | 1866 v1->Reset(); |
| 1861 v11->Reset(); | 1867 v11->Reset(); |
| 1862 v111->Reset(); | 1868 v111->Reset(); |
| 1863 v12->Reset(); | 1869 v12->Reset(); |
| 1864 v121->Reset(); | 1870 v121->Reset(); |
| 1865 v2->Reset(); | 1871 v2->Reset(); |
| 1866 v21->Reset(); | 1872 v21->Reset(); |
| 1867 | 1873 |
| 1868 // Move the mouse in v111. | 1874 // Move the mouse in v111. |
| 1869 gfx::Point p1(6, 6); | 1875 gfx::Point p1(6, 6); |
| 1870 ui::MouseEvent move1(ui::ET_MOUSE_MOVED, p1, p1, ui::EventTimeForNow(), 0, 0); | 1876 ui::MouseEvent move1( |
| 1877 ui::ET_MOUSE_MOVED, p1, p1, ui::EventTimeForNow(), 0, 0, |
| 1878 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1871 root_view->OnMouseMoved(move1); | 1879 root_view->OnMouseMoved(move1); |
| 1872 EXPECT_TRUE(v111->received_mouse_enter_); | 1880 EXPECT_TRUE(v111->received_mouse_enter_); |
| 1873 EXPECT_FALSE(v11->last_mouse_event_type_); | 1881 EXPECT_FALSE(v11->last_mouse_event_type_); |
| 1874 EXPECT_TRUE(v1->received_mouse_enter_); | 1882 EXPECT_TRUE(v1->received_mouse_enter_); |
| 1875 | 1883 |
| 1876 v111->Reset(); | 1884 v111->Reset(); |
| 1877 v1->Reset(); | 1885 v1->Reset(); |
| 1878 | 1886 |
| 1879 // Now, move into v121. | 1887 // Now, move into v121. |
| 1880 gfx::Point p2(65, 21); | 1888 gfx::Point p2(65, 21); |
| 1881 ui::MouseEvent move2(ui::ET_MOUSE_MOVED, p2, p2, ui::EventTimeForNow(), 0, 0); | 1889 ui::MouseEvent move2( |
| 1890 ui::ET_MOUSE_MOVED, p2, p2, ui::EventTimeForNow(), 0, 0, |
| 1891 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1882 root_view->OnMouseMoved(move2); | 1892 root_view->OnMouseMoved(move2); |
| 1883 EXPECT_TRUE(v111->received_mouse_exit_); | 1893 EXPECT_TRUE(v111->received_mouse_exit_); |
| 1884 EXPECT_TRUE(v121->received_mouse_enter_); | 1894 EXPECT_TRUE(v121->received_mouse_enter_); |
| 1885 EXPECT_FALSE(v1->last_mouse_event_type_); | 1895 EXPECT_FALSE(v1->last_mouse_event_type_); |
| 1886 | 1896 |
| 1887 v111->Reset(); | 1897 v111->Reset(); |
| 1888 v121->Reset(); | 1898 v121->Reset(); |
| 1889 | 1899 |
| 1890 // Now, move into v11. | 1900 // Now, move into v11. |
| 1891 gfx::Point p3(1, 1); | 1901 gfx::Point p3(1, 1); |
| 1892 ui::MouseEvent move3(ui::ET_MOUSE_MOVED, p3, p3, ui::EventTimeForNow(), 0, 0); | 1902 ui::MouseEvent move3( |
| 1903 ui::ET_MOUSE_MOVED, p3, p3, ui::EventTimeForNow(), 0, 0, |
| 1904 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1893 root_view->OnMouseMoved(move3); | 1905 root_view->OnMouseMoved(move3); |
| 1894 EXPECT_TRUE(v121->received_mouse_exit_); | 1906 EXPECT_TRUE(v121->received_mouse_exit_); |
| 1895 EXPECT_TRUE(v11->received_mouse_enter_); | 1907 EXPECT_TRUE(v11->received_mouse_enter_); |
| 1896 EXPECT_FALSE(v1->last_mouse_event_type_); | 1908 EXPECT_FALSE(v1->last_mouse_event_type_); |
| 1897 | 1909 |
| 1898 v121->Reset(); | 1910 v121->Reset(); |
| 1899 v11->Reset(); | 1911 v11->Reset(); |
| 1900 | 1912 |
| 1901 // Move to v21. | 1913 // Move to v21. |
| 1902 gfx::Point p4(121, 15); | 1914 gfx::Point p4(121, 15); |
| 1903 ui::MouseEvent move4(ui::ET_MOUSE_MOVED, p4, p4, ui::EventTimeForNow(), 0, 0); | 1915 ui::MouseEvent move4( |
| 1916 ui::ET_MOUSE_MOVED, p4, p4, ui::EventTimeForNow(), 0, 0, |
| 1917 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1904 root_view->OnMouseMoved(move4); | 1918 root_view->OnMouseMoved(move4); |
| 1905 EXPECT_TRUE(v21->received_mouse_enter_); | 1919 EXPECT_TRUE(v21->received_mouse_enter_); |
| 1906 EXPECT_FALSE(v2->last_mouse_event_type_); | 1920 EXPECT_FALSE(v2->last_mouse_event_type_); |
| 1907 EXPECT_TRUE(v11->received_mouse_exit_); | 1921 EXPECT_TRUE(v11->received_mouse_exit_); |
| 1908 EXPECT_TRUE(v1->received_mouse_exit_); | 1922 EXPECT_TRUE(v1->received_mouse_exit_); |
| 1909 | 1923 |
| 1910 v21->Reset(); | 1924 v21->Reset(); |
| 1911 v11->Reset(); | 1925 v11->Reset(); |
| 1912 v1->Reset(); | 1926 v1->Reset(); |
| 1913 | 1927 |
| 1914 // Move to v1. | 1928 // Move to v1. |
| 1915 gfx::Point p5(21, 0); | 1929 gfx::Point p5(21, 0); |
| 1916 ui::MouseEvent move5(ui::ET_MOUSE_MOVED, p5, p5, ui::EventTimeForNow(), 0, 0); | 1930 ui::MouseEvent move5( |
| 1931 ui::ET_MOUSE_MOVED, p5, p5, ui::EventTimeForNow(), 0, 0, |
| 1932 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1917 root_view->OnMouseMoved(move5); | 1933 root_view->OnMouseMoved(move5); |
| 1918 EXPECT_TRUE(v21->received_mouse_exit_); | 1934 EXPECT_TRUE(v21->received_mouse_exit_); |
| 1919 EXPECT_TRUE(v1->received_mouse_enter_); | 1935 EXPECT_TRUE(v1->received_mouse_enter_); |
| 1920 | 1936 |
| 1921 v21->Reset(); | 1937 v21->Reset(); |
| 1922 v1->Reset(); | 1938 v1->Reset(); |
| 1923 | 1939 |
| 1924 // Now, move into v11. | 1940 // Now, move into v11. |
| 1925 gfx::Point p6(15, 15); | 1941 gfx::Point p6(15, 15); |
| 1926 ui::MouseEvent mouse6(ui::ET_MOUSE_MOVED, p6, p6, ui::EventTimeForNow(), 0, | 1942 ui::MouseEvent mouse6( |
| 1927 0); | 1943 ui::ET_MOUSE_MOVED, p6, p6, ui::EventTimeForNow(), 0, 0, |
| 1944 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1928 root_view->OnMouseMoved(mouse6); | 1945 root_view->OnMouseMoved(mouse6); |
| 1929 EXPECT_TRUE(v11->received_mouse_enter_); | 1946 EXPECT_TRUE(v11->received_mouse_enter_); |
| 1930 EXPECT_FALSE(v1->last_mouse_event_type_); | 1947 EXPECT_FALSE(v1->last_mouse_event_type_); |
| 1931 | 1948 |
| 1932 v11->Reset(); | 1949 v11->Reset(); |
| 1933 v1->Reset(); | 1950 v1->Reset(); |
| 1934 | 1951 |
| 1935 // Move back into v1. Although |v1| had already received an ENTER for mouse6, | 1952 // Move back into v1. Although |v1| had already received an ENTER for mouse6, |
| 1936 // and the mouse remains inside |v1| the whole time, it receives another ENTER | 1953 // and the mouse remains inside |v1| the whole time, it receives another ENTER |
| 1937 // when the mouse leaves v11. | 1954 // when the mouse leaves v11. |
| 1938 gfx::Point p7(21, 0); | 1955 gfx::Point p7(21, 0); |
| 1939 ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, ui::EventTimeForNow(), 0, | 1956 ui::MouseEvent mouse7( |
| 1940 0); | 1957 ui::ET_MOUSE_MOVED, p7, p7, ui::EventTimeForNow(), 0, 0, |
| 1958 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 1941 root_view->OnMouseMoved(mouse7); | 1959 root_view->OnMouseMoved(mouse7); |
| 1942 EXPECT_TRUE(v11->received_mouse_exit_); | 1960 EXPECT_TRUE(v11->received_mouse_exit_); |
| 1943 EXPECT_FALSE(v1->received_mouse_enter_); | 1961 EXPECT_FALSE(v1->received_mouse_enter_); |
| 1944 | 1962 |
| 1945 widget->CloseNow(); | 1963 widget->CloseNow(); |
| 1946 } | 1964 } |
| 1947 | 1965 |
| 1948 TEST_F(ViewTest, Textfield) { | 1966 TEST_F(ViewTest, Textfield) { |
| 1949 const base::string16 kText = ASCIIToUTF16( | 1967 const base::string16 kText = ASCIIToUTF16( |
| 1950 "Reality is that which, when you stop believing it, doesn't go away."); | 1968 "Reality is that which, when you stop believing it, doesn't go away."); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 gfx::Transform transform(v1->GetTransform()); | 2594 gfx::Transform transform(v1->GetTransform()); |
| 2577 RotateCounterclockwise(&transform); | 2595 RotateCounterclockwise(&transform); |
| 2578 transform.matrix().set(1, 3, 500.0); | 2596 transform.matrix().set(1, 3, 500.0); |
| 2579 v1->SetTransform(transform); | 2597 v1->SetTransform(transform); |
| 2580 | 2598 |
| 2581 // |v2| now occupies (100, 200) to (200, 400) in |root|. | 2599 // |v2| now occupies (100, 200) to (200, 400) in |root|. |
| 2582 v1->Reset(); | 2600 v1->Reset(); |
| 2583 v2->Reset(); | 2601 v2->Reset(); |
| 2584 | 2602 |
| 2585 gfx::Point p1(110, 210); | 2603 gfx::Point p1(110, 210); |
| 2586 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), | 2604 ui::MouseEvent pressed( |
| 2587 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 2605 ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(), |
| 2606 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 2607 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 2588 root->OnMousePressed(pressed); | 2608 root->OnMousePressed(pressed); |
| 2589 EXPECT_EQ(0, v1->last_mouse_event_type_); | 2609 EXPECT_EQ(0, v1->last_mouse_event_type_); |
| 2590 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); | 2610 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); |
| 2591 EXPECT_EQ(190, v2->location_.x()); | 2611 EXPECT_EQ(190, v2->location_.x()); |
| 2592 EXPECT_EQ(10, v2->location_.y()); | 2612 EXPECT_EQ(10, v2->location_.y()); |
| 2593 | 2613 |
| 2594 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), | 2614 ui::MouseEvent released( |
| 2595 ui::EventTimeForNow(), 0, 0); | 2615 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 2616 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 2596 root->OnMouseReleased(released); | 2617 root->OnMouseReleased(released); |
| 2597 | 2618 |
| 2598 // Now rotate |v2| inside |v1| clockwise. | 2619 // Now rotate |v2| inside |v1| clockwise. |
| 2599 transform = v2->GetTransform(); | 2620 transform = v2->GetTransform(); |
| 2600 RotateClockwise(&transform); | 2621 RotateClockwise(&transform); |
| 2601 transform.matrix().set(0, 3, 100.f); | 2622 transform.matrix().set(0, 3, 100.f); |
| 2602 v2->SetTransform(transform); | 2623 v2->SetTransform(transform); |
| 2603 | 2624 |
| 2604 // Now, |v2| occupies (100, 100) to (200, 300) in |v1|, and (100, 300) to | 2625 // Now, |v2| occupies (100, 100) to (200, 300) in |v1|, and (100, 300) to |
| 2605 // (300, 400) in |root|. | 2626 // (300, 400) in |root|. |
| 2606 | 2627 |
| 2607 v1->Reset(); | 2628 v1->Reset(); |
| 2608 v2->Reset(); | 2629 v2->Reset(); |
| 2609 | 2630 |
| 2610 gfx::Point point2(110, 320); | 2631 gfx::Point point2(110, 320); |
| 2611 ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2, ui::EventTimeForNow(), | 2632 ui::MouseEvent p2( |
| 2612 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 2633 ui::ET_MOUSE_PRESSED, point2, point2, ui::EventTimeForNow(), |
| 2634 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 2635 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 2613 root->OnMousePressed(p2); | 2636 root->OnMousePressed(p2); |
| 2614 EXPECT_EQ(0, v1->last_mouse_event_type_); | 2637 EXPECT_EQ(0, v1->last_mouse_event_type_); |
| 2615 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); | 2638 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); |
| 2616 EXPECT_EQ(10, v2->location_.x()); | 2639 EXPECT_EQ(10, v2->location_.x()); |
| 2617 EXPECT_EQ(20, v2->location_.y()); | 2640 EXPECT_EQ(20, v2->location_.y()); |
| 2618 | 2641 |
| 2619 root->OnMouseReleased(released); | 2642 root->OnMouseReleased(released); |
| 2620 | 2643 |
| 2621 v1->SetTransform(gfx::Transform()); | 2644 v1->SetTransform(gfx::Transform()); |
| 2622 v2->SetTransform(gfx::Transform()); | 2645 v2->SetTransform(gfx::Transform()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2637 transform.matrix().set(1, 1, 0.5f); | 2660 transform.matrix().set(1, 1, 0.5f); |
| 2638 v2->SetTransform(transform); | 2661 v2->SetTransform(transform); |
| 2639 | 2662 |
| 2640 // |v3| occupies (108, 105) to (132, 115) in |root|. | 2663 // |v3| occupies (108, 105) to (132, 115) in |root|. |
| 2641 | 2664 |
| 2642 v1->Reset(); | 2665 v1->Reset(); |
| 2643 v2->Reset(); | 2666 v2->Reset(); |
| 2644 v3->Reset(); | 2667 v3->Reset(); |
| 2645 | 2668 |
| 2646 gfx::Point point(112, 110); | 2669 gfx::Point point(112, 110); |
| 2647 ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), | 2670 ui::MouseEvent p3( |
| 2648 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 2671 ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), |
| 2672 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 2673 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 2649 root->OnMousePressed(p3); | 2674 root->OnMousePressed(p3); |
| 2650 | 2675 |
| 2651 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); | 2676 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); |
| 2652 EXPECT_EQ(10, v3->location_.x()); | 2677 EXPECT_EQ(10, v3->location_.x()); |
| 2653 EXPECT_EQ(25, v3->location_.y()); | 2678 EXPECT_EQ(25, v3->location_.y()); |
| 2654 | 2679 |
| 2655 root->OnMouseReleased(released); | 2680 root->OnMouseReleased(released); |
| 2656 | 2681 |
| 2657 v1->SetTransform(gfx::Transform()); | 2682 v1->SetTransform(gfx::Transform()); |
| 2658 v2->SetTransform(gfx::Transform()); | 2683 v2->SetTransform(gfx::Transform()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2676 | 2701 |
| 2677 // Translate |v2| with respect to |v1|. | 2702 // Translate |v2| with respect to |v1|. |
| 2678 transform = v2->GetTransform(); | 2703 transform = v2->GetTransform(); |
| 2679 transform.matrix().set(0, 3, 10.f); | 2704 transform.matrix().set(0, 3, 10.f); |
| 2680 transform.matrix().set(1, 3, 10.f); | 2705 transform.matrix().set(1, 3, 10.f); |
| 2681 v2->SetTransform(transform); | 2706 v2->SetTransform(transform); |
| 2682 | 2707 |
| 2683 // |v3| now occupies (120, 120) to (144, 130) in |root|. | 2708 // |v3| now occupies (120, 120) to (144, 130) in |root|. |
| 2684 | 2709 |
| 2685 gfx::Point point3(124, 125); | 2710 gfx::Point point3(124, 125); |
| 2686 ui::MouseEvent p4(ui::ET_MOUSE_PRESSED, point3, point3, ui::EventTimeForNow(), | 2711 ui::MouseEvent p4( |
| 2687 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 2712 ui::ET_MOUSE_PRESSED, point3, point3, ui::EventTimeForNow(), |
| 2713 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 2714 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 2688 root->OnMousePressed(p4); | 2715 root->OnMousePressed(p4); |
| 2689 | 2716 |
| 2690 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); | 2717 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); |
| 2691 EXPECT_EQ(10, v3->location_.x()); | 2718 EXPECT_EQ(10, v3->location_.x()); |
| 2692 EXPECT_EQ(25, v3->location_.y()); | 2719 EXPECT_EQ(25, v3->location_.y()); |
| 2693 | 2720 |
| 2694 root->OnMouseReleased(released); | 2721 root->OnMouseReleased(released); |
| 2695 | 2722 |
| 2696 widget->CloseNow(); | 2723 widget->CloseNow(); |
| 2697 } | 2724 } |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4620 v->Reset(); | 4647 v->Reset(); |
| 4621 { | 4648 { |
| 4622 TestEventHandler handler(v); | 4649 TestEventHandler handler(v); |
| 4623 ui::ScopedTargetHandler scoped_target_handler(v, &handler); | 4650 ui::ScopedTargetHandler scoped_target_handler(v, &handler); |
| 4624 // View's target EventHandler should be set to the |scoped_target_handler|. | 4651 // View's target EventHandler should be set to the |scoped_target_handler|. |
| 4625 EXPECT_EQ(&scoped_target_handler, | 4652 EXPECT_EQ(&scoped_target_handler, |
| 4626 v->SetTargetHandler(&scoped_target_handler)); | 4653 v->SetTargetHandler(&scoped_target_handler)); |
| 4627 | 4654 |
| 4628 EXPECT_EQ(ui::ET_UNKNOWN, v->last_mouse_event_type_); | 4655 EXPECT_EQ(ui::ET_UNKNOWN, v->last_mouse_event_type_); |
| 4629 gfx::Point p(10, 120); | 4656 gfx::Point p(10, 120); |
| 4630 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p, p, ui::EventTimeForNow(), | 4657 ui::MouseEvent pressed( |
| 4631 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 4658 ui::ET_MOUSE_PRESSED, p, p, ui::EventTimeForNow(), |
| 4659 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON, |
| 4660 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 4632 root->OnMousePressed(pressed); | 4661 root->OnMousePressed(pressed); |
| 4633 | 4662 |
| 4634 // Both the View |v| and the |handler| should have received the event. | 4663 // Both the View |v| and the |handler| should have received the event. |
| 4635 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v->last_mouse_event_type_); | 4664 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v->last_mouse_event_type_); |
| 4636 EXPECT_TRUE(handler.had_mouse_event_); | 4665 EXPECT_TRUE(handler.had_mouse_event_); |
| 4637 } | 4666 } |
| 4638 | 4667 |
| 4639 // The View should continue receiving events after the |handler| is deleted. | 4668 // The View should continue receiving events after the |handler| is deleted. |
| 4640 v->Reset(); | 4669 v->Reset(); |
| 4641 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), | 4670 ui::MouseEvent released( |
| 4642 ui::EventTimeForNow(), 0, 0); | 4671 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 4672 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 4643 root->OnMouseReleased(released); | 4673 root->OnMouseReleased(released); |
| 4644 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_); | 4674 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_); |
| 4645 } | 4675 } |
| 4646 | 4676 |
| 4647 // See comment above test for details. | 4677 // See comment above test for details. |
| 4648 class WidgetWithCustomTheme : public Widget { | 4678 class WidgetWithCustomTheme : public Widget { |
| 4649 public: | 4679 public: |
| 4650 explicit WidgetWithCustomTheme(ui::NativeTheme* theme) : theme_(theme) {} | 4680 explicit WidgetWithCustomTheme(ui::NativeTheme* theme) : theme_(theme) {} |
| 4651 ~WidgetWithCustomTheme() override {} | 4681 ~WidgetWithCustomTheme() override {} |
| 4652 | 4682 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5017 std::unique_ptr<View> view = NewView(); | 5047 std::unique_ptr<View> view = NewView(); |
| 5018 std::unique_ptr<View> child_view = NewView(); | 5048 std::unique_ptr<View> child_view = NewView(); |
| 5019 std::unique_ptr<View> child_view2 = NewView(); | 5049 std::unique_ptr<View> child_view2 = NewView(); |
| 5020 view->AddChildView(child_view.get()); | 5050 view->AddChildView(child_view.get()); |
| 5021 view->AddChildView(child_view2.get()); | 5051 view->AddChildView(child_view2.get()); |
| 5022 view->ReorderChildView(child_view2.get(), 0); | 5052 view->ReorderChildView(child_view2.get(), 0); |
| 5023 EXPECT_EQ(child_view2.get(), view_reordered()); | 5053 EXPECT_EQ(child_view2.get(), view_reordered()); |
| 5024 } | 5054 } |
| 5025 | 5055 |
| 5026 } // namespace views | 5056 } // namespace views |
| OLD | NEW |