Chromium Code Reviews| 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/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 // Make a Widget to host the button. This ensures appropriate borders are | 74 // Make a Widget to host the button. This ensures appropriate borders are |
| 75 // used (which could be derived from the Widget's NativeTheme). | 75 // used (which could be derived from the Widget's NativeTheme). |
| 76 test_widget_ = CreateTopLevelPlatformWidget(); | 76 test_widget_ = CreateTopLevelPlatformWidget(); |
| 77 | 77 |
| 78 button_ = new TestLabelButton; | 78 button_ = new TestLabelButton; |
| 79 test_widget_->GetContentsView()->AddChildView(button_); | 79 test_widget_->GetContentsView()->AddChildView(button_); |
| 80 | 80 |
| 81 // Establish the expected text colors for testing changes due to state. | 81 // Establish the expected text colors for testing changes due to state. |
| 82 themed_normal_text_color_ = button_->GetNativeTheme()->GetSystemColor( | 82 themed_normal_text_color_ = button_->GetNativeTheme()->GetSystemColor( |
| 83 ui::NativeTheme::kColorId_LabelEnabledColor); | 83 ui::NativeTheme::kColorId_LabelEnabledColor); |
| 84 | |
| 85 // For styled buttons only, platforms other than Desktop Linux either ignore | |
| 86 // NativeTheme and use a hardcoded black or (on Mac) have a NativeTheme that | |
| 87 // reliably returns black. | |
| 88 styled_normal_text_color_ = SK_ColorBLACK; | |
| 84 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 89 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 85 // The Linux theme provides a non-black highlight text color, but it's not | 90 // The Linux theme provides a non-black highlight text color, but it's not |
| 86 // used for styled buttons. | 91 // used for styled buttons. |
| 87 styled_highlight_text_color_ = styled_normal_text_color_ = | 92 styled_highlight_text_color_ = styled_normal_text_color_ = |
|
tdanderson
2016/09/30 21:00:56
Can you break up the multiple assignment into two
Evan Stade
2016/09/30 22:19:00
is that a style rule? If not it seems like somethi
tdanderson
2016/09/30 22:39:37
I thought it was, but can't find it in the style g
| |
| 88 button_->GetNativeTheme()->GetSystemColor( | 93 button_->GetNativeTheme()->GetSystemColor( |
| 89 ui::NativeTheme::kColorId_ButtonEnabledColor); | 94 ui::NativeTheme::kColorId_ButtonEnabledColor); |
| 95 #elif defined(OS_MACOSX) | |
| 96 styled_highlight_text_color_ = SK_ColorWHITE; | |
| 90 #else | 97 #else |
| 91 styled_highlight_text_color_ = button_->GetNativeTheme()->GetSystemColor( | 98 styled_highlight_text_color_ = styled_normal_text_color_; |
| 92 ui::NativeTheme::kColorId_ButtonHighlightColor); | |
| 93 | |
| 94 // For styled buttons only, platforms other than Desktop Linux either ignore | |
| 95 // NativeTheme and use a hardcoded black or (on Mac) have a NativeTheme that | |
| 96 // reliably returns black. | |
| 97 styled_normal_text_color_ = SK_ColorBLACK; | |
| 98 #endif | 99 #endif |
| 99 } | 100 } |
| 100 | 101 |
| 101 void TearDown() override { | 102 void TearDown() override { |
| 102 test_widget_->CloseNow(); | 103 test_widget_->CloseNow(); |
| 103 WidgetTest::TearDown(); | 104 WidgetTest::TearDown(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 protected: | 107 protected: |
| 107 TestLabelButton* button_ = nullptr; | 108 TestLabelButton* button_ = nullptr; |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 | 503 |
| 503 // Verifies the target event handler View is the |LabelButton| and not any of | 504 // Verifies the target event handler View is the |LabelButton| and not any of |
| 504 // the child Views. | 505 // the child Views. |
| 505 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { | 506 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { |
| 506 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( | 507 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( |
| 507 button_->bounds().CenterPoint()); | 508 button_->bounds().CenterPoint()); |
| 508 EXPECT_EQ(button_, target_view); | 509 EXPECT_EQ(button_, target_view); |
| 509 } | 510 } |
| 510 | 511 |
| 511 } // namespace views | 512 } // namespace views |
| OLD | NEW |