| 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/controls/button/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/base/layout.h" | 8 #include "ui/base/layout.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 scoped_ptr<Widget> widget_; | 89 scoped_ptr<Widget> widget_; |
| 90 TestCustomButton* button_; | 90 TestCustomButton* button_; |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(CustomButtonTest); | 92 DISALLOW_COPY_AND_ASSIGN(CustomButtonTest); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 // Tests that hover state changes correctly when visiblity/enableness changes. | 97 // Tests that hover state changes correctly when visiblity/enableness changes. |
| 98 TEST_F(CustomButtonTest, HoverStateOnVisibilityChange) { | 98 TEST_F(CustomButtonTest, HoverStateOnVisibilityChange) { |
| 99 gfx::Point center(10, 10); | 99 gfx::PointF center(10.f, 10.f); |
| 100 button()->OnMousePressed(ui::MouseEvent( | 100 button()->OnMousePressed(ui::MouseEvent( |
| 101 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 101 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 102 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 102 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 103 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); | 103 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); |
| 104 | 104 |
| 105 button()->OnMouseReleased(ui::MouseEvent( | 105 button()->OnMouseReleased(ui::MouseEvent( |
| 106 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), | 106 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), |
| 107 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 107 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 108 EXPECT_EQ(CustomButton::STATE_HOVERED, button()->state()); | 108 EXPECT_EQ(CustomButton::STATE_HOVERED, button()->state()); |
| 109 | 109 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 138 button()->SetVisible(false); | 138 button()->SetVisible(false); |
| 139 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 139 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 140 | 140 |
| 141 button()->SetVisible(true); | 141 button()->SetVisible(true); |
| 142 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 142 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 143 #endif // !defined(OS_MACOSX) || defined(USE_AURA) | 143 #endif // !defined(OS_MACOSX) || defined(USE_AURA) |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Tests the different types of NotifyActions. | 146 // Tests the different types of NotifyActions. |
| 147 TEST_F(CustomButtonTest, NotifyAction) { | 147 TEST_F(CustomButtonTest, NotifyAction) { |
| 148 gfx::Point center(10, 10); | 148 gfx::PointF center(10.f, 10.f); |
| 149 | 149 |
| 150 // By default the button should notify its listener on mouse release. | 150 // By default the button should notify its listener on mouse release. |
| 151 button()->OnMousePressed(ui::MouseEvent( | 151 button()->OnMousePressed(ui::MouseEvent( |
| 152 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 152 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 153 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 153 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 154 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); | 154 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); |
| 155 EXPECT_FALSE(button()->notified()); | 155 EXPECT_FALSE(button()->notified()); |
| 156 | 156 |
| 157 button()->OnMouseReleased(ui::MouseEvent( | 157 button()->OnMouseReleased(ui::MouseEvent( |
| 158 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), | 158 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 EXPECT_FALSE(CustomButton::AsCustomButton(&label)); | 234 EXPECT_FALSE(CustomButton::AsCustomButton(&label)); |
| 235 | 235 |
| 236 Link link(text); | 236 Link link(text); |
| 237 EXPECT_FALSE(CustomButton::AsCustomButton(&link)); | 237 EXPECT_FALSE(CustomButton::AsCustomButton(&link)); |
| 238 | 238 |
| 239 Textfield textfield; | 239 Textfield textfield; |
| 240 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); | 240 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace views | 243 } // namespace views |
| OLD | NEW |