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

Side by Side Diff: chrome/browser/password_manager/password_manager_interactive_uitest.cc

Issue 1858513002: chrome/browser/password_manager: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows -- revert unwanted change Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/password_manager/password_manager_test_base.h" 7 #include "chrome/browser/password_manager/password_manager_test_base.h"
8 #include "chrome/browser/password_manager/password_store_factory.h" 8 #include "chrome/browser/password_manager/password_store_factory.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "components/password_manager/core/browser/test_password_store.h" 10 #include "components/password_manager/core/browser/test_password_store.h"
(...skipping 27 matching lines...) Expand all
38 38
39 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, UsernameChanged) { 39 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, UsernameChanged) {
40 scoped_refptr<password_manager::TestPasswordStore> password_store = 40 scoped_refptr<password_manager::TestPasswordStore> password_store =
41 static_cast<password_manager::TestPasswordStore*>( 41 static_cast<password_manager::TestPasswordStore*>(
42 PasswordStoreFactory::GetForProfile( 42 PasswordStoreFactory::GetForProfile(
43 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); 43 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
44 44
45 NavigateToFile("/password/signup_form.html"); 45 NavigateToFile("/password/signup_form.html");
46 46
47 NavigationObserver observer(WebContents()); 47 NavigationObserver observer(WebContents());
48 scoped_ptr<PromptObserver> prompt_observer( 48 std::unique_ptr<PromptObserver> prompt_observer(
49 PromptObserver::Create(WebContents())); 49 PromptObserver::Create(WebContents()));
50 std::string fill_and_submit = 50 std::string fill_and_submit =
51 "document.getElementById('username_field').value = 'temp';" 51 "document.getElementById('username_field').value = 'temp';"
52 "document.getElementById('password_field').value = 'random';" 52 "document.getElementById('password_field').value = 'random';"
53 "document.getElementById('input_submit_button').click()"; 53 "document.getElementById('input_submit_button').click()";
54 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 54 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
55 observer.Wait(); 55 observer.Wait();
56 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 56 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
57 prompt_observer->Accept(); 57 prompt_observer->Accept();
58 58
(...skipping 18 matching lines...) Expand all
77 77
78 // Change username and submit. This should add the characters "ORARY" to the 78 // Change username and submit. This should add the characters "ORARY" to the
79 // already autofilled username. 79 // already autofilled username.
80 SimulateUserTypingInField(RenderViewHost(), WebContents(), "username_field"); 80 SimulateUserTypingInField(RenderViewHost(), WebContents(), "username_field");
81 // TODO(gcasto): Not sure why this click is required. 81 // TODO(gcasto): Not sure why this click is required.
82 content::SimulateMouseClickAt( 82 content::SimulateMouseClickAt(
83 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); 83 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1));
84 WaitForElementValue("username_field", "tempORARY"); 84 WaitForElementValue("username_field", "tempORARY");
85 85
86 NavigationObserver second_observer(WebContents()); 86 NavigationObserver second_observer(WebContents());
87 scoped_ptr<PromptObserver> second_prompt_observer( 87 std::unique_ptr<PromptObserver> second_prompt_observer(
88 PromptObserver::Create(WebContents())); 88 PromptObserver::Create(WebContents()));
89 std::string submit = 89 std::string submit =
90 "document.getElementById('input_submit_button').click();"; 90 "document.getElementById('input_submit_button').click();";
91 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); 91 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
92 second_observer.Wait(); 92 second_observer.Wait();
93 EXPECT_TRUE(second_prompt_observer->IsShowingPrompt()); 93 EXPECT_TRUE(second_prompt_observer->IsShowingPrompt());
94 second_prompt_observer->Accept(); 94 second_prompt_observer->Accept();
95 95
96 // Spin the message loop to make sure the password store had a chance to save 96 // Spin the message loop to make sure the password store had a chance to save
97 // the password. 97 // the password.
98 base::RunLoop third_run_loop; 98 base::RunLoop third_run_loop;
99 third_run_loop.RunUntilIdle(); 99 third_run_loop.RunUntilIdle();
100 EXPECT_FALSE(password_store->IsEmpty()); 100 EXPECT_FALSE(password_store->IsEmpty());
101 101
102 // Verify that there are two saved password, the old password and the new 102 // Verify that there are two saved password, the old password and the new
103 // password. 103 // password.
104 password_manager::TestPasswordStore::PasswordMap stored_passwords = 104 password_manager::TestPasswordStore::PasswordMap stored_passwords =
105 password_store->stored_passwords(); 105 password_store->stored_passwords();
106 EXPECT_EQ(1u, stored_passwords.size()); 106 EXPECT_EQ(1u, stored_passwords.size());
107 EXPECT_EQ(2u, stored_passwords.begin()->second.size()); 107 EXPECT_EQ(2u, stored_passwords.begin()->second.size());
108 EXPECT_EQ(base::UTF8ToUTF16("temp"), 108 EXPECT_EQ(base::UTF8ToUTF16("temp"),
109 (stored_passwords.begin()->second)[0].username_value); 109 (stored_passwords.begin()->second)[0].username_value);
110 EXPECT_EQ(base::UTF8ToUTF16("tempORARY"), 110 EXPECT_EQ(base::UTF8ToUTF16("tempORARY"),
111 (stored_passwords.begin()->second)[1].username_value); 111 (stored_passwords.begin()->second)[1].username_value);
112 } 112 }
113 113
114 } // namespace password_manager 114 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698