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

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 2484613002: Migrate more tests to ScopedFeatureList. (Closed)
Patch Set: rebase Created 4 years, 1 month 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
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 <components/autofill/core/common/password_form.h> 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 #include "base/feature_list.h" 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/scoped_feature_list.h"
11 #include "chrome/renderer/autofill/fake_content_password_manager_driver.h" 12 #include "chrome/renderer/autofill/fake_content_password_manager_driver.h"
12 #include "chrome/renderer/autofill/fake_password_manager_client.h" 13 #include "chrome/renderer/autofill/fake_password_manager_client.h"
13 #include "chrome/renderer/autofill/password_generation_test_utils.h" 14 #include "chrome/renderer/autofill/password_generation_test_utils.h"
14 #include "chrome/test/base/chrome_render_view_test.h" 15 #include "chrome/test/base/chrome_render_view_test.h"
15 #include "components/autofill/content/renderer/autofill_agent.h" 16 #include "components/autofill/content/renderer/autofill_agent.h"
16 #include "components/autofill/content/renderer/form_autofill_util.h" 17 #include "components/autofill/content/renderer/form_autofill_util.h"
17 #include "components/autofill/content/renderer/password_autofill_agent.h"
18 #include "components/autofill/content/renderer/test_password_autofill_agent.h" 18 #include "components/autofill/content/renderer/test_password_autofill_agent.h"
19 #include "components/autofill/content/renderer/test_password_generation_agent.h" 19 #include "components/autofill/content/renderer/test_password_generation_agent.h"
20 #include "components/autofill/core/common/autofill_constants.h" 20 #include "components/autofill/core/common/autofill_constants.h"
21 #include "components/autofill/core/common/form_data.h" 21 #include "components/autofill/core/common/form_data.h"
22 #include "components/autofill/core/common/form_field_data.h" 22 #include "components/autofill/core/common/form_field_data.h"
23 #include "components/autofill/core/common/password_form.h"
23 #include "components/autofill/core/common/password_form_field_prediction_map.h" 24 #include "components/autofill/core/common/password_form_field_prediction_map.h"
24 #include "components/password_manager/core/common/password_manager_features.h" 25 #include "components/password_manager/core/common/password_manager_features.h"
25 #include "content/public/common/associated_interface_provider.h" 26 #include "content/public/common/associated_interface_provider.h"
26 #include "content/public/renderer/render_frame.h" 27 #include "content/public/renderer/render_frame.h"
27 #include "content/public/renderer/render_view.h" 28 #include "content/public/renderer/render_view.h"
28 #include "services/service_manager/public/cpp/interface_provider.h" 29 #include "services/service_manager/public/cpp/interface_provider.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 #include "third_party/WebKit/public/platform/WebString.h" 31 #include "third_party/WebKit/public/platform/WebString.h"
31 #include "third_party/WebKit/public/platform/WebVector.h" 32 #include "third_party/WebKit/public/platform/WebVector.h"
32 #include "third_party/WebKit/public/web/WebDocument.h" 33 #include "third_party/WebKit/public/web/WebDocument.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // the fake password client is only used for the main frame. 340 // the fake password client is only used for the main frame.
340 content::AssociatedInterfaceProvider* remote_associated_interfaces = 341 content::AssociatedInterfaceProvider* remote_associated_interfaces =
341 view_->GetMainRenderFrame()->GetRemoteAssociatedInterfaces(); 342 view_->GetMainRenderFrame()->GetRemoteAssociatedInterfaces();
342 remote_associated_interfaces->OverrideBinderForTesting( 343 remote_associated_interfaces->OverrideBinderForTesting(
343 mojom::PasswordManagerClient::Name_, 344 mojom::PasswordManagerClient::Name_,
344 base::Bind(&PasswordAutofillAgentTest::BindPasswordManagerClient, 345 base::Bind(&PasswordAutofillAgentTest::BindPasswordManagerClient,
345 base::Unretained(this))); 346 base::Unretained(this)));
346 } 347 }
347 348
348 void SetFillOnAccountSelect() { 349 void SetFillOnAccountSelect() {
349 base::FeatureList::ClearInstanceForTesting(); 350 scoped_feature_list_.InitAndEnableFeature(
350 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 351 password_manager::features::kFillOnAccountSelect);
351 feature_list->InitializeFromCommandLine(
352 password_manager::features::kFillOnAccountSelect.name, "");
353 base::FeatureList::SetInstance(std::move(feature_list));
354 } 352 }
355 353
356 void UpdateOriginForHTML(const std::string& html) { 354 void UpdateOriginForHTML(const std::string& html) {
357 std::string origin = "data:text/html;charset=utf-8," + html; 355 std::string origin = "data:text/html;charset=utf-8," + html;
358 fill_data_.origin = GURL(origin); 356 fill_data_.origin = GURL(origin);
359 } 357 }
360 358
361 void UpdateUsernameAndPasswordElements() { 359 void UpdateUsernameAndPasswordElements() {
362 WebDocument document = GetMainFrame()->document(); 360 WebDocument document = GetMainFrame()->document();
363 WebElement element = 361 WebElement element =
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 base::string16 username2_; 566 base::string16 username2_;
569 base::string16 username3_; 567 base::string16 username3_;
570 base::string16 password1_; 568 base::string16 password1_;
571 base::string16 password2_; 569 base::string16 password2_;
572 base::string16 password3_; 570 base::string16 password3_;
573 base::string16 alternate_username3_; 571 base::string16 alternate_username3_;
574 PasswordFormFillData fill_data_; 572 PasswordFormFillData fill_data_;
575 573
576 WebInputElement username_element_; 574 WebInputElement username_element_;
577 WebInputElement password_element_; 575 WebInputElement password_element_;
576 base::test::ScopedFeatureList scoped_feature_list_;
578 577
579 private: 578 private:
580 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgentTest); 579 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgentTest);
581 }; 580 };
582 581
583 // Tests that the password login is autocompleted as expected when the browser 582 // Tests that the password login is autocompleted as expected when the browser
584 // sends back the password info. 583 // sends back the password info.
585 TEST_F(PasswordAutofillAgentTest, InitialAutocomplete) { 584 TEST_F(PasswordAutofillAgentTest, InitialAutocomplete) {
586 /* 585 /*
587 * Right now we are not sending the message to the browser because we are 586 * Right now we are not sending the message to the browser because we are
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 SimulateElementClick("confirmpassword"); 2461 SimulateElementClick("confirmpassword");
2463 EXPECT_FALSE(GetCalledShowPasswordSuggestions()); 2462 EXPECT_FALSE(GetCalledShowPasswordSuggestions());
2464 2463
2465 // But when the user clicks on the autofilled password field again it should 2464 // But when the user clicks on the autofilled password field again it should
2466 // still produce a suggestion dropdown. 2465 // still produce a suggestion dropdown.
2467 SimulateElementClick("password"); 2466 SimulateElementClick("password");
2468 CheckSuggestions("", false); 2467 CheckSuggestions("", false);
2469 } 2468 }
2470 2469
2471 } // namespace autofill 2470 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui_browsertest.cc ('k') | components/sync/engine_impl/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698