OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/accessibility/accessibility_events.h" | 5 #include "chrome/browser/accessibility/accessibility_events.h" |
6 #include "chrome/browser/chromeos/login/wizard_accessibility_handler.h" | 6 #include "chrome/browser/chromeos/login/wizard_accessibility_handler.h" |
7 #include "chrome/common/chrome_notification_types.h" | 7 #include "chrome/common/chrome_notification_types.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using chromeos::EarconType; | 10 using chromeos::EarconType; |
(...skipping 26 matching lines...) Expand all Loading... |
37 EarconType earcon; | 37 EarconType earcon; |
38 | 38 |
39 // No need to test every possible control, but test several types | 39 // No need to test every possible control, but test several types |
40 // to exercise different types of string concatenation. | 40 // to exercise different types of string concatenation. |
41 | 41 |
42 // NOTE: unittests are forced to run under the en-US locale, so it's | 42 // NOTE: unittests are forced to run under the en-US locale, so it's |
43 // safe to do these string comparisons without using l10n_util. | 43 // safe to do these string comparisons without using l10n_util. |
44 | 44 |
45 // Test a simple control. | 45 // Test a simple control. |
46 std::string button_name = "Save"; | 46 std::string button_name = "Save"; |
47 AccessibilityButtonInfo button_info(NULL, button_name); | 47 AccessibilityButtonInfo button_info(NULL, button_name, ""); |
48 handler.DescribeAccessibilityEvent( | 48 handler.DescribeAccessibilityEvent( |
49 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, | 49 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
50 &button_info, | 50 &button_info, |
51 &description, | 51 &description, |
52 &earcon); | 52 &earcon); |
53 EXPECT_EQ(chromeos::EARCON_BUTTON, earcon); | 53 EXPECT_EQ(chromeos::EARCON_BUTTON, earcon); |
54 EXPECT_EQ("Save Button", description); | 54 EXPECT_EQ("Save Button", description); |
55 | 55 |
56 // Test a control with multiple states. | 56 // Test a control with multiple states. |
57 std::string checkbox_name = "Accessibility"; | 57 std::string checkbox_name = "Accessibility"; |
58 AccessibilityCheckboxInfo checkbox_info(NULL, checkbox_name, false); | 58 AccessibilityCheckboxInfo checkbox_info(NULL, checkbox_name, "", false); |
59 handler.DescribeAccessibilityEvent( | 59 handler.DescribeAccessibilityEvent( |
60 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, | 60 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
61 &checkbox_info, | 61 &checkbox_info, |
62 &description, | 62 &description, |
63 &earcon); | 63 &earcon); |
64 EXPECT_EQ(chromeos::EARCON_CHECK_OFF, earcon); | 64 EXPECT_EQ(chromeos::EARCON_CHECK_OFF, earcon); |
65 EXPECT_EQ("Accessibility Unchecked check box", description); | 65 EXPECT_EQ("Accessibility Unchecked check box", description); |
66 checkbox_info.SetChecked(true); | 66 checkbox_info.SetChecked(true); |
67 handler.DescribeAccessibilityEvent( | 67 handler.DescribeAccessibilityEvent( |
68 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, | 68 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
69 &checkbox_info, | 69 &checkbox_info, |
70 &description, | 70 &description, |
71 &earcon); | 71 &earcon); |
72 EXPECT_EQ(chromeos::EARCON_CHECK_ON, earcon); | 72 EXPECT_EQ(chromeos::EARCON_CHECK_ON, earcon); |
73 EXPECT_EQ("Accessibility Checked check box", description); | 73 EXPECT_EQ("Accessibility Checked check box", description); |
74 | 74 |
75 // Test a control with a value and index. | 75 // Test a control with a value and index. |
76 std::string combobox_name = "Language"; | 76 std::string combobox_name = "Language"; |
77 std::string combobox_value = "English"; | 77 std::string combobox_value = "English"; |
78 AccessibilityComboBoxInfo combobox_info( | 78 AccessibilityComboBoxInfo combobox_info( |
79 NULL, combobox_name, combobox_value, 12, 35); | 79 NULL, combobox_name, "", combobox_value, 12, 35); |
80 handler.DescribeAccessibilityEvent( | 80 handler.DescribeAccessibilityEvent( |
81 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, | 81 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
82 &combobox_info, | 82 &combobox_info, |
83 &description, | 83 &description, |
84 &earcon); | 84 &earcon); |
85 EXPECT_EQ(chromeos::EARCON_LISTBOX, earcon); | 85 EXPECT_EQ(chromeos::EARCON_LISTBOX, earcon); |
86 EXPECT_EQ("English Language Combo box 13 of 35", description); | 86 EXPECT_EQ("English Language Combo box 13 of 35", description); |
87 } | 87 } |
88 | 88 |
89 TEST_F(WizardAccessibilityHandlerTest, TestTextEvents) { | 89 TEST_F(WizardAccessibilityHandlerTest, TestTextEvents) { |
90 WizardAccessibilityHandler handler; | 90 WizardAccessibilityHandler handler; |
91 | 91 |
92 std::string description; | 92 std::string description; |
93 EarconType earcon; | 93 EarconType earcon; |
94 | 94 |
95 AccessibilityTextBoxInfo textbox_info(NULL, "", false); | 95 AccessibilityTextBoxInfo textbox_info(NULL, "", "", false); |
96 handler.DescribeAccessibilityEvent( | 96 handler.DescribeAccessibilityEvent( |
97 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, | 97 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
98 &textbox_info, | 98 &textbox_info, |
99 &description, | 99 &description, |
100 &earcon); | 100 &earcon); |
101 EXPECT_EQ("Text box", description); | 101 EXPECT_EQ("Text box", description); |
102 EXPECT_EQ(chromeos::EARCON_TEXTBOX, earcon); | 102 EXPECT_EQ(chromeos::EARCON_TEXTBOX, earcon); |
103 | 103 |
104 // Type "hello world.", one character at a time. | 104 // Type "hello world.", one character at a time. |
105 ChangeText(&handler, &textbox_info, "h", 1, 1, &description); | 105 ChangeText(&handler, &textbox_info, "h", 1, 1, &description); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 EXPECT_EQ("Space", description); | 156 EXPECT_EQ("Space", description); |
157 ChangeText(&handler, &textbox_info, " world.", 4, 4, &description); | 157 ChangeText(&handler, &textbox_info, " world.", 4, 4, &description); |
158 EXPECT_EQ("Unselected", description); | 158 EXPECT_EQ("Unselected", description); |
159 | 159 |
160 // If the string suddenly changes, it should just speak the new value. | 160 // If the string suddenly changes, it should just speak the new value. |
161 ChangeText(&handler, &textbox_info, "Potato", 0, 0, &description); | 161 ChangeText(&handler, &textbox_info, "Potato", 0, 0, &description); |
162 EXPECT_EQ("Potato", description); | 162 EXPECT_EQ("Potato", description); |
163 } | 163 } |
164 | 164 |
165 } | 165 } |
OLD | NEW |