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

Side by Side Diff: chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc

Issue 13584010: views: Migrate the cases of "new .*NativeTextButton(" to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: back out the changes to one_click_signin_bubble_view.* Created 7 years, 8 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) 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 <string> 5 #include <string>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/accessibility/accessibility_extension_api.h" 10 #include "chrome/browser/accessibility/accessibility_extension_api.h"
11 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views .h" 11 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views .h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/base/accessibility/accessible_view_state.h" 17 #include "ui/base/accessibility/accessible_view_state.h"
18 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/button/text_button.h"
19 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
20 #include "ui/views/layout/grid_layout.h" 20 #include "ui/views/layout/grid_layout.h"
21 #include "ui/views/test/test_views_delegate.h" 21 #include "ui/views/test/test_views_delegate.h"
22 #include "ui/views/widget/native_widget.h" 22 #include "ui/views/widget/native_widget.h"
23 #include "ui/views/widget/root_view.h" 23 #include "ui/views/widget/root_view.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_delegate.h" 25 #include "ui/views/widget/widget_delegate.h"
26 26
27 #if defined(OS_WIN) 27 #if defined(OS_WIN)
28 #include "ui/base/win/scoped_ole_initializer.h" 28 #include "ui/base/win/scoped_ole_initializer.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 }; 160 };
161 161
162 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { 162 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) {
163 const char kButton1ASCII[] = "Button1"; 163 const char kButton1ASCII[] = "Button1";
164 const char kButton2ASCII[] = "Button2"; 164 const char kButton2ASCII[] = "Button2";
165 const char kButton3ASCII[] = "Button3"; 165 const char kButton3ASCII[] = "Button3";
166 const char kButton3NewASCII[] = "Button3New"; 166 const char kButton3NewASCII[] = "Button3New";
167 167
168 // Create a contents view with 3 buttons. 168 // Create a contents view with 3 buttons.
169 views::View* contents = new views::View(); 169 views::View* contents = new views::View();
170 views::LabelButton* button1 = new views::LabelButton( 170 views::NativeTextButton* button1 = new views::NativeTextButton(
171 NULL, ASCIIToUTF16(kButton1ASCII)); 171 NULL, ASCIIToUTF16(kButton1ASCII));
172 button1->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
173 contents->AddChildView(button1); 172 contents->AddChildView(button1);
174 views::LabelButton* button2 = new views::LabelButton( 173 views::NativeTextButton* button2 = new views::NativeTextButton(
175 NULL, ASCIIToUTF16(kButton2ASCII)); 174 NULL, ASCIIToUTF16(kButton2ASCII));
176 button2->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
177 contents->AddChildView(button2); 175 contents->AddChildView(button2);
178 views::LabelButton* button3 = new views::LabelButton( 176 views::NativeTextButton* button3 = new views::NativeTextButton(
179 NULL, ASCIIToUTF16(kButton3ASCII)); 177 NULL, ASCIIToUTF16(kButton3ASCII));
180 button3->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
181 contents->AddChildView(button3); 178 contents->AddChildView(button3);
182 179
183 // Put the view in a window. 180 // Put the view in a window.
184 views::Widget* window = CreateWindowWithContents(contents); 181 views::Widget* window = CreateWindowWithContents(contents);
185 window->Show(); 182 window->Show();
186 window->Activate(); 183 window->Activate();
187 184
188 // Set focus to the first button initially. 185 // Set focus to the first button initially.
189 button1->RequestFocus(); 186 button1->RequestFocus();
190 187
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 225 }
229 226
230 TEST_F(AccessibilityEventRouterViewsTest, TestToolbarContext) { 227 TEST_F(AccessibilityEventRouterViewsTest, TestToolbarContext) {
231 const char kToolbarNameASCII[] = "MyToolbar"; 228 const char kToolbarNameASCII[] = "MyToolbar";
232 const char kButtonNameASCII[] = "MyButton"; 229 const char kButtonNameASCII[] = "MyButton";
233 230
234 // Create a toolbar with a button. 231 // Create a toolbar with a button.
235 views::View* contents = new ViewWithNameAndRole( 232 views::View* contents = new ViewWithNameAndRole(
236 ASCIIToUTF16(kToolbarNameASCII), 233 ASCIIToUTF16(kToolbarNameASCII),
237 ui::AccessibilityTypes::ROLE_TOOLBAR); 234 ui::AccessibilityTypes::ROLE_TOOLBAR);
238 views::LabelButton* button = new views::LabelButton( 235 views::NativeTextButton* button = new views::NativeTextButton(
239 NULL, ASCIIToUTF16(kButtonNameASCII)); 236 NULL, ASCIIToUTF16(kButtonNameASCII));
240 button->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
241 contents->AddChildView(button); 237 contents->AddChildView(button);
242 238
243 // Put the view in a window. 239 // Put the view in a window.
244 views::Widget* window = CreateWindowWithContents(contents); 240 views::Widget* window = CreateWindowWithContents(contents);
245 241
246 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications. 242 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications.
247 content::NotificationRegistrar registrar; 243 content::NotificationRegistrar registrar;
248 registrar.Add(this, 244 registrar.Add(this,
249 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, 245 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
250 content::NotificationService::AllSources()); 246 content::NotificationService::AllSources());
(...skipping 22 matching lines...) Expand all
273 TEST_F(AccessibilityEventRouterViewsTest, TestAlertContext) { 269 TEST_F(AccessibilityEventRouterViewsTest, TestAlertContext) {
274 const char kAlertTextASCII[] = "MyAlertText"; 270 const char kAlertTextASCII[] = "MyAlertText";
275 const char kButtonNameASCII[] = "MyButton"; 271 const char kButtonNameASCII[] = "MyButton";
276 272
277 // Create an alert with static text and a button, similar to an infobar. 273 // Create an alert with static text and a button, similar to an infobar.
278 views::View* contents = new ViewWithNameAndRole( 274 views::View* contents = new ViewWithNameAndRole(
279 string16(), 275 string16(),
280 ui::AccessibilityTypes::ROLE_ALERT); 276 ui::AccessibilityTypes::ROLE_ALERT);
281 views::Label* label = new views::Label(ASCIIToUTF16(kAlertTextASCII)); 277 views::Label* label = new views::Label(ASCIIToUTF16(kAlertTextASCII));
282 contents->AddChildView(label); 278 contents->AddChildView(label);
283 views::LabelButton* button = new views::LabelButton( 279 views::NativeTextButton* button = new views::NativeTextButton(
284 NULL, ASCIIToUTF16(kButtonNameASCII)); 280 NULL, ASCIIToUTF16(kButtonNameASCII));
285 button->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
286 contents->AddChildView(button); 281 contents->AddChildView(button);
287 282
288 // Put the view in a window. 283 // Put the view in a window.
289 views::Widget* window = CreateWindowWithContents(contents); 284 views::Widget* window = CreateWindowWithContents(contents);
290 285
291 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications. 286 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications.
292 content::NotificationRegistrar registrar; 287 content::NotificationRegistrar registrar;
293 registrar.Add(this, 288 registrar.Add(this,
294 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, 289 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
295 content::NotificationService::AllSources()); 290 content::NotificationService::AllSources());
(...skipping 13 matching lines...) Expand all
309 304
310 // Test that we got the event with the expected name and context. 305 // Test that we got the event with the expected name and context.
311 EXPECT_EQ(1, focus_event_count_); 306 EXPECT_EQ(1, focus_event_count_);
312 EXPECT_EQ(kButtonNameASCII, last_control_name_); 307 EXPECT_EQ(kButtonNameASCII, last_control_name_);
313 EXPECT_EQ(kAlertTextASCII, last_control_context_); 308 EXPECT_EQ(kAlertTextASCII, last_control_context_);
314 309
315 window->CloseNow(); 310 window->CloseNow();
316 } 311 }
317 312
318 #endif // defined(TOOLKIT_VIEWS) 313 #endif // defined(TOOLKIT_VIEWS)
OLDNEW
« no previous file with comments | « chrome/browser/first_run/try_chrome_dialog_view.cc ('k') | chrome/browser/ui/views/chrome_to_mobile_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698