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

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: one more fix in one_click_signin_bubble_view.cc 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/text_button.h" 18 #include "ui/views/controls/button/label_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::NativeTextButton* button1 = new views::NativeTextButton( 170 views::LabelButton* button1 = new views::LabelButton(
171 NULL, ASCIIToUTF16(kButton1ASCII)); 171 NULL, ASCIIToUTF16(kButton1ASCII));
172 button1->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
172 contents->AddChildView(button1); 173 contents->AddChildView(button1);
173 views::NativeTextButton* button2 = new views::NativeTextButton( 174 views::LabelButton* button2 = new views::LabelButton(
174 NULL, ASCIIToUTF16(kButton2ASCII)); 175 NULL, ASCIIToUTF16(kButton2ASCII));
176 button2->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
175 contents->AddChildView(button2); 177 contents->AddChildView(button2);
176 views::NativeTextButton* button3 = new views::NativeTextButton( 178 views::LabelButton* button3 = new views::LabelButton(
177 NULL, ASCIIToUTF16(kButton3ASCII)); 179 NULL, ASCIIToUTF16(kButton3ASCII));
180 button3->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
178 contents->AddChildView(button3); 181 contents->AddChildView(button3);
179 182
180 // Put the view in a window. 183 // Put the view in a window.
181 views::Widget* window = CreateWindowWithContents(contents); 184 views::Widget* window = CreateWindowWithContents(contents);
182 window->Show(); 185 window->Show();
183 window->Activate(); 186 window->Activate();
184 187
185 // Set focus to the first button initially. 188 // Set focus to the first button initially.
186 button1->RequestFocus(); 189 button1->RequestFocus();
187 190
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 228 }
226 229
227 TEST_F(AccessibilityEventRouterViewsTest, TestToolbarContext) { 230 TEST_F(AccessibilityEventRouterViewsTest, TestToolbarContext) {
228 const char kToolbarNameASCII[] = "MyToolbar"; 231 const char kToolbarNameASCII[] = "MyToolbar";
229 const char kButtonNameASCII[] = "MyButton"; 232 const char kButtonNameASCII[] = "MyButton";
230 233
231 // Create a toolbar with a button. 234 // Create a toolbar with a button.
232 views::View* contents = new ViewWithNameAndRole( 235 views::View* contents = new ViewWithNameAndRole(
233 ASCIIToUTF16(kToolbarNameASCII), 236 ASCIIToUTF16(kToolbarNameASCII),
234 ui::AccessibilityTypes::ROLE_TOOLBAR); 237 ui::AccessibilityTypes::ROLE_TOOLBAR);
235 views::NativeTextButton* button = new views::NativeTextButton( 238 views::LabelButton* button = new views::LabelButton(
236 NULL, ASCIIToUTF16(kButtonNameASCII)); 239 NULL, ASCIIToUTF16(kButtonNameASCII));
240 button->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
237 contents->AddChildView(button); 241 contents->AddChildView(button);
238 242
239 // Put the view in a window. 243 // Put the view in a window.
240 views::Widget* window = CreateWindowWithContents(contents); 244 views::Widget* window = CreateWindowWithContents(contents);
241 245
242 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications. 246 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications.
243 content::NotificationRegistrar registrar; 247 content::NotificationRegistrar registrar;
244 registrar.Add(this, 248 registrar.Add(this,
245 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, 249 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
246 content::NotificationService::AllSources()); 250 content::NotificationService::AllSources());
(...skipping 22 matching lines...) Expand all
269 TEST_F(AccessibilityEventRouterViewsTest, TestAlertContext) { 273 TEST_F(AccessibilityEventRouterViewsTest, TestAlertContext) {
270 const char kAlertTextASCII[] = "MyAlertText"; 274 const char kAlertTextASCII[] = "MyAlertText";
271 const char kButtonNameASCII[] = "MyButton"; 275 const char kButtonNameASCII[] = "MyButton";
272 276
273 // Create an alert with static text and a button, similar to an infobar. 277 // Create an alert with static text and a button, similar to an infobar.
274 views::View* contents = new ViewWithNameAndRole( 278 views::View* contents = new ViewWithNameAndRole(
275 string16(), 279 string16(),
276 ui::AccessibilityTypes::ROLE_ALERT); 280 ui::AccessibilityTypes::ROLE_ALERT);
277 views::Label* label = new views::Label(ASCIIToUTF16(kAlertTextASCII)); 281 views::Label* label = new views::Label(ASCIIToUTF16(kAlertTextASCII));
278 contents->AddChildView(label); 282 contents->AddChildView(label);
279 views::NativeTextButton* button = new views::NativeTextButton( 283 views::LabelButton* button = new views::LabelButton(
280 NULL, ASCIIToUTF16(kButtonNameASCII)); 284 NULL, ASCIIToUTF16(kButtonNameASCII));
285 button->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
281 contents->AddChildView(button); 286 contents->AddChildView(button);
282 287
283 // Put the view in a window. 288 // Put the view in a window.
284 views::Widget* window = CreateWindowWithContents(contents); 289 views::Widget* window = CreateWindowWithContents(contents);
285 290
286 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications. 291 // Start listening to ACCESSIBILITY_CONTROL_FOCUSED notifications.
287 content::NotificationRegistrar registrar; 292 content::NotificationRegistrar registrar;
288 registrar.Add(this, 293 registrar.Add(this,
289 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, 294 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED,
290 content::NotificationService::AllSources()); 295 content::NotificationService::AllSources());
(...skipping 13 matching lines...) Expand all
304 309
305 // Test that we got the event with the expected name and context. 310 // Test that we got the event with the expected name and context.
306 EXPECT_EQ(1, focus_event_count_); 311 EXPECT_EQ(1, focus_event_count_);
307 EXPECT_EQ(kButtonNameASCII, last_control_name_); 312 EXPECT_EQ(kButtonNameASCII, last_control_name_);
308 EXPECT_EQ(kAlertTextASCII, last_control_context_); 313 EXPECT_EQ(kAlertTextASCII, last_control_context_);
309 314
310 window->CloseNow(); 315 window->CloseNow();
311 } 316 }
312 317
313 #endif // defined(TOOLKIT_VIEWS) 318 #endif // defined(TOOLKIT_VIEWS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698