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

Side by Side Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 1164823002: Remove URLRequestStatus mutators and introduce FromError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 28 matching lines...) Expand all
39 #include "components/translate/core/browser/translate_infobar_delegate.h" 39 #include "components/translate/core/browser/translate_infobar_delegate.h"
40 #include "content/public/browser/navigation_controller.h" 40 #include "content/public/browser/navigation_controller.h"
41 #include "content/public/browser/notification_observer.h" 41 #include "content/public/browser/notification_observer.h"
42 #include "content/public/browser/notification_registrar.h" 42 #include "content/public/browser/notification_registrar.h"
43 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
44 #include "content/public/browser/render_view_host.h" 44 #include "content/public/browser/render_view_host.h"
45 #include "content/public/browser/render_widget_host.h" 45 #include "content/public/browser/render_widget_host.h"
46 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
47 #include "content/public/test/browser_test_utils.h" 47 #include "content/public/test/browser_test_utils.h"
48 #include "content/public/test/test_renderer_host.h" 48 #include "content/public/test/test_renderer_host.h"
49 #include "net/base/net_errors.h"
49 #include "net/url_request/test_url_fetcher_factory.h" 50 #include "net/url_request/test_url_fetcher_factory.h"
51 #include "net/url_request/url_request_status.h"
50 #include "testing/gmock/include/gmock/gmock.h" 52 #include "testing/gmock/include/gmock/gmock.h"
51 #include "testing/gtest/include/gtest/gtest.h" 53 #include "testing/gtest/include/gtest/gtest.h"
52 #include "ui/events/keycodes/keyboard_codes.h" 54 #include "ui/events/keycodes/keyboard_codes.h"
53 55
54 using base::ASCIIToUTF16; 56 using base::ASCIIToUTF16;
55 57
56 namespace autofill { 58 namespace autofill {
57 59
58 static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; 60 static const char kDataURIPrefix[] = "data:text/html;charset=utf-8,";
59 static const char kTestFormString[] = 61 static const char kTestFormString[] =
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 GetWebContents(), 216 GetWebContents(),
215 "window.domAutomationController.send(" 217 "window.domAutomationController.send("
216 " document.defaultView.getComputedStyle(document.getElementById('" + 218 " document.defaultView.getComputedStyle(document.getElementById('" +
217 field_name + "')).backgroundColor);", 219 field_name + "')).backgroundColor);",
218 color)); 220 color));
219 } 221 }
220 222
221 void SimulateURLFetch(bool success) { 223 void SimulateURLFetch(bool success) {
222 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 224 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
223 ASSERT_TRUE(fetcher); 225 ASSERT_TRUE(fetcher);
224 net::URLRequestStatus status; 226 int error = success ? net::OK : net::ERR_FAILED;
mmenke 2015/06/02 18:41:33 Suggest making these net::Errors - not the current
davidben 2015/06/02 19:19:42 Done. Should I also change URLRequestStatus? I lef
mmenke 2015/06/02 19:22:25 I guess we never store (Or *should* never store) b
225 status.set_status(success ? net::URLRequestStatus::SUCCESS :
226 net::URLRequestStatus::FAILED);
227 227
228 std::string script = " var google = {};" 228 std::string script = " var google = {};"
229 "google.translate = (function() {" 229 "google.translate = (function() {"
230 " return {" 230 " return {"
231 " TranslateService: function() {" 231 " TranslateService: function() {"
232 " return {" 232 " return {"
233 " isAvailable : function() {" 233 " isAvailable : function() {"
234 " return true;" 234 " return true;"
235 " }," 235 " },"
236 " restore : function() {" 236 " restore : function() {"
237 " return;" 237 " return;"
238 " }," 238 " },"
239 " getDetectedLanguage : function() {" 239 " getDetectedLanguage : function() {"
240 " return \"ja\";" 240 " return \"ja\";"
241 " }," 241 " },"
242 " translatePage : function(originalLang, targetLang," 242 " translatePage : function(originalLang, targetLang,"
243 " onTranslateProgress) {" 243 " onTranslateProgress) {"
244 " document.getElementsByTagName(\"body\")[0].innerHTML = '" + 244 " document.getElementsByTagName(\"body\")[0].innerHTML = '" +
245 std::string(kTestFormString) + 245 std::string(kTestFormString) +
246 " ';" 246 " ';"
247 " onTranslateProgress(100, true, false);" 247 " onTranslateProgress(100, true, false);"
248 " }" 248 " }"
249 " };" 249 " };"
250 " }" 250 " }"
251 " };" 251 " };"
252 "})();" 252 "})();"
253 "cr.googleTranslate.onTranslateElementLoad();"; 253 "cr.googleTranslate.onTranslateElementLoad();";
254 254
255 fetcher->set_url(fetcher->GetOriginalURL()); 255 fetcher->set_url(fetcher->GetOriginalURL());
256 fetcher->set_status(status); 256 fetcher->set_status(net::URLRequestStatus::FromError(error));
257 fetcher->set_response_code(success ? 200 : 500); 257 fetcher->set_response_code(success ? 200 : 500);
258 fetcher->SetResponseString(script); 258 fetcher->SetResponseString(script);
259 fetcher->delegate()->OnURLFetchComplete(fetcher); 259 fetcher->delegate()->OnURLFetchComplete(fetcher);
260 } 260 }
261 261
262 void FocusFirstNameField() { 262 void FocusFirstNameField() {
263 bool result = false; 263 bool result = false;
264 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 264 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
265 GetRenderViewHost(), 265 GetRenderViewHost(),
266 "if (document.readyState === 'complete')" 266 "if (document.readyState === 'complete')"
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 ASSERT_TRUE(content::ExecuteScript( 1358 ASSERT_TRUE(content::ExecuteScript(
1359 GetRenderViewHost(), 1359 GetRenderViewHost(),
1360 "document.querySelector('input').autocomplete = 'off';")); 1360 "document.querySelector('input').autocomplete = 'off';"));
1361 1361
1362 // Press the down arrow to select the suggestion and attempt to preview the 1362 // Press the down arrow to select the suggestion and attempt to preview the
1363 // autofilled form. 1363 // autofilled form.
1364 SendKeyToPopupAndWait(ui::VKEY_DOWN); 1364 SendKeyToPopupAndWait(ui::VKEY_DOWN);
1365 } 1365 }
1366 1366
1367 } // namespace autofill 1367 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/translate/translate_browsertest.cc » ('j') | components/domain_reliability/monitor_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698