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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 10 matching lines...) Expand all
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.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/renderer/translate_helper.h" 26 #include "chrome/renderer/translate_helper.h"
27 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
29 #include "content/browser/renderer_host/mock_render_process_host.h" 29 #include "content/browser/renderer_host/mock_render_process_host.h"
30 #include "content/browser/renderer_host/render_view_host.h" 30 #include "content/browser/renderer_host/render_view_host.h"
31 #include "content/browser/tab_contents/tab_contents.h" 31 #include "content/browser/tab_contents/navigation_controller.h"
32 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/web_contents.h"
33 #include "content/test/test_url_fetcher_factory.h" 34 #include "content/test/test_url_fetcher_factory.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/keycodes/keyboard_codes.h" 36 #include "ui/base/keycodes/keyboard_codes.h"
36 37
38 using content::WebContents;
39
37 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,"; 40 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,";
38 static const char* kTestFormString = 41 static const char* kTestFormString =
39 "<form action=\"http://www.example.com/\" method=\"POST\">" 42 "<form action=\"http://www.example.com/\" method=\"POST\">"
40 "<label for=\"firstname\">First name:</label>" 43 "<label for=\"firstname\">First name:</label>"
41 " <input type=\"text\" id=\"firstname\"" 44 " <input type=\"text\" id=\"firstname\""
42 " onFocus=\"domAutomationController.send(true)\"><br>" 45 " onFocus=\"domAutomationController.send(true)\"><br>"
43 "<label for=\"lastname\">Last name:</label>" 46 "<label for=\"lastname\">Last name:</label>"
44 " <input type=\"text\" id=\"lastname\"><br>" 47 " <input type=\"text\" id=\"lastname\"><br>"
45 "<label for=\"address1\">Address line 1:</label>" 48 "<label for=\"address1\">Address line 1:</label>"
46 " <input type=\"text\" id=\"address1\"><br>" 49 " <input type=\"text\" id=\"address1\"><br>"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // AddProfile is asynchronous. Wait for it to finish before continuing the 125 // AddProfile is asynchronous. Wait for it to finish before continuing the
123 // tests. 126 // tests.
124 observer.Wait(); 127 observer.Wait();
125 personal_data_manager->RemoveObserver(&observer); 128 personal_data_manager->RemoveObserver(&observer);
126 } 129 }
127 130
128 void ExpectFieldValue(const std::wstring& field_name, 131 void ExpectFieldValue(const std::wstring& field_name,
129 const std::string& expected_value) { 132 const std::string& expected_value) {
130 std::string value; 133 std::string value;
131 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 134 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
132 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 135 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
133 L"window.domAutomationController.send(" 136 L"window.domAutomationController.send("
134 L"document.getElementById('" + field_name + L"').value);", &value)); 137 L"document.getElementById('" + field_name + L"').value);", &value));
135 EXPECT_EQ(expected_value, value); 138 EXPECT_EQ(expected_value, value);
136 } 139 }
137 140
138 RenderViewHost* render_view_host() { 141 RenderViewHost* render_view_host() {
139 return browser()->GetSelectedTabContents()->GetRenderViewHost(); 142 return browser()->GetSelectedWebContents()->GetRenderViewHost();
140 } 143 }
141 144
142 void SimulateURLFetch(bool success) { 145 void SimulateURLFetch(bool success) {
143 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 146 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
144 ASSERT_TRUE(fetcher); 147 ASSERT_TRUE(fetcher);
145 net::URLRequestStatus status; 148 net::URLRequestStatus status;
146 status.set_status(success ? net::URLRequestStatus::SUCCESS : 149 status.set_status(success ? net::URLRequestStatus::SUCCESS :
147 net::URLRequestStatus::FAILED); 150 net::URLRequestStatus::FAILED);
148 151
149 std::string script = " var google = {};" 152 std::string script = " var google = {};"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 629
627 // Load the test page. 630 // Load the test page.
628 LOG(WARNING) << "Bringing browser window to front."; 631 LOG(WARNING) << "Bringing browser window to front.";
629 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 632 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
630 LOG(WARNING) << "Navigating to URL."; 633 LOG(WARNING) << "Navigating to URL.";
631 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 634 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
632 GURL(std::string(kDataURIPrefix) + kTestFormString))); 635 GURL(std::string(kDataURIPrefix) + kTestFormString)));
633 636
634 // Reload the page. 637 // Reload the page.
635 LOG(WARNING) << "Reloading the page."; 638 LOG(WARNING) << "Reloading the page.";
636 TabContents* tab = 639 WebContents* tab =
637 browser()->GetSelectedTabContentsWrapper()->tab_contents(); 640 browser()->GetSelectedTabContentsWrapper()->web_contents();
638 tab->GetController().Reload(false); 641 tab->GetController().Reload(false);
639 ui_test_utils::WaitForLoadStop(tab); 642 ui_test_utils::WaitForLoadStop(tab);
640 643
641 // Invoke Autofill. 644 // Invoke Autofill.
642 LOG(WARNING) << "Trying to fill the form."; 645 LOG(WARNING) << "Trying to fill the form.";
643 TryBasicFormFill(); 646 TryBasicFormFill();
644 } 647 }
645 648
646 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 649 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
647 // Test that autofill works after page translation. 650 // Test that autofill works after page translation.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // Once click the text field, it starts again. 715 // Once click the text field, it starts again.
713 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 716 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
714 render_view_host(), L"", 717 render_view_host(), L"",
715 L"cr.googleTranslate.onTranslateElementLoad();")); 718 L"cr.googleTranslate.onTranslateElementLoad();"));
716 719
717 // Simulate the render notifying the translation has been done. 720 // Simulate the render notifying the translation has been done.
718 translation_observer.Wait(); 721 translation_observer.Wait();
719 722
720 TryBasicFormFill(); 723 TryBasicFormFill();
721 } 724 }
OLDNEW
« no previous file with comments | « chrome/browser/accessibility/dump_accessibility_tree_browsertest.cc ('k') | chrome/browser/automation/automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698