Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/chromeos/accessibility/select_to_speak_browsertest.cc

Issue 2795633002: Make select-to-speak work with Google Docs. (Closed)
Patch Set: Add manual test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/select_to_speak/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "ash/shell.h" 5 #include "ash/shell.h"
6 #include "ash/system/tray/system_tray.h" 6 #include "ash/system/tray/system_tray.h"
7 #include "base/strings/pattern.h" 7 #include "base/strings/pattern.h"
8 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 8 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
9 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" 9 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/browser_accessibility_state.h"
12 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
13 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/test/browser_test_utils.h"
14 #include "extensions/browser/notification_types.h" 19 #include "extensions/browser/notification_types.h"
20 #include "net/dns/mock_host_resolver.h"
15 #include "ui/events/test/event_generator.h" 21 #include "ui/events/test/event_generator.h"
16 #include "url/url_constants.h" 22 #include "url/url_constants.h"
17 23
18 namespace chromeos { 24 namespace chromeos {
19 25
20 class SelectToSpeakTest : public InProcessBrowserTest { 26 class SelectToSpeakTest : public InProcessBrowserTest {
21 protected: 27 protected:
22 SelectToSpeakTest() {} 28 SelectToSpeakTest() {}
23 ~SelectToSpeakTest() override {} 29 ~SelectToSpeakTest() override {}
24 30
(...skipping 28 matching lines...) Expand all
53 generator_->PressKey(ui::VKEY_LWIN, 0 /* flags */); 59 generator_->PressKey(ui::VKEY_LWIN, 0 /* flags */);
54 generator_->MoveMouseTo(tray_bounds.x() + 8, tray_bounds.y() + 8); 60 generator_->MoveMouseTo(tray_bounds.x() + 8, tray_bounds.y() + 8);
55 generator_->PressLeftButton(); 61 generator_->PressLeftButton();
56 generator_->ReleaseLeftButton(); 62 generator_->ReleaseLeftButton();
57 generator_->ReleaseKey(ui::VKEY_LWIN, 0 /* flags */); 63 generator_->ReleaseKey(ui::VKEY_LWIN, 0 /* flags */);
58 64
59 EXPECT_TRUE( 65 EXPECT_TRUE(
60 base::MatchPattern(speech_monitor_.GetNextUtterance(), "Status tray*")); 66 base::MatchPattern(speech_monitor_.GetNextUtterance(), "Status tray*"));
61 } 67 }
62 68
69 class SelectToSpeakManualTest : public SelectToSpeakTest {
70 protected:
71 void SetUpInProcessBrowserTestFixture() override {
72 // To avoid depending on external resources, browser tests don't allow
73 // non-local DNS queries by default. Override this for this specific
74 // manual test suite.
75 scoped_refptr<net::RuleBasedHostResolverProc> resolver =
76 new net::RuleBasedHostResolverProc(host_resolver());
77 resolver->AllowDirectLookup("*.google.com");
78 resolver->AllowDirectLookup("*.gstatic.com");
79 mock_host_resolver_override_.reset(
80 new net::ScopedDefaultHostResolverProc(resolver.get()));
81 }
82
83 void TearDownInProcessBrowserTestFixture() override {
84 mock_host_resolver_override_.reset();
85 }
86
87 private:
88 std::unique_ptr<net::ScopedDefaultHostResolverProc>
89 mock_host_resolver_override_;
90 };
91
92 // This is a sanity check / integration test that Select-to-speak works
93 // with Google Docs, since we have a small amount of code that works
94 // around a compatibility issue.
95 //
96 // It's a manual test because we don't want Docs outages to affect the
97 // Chrome waterfall.
98 //
99 // To run manually:
100 //
101 // interactive_ui_tests \
102 // --gtest_filter="SelectToSpeakManualTest.MANUAL_GoogleDocsSupport" \
103 // --run-manual
104 //
105 // To visually see what's happening while the test is running,
106 // add this option too:
107 // --enable-pixel-output-in-tests
108 IN_PROC_BROWSER_TEST_F(SelectToSpeakManualTest, MANUAL_GoogleDocsSupport) {
109 const char* kGoogleDocsUrl =
110 "https://docs.google.com/document/d/"
111 "1qpu3koSIHpBzQbxeEE-dofSKXCIgdc4yJLI-o1LpCPs/view";
112 const char* kTextFoundInGoogleDoc = "Long-string-to-test-select-to-speak";
113
114 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility();
115
116 ui_test_utils::NavigateToURL(browser(), GURL(kGoogleDocsUrl));
117 content::WebContents* web_contents =
118 browser()->tab_strip_model()->GetActiveWebContents();
119 content::EnableAccessibilityForWebContents(web_contents);
120
121 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.
122 content::WaitForAccessibilityTreeToContainNodeWithName(
123 web_contents, "Long-string-to-test-select-to-speak");
124
125 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.
126 gfx::Rect bounds = browser()->window()->GetBounds();
127 generator_->PressKey(ui::VKEY_LWIN, 0 /* flags */);
128 generator_->MoveMouseTo(bounds.x() + 8, bounds.y() + 200);
129 generator_->PressLeftButton();
130 generator_->MoveMouseTo(bounds.x() + bounds.width() - 8,
131 bounds.y() + bounds.height() - 8);
132 generator_->ReleaseLeftButton();
133 generator_->ReleaseKey(ui::VKEY_LWIN, 0 /* flags */);
134
135 for (;;) {
136 std::string utterance = speech_monitor_.GetNextUtterance();
137 LOG(INFO) << "Utterance: '" << utterance << "'";
David Tseng 2017/05/10 16:26:36 Remove logging.
dmazzoni 2017/05/17 05:33:38 Done.
138 if (utterance == kTextFoundInGoogleDoc)
139 break;
140 }
141 }
142
63 } // namespace chromeos 143 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/select_to_speak/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698