OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/animation/ink_drop_host_view.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/events/event.h" |
| 10 #include "ui/events/event_constants.h" |
| 11 #include "ui/events/event_utils.h" |
| 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" |
| 15 |
| 16 namespace views { |
| 17 namespace test { |
| 18 |
| 19 class InkDropHostViewTest : public testing::Test { |
| 20 public: |
| 21 InkDropHostViewTest(); |
| 22 ~InkDropHostViewTest() override; |
| 23 |
| 24 protected: |
| 25 // Test target. |
| 26 InkDropHostView host_view_; |
| 27 |
| 28 // Provides internal access to |host_view_| test target. |
| 29 InkDropHostViewTestApi test_api_; |
| 30 |
| 31 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(InkDropHostViewTest); |
| 33 }; |
| 34 |
| 35 InkDropHostViewTest::InkDropHostViewTest() : test_api_(&host_view_) {} |
| 36 |
| 37 InkDropHostViewTest::~InkDropHostViewTest() {} |
| 38 |
| 39 // Verifies the return value of GetInkDropCenterBasedOnLastEvent() for a null |
| 40 // Event. |
| 41 TEST_F(InkDropHostViewTest, GetInkDropCenterBasedOnLastEventForNullEvent) { |
| 42 host_view_.SetSize(gfx::Size(20, 20)); |
| 43 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, nullptr); |
| 44 EXPECT_EQ(gfx::Point(10, 10), test_api_.GetInkDropCenterBasedOnLastEvent()); |
| 45 } |
| 46 |
| 47 // Verifies the return value of GetInkDropCenterBasedOnLastEvent() for a located |
| 48 // Event. |
| 49 TEST_F(InkDropHostViewTest, GetInkDropCenterBasedOnLastEventForLocatedEvent) { |
| 50 host_view_.SetSize(gfx::Size(20, 20)); |
| 51 |
| 52 ui::MouseEvent located_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), |
| 53 gfx::Point(5, 6), ui::EventTimeForNow(), |
| 54 ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 55 |
| 56 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); |
| 57 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); |
| 58 } |
| 59 |
| 60 } // namespace test |
| 61 } // namespace views |
OLD | NEW |