Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Side by Side Diff: chrome/browser/chromeos/login/wizard_accessibility_handler_unittest.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_events.h" 5 #include "chrome/browser/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 "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 using chromeos::EarconType; 10 using chromeos::EarconType;
10 using chromeos::WizardAccessibilityHandler; 11 using chromeos::WizardAccessibilityHandler;
11 12
12 namespace chromeos { 13 namespace chromeos {
13 14
14 class WizardAccessibilityHandlerTest : public testing::Test { 15 class WizardAccessibilityHandlerTest : public testing::Test {
15 protected: 16 protected:
16 void ChangeText(WizardAccessibilityHandler* handler, 17 void ChangeText(WizardAccessibilityHandler* handler,
17 AccessibilityTextBoxInfo* textbox_info, 18 AccessibilityTextBoxInfo* textbox_info,
18 const std::string& value, 19 const std::string& value,
19 int selection_start, 20 int selection_start,
20 int selection_end, 21 int selection_end,
21 std::string* description) { 22 std::string* description) {
22 textbox_info->SetValue(value, selection_start, selection_end); 23 textbox_info->SetValue(value, selection_start, selection_end);
23 EarconType earcon = chromeos::NO_EARCON; 24 EarconType earcon = chromeos::NO_EARCON;
24 handler->DescribeAccessibilityEvent( 25 handler->DescribeAccessibilityEvent(
25 NotificationType::ACCESSIBILITY_TEXT_CHANGED, 26 chrome::NOTIFICATION_ACCESSIBILITY_TEXT_CHANGED,
26 textbox_info, 27 textbox_info,
27 description, 28 description,
28 &earcon); 29 &earcon);
29 } 30 }
30 }; 31 };
31 32
32 TEST_F(WizardAccessibilityHandlerTest, TestFocusEvents) { 33 TEST_F(WizardAccessibilityHandlerTest, TestFocusEvents) {
33 WizardAccessibilityHandler handler; 34 WizardAccessibilityHandler handler;
34 35
35 std::string description; 36 std::string description;
36 EarconType earcon; 37 EarconType earcon;
37 38
38 // No need to test every possible control, but test several types 39 // No need to test every possible control, but test several types
39 // to exercise different types of string concatenation. 40 // to exercise different types of string concatenation.
40 41
41 // 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
42 // safe to do these string comparisons without using l10n_util. 43 // safe to do these string comparisons without using l10n_util.
43 44
44 // Test a simple control. 45 // Test a simple control.
45 std::string button_name = "Save"; 46 std::string button_name = "Save";
46 AccessibilityButtonInfo button_info(NULL, button_name); 47 AccessibilityButtonInfo button_info(NULL, button_name);
47 handler.DescribeAccessibilityEvent( 48 handler.DescribeAccessibilityEvent(
48 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, 49 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
49 &button_info, 50 &button_info,
50 &description, 51 &description,
51 &earcon); 52 &earcon);
52 EXPECT_EQ(chromeos::EARCON_BUTTON, earcon); 53 EXPECT_EQ(chromeos::EARCON_BUTTON, earcon);
53 EXPECT_EQ("Save Button", description); 54 EXPECT_EQ("Save Button", description);
54 55
55 // Test a control with multiple states. 56 // Test a control with multiple states.
56 std::string checkbox_name = "Accessibility"; 57 std::string checkbox_name = "Accessibility";
57 AccessibilityCheckboxInfo checkbox_info(NULL, checkbox_name, false); 58 AccessibilityCheckboxInfo checkbox_info(NULL, checkbox_name, false);
58 handler.DescribeAccessibilityEvent( 59 handler.DescribeAccessibilityEvent(
59 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, 60 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
60 &checkbox_info, 61 &checkbox_info,
61 &description, 62 &description,
62 &earcon); 63 &earcon);
63 EXPECT_EQ(chromeos::EARCON_CHECK_OFF, earcon); 64 EXPECT_EQ(chromeos::EARCON_CHECK_OFF, earcon);
64 EXPECT_EQ("Accessibility Unchecked check box", description); 65 EXPECT_EQ("Accessibility Unchecked check box", description);
65 checkbox_info.SetChecked(true); 66 checkbox_info.SetChecked(true);
66 handler.DescribeAccessibilityEvent( 67 handler.DescribeAccessibilityEvent(
67 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, 68 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
68 &checkbox_info, 69 &checkbox_info,
69 &description, 70 &description,
70 &earcon); 71 &earcon);
71 EXPECT_EQ(chromeos::EARCON_CHECK_ON, earcon); 72 EXPECT_EQ(chromeos::EARCON_CHECK_ON, earcon);
72 EXPECT_EQ("Accessibility Checked check box", description); 73 EXPECT_EQ("Accessibility Checked check box", description);
73 74
74 // Test a control with a value and index. 75 // Test a control with a value and index.
75 std::string combobox_name = "Language"; 76 std::string combobox_name = "Language";
76 std::string combobox_value = "English"; 77 std::string combobox_value = "English";
77 AccessibilityComboBoxInfo combobox_info( 78 AccessibilityComboBoxInfo combobox_info(
78 NULL, combobox_name, combobox_value, 12, 35); 79 NULL, combobox_name, combobox_value, 12, 35);
79 handler.DescribeAccessibilityEvent( 80 handler.DescribeAccessibilityEvent(
80 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, 81 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
81 &combobox_info, 82 &combobox_info,
82 &description, 83 &description,
83 &earcon); 84 &earcon);
84 EXPECT_EQ(chromeos::EARCON_LISTBOX, earcon); 85 EXPECT_EQ(chromeos::EARCON_LISTBOX, earcon);
85 EXPECT_EQ("English Language Combo box 13 of 35", description); 86 EXPECT_EQ("English Language Combo box 13 of 35", description);
86 } 87 }
87 88
88 TEST_F(WizardAccessibilityHandlerTest, TestTextEvents) { 89 TEST_F(WizardAccessibilityHandlerTest, TestTextEvents) {
89 WizardAccessibilityHandler handler; 90 WizardAccessibilityHandler handler;
90 91
91 std::string description; 92 std::string description;
92 EarconType earcon; 93 EarconType earcon;
93 94
94 AccessibilityTextBoxInfo textbox_info(NULL, "", false); 95 AccessibilityTextBoxInfo textbox_info(NULL, "", false);
95 handler.DescribeAccessibilityEvent( 96 handler.DescribeAccessibilityEvent(
96 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, 97 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
97 &textbox_info, 98 &textbox_info,
98 &description, 99 &description,
99 &earcon); 100 &earcon);
100 EXPECT_EQ("Text box", description); 101 EXPECT_EQ("Text box", description);
101 EXPECT_EQ(chromeos::EARCON_TEXTBOX, earcon); 102 EXPECT_EQ(chromeos::EARCON_TEXTBOX, earcon);
102 103
103 // Type "hello world.", one character at a time. 104 // Type "hello world.", one character at a time.
104 ChangeText(&handler, &textbox_info, "h", 1, 1, &description); 105 ChangeText(&handler, &textbox_info, "h", 1, 1, &description);
105 EXPECT_EQ("h", description); 106 EXPECT_EQ("h", description);
106 ChangeText(&handler, &textbox_info, "he", 2, 2, &description); 107 ChangeText(&handler, &textbox_info, "he", 2, 2, &description);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_EQ("Space", description); 156 EXPECT_EQ("Space", description);
156 ChangeText(&handler, &textbox_info, " world.", 4, 4, &description); 157 ChangeText(&handler, &textbox_info, " world.", 4, 4, &description);
157 EXPECT_EQ("Unselected", description); 158 EXPECT_EQ("Unselected", description);
158 159
159 // 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.
160 ChangeText(&handler, &textbox_info, "Potato", 0, 0, &description); 161 ChangeText(&handler, &textbox_info, "Potato", 0, 0, &description);
161 EXPECT_EQ("Potato", description); 162 EXPECT_EQ("Potato", description);
162 } 163 }
163 164
164 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698