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

Unified Diff: content/renderer/render_view_browsertest_mac.mm

Issue 342143004: Defect 248426: Speak rendered text when no selection is made on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uploading a clean patch Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_browsertest_mac.mm
diff --git a/content/renderer/render_view_browsertest_mac.mm b/content/renderer/render_view_browsertest_mac.mm
index b2473c6f40a1d443bd9c42ebe455600c6c24a897..c33abed959fc7f49878098b9e96a73f4dd622b88 100644
--- a/content/renderer/render_view_browsertest_mac.mm
+++ b/content/renderer/render_view_browsertest_mac.mm
@@ -140,4 +140,42 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
EXPECT_EQ(kArrowUpNoScroll, base::UTF16ToASCII(output));
}
+TEST_F(RenderViewTest, OnTtsForEmptySelection) {
jeremy 2014/06/29 11:38:55 I'm sorry but I don't understand this test. Can yo
sarka 2014/06/30 16:18:04 The patch uses contentAsText to receive web page c
+ #define HTML(s) #s
+ const char* kRawHtml = HTML(
+ <!DOCTYPE html>
+ <style>
+ /* Add a vertical scrollbar */
+ body { height: 10128px; }
+ </style>
+ <div id='text'>
+ <p> A "Hello World" program has become the traditional first program that
+ many people learn. In general it is simple enough so that people who
+ experience with computer programming can easily understand it especially
+ the guidance of a teacher a written guide. Using this simple program
+ basis computer science principles elements of a specific programming
+ language can be explained to novice programmers. Experienced programmers
+ learning languages can also gain a lot of information about a given
+ languages syntax structure from a hello world program. </p>
+ </div>
+ );
+ #undef HTML
+
+ RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
+ view->set_send_content_state_immediately(true);
+ LoadHTML(kRawHtml);
+ render_thread_->sink().ClearMessages();
+ // contentAsText doesn't depend on scroll position or focussed frame location
+ // hence the returned value would be same throughout.
+ // Scroll down further.
+ ExecuteJavaScript("window.scrollTo(0, 9030)");
+ // Execute a command to Select all text in DOM.
+ ExecuteJavaScript("document.execCommand('SelectAll', false, null)");
+
+ const int kMaxOutputCharacters = 1024;
+ base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
+ base::string16 select_all_text = GetMainFrame()->selectionAsText();
+ EXPECT_EQ(output, select_all_text);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698