| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #include "base/test/test_timeouts.h" |
| 8 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/test/ui/ui_test.h" | 10 #include "chrome/test/ui/ui_test.h" |
| 10 | 11 |
| 11 // The following tests exercise the Chrome Mac accessibility implementation | 12 // The following tests exercise the Chrome Mac accessibility implementation |
| 12 // similarly to the way in which VoiceOver would. | 13 // similarly to the way in which VoiceOver would. |
| 13 // We achieve this by utilizing the same carbon API (HIServices) as do | 14 // We achieve this by utilizing the same carbon API (HIServices) as do |
| 14 // other assistive technologies. | 15 // other assistive technologies. |
| 15 // Note that the tests must be UITests since these API's only work if not | 16 // Note that the tests must be UITests since these API's only work if not |
| 16 // called within the same process begin examined. | 17 // called within the same process begin examined. |
| 17 class AccessibilityMacUITest : public UITest { | 18 class AccessibilityMacUITest : public UITest { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 33 [AccessibilityMacUITest::expectedEvents addObject:notificationName]; | 34 [AccessibilityMacUITest::expectedEvents addObject:notificationName]; |
| 34 } | 35 } |
| 35 | 36 |
| 36 // Assert that there are no remaining expected events. | 37 // Assert that there are no remaining expected events. |
| 37 // CFRunLoop necessary to receive AX callbacks. | 38 // CFRunLoop necessary to receive AX callbacks. |
| 38 // Assumes that there is at least one expected event. | 39 // Assumes that there is at least one expected event. |
| 39 // The runloop stops only if we receive all expected notifications. | 40 // The runloop stops only if we receive all expected notifications. |
| 40 void WaitAndAssertAllEventsObserved() { | 41 void WaitAndAssertAllEventsObserved() { |
| 41 ASSERT_GE([expectedEvents count], 1U); | 42 ASSERT_GE([expectedEvents count], 1U); |
| 42 CFRunLoopRunInMode( | 43 CFRunLoopRunInMode( |
| 43 kCFRunLoopDefaultMode, action_max_timeout_ms()/1000, false); | 44 kCFRunLoopDefaultMode, |
| 45 TestTimeouts::action_max_timeout_ms() / 1000, false); |
| 44 ASSERT_EQ(0U, [AccessibilityMacUITest::expectedEvents count]); | 46 ASSERT_EQ(0U, [AccessibilityMacUITest::expectedEvents count]); |
| 45 } | 47 } |
| 46 | 48 |
| 47 // The Callback handler added to each AXUIElement. | 49 // The Callback handler added to each AXUIElement. |
| 48 static void EventReceiver( | 50 static void EventReceiver( |
| 49 AXObserverRef observerRef, | 51 AXObserverRef observerRef, |
| 50 AXUIElementRef element, | 52 AXUIElementRef element, |
| 51 CFStringRef notificationName, | 53 CFStringRef notificationName, |
| 52 void *refcon) { | 54 void *refcon) { |
| 53 if ([[AccessibilityMacUITest::expectedEvents objectAtIndex:0] | 55 if ([[AccessibilityMacUITest::expectedEvents objectAtIndex:0] |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 "<body><input type='button' value='push' /><input type='checkbox' />" | 191 "<body><input type='button' value='push' /><input type='checkbox' />" |
| 190 "</body></html>"); | 192 "</body></html>"); |
| 191 NavigateToURLAsync(tree_url); | 193 NavigateToURLAsync(tree_url); |
| 192 | 194 |
| 193 // Test for navigation. | 195 // Test for navigation. |
| 194 AddExpectedEvent(@"AXLoadComplete"); | 196 AddExpectedEvent(@"AXLoadComplete"); |
| 195 | 197 |
| 196 // Check all the expected Mac notifications. | 198 // Check all the expected Mac notifications. |
| 197 WaitAndAssertAllEventsObserved(); | 199 WaitAndAssertAllEventsObserved(); |
| 198 } | 200 } |
| OLD | NEW |