| OLD | NEW |
| 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" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/autofill/autofill_common_test.h" | 12 #include "chrome/browser/autofill/autofill_common_test.h" |
| 13 #include "chrome/browser/autofill/autofill_profile.h" | 13 #include "chrome/browser/autofill/autofill_profile.h" |
| 14 #include "chrome/browser/autofill/personal_data_manager.h" | 14 #include "chrome/browser/autofill/personal_data_manager.h" |
| 15 #include "chrome/browser/net/predictor_api.h" | 15 #include "chrome/browser/net/predictor_api.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/translate/translate_infobar_delegate.h" | 17 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 18 #include "chrome/browser/translate/translate_manager.h" | 18 #include "chrome/browser/translate/translate_manager.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
| 24 #include "chrome/renderer/translate_helper.h" | 24 #include "chrome/renderer/translate_helper.h" |
| 25 #include "chrome/test/in_process_browser_test.h" | 25 #include "chrome/test/in_process_browser_test.h" |
| 26 #include "chrome/test/ui_test_utils.h" | 26 #include "chrome/test/ui_test_utils.h" |
| 27 #include "content/browser/renderer_host/mock_render_process_host.h" | 27 #include "content/browser/renderer_host/mock_render_process_host.h" |
| 28 #include "content/browser/renderer_host/render_view_host.h" | 28 #include "content/browser/renderer_host/render_view_host.h" |
| 29 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/tab_contents/tab_contents.h" |
| 30 #include "content/common/test_url_fetcher_factory.h" | 30 #include "content/test/test_url_fetcher_factory.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "ui/base/keycodes/keyboard_codes.h" | 32 #include "ui/base/keycodes/keyboard_codes.h" |
| 33 | 33 |
| 34 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,"; | 34 static const char* kDataURIPrefix = "data:text/html;charset=utf-8,"; |
| 35 static const char* kTestFormString = | 35 static const char* kTestFormString = |
| 36 "<form action=\"http://www.example.com/\" method=\"POST\">" | 36 "<form action=\"http://www.example.com/\" method=\"POST\">" |
| 37 "<label for=\"firstname\">First name:</label>" | 37 "<label for=\"firstname\">First name:</label>" |
| 38 " <input type=\"text\" id=\"firstname\"" | 38 " <input type=\"text\" id=\"firstname\"" |
| 39 " onFocus=\"domAutomationController.send(true)\" /><br />" | 39 " onFocus=\"domAutomationController.send(true)\" /><br />" |
| 40 "<label for=\"lastname\">Last name:</label>" | 40 "<label for=\"lastname\">Last name:</label>" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 63 " <input type=\"text\" id=\"phone\" /><br />" | 63 " <input type=\"text\" id=\"phone\" /><br />" |
| 64 "</form>"; | 64 "</form>"; |
| 65 | 65 |
| 66 class AutofillTest : public InProcessBrowserTest { | 66 class AutofillTest : public InProcessBrowserTest { |
| 67 protected: | 67 protected: |
| 68 AutofillTest() { | 68 AutofillTest() { |
| 69 set_show_window(true); | 69 set_show_window(true); |
| 70 EnableDOMAutomation(); | 70 EnableDOMAutomation(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
| 74 URLFetcher::set_factory(&url_fetcher_factory_); | |
| 75 } | |
| 76 | |
| 77 void CreateTestProfile() { | 73 void CreateTestProfile() { |
| 78 autofill_test::DisableSystemServices(browser()->profile()); | 74 autofill_test::DisableSystemServices(browser()->profile()); |
| 79 | 75 |
| 80 AutofillProfile profile; | 76 AutofillProfile profile; |
| 81 autofill_test::SetProfileInfo( | 77 autofill_test::SetProfileInfo( |
| 82 &profile, "Milton", "C.", "Waddams", | 78 &profile, "Milton", "C.", "Waddams", |
| 83 "red.swingline@initech.com", "Initech", "4120 Freidrich Lane", | 79 "red.swingline@initech.com", "Initech", "4120 Freidrich Lane", |
| 84 "Basement", "Austin", "Texas", "78744", "United States", "5125551234", | 80 "Basement", "Austin", "Texas", "78744", "United States", "5125551234", |
| 85 "5125550000"); | 81 "5125550000"); |
| 86 | 82 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 // Once click the text field, it starts again. | 527 // Once click the text field, it starts again. |
| 532 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | 528 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 533 render_view_host(), L"", | 529 render_view_host(), L"", |
| 534 L"cr.googleTranslate.onTranslateElementLoad();")); | 530 L"cr.googleTranslate.onTranslateElementLoad();")); |
| 535 | 531 |
| 536 // Simulate the render notifying the translation has been done. | 532 // Simulate the render notifying the translation has been done. |
| 537 ui_test_utils::WaitForNotification(chrome::NOTIFICATION_PAGE_TRANSLATED); | 533 ui_test_utils::WaitForNotification(chrome::NOTIFICATION_PAGE_TRANSLATED); |
| 538 | 534 |
| 539 TryBasicFormFill(); | 535 TryBasicFormFill(); |
| 540 } | 536 } |
| OLD | NEW |