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

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

Issue 14241006: Eliminate InfoBarTabHelper. Make InfoBarService a concrete class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 has_run_message_loop_(false), 130 has_run_message_loop_(false),
131 browser_(browser), 131 browser_(browser),
132 infobar_service_(NULL) { 132 infobar_service_(NULL) {
133 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 133 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
134 AddObserver(this); 134 AddObserver(this);
135 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 135 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
136 content::NotificationService::AllSources()); 136 content::NotificationService::AllSources());
137 } 137 }
138 138
139 virtual ~WindowedPersonalDataManagerObserver() { 139 virtual ~WindowedPersonalDataManagerObserver() {
140 if (!infobar_service_) 140 if (infobar_service_ && infobar_service_->infobar_count() > 0)
141 return; 141 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
142
143 InfoBarDelegate* infobar = NULL;
144 if (infobar_service_->GetInfoBarCount() > 0 &&
145 (infobar = infobar_service_->GetInfoBarDelegateAt(0))) {
146 infobar_service_->RemoveInfoBar(infobar);
147 }
148 } 142 }
149 143
150 void Wait() { 144 void Wait() {
151 if (!alerted_) { 145 if (!alerted_) {
152 has_run_message_loop_ = true; 146 has_run_message_loop_ = true;
153 content::RunMessageLoop(); 147 content::RunMessageLoop();
154 } 148 }
155 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 149 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
156 RemoveObserver(this); 150 RemoveObserver(this);
157 } 151 }
(...skipping 11 matching lines...) Expand all
169 OnPersonalDataChanged(); 163 OnPersonalDataChanged();
170 } 164 }
171 165
172 // content::NotificationObserver: 166 // content::NotificationObserver:
173 virtual void Observe(int type, 167 virtual void Observe(int type,
174 const content::NotificationSource& source, 168 const content::NotificationSource& source,
175 const content::NotificationDetails& details) OVERRIDE { 169 const content::NotificationDetails& details) OVERRIDE {
176 // Accept in the infobar. 170 // Accept in the infobar.
177 infobar_service_ = InfoBarService::FromWebContents( 171 infobar_service_ = InfoBarService::FromWebContents(
178 browser_->tab_strip_model()->GetActiveWebContents()); 172 browser_->tab_strip_model()->GetActiveWebContents());
179 InfoBarDelegate* infobar = infobar_service_->GetInfoBarDelegateAt(0); 173 InfoBarDelegate* infobar = infobar_service_->infobar_at(0);
180 174
181 ConfirmInfoBarDelegate* confirm_infobar = 175 ConfirmInfoBarDelegate* confirm_infobar =
182 infobar->AsConfirmInfoBarDelegate(); 176 infobar->AsConfirmInfoBarDelegate();
183 confirm_infobar->Accept(); 177 confirm_infobar->Accept();
184 } 178 }
185 179
186 private: 180 private:
187 bool alerted_; 181 bool alerted_;
188 bool has_run_message_loop_; 182 bool has_run_message_loop_;
189 Browser* browser_; 183 Browser* browser_;
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 "<label for=\"ph\">Phone number:</label>" 947 "<label for=\"ph\">Phone number:</label>"
954 " <input type=\"text\" id=\"ph\"><br>" 948 " <input type=\"text\" id=\"ph\"><br>"
955 "</form>"); 949 "</form>");
956 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url)); 950 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
957 951
958 // Get translation bar. 952 // Get translation bar.
959 RenderViewHostTester::TestOnMessageReceived( 953 RenderViewHostTester::TestOnMessageReceived(
960 render_view_host(), 954 render_view_host(),
961 ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true)); 955 ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true));
962 TranslateInfoBarDelegate* infobar = InfoBarService::FromWebContents( 956 TranslateInfoBarDelegate* infobar = InfoBarService::FromWebContents(
963 browser()->tab_strip_model()->GetActiveWebContents())-> 957 browser()->tab_strip_model()->GetActiveWebContents())->infobar_at(0)->
964 GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate(); 958 AsTranslateInfoBarDelegate();
965 959
966 ASSERT_TRUE(infobar != NULL); 960 ASSERT_TRUE(infobar != NULL);
967 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, 961 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE,
968 infobar->infobar_type()); 962 infobar->infobar_type());
969 963
970 // Simulate translation button press. 964 // Simulate translation button press.
971 infobar->Translate(); 965 infobar->Translate();
972 966
973 // Simulate the translate script being retrieved. 967 // Simulate the translate script being retrieved.
974 // Pass fake google.translate lib as the translate script. 968 // Pass fake google.translate lib as the translate script.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 // pass the Luhn test) the credit card info should not be saved into Autofill 1182 // pass the Luhn test) the credit card info should not be saved into Autofill
1189 // preferences. 1183 // preferences.
1190 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { 1184 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) {
1191 ASSERT_TRUE(test_server()->Start()); 1185 ASSERT_TRUE(test_server()->Start());
1192 std::string card("4408 0412 3456 7890"); 1186 std::string card("4408 0412 3456 7890");
1193 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); 1187 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card)));
1194 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); 1188 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014");
1195 ASSERT_EQ(0u, 1189 ASSERT_EQ(0u,
1196 InfoBarService::FromWebContents( 1190 InfoBarService::FromWebContents(
1197 browser()->tab_strip_model()->GetActiveWebContents())-> 1191 browser()->tab_strip_model()->GetActiveWebContents())->
1198 GetInfoBarCount()); 1192 infobar_count());
1199 } 1193 }
1200 1194
1201 // Test whitespaces and separator chars are stripped for valid CC numbers. 1195 // Test whitespaces and separator chars are stripped for valid CC numbers.
1202 // The credit card numbers used in this test pass the Luhn test. For reference: 1196 // The credit card numbers used in this test pass the Luhn test. For reference:
1203 // http://www.merriampark.com/anatomycc.htm 1197 // http://www.merriampark.com/anatomycc.htm
1204 IN_PROC_BROWSER_TEST_F(AutofillTest, 1198 IN_PROC_BROWSER_TEST_F(AutofillTest,
1205 WhitespacesAndSeparatorCharsStrippedForValidCCNums) { 1199 WhitespacesAndSeparatorCharsStrippedForValidCCNums) {
1206 ASSERT_TRUE(test_server()->Start()); 1200 ASSERT_TRUE(test_server()->Start());
1207 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014"); 1201 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014");
1208 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013"); 1202 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013");
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 FormMap data; 1405 FormMap data;
1412 data["CREDIT_CARD_NAME"] = "Bob Smith"; 1406 data["CREDIT_CARD_NAME"] = "Bob Smith";
1413 data["CREDIT_CARD_NUMBER"] = "4408041234567893"; 1407 data["CREDIT_CARD_NUMBER"] = "4408041234567893";
1414 data["CREDIT_CARD_EXP_MONTH"] = "12"; 1408 data["CREDIT_CARD_EXP_MONTH"] = "12";
1415 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = "2014"; 1409 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = "2014";
1416 FillFormAndSubmit("cc_autocomplete_off_test.html", data); 1410 FillFormAndSubmit("cc_autocomplete_off_test.html", data);
1417 1411
1418 ASSERT_EQ(0u, 1412 ASSERT_EQ(0u,
1419 InfoBarService::FromWebContents( 1413 InfoBarService::FromWebContents(
1420 browser()->tab_strip_model()->GetActiveWebContents())-> 1414 browser()->tab_strip_model()->GetActiveWebContents())->
1421 GetInfoBarCount()); 1415 infobar_count());
1422 } 1416 }
1423 1417
1424 // http://crbug.com/150084 1418 // http://crbug.com/150084
1425 #if defined(OS_MACOSX) 1419 #if defined(OS_MACOSX)
1426 #define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields 1420 #define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields
1427 #else 1421 #else
1428 #define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields 1422 #define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields
1429 #endif 1423 #endif
1430 // Test that Autofill does not fill in read-only fields. 1424 // Test that Autofill does not fill in read-only fields.
1431 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_NoAutofillForReadOnlyFields) { 1425 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_NoAutofillForReadOnlyFields) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 IN_PROC_BROWSER_TEST_F(AutofillTest, 1710 IN_PROC_BROWSER_TEST_F(AutofillTest,
1717 DISABLED_MergeAggregatedDuplicatedProfiles) { 1711 DISABLED_MergeAggregatedDuplicatedProfiles) {
1718 int num_of_profiles = 1712 int num_of_profiles =
1719 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); 1713 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt");
1720 1714
1721 ASSERT_GT(num_of_profiles, 1715 ASSERT_GT(num_of_profiles,
1722 static_cast<int>(personal_data_manager()->GetProfiles().size())); 1716 static_cast<int>(personal_data_manager()->GetProfiles().size()));
1723 } 1717 }
1724 1718
1725 } // namespace autofill 1719 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/accessibility/accessibility_extension_api.cc ('k') | chrome/browser/autofill/autofill_cc_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698