diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 00:39:41 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 00:39:41 +0000 |
commit | 2ee0e7564803f87b195d63c497a1101a2b29ab4f (patch) | |
tree | 0795001761a54463b710c58799cc41655dd842c0 /chrome/browser/browser_accessibility_unittest.cc | |
parent | 3a51cfdd1775075f13dab50f6d8a9cb04bd6beb9 (diff) | |
download | chromium_src-2ee0e7564803f87b195d63c497a1101a2b29ab4f.zip chromium_src-2ee0e7564803f87b195d63c497a1101a2b29ab4f.tar.gz chromium_src-2ee0e7564803f87b195d63c497a1101a2b29ab4f.tar.bz2 |
Revert 46567 - Reimplement accessibility of web content by caching the entire
accessibility tree in the browser process.
Adds new RPCs for a browser tab to request accessibility info from
a renderer; the renderer responds with a complete tree of
accessibility metadata for the entire DOM, which is then cached
in the RenderWidgetHostView. This part is crossplatform and will
help with accessibility on both Windows and Mac OS X.
For Windows, MSAA support for web content has been rewritten to
use this new cache. Tested in JAWS and NVDA screen readers.
Using Chrome with a screen reader is now fast and stable,
unlike the previous implementation. However, note that most
advanced functionality is still not supported, and much work remains
to make Chrome work well with a screen reader. This is a necessary
step to improve stability first.
BUG=25564
BUG=13291
TEST=See http://codereview.chromium.org/1806001
Review URL: http://codereview.chromium.org/1637018
TBR=dmazzoni@chromium.org
Review URL: http://codereview.chromium.org/2031004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_accessibility_unittest.cc')
-rw-r--r-- | chrome/browser/browser_accessibility_unittest.cc | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/chrome/browser/browser_accessibility_unittest.cc b/chrome/browser/browser_accessibility_unittest.cc deleted file mode 100644 index f2429ea..0000000 --- a/chrome/browser/browser_accessibility_unittest.cc +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 2010 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. - -#include "base/scoped_ptr.h" -#include "chrome/browser/browser_accessibility_manager.h" -#include "chrome/browser/browser_accessibility.h" -#include "testing/gtest/include/gtest/gtest.h" - -using webkit_glue::WebAccessibility; - -// Subclass of BrowserAccessibility that counts the number of instances. -class CountedBrowserAccessibility : public BrowserAccessibility { - public: - CountedBrowserAccessibility() { global_obj_count_++; } - virtual ~CountedBrowserAccessibility() { global_obj_count_--; } - static int global_obj_count_; -}; - -int CountedBrowserAccessibility::global_obj_count_ = 0; - -// Factory that creates a CountedBrowserAccessibility. -class CountedBrowserAccessibilityFactory : public BrowserAccessibilityFactory { - public: - virtual ~CountedBrowserAccessibilityFactory() {} - virtual BrowserAccessibility* Create() { - CComObject<CountedBrowserAccessibility>* instance; - HRESULT hr = CComObject<CountedBrowserAccessibility>::CreateInstance( - &instance); - DCHECK(SUCCEEDED(hr)); - return instance->NewReference(); - } -}; - -// Test that BrowserAccessibilityManager correctly releases the tree of -// BrowserAccessibility instances upon delete. -TEST(BrowserAccessibilityTest, TestNoLeaks) { - // ATL needs a pointer to a COM module. - CComModule module; - _pAtlModule = &module; - // Make sure COM is initialized for this thread; it's safe to call twice. - ::CoInitialize(NULL); - - // Create WebAccessibility objects for a simple document tree, - // representing the accessibility information used to initialize - // BrowserAccessibilityManager. - WebAccessibility button; - button.id = 2; - button.name = L"Button"; - button.role = WebAccessibility::ROLE_PUSHBUTTON; - button.state = 0; - - WebAccessibility checkbox; - checkbox.id = 3; - checkbox.name = L"Checkbox"; - checkbox.role = WebAccessibility::ROLE_CHECKBUTTON; - checkbox.state = 0; - - WebAccessibility root; - root.id = 1; - root.name = L"Document"; - root.role = WebAccessibility::ROLE_DOCUMENT; - root.state = 0; - root.children.push_back(button); - root.children.push_back(checkbox); - - // Construct a BrowserAccessibilityManager with this WebAccessibility tree - // and a factory for an instance-counting BrowserAccessibility, and ensure - // that exactly 3 instances were created. Note that the manager takes - // ownership of the factory. - CountedBrowserAccessibility::global_obj_count_ = 0; - BrowserAccessibilityManager* manager = - new BrowserAccessibilityManager( - GetDesktopWindow(), root, new CountedBrowserAccessibilityFactory()); - ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); - - // Delete the manager and test that all 3 instances are deleted. - delete manager; - ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); - - // Construct a manager again, and this time use the IAccessible interface - // to get new references to two of the three nodes in the tree. - manager = new BrowserAccessibilityManager( - GetDesktopWindow(), root, new CountedBrowserAccessibilityFactory()); - ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); - BrowserAccessibility* root_accessible = manager->GetRoot(); - IDispatch* root_iaccessible = NULL; - IDispatch* child1_iaccessible = NULL; - VARIANT var_child; - var_child.vt = VT_I4; - var_child.lVal = CHILDID_SELF; - HRESULT hr = root_accessible->get_accChild(var_child, &root_iaccessible); - ASSERT_EQ(S_OK, hr); - var_child.lVal = 1; - hr = root_accessible->get_accChild(var_child, &child1_iaccessible); - ASSERT_EQ(S_OK, hr); - - // Now delete the manager, and only one of the three nodes in the tree - // should be released. - delete manager; - ASSERT_EQ(2, CountedBrowserAccessibility::global_obj_count_); - - // Release each of our references and make sure that each one results in - // the instance being deleted as its reference count hits zero. - root_iaccessible->Release(); - ASSERT_EQ(1, CountedBrowserAccessibility::global_obj_count_); - child1_iaccessible->Release(); - ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); -} |