| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 public: | 96 public: |
| 97 CustomButtonTest() {} | 97 CustomButtonTest() {} |
| 98 ~CustomButtonTest() override {} | 98 ~CustomButtonTest() override {} |
| 99 | 99 |
| 100 void SetUp() override { | 100 void SetUp() override { |
| 101 ViewsTestBase::SetUp(); | 101 ViewsTestBase::SetUp(); |
| 102 | 102 |
| 103 // Create a widget so that the CustomButton can query the hover state | 103 // Create a widget so that the CustomButton can query the hover state |
| 104 // correctly. | 104 // correctly. |
| 105 widget_.reset(new Widget); | 105 widget_.reset(new Widget); |
| 106 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 106 Widget::InitParams params = |
| 107 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 107 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 108 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 108 params.bounds = gfx::Rect(0, 0, 650, 650); | 109 params.bounds = gfx::Rect(0, 0, 650, 650); |
| 109 widget_->Init(params); | 110 widget_->Init(params); |
| 110 widget_->Show(); | 111 widget_->Show(); |
| 111 | 112 |
| 112 button_ = new TestCustomButton(false); | 113 button_ = new TestCustomButton(false); |
| 113 widget_->SetContentsView(button_); | 114 widget_->SetContentsView(button_); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void TearDown() override { | 117 void TearDown() override { |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); | 586 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); |
| 586 EXPECT_FALSE(button()->pressed()); | 587 EXPECT_FALSE(button()->pressed()); |
| 587 | 588 |
| 588 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); | 589 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); |
| 589 SimulateKeyEvent(&space_release); | 590 SimulateKeyEvent(&space_release); |
| 590 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | 591 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); |
| 591 EXPECT_TRUE(button()->pressed()); | 592 EXPECT_TRUE(button()->pressed()); |
| 592 } | 593 } |
| 593 | 594 |
| 594 } // namespace views | 595 } // namespace views |
| OLD | NEW |