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

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

Issue 8921026: [Autofill] Fix flakiness in autofill browsertest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | « no previous file | 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) 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/autofill/personal_data_manager_factory.h" 15 #include "chrome/browser/autofill/personal_data_manager_factory.h"
16 #include "chrome/browser/autofill/personal_data_manager_observer.h"
16 #include "chrome/browser/infobars/infobar_tab_helper.h" 17 #include "chrome/browser/infobars/infobar_tab_helper.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/translate/translate_infobar_delegate.h" 19 #include "chrome/browser/translate/translate_infobar_delegate.h"
19 #include "chrome/browser/translate/translate_manager.h" 20 #include "chrome/browser/translate/translate_manager.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
23 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
25 #include "chrome/renderer/translate_helper.h" 26 #include "chrome/renderer/translate_helper.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 "<label for=\"country\">Country:</label>" 59 "<label for=\"country\">Country:</label>"
59 " <select id=\"country\">" 60 " <select id=\"country\">"
60 " <option value=\"\" selected=\"yes\">--</option>" 61 " <option value=\"\" selected=\"yes\">--</option>"
61 " <option value=\"CA\">Canada</option>" 62 " <option value=\"CA\">Canada</option>"
62 " <option value=\"US\">United States</option>" 63 " <option value=\"US\">United States</option>"
63 " </select><br>" 64 " </select><br>"
64 "<label for=\"phone\">Phone number:</label>" 65 "<label for=\"phone\">Phone number:</label>"
65 " <input type=\"text\" id=\"phone\"><br>" 66 " <input type=\"text\" id=\"phone\"><br>"
66 "</form>"; 67 "</form>";
67 68
69 class TestPersonalDataManagerObserver : public PersonalDataManagerObserver {
Ilya Sherman 2011/12/13 00:02:56 nit: Perhaps name this "WindowedPersonalDataManage
binji 2011/12/13 01:54:25 Done.
70 public:
71 void Wait() {
72 ui_test_utils::RunMessageLoop();
73 }
74
75 void OnPersonalDataChanged() OVERRIDE {
76 MessageLoopForUI::current()->Quit();
77 }
78 };
Ilya Sherman 2011/12/13 00:02:56 I think this class needs to track whether OnPerson
binji 2011/12/13 01:54:25 Done.
79
68 class AutofillTest : public InProcessBrowserTest { 80 class AutofillTest : public InProcessBrowserTest {
69 protected: 81 protected:
70 AutofillTest() { 82 AutofillTest() {
71 set_show_window(true); 83 set_show_window(true);
72 EnableDOMAutomation(); 84 EnableDOMAutomation();
73 } 85 }
74 86
75 void CreateTestProfile() { 87 void CreateTestProfile() {
76 autofill_test::DisableSystemServices(browser()->profile()); 88 autofill_test::DisableSystemServices(browser()->profile());
77 89
78 AutofillProfile profile; 90 AutofillProfile profile;
79 autofill_test::SetProfileInfo( 91 autofill_test::SetProfileInfo(
80 &profile, "Milton", "C.", "Waddams", 92 &profile, "Milton", "C.", "Waddams",
81 "red.swingline@initech.com", "Initech", "4120 Freidrich Lane", 93 "red.swingline@initech.com", "Initech", "4120 Freidrich Lane",
82 "Basement", "Austin", "Texas", "78744", "United States", "5125551234"); 94 "Basement", "Austin", "Texas", "78744", "United States", "5125551234");
83 95
84 PersonalDataManager* personal_data_manager = 96 PersonalDataManager* personal_data_manager =
85 PersonalDataManagerFactory::GetForProfile(browser()->profile()); 97 PersonalDataManagerFactory::GetForProfile(browser()->profile());
86 ASSERT_TRUE(personal_data_manager); 98 ASSERT_TRUE(personal_data_manager);
87 99
100 TestPersonalDataManagerObserver observer;
101 personal_data_manager->SetObserver(&observer);
102
88 personal_data_manager->AddProfile(profile); 103 personal_data_manager->AddProfile(profile);
104
105 observer.Wait();
Ilya Sherman 2011/12/13 00:02:56 nit: Please add a comment describing what this is
binji 2011/12/13 01:54:25 Done.
106 personal_data_manager->RemoveObserver(&observer);
89 } 107 }
90 108
91 void ExpectFieldValue(const std::wstring& field_name, 109 void ExpectFieldValue(const std::wstring& field_name,
92 const std::string& expected_value) { 110 const std::string& expected_value) {
93 std::string value; 111 std::string value;
94 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 112 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
95 browser()->GetSelectedTabContents()->render_view_host(), L"", 113 browser()->GetSelectedTabContents()->render_view_host(), L"",
96 L"window.domAutomationController.send(" 114 L"window.domAutomationController.send("
97 L"document.getElementById('" + field_name + L"').value);", &value)); 115 L"document.getElementById('" + field_name + L"').value);", &value));
98 EXPECT_EQ(expected_value, value); 116 EXPECT_EQ(expected_value, value);
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // Once click the text field, it starts again. 693 // Once click the text field, it starts again.
676 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 694 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
677 render_view_host(), L"", 695 render_view_host(), L"",
678 L"cr.googleTranslate.onTranslateElementLoad();")); 696 L"cr.googleTranslate.onTranslateElementLoad();"));
679 697
680 // Simulate the render notifying the translation has been done. 698 // Simulate the render notifying the translation has been done.
681 translation_observer.Wait(); 699 translation_observer.Wait();
682 700
683 TryBasicFormFill(); 701 TryBasicFormFill();
684 } 702 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698