diff options
author | evy@chromium.org <evy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-14 08:06:27 +0000 |
---|---|---|
committer | evy@chromium.org <evy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-14 08:06:27 +0000 |
commit | d4944ce50da6d37e1af68d90b3a3e3ef6566c712 (patch) | |
tree | c34d6f4cfc343cbe1d5ae0861a54defd02a4a600 | |
parent | 564fb182e457e13cc2529e198262d3c9a41b6a52 (diff) | |
download | chromium_src-d4944ce50da6d37e1af68d90b3a3e3ef6566c712.zip chromium_src-d4944ce50da6d37e1af68d90b3a3e3ef6566c712.tar.gz chromium_src-d4944ce50da6d37e1af68d90b3a3e3ef6566c712.tar.bz2 |
Test that simulates touch exploration and checks speech on tabs and also the empty bookmark bar.
BUG=393768, 395895
Review URL: https://codereview.chromium.org/447893003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289488 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 113 insertions, 18 deletions
diff --git a/chrome/browser/chromeos/accessibility/accessibility_util.cc b/chrome/browser/chromeos/accessibility/accessibility_util.cc index 3d2d95d..949b9f2 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_util.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_util.cc @@ -7,8 +7,13 @@ #include "base/prefs/pref_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/ui/singleton_tabs.h" +#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "content/public/test/browser_test_utils.h" +#include "extensions/browser/extension_host.h" +#include "extensions/browser/extension_system.h" +#include "extensions/browser/process_manager.h" #include "url/gurl.h" // TODO(yoshiki): move the following method to accessibility_manager.cc and @@ -38,5 +43,20 @@ void ShowAccessibilityHelp(Browser* browser) { chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); } + +void SimulateTouchScreenInChromeVoxForTest(content::BrowserContext* profile) { + // ChromeVox looks at whether 'ontouchstart' exists to know whether or not it + // should respond to hover events. Fake it so that touch exploration events + // get spoken. + extensions::ExtensionHost* host = + extensions::ExtensionSystem::Get(profile) + ->process_manager() + ->GetBackgroundHostForExtension( + extension_misc::kChromeVoxExtensionId); + CHECK(content::ExecuteScript( + host->host_contents(), + "if (!('ontouchstart' in window)) window.ontouchstart = function() {};")); +} + } // namespace accessibility } // namespace chromeos diff --git a/chrome/browser/chromeos/accessibility/accessibility_util.h b/chrome/browser/chromeos/accessibility/accessibility_util.h index 7f70312..b4d2e58 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_util.h +++ b/chrome/browser/chromeos/accessibility/accessibility_util.h @@ -7,6 +7,10 @@ class Browser; +namespace content { +class BrowserContext; +} + namespace chromeos { namespace accessibility { @@ -19,6 +23,8 @@ bool IsVirtualKeyboardEnabled(); // Shows the accessibility help tab on the browser. void ShowAccessibilityHelp(Browser* browser); +void SimulateTouchScreenInChromeVoxForTest(content::BrowserContext* profile); + } // namespace accessibility } // namespace chromeos diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc index 56108d6..5cfb990 100644 --- a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc +++ b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc @@ -10,6 +10,7 @@ #include "base/strings/string_util.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "chrome/browser/chromeos/accessibility/accessibility_util.h" #include "chrome/browser/chromeos/accessibility/speech_monitor.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" @@ -22,7 +23,6 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/extensions/extension_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/testing_profile.h" @@ -32,8 +32,6 @@ #include "content/public/common/url_constants.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_utils.h" -#include "extensions/browser/extension_host.h" -#include "extensions/browser/process_manager.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/test/ui_controls.h" #include "ui/views/widget/widget.h" @@ -67,19 +65,6 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest { root_window, key, false, false, false, false)); } - void SimulateTouchScreenInChromeVox() { - // ChromeVox looks at whether 'ontouchstart' exists to know whether - // or not it should respond to hover events. Fake it so that touch - // exploration events get spoken. - extensions::ExtensionHost* host = - extensions::ExtensionSystem::Get(browser()->profile())-> - process_manager()->GetBackgroundHostForExtension( - extension_misc::kChromeVoxExtensionId); - CHECK(content::ExecuteScript( - host->host_contents(), - "window.ontouchstart = function() {};")); - } - private: StubBrailleController braille_controller_; DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest); @@ -232,7 +217,7 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) { true, ash::A11Y_NOTIFICATION_NONE); EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); - SimulateTouchScreenInChromeVox(); + accessibility::SimulateTouchScreenInChromeVoxForTest(browser()->profile()); // Send an accessibility hover event on the system tray, which is // what we get when you tap it on a touch screen when ChromeVox is on. diff --git a/chrome/browser/ui/views/accessibility/spoken_feedback_chromeos_views_browsertest.cc b/chrome/browser/ui/views/accessibility/spoken_feedback_chromeos_views_browsertest.cc new file mode 100644 index 0000000..7574285 --- /dev/null +++ b/chrome/browser/ui/views/accessibility/spoken_feedback_chromeos_views_browsertest.cc @@ -0,0 +1,72 @@ +// Copyright 2014 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/strings/string_util.h" +#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "chrome/browser/chromeos/accessibility/accessibility_util.h" +#include "chrome/browser/chromeos/accessibility/speech_monitor.h" +#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/views/tabs/tab_strip.h" +#include "chrome/test/base/in_process_browser_test.h" + +// There are spoken feedback tests in browser/chromeos/accessibility but +// these tests rely on browser views, so they have been placed in this file +// in the views directory. The shared function between the spoken feedback +// tests that simulates the touch screen with ChromeVox is kept in the +// accessiblity utils file. +typedef InProcessBrowserTest SpokenFeedbackViewsTest; + +namespace chromeos { + +// Fetch the bookmark bar instructions view from the browser and trigger an +// accessibilty event on the view to ensure the correct text is being read. +IN_PROC_BROWSER_TEST_F(SpokenFeedbackViewsTest, + TouchExploreBookmarkBarInstructions) { + ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); + SpeechMonitor monitor; + AccessibilityManager::Get()->EnableSpokenFeedback( + true, ash::A11Y_NOTIFICATION_NONE); + EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); + + accessibility::SimulateTouchScreenInChromeVoxForTest(browser()->profile()); + + // Send an accessibility hover event on the empty bookmarks bar, which is + // what we get when you tap it on a touch screen when ChromeVox is on. + BrowserView* browser_view = + static_cast<BrowserView*>(browser()->window()); + BookmarkBarView* bookmarks_bar = browser_view->GetBookmarkBarView(); + views::View* instructions = bookmarks_bar->GetBookmarkBarInstructionsView(); + instructions->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); + + EXPECT_EQ("Bookmarks,", monitor.GetNextUtterance()); + EXPECT_EQ("For quick access,", monitor.GetNextUtterance()); + EXPECT_EQ("place your bookmarks here on the bookmarks bar.", + monitor.GetNextUtterance()); +} + +// Fetch a tab view from the browser and trigger an accessibilty event on the +// view to ensure the correct text is being read. +IN_PROC_BROWSER_TEST_F(SpokenFeedbackViewsTest, TouchExploreTabs) { + ASSERT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); + SpeechMonitor monitor; + AccessibilityManager::Get()->EnableSpokenFeedback( + true, ash::A11Y_NOTIFICATION_NONE); + EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); + + accessibility::SimulateTouchScreenInChromeVoxForTest(browser()->profile()); + + // Send an accessibility hover event on a tab in the tap strip, which is + // what we get when you tap it on a touch screen when ChromeVox is on. + BrowserView* browser_view = + static_cast<BrowserView*>(browser()->window()); + TabStrip* tab_strip = browser_view->tabstrip(); + ASSERT_EQ(tab_strip->tab_count(), 1); + + Tab* tab = tab_strip->tab_at(0); + tab->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); + EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*, tab * of *")); +} + +} // namespace chromeos diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 7292a6e..25af20a 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -626,6 +626,12 @@ views::MenuItemView* BookmarkBarView::GetDropMenu() { return bookmark_drop_menu_ ? bookmark_drop_menu_->menu() : NULL; } +views::View* BookmarkBarView::GetBookmarkBarInstructionsView() { + if (instructions_->visible()) + return instructions_; + return NULL; +} + void BookmarkBarView::StopThrobbing(bool immediate) { if (!throbbing_view_) return; diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h index 8c072bd..5d6d8a6 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h @@ -142,6 +142,9 @@ class BookmarkBarView : public DetachableToolbarView, // Returns the drop MenuItemView, or NULL if a menu isn't showing. views::MenuItemView* GetDropMenu(); + // Returns the BookmarkBarInstructionView, or NULL if it isn't showing. + views::View* GetBookmarkBarInstructionsView(); + // If a button is currently throbbing, it is stopped. If immediate is true // the throb stops immediately, otherwise it stops after a couple more // throbs. diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index b81c557..851f26b 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -280,6 +280,8 @@ }], ], 'sources': [ + 'browser/chromeos/accessibility/accessibility_util.cc', + 'browser/chromeos/accessibility/accessibility_util.h', 'browser/chromeos/accessibility/speech_monitor.cc', 'browser/chromeos/accessibility/speech_monitor.h', 'browser/chromeos/accessibility/spoken_feedback_browsertest.cc', @@ -302,6 +304,7 @@ 'browser/chromeos/login/users/wallpaper/wallpaper_manager_browsertest.cc', 'browser/chromeos/login/users/wallpaper/wallpaper_manager_test_utils.cc', 'browser/chromeos/login/users/wallpaper/wallpaper_manager_test_utils.h', + 'browser/ui/views/accessibility/spoken_feedback_chromeos_views_browsertest.cc', 'test/data/chromeos/service_login.html', ], 'sources!': [ diff --git a/chrome/common/extensions/api/accessibility_private.json b/chrome/common/extensions/api/accessibility_private.json index bdc3520..18c8e9d 100644 --- a/chrome/common/extensions/api/accessibility_private.json +++ b/chrome/common/extensions/api/accessibility_private.json @@ -131,7 +131,7 @@ "type": { "type": "string", "description": "The type of this object, which determines the contents of 'details'.", - "enum": ["alert", "button", "checkbox", "combobox", "link", "menu", "menuitem", "radiobutton", "slider", "tab", "textbox", "tree", "treeitem", "window"] + "enum": ["alert", "button", "checkbox", "combobox", "link", "menu", "menuitem", "radiobutton", "slider", "statictext", "tab", "textbox", "tree", "treeitem", "window"] }, "name": { "type": "string", |