| 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/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
| 10 #include "ui/views/controls/button/checkbox.h" | 10 #include "ui/views/controls/button/checkbox.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 widget->GetNativeView())->GetCursorScreenPoint(); | 73 widget->GetNativeView())->GetCursorScreenPoint(); |
| 74 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); | 74 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); |
| 75 widget_bounds.set_origin(cursor); | 75 widget_bounds.set_origin(cursor); |
| 76 widget->SetBounds(widget_bounds); | 76 widget->SetBounds(widget_bounds); |
| 77 | 77 |
| 78 TestCustomButton* button = new TestCustomButton(NULL); | 78 TestCustomButton* button = new TestCustomButton(NULL); |
| 79 widget->SetContentsView(button); | 79 widget->SetContentsView(button); |
| 80 | 80 |
| 81 gfx::Point center(10, 10); | 81 gfx::Point center(10, 10); |
| 82 button->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, | 82 button->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, |
| 83 ui::EF_LEFT_MOUSE_BUTTON, |
| 83 ui::EF_LEFT_MOUSE_BUTTON)); | 84 ui::EF_LEFT_MOUSE_BUTTON)); |
| 84 EXPECT_EQ(CustomButton::STATE_PRESSED, button->state()); | 85 EXPECT_EQ(CustomButton::STATE_PRESSED, button->state()); |
| 85 | 86 |
| 86 button->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, center, center, | 87 button->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, center, center, |
| 88 ui::EF_LEFT_MOUSE_BUTTON, |
| 87 ui::EF_LEFT_MOUSE_BUTTON)); | 89 ui::EF_LEFT_MOUSE_BUTTON)); |
| 88 EXPECT_EQ(CustomButton::STATE_HOVERED, button->state()); | 90 EXPECT_EQ(CustomButton::STATE_HOVERED, button->state()); |
| 89 | 91 |
| 90 button->SetEnabled(false); | 92 button->SetEnabled(false); |
| 91 EXPECT_EQ(CustomButton::STATE_DISABLED, button->state()); | 93 EXPECT_EQ(CustomButton::STATE_DISABLED, button->state()); |
| 92 | 94 |
| 93 button->SetEnabled(true); | 95 button->SetEnabled(true); |
| 94 EXPECT_EQ(CustomButton::STATE_HOVERED, button->state()); | 96 EXPECT_EQ(CustomButton::STATE_HOVERED, button->state()); |
| 95 | 97 |
| 96 button->SetVisible(false); | 98 button->SetVisible(false); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 EXPECT_FALSE(CustomButton::AsCustomButton(&label)); | 176 EXPECT_FALSE(CustomButton::AsCustomButton(&label)); |
| 175 | 177 |
| 176 Link link(text); | 178 Link link(text); |
| 177 EXPECT_FALSE(CustomButton::AsCustomButton(&link)); | 179 EXPECT_FALSE(CustomButton::AsCustomButton(&link)); |
| 178 | 180 |
| 179 Textfield textfield(Textfield::STYLE_DEFAULT); | 181 Textfield textfield(Textfield::STYLE_DEFAULT); |
| 180 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); | 182 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); |
| 181 } | 183 } |
| 182 | 184 |
| 183 } // namespace views | 185 } // namespace views |
| OLD | NEW |