Index: chrome/browser/chromeos/accessibility/select_to_speak_browsertest.cc |
diff --git a/chrome/browser/chromeos/accessibility/select_to_speak_browsertest.cc b/chrome/browser/chromeos/accessibility/select_to_speak_browsertest.cc |
index c6cfad40190fd2db96175e636ba1e50274d61fca..89a64fe0b5cf902724220378d121564f9a2a2a38 100644 |
--- a/chrome/browser/chromeos/accessibility/select_to_speak_browsertest.cc |
+++ b/chrome/browser/chromeos/accessibility/select_to_speak_browsertest.cc |
@@ -7,11 +7,17 @@ |
#include "base/strings/pattern.h" |
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
#include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_window.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/ui_test_utils.h" |
+#include "content/public/browser/browser_accessibility_state.h" |
#include "content/public/browser/notification_details.h" |
#include "content/public/browser/notification_service.h" |
+#include "content/public/test/browser_test_utils.h" |
#include "extensions/browser/notification_types.h" |
+#include "net/dns/mock_host_resolver.h" |
#include "ui/events/test/event_generator.h" |
#include "url/url_constants.h" |
@@ -60,4 +66,78 @@ IN_PROC_BROWSER_TEST_F(SelectToSpeakTest, SpeakStatusTray) { |
base::MatchPattern(speech_monitor_.GetNextUtterance(), "Status tray*")); |
} |
+class SelectToSpeakManualTest : public SelectToSpeakTest { |
+ protected: |
+ void SetUpInProcessBrowserTestFixture() override { |
+ // To avoid depending on external resources, browser tests don't allow |
+ // non-local DNS queries by default. Override this for this specific |
+ // manual test suite. |
+ scoped_refptr<net::RuleBasedHostResolverProc> resolver = |
+ new net::RuleBasedHostResolverProc(host_resolver()); |
+ resolver->AllowDirectLookup("*.google.com"); |
+ resolver->AllowDirectLookup("*.gstatic.com"); |
+ mock_host_resolver_override_.reset( |
+ new net::ScopedDefaultHostResolverProc(resolver.get())); |
+ } |
+ |
+ void TearDownInProcessBrowserTestFixture() override { |
+ mock_host_resolver_override_.reset(); |
+ } |
+ |
+ private: |
+ std::unique_ptr<net::ScopedDefaultHostResolverProc> |
+ mock_host_resolver_override_; |
+}; |
+ |
+// This is a sanity check / integration test that Select-to-speak works |
+// with Google Docs, since we have a small amount of code that works |
+// around a compatibility issue. |
+// |
+// It's a manual test because we don't want Docs outages to affect the |
+// Chrome waterfall. |
+// |
+// To run manually: |
+// |
+// interactive_ui_tests \ |
+// --gtest_filter="SelectToSpeakManualTest.MANUAL_GoogleDocsSupport" \ |
+// --run-manual |
+// |
+// To visually see what's happening while the test is running, |
+// add this option too: |
+// --enable-pixel-output-in-tests |
+IN_PROC_BROWSER_TEST_F(SelectToSpeakManualTest, MANUAL_GoogleDocsSupport) { |
+ const char* kGoogleDocsUrl = |
+ "https://docs.google.com/document/d/" |
+ "1qpu3koSIHpBzQbxeEE-dofSKXCIgdc4yJLI-o1LpCPs/view"; |
+ const char* kTextFoundInGoogleDoc = "Long-string-to-test-select-to-speak"; |
+ |
+ content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); |
+ |
+ ui_test_utils::NavigateToURL(browser(), GURL(kGoogleDocsUrl)); |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::EnableAccessibilityForWebContents(web_contents); |
+ |
+ LOG(INFO) << "Waiting for Google Doc to load"; |
David Tseng
2017/05/10 16:26:36
Remove logging.
dmazzoni
2017/05/17 05:33:38
Done.
|
+ content::WaitForAccessibilityTreeToContainNodeWithName( |
+ web_contents, "Long-string-to-test-select-to-speak"); |
+ |
+ LOG(INFO) << "Doc loaded, triggering select-to-speak"; |
David Tseng
2017/05/10 16:26:36
Remove logging.
dmazzoni
2017/05/17 05:33:38
Done.
|
+ gfx::Rect bounds = browser()->window()->GetBounds(); |
+ generator_->PressKey(ui::VKEY_LWIN, 0 /* flags */); |
+ generator_->MoveMouseTo(bounds.x() + 8, bounds.y() + 200); |
+ generator_->PressLeftButton(); |
+ generator_->MoveMouseTo(bounds.x() + bounds.width() - 8, |
+ bounds.y() + bounds.height() - 8); |
+ generator_->ReleaseLeftButton(); |
+ generator_->ReleaseKey(ui::VKEY_LWIN, 0 /* flags */); |
+ |
+ for (;;) { |
+ std::string utterance = speech_monitor_.GetNextUtterance(); |
+ LOG(INFO) << "Utterance: '" << utterance << "'"; |
David Tseng
2017/05/10 16:26:36
Remove logging.
dmazzoni
2017/05/17 05:33:38
Done.
|
+ if (utterance == kTextFoundInGoogleDoc) |
+ break; |
+ } |
+} |
+ |
} // namespace chromeos |