OLD | NEW |
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 <oleacc.h> | 5 #include <oleacc.h> |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/scoped_comptr_win.h" | 8 #include "base/scoped_comptr_win.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ASSERT_TRUE(NULL != hwnd); | 122 ASSERT_TRUE(NULL != hwnd); |
123 | 123 |
124 // Get accessibility object. | 124 // Get accessibility object. |
125 ScopedComPtr<IAccessible> acc_obj; | 125 ScopedComPtr<IAccessible> acc_obj; |
126 HRESULT hr = ::AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, IID_IAccessible, | 126 HRESULT hr = ::AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, IID_IAccessible, |
127 reinterpret_cast<void**>(&acc_obj)); | 127 reinterpret_cast<void**>(&acc_obj)); |
128 ASSERT_EQ(S_OK, hr); | 128 ASSERT_EQ(S_OK, hr); |
129 ASSERT_TRUE(NULL != acc_obj); | 129 ASSERT_TRUE(NULL != acc_obj); |
130 | 130 |
131 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 131 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
132 std::wstring title = | 132 std::wstring title = UTF16ToWide(l10n_util::GetStringFUTF16( |
133 l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, | 133 IDS_BROWSER_WINDOW_TITLE_FORMAT, |
134 ASCIIToWide(chrome::kAboutBlankURL)); | 134 ASCIIToUTF16(chrome::kAboutBlankURL))); |
135 TestAccessibilityInfo(acc_obj, title, ROLE_SYSTEM_WINDOW); | 135 TestAccessibilityInfo(acc_obj, title, ROLE_SYSTEM_WINDOW); |
136 } | 136 } |
137 | 137 |
138 // Retrieve accessibility object for non client view and verify accessibility | 138 // Retrieve accessibility object for non client view and verify accessibility |
139 // info. | 139 // info. |
140 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestNonClientViewAccObj) { | 140 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestNonClientViewAccObj) { |
141 views::View* non_client_view = | 141 views::View* non_client_view = |
142 GetBrowserView()->GetWindow()->GetNonClientView(); | 142 GetBrowserView()->GetWindow()->GetNonClientView(); |
143 | 143 |
144 TestViewAccessibilityObject(non_client_view, | 144 TestViewAccessibilityObject(non_client_view, |
145 l10n_util::GetString(IDS_PRODUCT_NAME), | 145 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), |
146 ROLE_SYSTEM_WINDOW); | 146 ROLE_SYSTEM_WINDOW); |
147 } | 147 } |
148 | 148 |
149 // Retrieve accessibility object for browser root view and verify | 149 // Retrieve accessibility object for browser root view and verify |
150 // accessibility info. | 150 // accessibility info. |
151 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, | 151 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, |
152 TestBrowserRootViewAccObj) { | 152 TestBrowserRootViewAccObj) { |
153 views::View* browser_root_view = | 153 views::View* browser_root_view = |
154 GetBrowserView()->frame()->GetFrameView()->GetRootView(); | 154 GetBrowserView()->frame()->GetFrameView()->GetRootView(); |
155 | 155 |
156 TestViewAccessibilityObject(browser_root_view, | 156 TestViewAccessibilityObject( |
157 l10n_util::GetString(IDS_PRODUCT_NAME), | 157 browser_root_view, |
158 ROLE_SYSTEM_APPLICATION); | 158 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), |
| 159 ROLE_SYSTEM_APPLICATION); |
159 } | 160 } |
160 | 161 |
161 // Retrieve accessibility object for browser view and verify accessibility info. | 162 // Retrieve accessibility object for browser view and verify accessibility info. |
162 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBrowserViewAccObj) { | 163 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBrowserViewAccObj) { |
163 // Verify root view MSAA name and role. | 164 // Verify root view MSAA name and role. |
164 TestViewAccessibilityObject(GetBrowserView(), | 165 TestViewAccessibilityObject( |
165 l10n_util::GetString(IDS_PRODUCT_NAME), | 166 GetBrowserView(), |
166 ROLE_SYSTEM_CLIENT); | 167 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), |
| 168 ROLE_SYSTEM_CLIENT); |
167 } | 169 } |
168 | 170 |
169 // Retrieve accessibility object for toolbar view and verify accessibility info. | 171 // Retrieve accessibility object for toolbar view and verify accessibility info. |
170 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestToolbarViewAccObj) { | 172 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestToolbarViewAccObj) { |
171 // Verify toolbar MSAA name and role. | 173 // Verify toolbar MSAA name and role. |
172 TestViewAccessibilityObject(GetToolbarView(), | 174 TestViewAccessibilityObject( |
173 l10n_util::GetString(IDS_ACCNAME_TOOLBAR), | 175 GetToolbarView(), |
174 ROLE_SYSTEM_TOOLBAR); | 176 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR)), |
| 177 ROLE_SYSTEM_TOOLBAR); |
175 } | 178 } |
176 | 179 |
177 // Retrieve accessibility object for Back button and verify accessibility info. | 180 // Retrieve accessibility object for Back button and verify accessibility info. |
178 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBackButtonAccObj) { | 181 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBackButtonAccObj) { |
179 // Verify Back button MSAA name and role. | 182 // Verify Back button MSAA name and role. |
180 TestViewAccessibilityObject( | 183 TestViewAccessibilityObject( |
181 GetToolbarView()->GetViewByID(VIEW_ID_BACK_BUTTON), | 184 GetToolbarView()->GetViewByID(VIEW_ID_BACK_BUTTON), |
182 l10n_util::GetString(IDS_ACCNAME_BACK), ROLE_SYSTEM_BUTTONDROPDOWN); | 185 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)), |
| 186 ROLE_SYSTEM_BUTTONDROPDOWN); |
183 } | 187 } |
184 | 188 |
185 // Retrieve accessibility object for Forward button and verify accessibility | 189 // Retrieve accessibility object for Forward button and verify accessibility |
186 // info. | 190 // info. |
187 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestForwardButtonAccObj) { | 191 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestForwardButtonAccObj) { |
188 // Verify Forward button MSAA name and role. | 192 // Verify Forward button MSAA name and role. |
189 TestViewAccessibilityObject( | 193 TestViewAccessibilityObject( |
190 GetToolbarView()->GetViewByID(VIEW_ID_FORWARD_BUTTON), | 194 GetToolbarView()->GetViewByID(VIEW_ID_FORWARD_BUTTON), |
191 l10n_util::GetString(IDS_ACCNAME_FORWARD), ROLE_SYSTEM_BUTTONDROPDOWN); | 195 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)), |
| 196 ROLE_SYSTEM_BUTTONDROPDOWN); |
192 } | 197 } |
193 | 198 |
194 // Retrieve accessibility object for Reload button and verify accessibility | 199 // Retrieve accessibility object for Reload button and verify accessibility |
195 // info. | 200 // info. |
196 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestReloadButtonAccObj) { | 201 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestReloadButtonAccObj) { |
197 // Verify Reload button MSAA name and role. | 202 // Verify Reload button MSAA name and role. |
198 TestViewAccessibilityObject( | 203 TestViewAccessibilityObject( |
199 GetToolbarView()->GetViewByID(VIEW_ID_RELOAD_BUTTON), | 204 GetToolbarView()->GetViewByID(VIEW_ID_RELOAD_BUTTON), |
200 l10n_util::GetString(IDS_ACCNAME_RELOAD), ROLE_SYSTEM_PUSHBUTTON); | 205 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)), |
| 206 ROLE_SYSTEM_PUSHBUTTON); |
201 } | 207 } |
202 | 208 |
203 // Retrieve accessibility object for Home button and verify accessibility info. | 209 // Retrieve accessibility object for Home button and verify accessibility info. |
204 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestHomeButtonAccObj) { | 210 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestHomeButtonAccObj) { |
205 // Verify Home button MSAA name and role. | 211 // Verify Home button MSAA name and role. |
206 TestViewAccessibilityObject( | 212 TestViewAccessibilityObject( |
207 GetToolbarView()->GetViewByID(VIEW_ID_HOME_BUTTON), | 213 GetToolbarView()->GetViewByID(VIEW_ID_HOME_BUTTON), |
208 l10n_util::GetString(IDS_ACCNAME_HOME), ROLE_SYSTEM_PUSHBUTTON); | 214 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_HOME)), |
| 215 ROLE_SYSTEM_PUSHBUTTON); |
209 } | 216 } |
210 | 217 |
211 // Retrieve accessibility object for Star button and verify accessibility info. | 218 // Retrieve accessibility object for Star button and verify accessibility info. |
212 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, | 219 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, |
213 TestStarButtonAccObj) { | 220 TestStarButtonAccObj) { |
214 // Verify Star button MSAA name and role. | 221 // Verify Star button MSAA name and role. |
215 TestViewAccessibilityObject( | 222 TestViewAccessibilityObject( |
216 GetToolbarView()->GetViewByID(VIEW_ID_STAR_BUTTON), | 223 GetToolbarView()->GetViewByID(VIEW_ID_STAR_BUTTON), |
217 l10n_util::GetString(IDS_ACCNAME_STAR), ROLE_SYSTEM_PUSHBUTTON); | 224 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_STAR)), |
| 225 ROLE_SYSTEM_PUSHBUTTON); |
218 } | 226 } |
219 | 227 |
220 // Retrieve accessibility object for App menu button and verify accessibility | 228 // Retrieve accessibility object for App menu button and verify accessibility |
221 // info. | 229 // info. |
222 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestAppMenuAccObj) { | 230 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestAppMenuAccObj) { |
223 // Verify App menu button MSAA name and role. | 231 // Verify App menu button MSAA name and role. |
224 TestViewAccessibilityObject(GetToolbarView()->GetViewByID(VIEW_ID_APP_MENU), | 232 TestViewAccessibilityObject( |
225 l10n_util::GetString(IDS_ACCNAME_APP), | 233 GetToolbarView()->GetViewByID(VIEW_ID_APP_MENU), |
226 ROLE_SYSTEM_BUTTONMENU); | 234 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_APP)), |
| 235 ROLE_SYSTEM_BUTTONMENU); |
227 } | 236 } |
228 | 237 |
229 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, | 238 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, |
230 TestBookmarkBarViewAccObj) { | 239 TestBookmarkBarViewAccObj) { |
231 TestViewAccessibilityObject(GetBookmarkBarView(), | 240 TestViewAccessibilityObject( |
232 l10n_util::GetString(IDS_ACCNAME_BOOKMARKS), | 241 GetBookmarkBarView(), |
233 ROLE_SYSTEM_TOOLBAR); | 242 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS)), |
| 243 ROLE_SYSTEM_TOOLBAR); |
234 } | 244 } |
235 | 245 |
236 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, | 246 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, |
237 TestAboutChromeViewAccObj) { | 247 TestAboutChromeViewAccObj) { |
238 // Firstly, test that the WindowDelegate got updated. | 248 // Firstly, test that the WindowDelegate got updated. |
239 views::Window* aboutChromeWindow = GetBrowserView()->ShowAboutChromeDialog(); | 249 views::Window* aboutChromeWindow = GetBrowserView()->ShowAboutChromeDialog(); |
240 EXPECT_STREQ(aboutChromeWindow->GetDelegate()->GetWindowTitle().c_str(), | 250 EXPECT_STREQ( |
241 l10n_util::GetString(IDS_ABOUT_CHROME_TITLE).c_str()); | 251 aboutChromeWindow->GetDelegate()->GetWindowTitle().c_str(), |
| 252 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_TITLE)).c_str()); |
242 EXPECT_EQ(aboutChromeWindow->GetDelegate()->accessible_role(), | 253 EXPECT_EQ(aboutChromeWindow->GetDelegate()->accessible_role(), |
243 AccessibilityTypes::ROLE_DIALOG); | 254 AccessibilityTypes::ROLE_DIALOG); |
244 | 255 |
245 // Also test the accessibility object directly. | 256 // Also test the accessibility object directly. |
246 IAccessible* acc_obj = NULL; | 257 IAccessible* acc_obj = NULL; |
247 HRESULT hr = | 258 HRESULT hr = |
248 ::AccessibleObjectFromWindow(aboutChromeWindow->GetNativeWindow(), | 259 ::AccessibleObjectFromWindow(aboutChromeWindow->GetNativeWindow(), |
249 OBJID_CLIENT, | 260 OBJID_CLIENT, |
250 IID_IAccessible, | 261 IID_IAccessible, |
251 reinterpret_cast<void**>(&acc_obj)); | 262 reinterpret_cast<void**>(&acc_obj)); |
252 ASSERT_EQ(S_OK, hr); | 263 ASSERT_EQ(S_OK, hr); |
253 ASSERT_TRUE(NULL != acc_obj); | 264 ASSERT_TRUE(NULL != acc_obj); |
254 | 265 |
255 TestAccessibilityInfo(acc_obj, l10n_util::GetString(IDS_ABOUT_CHROME_TITLE), | 266 TestAccessibilityInfo( |
256 ROLE_SYSTEM_DIALOG); | 267 acc_obj, |
| 268 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_TITLE)), |
| 269 ROLE_SYSTEM_DIALOG); |
257 | 270 |
258 acc_obj->Release(); | 271 acc_obj->Release(); |
259 } | 272 } |
260 } // Namespace. | 273 } // Namespace. |
OLD | NEW |