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/label.h" | 5 #include "ui/views/controls/label.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 EXPECT_LT(label()->font_list().GetHeight(), focus_bounds.height()); | 813 EXPECT_LT(label()->font_list().GetHeight(), focus_bounds.height()); |
814 } | 814 } |
815 | 815 |
816 TEST_F(LabelSelectionTest, Selectable) { | 816 TEST_F(LabelSelectionTest, Selectable) { |
817 // By default, labels don't support text selection. | 817 // By default, labels don't support text selection. |
818 EXPECT_FALSE(label()->selectable()); | 818 EXPECT_FALSE(label()->selectable()); |
819 | 819 |
820 ASSERT_TRUE(label()->SetSelectable(true)); | 820 ASSERT_TRUE(label()->SetSelectable(true)); |
821 EXPECT_TRUE(label()->selectable()); | 821 EXPECT_TRUE(label()->selectable()); |
822 | 822 |
823 // Verify that making a label multiline causes the label to not support text | 823 // Verify that making a label multiline still causes the label to support text |
824 // selection. | 824 // selection. |
825 label()->SetMultiLine(true); | 825 label()->SetMultiLine(true); |
826 EXPECT_FALSE(label()->selectable()); | |
827 | |
828 label()->SetMultiLine(false); | |
829 ASSERT_TRUE(label()->SetSelectable(true)); | |
830 EXPECT_TRUE(label()->selectable()); | 826 EXPECT_TRUE(label()->selectable()); |
831 | 827 |
832 // Verify that obscuring the label text causes the label to not support text | 828 // Verify that obscuring the label text causes the label to not support text |
833 // selection. | 829 // selection. |
834 label()->SetObscured(true); | 830 label()->SetObscured(true); |
835 EXPECT_FALSE(label()->selectable()); | 831 EXPECT_FALSE(label()->selectable()); |
836 } | 832 } |
837 | 833 |
838 // Verify that labels supporting text selection get focus on clicks. | 834 // Verify that labels supporting text selection get focus on clicks. |
839 TEST_F(LabelSelectionTest, FocusOnClick) { | 835 TEST_F(LabelSelectionTest, FocusOnClick) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 label()->SetObscured(false); | 1030 label()->SetObscured(false); |
1035 | 1031 |
1036 // For an empty label, both COPY and SELECT_ALL should be disabled. | 1032 // For an empty label, both COPY and SELECT_ALL should be disabled. |
1037 label()->SetText(base::string16()); | 1033 label()->SetText(base::string16()); |
1038 ASSERT_TRUE(label()->SetSelectable(true)); | 1034 ASSERT_TRUE(label()->SetSelectable(true)); |
1039 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY)); | 1035 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY)); |
1040 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL)); | 1036 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL)); |
1041 } | 1037 } |
1042 | 1038 |
1043 } // namespace views | 1039 } // namespace views |
OLD | NEW |