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

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: Removed empty lines from render_view_browsertest_mac.mm 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_);
Alexei Svitkine (slow) 2014/06/25 13:58:29 Nit: Move this closer to where it's used - i.e. ri
165
166 const int kMaxOutputCharacters = 1024;
167 base::string16 select_all_text;
168 base::string16 output;
Alexei Svitkine (slow) 2014/06/25 13:58:29 Nit: Move this closer to where it's used - i.e. yo
169
170 view->set_send_content_state_immediately(true);
171 LoadHTML(kRawHtml);
172 render_thread_->sink().ClearMessages();
173 // contentAsText doesn't depend on scroll position or focussed frame location
174 // hence the returned value would be same throughout.
175 // Scroll down further.
176 ExecuteJavaScript("window.scrollTo(0, 9030)");
177 // Execute a command to Select all text in DOM.
178 ExecuteJavaScript("document.execCommand('SelectAll', false, null)");
179 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
180 select_all_text = GetMainFrame()->selectionAsText();
181 EXPECT_EQ(output, select_all_text);
182 }
183
143 } // namespace content 184 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698