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

Side by Side 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: Changed message size from Renderer to Browser for a TTS session to something resonable ~8.5 mb. Created 6 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/strings/string16.h" 5 #include "base/strings/string16.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/native_web_keyboard_event.h" 8 #include "content/public/browser/native_web_keyboard_event.h"
9 #include "content/public/test/render_view_test.h" 9 #include "content/public/test/render_view_test.h"
10 #include "content/renderer/render_view_impl.h" 10 #include "content/renderer/render_view_impl.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 const char* kArrowUpNoScroll = "38,false,false,true,false\n100\np1"; 133 const char* kArrowUpNoScroll = "38,false,false,true,false\n100\np1";
134 view->OnSetEditCommandsForNextKeyEvent( 134 view->OnSetEditCommandsForNextKeyEvent(
135 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); 135 EditCommands(1, EditCommand("moveToBeginningOfDocument", "")));
136 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); 136 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown));
137 ProcessPendingMessages(); 137 ProcessPendingMessages();
138 ExecuteJavaScript("scroll.textContent = window.pageYOffset"); 138 ExecuteJavaScript("scroll.textContent = window.pageYOffset");
139 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); 139 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
140 EXPECT_EQ(kArrowUpNoScroll, base::UTF16ToASCII(output)); 140 EXPECT_EQ(kArrowUpNoScroll, base::UTF16ToASCII(output));
141 } 141 }
142 142
143 TEST_F(RenderViewTest, OnTtsForEmptySelection) {
144 #define HTML(s) #s
145 const char* kRawHtml = HTML(
146 <!DOCTYPE html>
147 <style>
148 /* Add a vertical scrollbar */
149 body { height: 10128px; }
150 </style>
151 <div id='text'>
152 <p> A "Hello World" program has become the traditional first program that
153 many people learn. In general it is simple enough so that people who
154 experience with computer programming can easily understand it especially
155 the guidance of a teacher a written guide. Using this simple program
156 basis computer science principles elements of a specific programming
157 language can be explained to novice programmers. Experienced programmers
158 learning languages can also gain a lot of information about a given
159 languages syntax structure from a hello world program. </p>
160 </div>
161 );
162 #undef HTML
163
164 RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
165 view->set_send_content_state_immediately(true);
166 LoadHTML(kRawHtml);
167 render_thread_->sink().ClearMessages();
168
169 // Execute a command to Select all text in DOM.
170 ExecuteJavaScript("document.execCommand('SelectAll', false, null)");
171
172 const int kMaxOutputCharacters = 1024;
173 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
174 base::string16 select_all_text = GetMainFrame()->selectionAsText();
175 EXPECT_EQ(output, select_all_text);
176 }
177
143 } // namespace content 178 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698