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

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

Issue 137993009: Remove more non-aura windows code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: renable the disabled tests Created 6 years, 11 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/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/accessibility/accessibility_extension_api.h" 10 #include "chrome/browser/accessibility/accessibility_extension_api.h"
(...skipping 20 matching lines...) Expand all
31 #include "ui/base/win/scoped_ole_initializer.h" 31 #include "ui/base/win/scoped_ole_initializer.h"
32 #endif 32 #endif
33 33
34 #if defined(USE_AURA) 34 #if defined(USE_AURA)
35 #include "ui/aura/root_window.h" 35 #include "ui/aura/root_window.h"
36 #include "ui/aura/test/aura_test_helper.h" 36 #include "ui/aura/test/aura_test_helper.h"
37 #endif 37 #endif
38 38
39 using base::ASCIIToUTF16; 39 using base::ASCIIToUTF16;
40 40
41 namespace {
42
43 // The expected initial focus count.
44 #if defined(OS_WIN) && !defined(USE_AURA)
45 // On windows (non-aura) this code triggers activating the window. Activating
46 // the window triggers clearing the focus then resetting it. This results in an
47 // additional focus change.
48 const int kInitialFocusCount = 2;
49 #else
50 const int kInitialFocusCount = 1;
51 #endif
52
53 } // namespace
54
55 class AccessibilityViewsDelegate : public views::TestViewsDelegate { 41 class AccessibilityViewsDelegate : public views::TestViewsDelegate {
56 public: 42 public:
57 AccessibilityViewsDelegate() {} 43 AccessibilityViewsDelegate() {}
58 virtual ~AccessibilityViewsDelegate() {} 44 virtual ~AccessibilityViewsDelegate() {}
59 45
60 // Overridden from views::TestViewsDelegate: 46 // Overridden from views::TestViewsDelegate:
61 virtual void NotifyAccessibilityEvent( 47 virtual void NotifyAccessibilityEvent(
62 views::View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE { 48 views::View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE {
63 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( 49 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent(
64 view, event_type); 50 view, event_type);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // Put the view in a window. 260 // Put the view in a window.
275 views::Widget* window = CreateWindowWithContents(contents); 261 views::Widget* window = CreateWindowWithContents(contents);
276 262
277 // Set focus to the button. 263 // Set focus to the button.
278 control_event_count_ = 0; 264 control_event_count_ = 0;
279 button->RequestFocus(); 265 button->RequestFocus();
280 266
281 base::MessageLoop::current()->RunUntilIdle(); 267 base::MessageLoop::current()->RunUntilIdle();
282 268
283 // Test that we got the event with the expected name and context. 269 // Test that we got the event with the expected name and context.
284 EXPECT_EQ(kInitialFocusCount, control_event_count_); 270 EXPECT_EQ(1, control_event_count_);
285 EXPECT_EQ(kButtonNameASCII, last_control_name_); 271 EXPECT_EQ(kButtonNameASCII, last_control_name_);
286 EXPECT_EQ(kToolbarNameASCII, last_control_context_); 272 EXPECT_EQ(kToolbarNameASCII, last_control_context_);
287 273
288 window->CloseNow(); 274 window->CloseNow();
289 } 275 }
290 276
291 TEST_F(AccessibilityEventRouterViewsTest, TestAlertContext) { 277 TEST_F(AccessibilityEventRouterViewsTest, TestAlertContext) {
292 const char kAlertTextASCII[] = "MyAlertText"; 278 const char kAlertTextASCII[] = "MyAlertText";
293 const char kButtonNameASCII[] = "MyButton"; 279 const char kButtonNameASCII[] = "MyButton";
294 280
(...skipping 11 matching lines...) Expand all
306 // Put the view in a window. 292 // Put the view in a window.
307 views::Widget* window = CreateWindowWithContents(contents); 293 views::Widget* window = CreateWindowWithContents(contents);
308 294
309 // Set focus to the button. 295 // Set focus to the button.
310 control_event_count_ = 0; 296 control_event_count_ = 0;
311 button->RequestFocus(); 297 button->RequestFocus();
312 298
313 base::MessageLoop::current()->RunUntilIdle(); 299 base::MessageLoop::current()->RunUntilIdle();
314 300
315 // Test that we got the event with the expected name and context. 301 // Test that we got the event with the expected name and context.
316 EXPECT_EQ(kInitialFocusCount, control_event_count_); 302 EXPECT_EQ(1, control_event_count_);
317 EXPECT_EQ(kButtonNameASCII, last_control_name_); 303 EXPECT_EQ(kButtonNameASCII, last_control_name_);
318 EXPECT_EQ(kAlertTextASCII, last_control_context_); 304 EXPECT_EQ(kAlertTextASCII, last_control_context_);
319 305
320 window->CloseNow(); 306 window->CloseNow();
321 } 307 }
322 308
323 TEST_F(AccessibilityEventRouterViewsTest, StateChangeAfterNotification) { 309 TEST_F(AccessibilityEventRouterViewsTest, StateChangeAfterNotification) {
324 const char kContentsNameASCII[] = "Contents"; 310 const char kContentsNameASCII[] = "Contents";
325 const char kOldNameASCII[] = "OldName"; 311 const char kOldNameASCII[] = "OldName";
326 const char kNewNameASCII[] = "NewName"; 312 const char kNewNameASCII[] = "NewName";
(...skipping 17 matching lines...) Expand all
344 330
345 // Change the child's name after the focus notification. 331 // Change the child's name after the focus notification.
346 child->set_name(ASCIIToUTF16(kNewNameASCII)); 332 child->set_name(ASCIIToUTF16(kNewNameASCII));
347 333
348 // We shouldn't get the notification right away. 334 // We shouldn't get the notification right away.
349 EXPECT_EQ(0, control_event_count_); 335 EXPECT_EQ(0, control_event_count_);
350 336
351 // Process anything in the event loop. Now we should get the notification, 337 // Process anything in the event loop. Now we should get the notification,
352 // and it should give us the new control name, not the old one. 338 // and it should give us the new control name, not the old one.
353 base::MessageLoop::current()->RunUntilIdle(); 339 base::MessageLoop::current()->RunUntilIdle();
354 EXPECT_EQ(kInitialFocusCount, control_event_count_); 340 EXPECT_EQ(1, control_event_count_);
355 EXPECT_EQ(kNewNameASCII, last_control_name_); 341 EXPECT_EQ(kNewNameASCII, last_control_name_);
356 342
357 window->CloseNow(); 343 window->CloseNow();
358 } 344 }
359 345
360 TEST_F(AccessibilityEventRouterViewsTest, NotificationOnDeletedObject) { 346 TEST_F(AccessibilityEventRouterViewsTest, NotificationOnDeletedObject) {
361 const char kContentsNameASCII[] = "Contents"; 347 const char kContentsNameASCII[] = "Contents";
362 const char kNameASCII[] = "OldName"; 348 const char kNameASCII[] = "OldName";
363 349
364 // Create a toolbar with a button. 350 // Create a toolbar with a button.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 494
509 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( 495 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount(
510 menu_container, 496 menu_container,
511 menu->GetMenuItemByID(kTestCases[i].command_id), 497 menu->GetMenuItemByID(kTestCases[i].command_id),
512 &index, 498 &index,
513 &count); 499 &count);
514 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; 500 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i;
515 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; 501 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i;
516 } 502 }
517 } 503 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_window.h ('k') | chrome/browser/ui/views/autofill/autofill_dialog_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698