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

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

Issue 10581012: Move test_url_fetcher_factory.* from content/ to net/url_request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove export annotations Created 8 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents.h"
24 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
26 #include "chrome/test/base/in_process_browser_test.h" 26 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/ui_test_utils.h" 27 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/public/browser/navigation_controller.h" 28 #include "content/public/browser/navigation_controller.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "content/public/test/test_renderer_host.h" 32 #include "content/public/test/test_renderer_host.h"
33 #include "content/public/test/test_url_fetcher_factory.h" 33 #include "net/url_request/test_url_fetcher_factory.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/keycodes/keyboard_codes.h" 35 #include "ui/base/keycodes/keyboard_codes.h"
36 36
37 using content::RenderViewHost; 37 using content::RenderViewHost;
38 using content::RenderViewHostTester; 38 using content::RenderViewHostTester;
39 using content::WebContents; 39 using content::WebContents;
40 40
41 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,"; 41 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,";
42 static const char* kTestFormString = 42 static const char* kTestFormString =
43 "<form action=\"http://www.example.com/\" method=\"POST\">" 43 "<form action=\"http://www.example.com/\" method=\"POST\">"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 L"window.domAutomationController.send(" 136 L"window.domAutomationController.send("
137 L"document.getElementById('" + field_name + L"').value);", &value)); 137 L"document.getElementById('" + field_name + L"').value);", &value));
138 EXPECT_EQ(expected_value, value); 138 EXPECT_EQ(expected_value, value);
139 } 139 }
140 140
141 RenderViewHost* render_view_host() { 141 RenderViewHost* render_view_host() {
142 return browser()->GetActiveWebContents()->GetRenderViewHost(); 142 return browser()->GetActiveWebContents()->GetRenderViewHost();
143 } 143 }
144 144
145 void SimulateURLFetch(bool success) { 145 void SimulateURLFetch(bool success) {
146 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 146 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
147 ASSERT_TRUE(fetcher); 147 ASSERT_TRUE(fetcher);
148 net::URLRequestStatus status; 148 net::URLRequestStatus status;
149 status.set_status(success ? net::URLRequestStatus::SUCCESS : 149 status.set_status(success ? net::URLRequestStatus::SUCCESS :
150 net::URLRequestStatus::FAILED); 150 net::URLRequestStatus::FAILED);
151 151
152 std::string script = " var google = {};" 152 std::string script = " var google = {};"
153 "google.translate = (function() {" 153 "google.translate = (function() {"
154 " return {" 154 " return {"
155 " TranslateService: function() {" 155 " TranslateService: function() {"
156 " return {" 156 " return {"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // Press Enter to accept the autofill suggestions. 249 // Press Enter to accept the autofill suggestions.
250 LOG(WARNING) << "Simulating Return press to fill the form."; 250 LOG(WARNING) << "Simulating Return press to fill the form.";
251 SendKeyAndWait( 251 SendKeyAndWait(
252 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA); 252 ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
253 253
254 // The form should be filled. 254 // The form should be filled.
255 ExpectFilledTestForm(); 255 ExpectFilledTestForm();
256 } 256 }
257 257
258 private: 258 private:
259 TestURLFetcherFactory url_fetcher_factory_; 259 net::TestURLFetcherFactory url_fetcher_factory_;
260 }; 260 };
261 261
262 // Test that basic form fill is working. 262 // Test that basic form fill is working.
263 IN_PROC_BROWSER_TEST_F(AutofillTest, BasicFormFill) { 263 IN_PROC_BROWSER_TEST_F(AutofillTest, BasicFormFill) {
264 CreateTestProfile(); 264 CreateTestProfile();
265 265
266 // Load the test page. 266 // Load the test page.
267 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 267 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
268 GURL(std::string(kDataURIPrefix) + kTestFormString))); 268 GURL(std::string(kDataURIPrefix) + kTestFormString)));
269 269
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 // Once click the text field, it starts again. 701 // Once click the text field, it starts again.
702 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 702 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
703 render_view_host(), L"", 703 render_view_host(), L"",
704 L"cr.googleTranslate.onTranslateElementLoad();")); 704 L"cr.googleTranslate.onTranslateElementLoad();"));
705 705
706 // Simulate the render notifying the translation has been done. 706 // Simulate the render notifying the translation has been done.
707 translation_observer.Wait(); 707 translation_observer.Wait();
708 708
709 TryBasicFormFill(); 709 TryBasicFormFill();
710 } 710 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | chrome/browser/autofill/autofill_download_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698