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

Side by Side Diff: chrome/renderer/translate/page_translator_unittest.cc

Issue 577032: The translate feature was only translating the main frame of the page.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/translate/page_translator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/renderer/translate/page_translator.h" 8 #include "chrome/renderer/translate/page_translator.h"
9 #include "chrome/test/render_view_test.h" 9 #include "chrome/test/render_view_test.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 static_cast<int>(size))); 162 static_cast<int>(size)));
163 buffer[static_cast<size_t>(size)] = '\0'; 163 buffer[static_cast<size_t>(size)] = '\0';
164 LoadHTML(buffer.get()); 164 LoadHTML(buffer.get());
165 165
166 WebKit::WebFrame* web_frame = GetMainFrame(); 166 WebKit::WebFrame* web_frame = GetMainFrame();
167 ASSERT_TRUE(web_frame); 167 ASSERT_TRUE(web_frame);
168 168
169 // Translate it. 169 // Translate it.
170 ReverseTextTranslator text_translator; 170 ReverseTextTranslator text_translator;
171 PageTranslator translator(&text_translator, NULL); 171 PageTranslator translator(&text_translator, NULL);
172 translator.Translate(0, web_frame, "en", "fr"); 172 translator.TranslatePage(0, web_frame, "en", "fr");
173 173
174 // Translation is asynchronous, so we need to process the pending messages 174 // Translation is asynchronous, so we need to process the pending messages
175 // to make it happen. 175 // to make it happen.
176 MessageLoop::current()->RunAllPending(); 176 MessageLoop::current()->RunAllPending();
177 177
178 WebKit::WebString actual_translated_contents = web_frame->contentAsMarkup(); 178 WebKit::WebString actual_translated_contents = web_frame->contentAsMarkup();
179 179
180 // Load the translated page. 180 // Load the translated page.
181 ASSERT_TRUE(file_util::GetFileSize(translated_file_path, &size)); 181 ASSERT_TRUE(file_util::GetFileSize(translated_file_path, &size));
182 buffer.reset(new char[static_cast<size_t>(size) + 1]); 182 buffer.reset(new char[static_cast<size_t>(size) + 1]);
(...skipping 20 matching lines...) Expand all
203 string16 expected(expected_translated_contents.data() + index, len); 203 string16 expected(expected_translated_contents.data() + index, len);
204 string16 actual(actual_translated_contents.data() + index, len); 204 string16 actual(actual_translated_contents.data() + index, len);
205 ASSERT_EQ(expected, actual); 205 ASSERT_EQ(expected, actual);
206 index += 80; 206 index += 80;
207 } 207 }
208 208
209 // Iterate to the next file to test. 209 // Iterate to the next file to test.
210 original_file_path = file_enumerator.Next(); 210 original_file_path = file_enumerator.Next();
211 } 211 }
212 } 212 }
OLDNEW
« no previous file with comments | « chrome/renderer/translate/page_translator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698