Commit 5795ee19 authored by jam@chromium.org's avatar jam@chromium.org

Remove the last UITest in interactive_ui_tests which was disabled and is not...

Remove the last UITest in interactive_ui_tests which was disabled and is not necessary now since there are cross-platform tests. Remove the dependency on UITest code to prevent new UITests creeping in.

Also move ConstrainedWindowViewTest and InspectUITest tests to browser_tests since they don't need to be interactive.

BUG=121574,89583
Review URL: https://chromiumcodereview.appspot.com/10382189

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137435 0039d316-1c4b-4281-b951-d872f2087c98
parent 65d137ce
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
#include "base/memory/scoped_nsobject.h"
#include "base/test/test_timeouts.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/ui/ui_test.h"
// The following tests exercise the Chrome Mac accessibility implementation
// similarly to the way in which VoiceOver would.
// We achieve this by utilizing the same carbon API (HIServices) as do
// other assistive technologies.
// Note that the tests must be UITests since these API's only work if not
// called within the same process begin examined.
class AccessibilityMacUITest : public UITest {
public:
AccessibilityMacUITest() {
// TODO(dtseng): fake the VoiceOver defaults value?
launch_arguments_.AppendSwitch(switches::kForceRendererAccessibility);
}
virtual void SetUp() {
UITest::SetUp();
SetupObservedNotifications();
Initialize();
}
// Called to insert an event for validation.
// This is a order sensitive expectation.
void AddExpectedEvent(NSString* notificationName) {
[expectedEvents_ addObject:notificationName];
}
// Assert that there are no remaining expected events.
// CFRunLoop necessary to receive AX callbacks.
// Assumes that there is at least one expected event.
// The runloop stops only if we receive all expected notifications.
void WaitAndAssertAllEventsObserved() {
ASSERT_GE([expectedEvents_ count], 1U);
CFRunLoopRunInMode(
kCFRunLoopDefaultMode,
TestTimeouts::action_max_timeout_ms() / 1000, false);
ASSERT_EQ(0U, [expectedEvents_ count]);
}
// The Callback handler added to each AXUIElement.
static void EventReceiver(
AXObserverRef observerRef,
AXUIElementRef element,
CFStringRef notificationName,
void *refcon) {
AccessibilityMacUITest* this_pointer =
reinterpret_cast<AccessibilityMacUITest*>(refcon);
if ([[this_pointer->expectedEvents_ objectAtIndex:0]
isEqualToString:(NSString*)notificationName]) {
[this_pointer->expectedEvents_ removeObjectAtIndex:0];
}
if ([this_pointer->expectedEvents_ count] == 0) {
CFRunLoopStop(CFRunLoopGetCurrent());
}
// TODO(dtseng): currently refreshing on all notifications; scope later.
this_pointer->SetAllObserversOnDescendants(element, observerRef);
}
private:
// Perform AX setup.
void Initialize() {
expectedEvents_.reset([[NSMutableArray alloc] init]);
// Construct the Chrome AXUIElementRef.
ASSERT_NE(-1, browser_process_id());
AXUIElementRef browserUiElement =
AXUIElementCreateApplication(browser_process_id());
ASSERT_TRUE(browserUiElement);
// Setup our callbacks.
AXObserverRef observerRef;
ASSERT_EQ(kAXErrorSuccess,
AXObserverCreate(browser_process_id(),
AccessibilityMacUITest::EventReceiver,
&observerRef));
SetAllObserversOnDescendants(browserUiElement, observerRef);
// Add the observer to the current message loop.
CFRunLoopAddSource(
[[NSRunLoop currentRunLoop] getCFRunLoop],
AXObserverGetRunLoopSource(observerRef),
kCFRunLoopDefaultMode);
}
// Taken largely from AXNotificationConstants.h
// (substituted NSAccessibility* to avoid casting).
void SetupObservedNotifications() {
observedNotifications_.reset(
[[NSArray alloc] initWithObjects:
// focus notifications
NSAccessibilityMainWindowChangedNotification,
NSAccessibilityFocusedWindowChangedNotification,
NSAccessibilityFocusedUIElementChangedNotification,
// application notifications
NSAccessibilityApplicationActivatedNotification,
NSAccessibilityApplicationDeactivatedNotification,
NSAccessibilityApplicationHiddenNotification,
NSAccessibilityApplicationShownNotification,
// window notifications
NSAccessibilityWindowCreatedNotification,
NSAccessibilityWindowMovedNotification,
NSAccessibilityWindowResizedNotification,
NSAccessibilityWindowMiniaturizedNotification,
NSAccessibilityWindowDeminiaturizedNotification,
// new drawer, sheet, and help tag notifications
NSAccessibilityDrawerCreatedNotification,
NSAccessibilitySheetCreatedNotification,
NSAccessibilityHelpTagCreatedNotification,
// element notifications
NSAccessibilityValueChangedNotification,
NSAccessibilityUIElementDestroyedNotification,
// menu notifications
(NSString*)kAXMenuOpenedNotification,
(NSString*)kAXMenuClosedNotification,
(NSString*)kAXMenuItemSelectedNotification,
// table/outline notifications
NSAccessibilityRowCountChangedNotification,
// other notifications
NSAccessibilitySelectedChildrenChangedNotification,
NSAccessibilityResizedNotification,
NSAccessibilityMovedNotification,
NSAccessibilityCreatedNotification,
NSAccessibilitySelectedRowsChangedNotification,
NSAccessibilitySelectedColumnsChangedNotification,
NSAccessibilitySelectedTextChangedNotification,
NSAccessibilityTitleChangedNotification,
// Webkit specific notifications.
@"AXLoadComplete",
nil]);
}
// Observe AX notifications on element and all descendants.
void SetAllObserversOnDescendants(
AXUIElementRef element,
AXObserverRef observerRef) {
SetAllObservers(element, observerRef);
CFTypeRef childrenRef;
if ((AXUIElementCopyAttributeValue(
element, kAXChildrenAttribute, &childrenRef)) == kAXErrorSuccess) {
NSArray* children = (NSArray*)childrenRef;
for (uint32 i = 0; i < [children count]; ++i) {
SetAllObserversOnDescendants(
(AXUIElementRef)[children objectAtIndex:i], observerRef);
}
}
}
// Add observers for all notifications we know about.
void SetAllObservers(
AXUIElementRef element,
AXObserverRef observerRef) {
for (NSString* notification in observedNotifications_.get()) {
AXObserverAddNotification(
observerRef, element, (CFStringRef)notification, this);
}
}
// Used to keep track of events received during the lifetime of the tests.
scoped_nsobject<NSMutableArray> expectedEvents_;
// NSString collection of all AX notifications.
scoped_nsobject<NSArray> observedNotifications_;
};
// Timing out frequently. http://crbug.com/98388
TEST_F(AccessibilityMacUITest, DISABLED_TestInitialPageNotifications) {
// Browse to a new page.
GURL tree_url(
"data:text/html,<html><head><title>Accessibility Mac Test</title></head>"
"<body><input type='button' value='push' /><input type='checkbox' />"
"</body></html>");
NavigateToURLAsync(tree_url);
// Test for navigation.
AddExpectedEvent(@"AXLoadComplete");
// Check all the expected Mac notifications.
WaitAndAssertAllEventsObserved();
}
......@@ -449,7 +449,8 @@
'chrome_resources.gyp:chrome_strings',
'debugger',
'test_support_common',
'test_support_ui',
# NOTE: don't add test_support_ui, no more UITests. See
# http://crbug.com/137365
'../third_party/hunspell/hunspell.gyp:hunspell',
'../net/net.gyp:net',
'../net/net.gyp:net_resources',
......@@ -473,7 +474,6 @@
'BROWSER_TESTS_HEADER_OVERRIDE="chrome/test/base/in_process_browser_test.h"',
],
'sources': [
'browser/accessibility/accessibility_mac_uitest.mm',
'browser/browser_focus_uitest.cc',
'browser/browser_keyevents_browsertest.cc',
'browser/instant/instant_browsertest.cc',
......@@ -489,7 +489,6 @@
'browser/ui/panels/panel_resize_browsertest.cc',
'browser/ui/views/bookmarks/bookmark_bar_view_test.cc',
'browser/ui/views/button_dropdown_test.cc',
'browser/ui/views/constrained_window_views_browsertest.cc',
'browser/ui/views/find_bar_host_interactive_uitest.cc',
'browser/ui/views/menu_item_view_test.cc',
'browser/ui/views/menu_model_adapter_test.cc',
......@@ -497,7 +496,6 @@
'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc',
'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h',
'browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc',
'browser/ui/webui/inspect_ui_browsertest.cc',
'test/base/chrome_test_launcher.cc',
'test/base/view_event_test_base.cc',
'test/base/view_event_test_base.h',
......@@ -657,7 +655,6 @@
}, # configurations
}, { # else: OS != "win"
'sources!': [
'browser/ui/views/constrained_window_views_browsertest.cc',
'browser/ui/views/ssl_client_certificate_selector_browsertest.cc',
],
}], # OS != "win"
......@@ -2852,6 +2849,7 @@
'browser/ui/views/ash/caps_lock_handler_browsertest.cc',
'browser/ui/views/ash/launcher/launcher_favicon_loader_browsertest.cc',
'browser/ui/views/browser_actions_container_browsertest.cc',
'browser/ui/views/constrained_window_views_browsertest.cc',
'browser/ui/views/frame/app_non_client_frame_view_aura_browsertest.cc',
'browser/ui/views/select_file_dialog_extension_browsertest.cc',
'browser/ui/views/sync/one_click_signin_bubble_view_browsertest.cc',
......@@ -2863,6 +2861,7 @@
'browser/ui/webui/bidi_checker_web_ui_test.h',
'browser/ui/webui/bookmarks_ui_browsertest.cc',
'browser/ui/webui/extensions/extension_settings_browsertest.js',
'browser/ui/webui/inspect_ui_browsertest.cc',
'browser/ui/webui/net_internals/net_internals_ui_browsertest.cc',
'browser/ui/webui/net_internals/net_internals_ui_browsertest.h',
'browser/ui/webui/ntp/new_tab_ui_browsertest.cc',
......@@ -2941,7 +2940,7 @@
'test/data/webui/print_preview.cc',
'test/data/webui/print_preview.h',
'test/data/webui/print_preview.js',
'test/data/webui/suidsandbox_browsertest.js',
'test/data/webui/suidsandbox_browsertest.js',
'test/gpu/gpu_feature_browsertest.cc',
'test/security_tests/sandbox_browsertest.cc',
'test/ui/ppapi_uitest.cc',
......@@ -3179,6 +3178,7 @@
'app/chrome_version.rc.version',
# TODO(port): http://crbug.com/45770
'browser/printing/printing_layout_browsertest.cc',
'browser/ui/views/constrained_window_views_browsertest.cc',
],
}],
['toolkit_uses_gtk == 1', {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment