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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_test.cc

Issue 2869683003: Views/Harmony: Remove references to layout constants in c/b/u/v/passwords. (Closed)
Patch Set: Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/passwords/manage_passwords_test.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_test.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_command_controller.h" 16 #include "chrome/browser/ui/browser_command_controller.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" 18 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/interactive_test_utils.h" 21 #include "chrome/test/base/interactive_test_utils.h"
22 #include "components/autofill/core/common/password_form.h" 22 #include "components/autofill/core/common/password_form.h"
23 #include "components/password_manager/core/browser/password_form_manager.h" 23 #include "components/password_manager/core/browser/password_form_manager.h"
24 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 24 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
25 #include "components/password_manager/core/browser/stub_form_saver.h" 25 #include "components/password_manager/core/browser/stub_form_saver.h"
26 26
27 namespace {
28 std::string kTestOrigin = "https://www.example.com";
tapted 2017/05/10 05:30:10 these will make static initializers (basically eve
Patti Lor 2017/05/11 06:59:17 Ooh, I didn't know that, thanks! Fixed.
29 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
30 base::string16 kTestPassword = base::ASCIIToUTF16("test_password");
31 }
tapted 2017/05/10 05:30:11 // namespace
Patti Lor 2017/05/11 06:59:17 Done.
32
27 ManagePasswordsTest::ManagePasswordsTest() { 33 ManagePasswordsTest::ManagePasswordsTest() {
28 fetcher_.Fetch(); 34 fetcher_.Fetch();
35
36 // Populate |test_form_| with some dummy data.
37 test_form_.signon_realm = kTestOrigin;
38 test_form_.origin = GURL(kTestOrigin);
39 test_form_.username_value = kTestUsername;
40 test_form_.password_value = kTestPassword;
29 } 41 }
30 42
31 ManagePasswordsTest::~ManagePasswordsTest() { 43 ManagePasswordsTest::~ManagePasswordsTest() {
32 } 44 }
33 45
34 void ManagePasswordsTest::SetUpOnMainThread() { 46 void ManagePasswordsTest::SetUpOnMainThread() {
35 AddTabAtIndex(0, GURL("http://example.com/"), ui::PAGE_TRANSITION_TYPED); 47 AddTabAtIndex(0, GURL(kTestOrigin), ui::PAGE_TRANSITION_TYPED);
36 } 48 }
37 49
38 void ManagePasswordsTest::ExecuteManagePasswordsCommand() { 50 void ManagePasswordsTest::ExecuteManagePasswordsCommand() {
39 // Show the window to ensure that it's active. 51 // Show the window to ensure that it's active.
40 browser()->window()->Show(); 52 browser()->window()->Show();
41 53
42 CommandUpdater* updater = browser()->command_controller()->command_updater(); 54 CommandUpdater* updater = browser()->command_controller()->command_updater();
43 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE)); 55 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE));
44 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE)); 56 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE));
45 57
46 // Wait for the command execution to pop up the bubble. 58 // Wait for the command execution to pop up the bubble.
47 content::RunAllPendingInMessageLoop(); 59 content::RunAllPendingInMessageLoop();
48 } 60 }
49 61
50 void ManagePasswordsTest::SetupManagingPasswords() { 62 void ManagePasswordsTest::SetupManagingPasswords() {
51 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
52 std::map<base::string16, const autofill::PasswordForm*> map; 63 std::map<base::string16, const autofill::PasswordForm*> map;
53 map.insert(std::make_pair(kTestUsername, test_form())); 64 map.insert(std::make_pair(kTestUsername, test_form()));
54 GetController()->OnPasswordAutofilled(map, map.begin()->second->origin, 65 GetController()->OnPasswordAutofilled(map, map.begin()->second->origin,
55 nullptr); 66 nullptr);
56 } 67 }
57 68
58 void ManagePasswordsTest::SetupPendingPassword() { 69 void ManagePasswordsTest::SetupPendingPassword() {
59 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 70 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
60 new password_manager::PasswordFormManager( 71 new password_manager::PasswordFormManager(
61 nullptr, &client_, driver_.AsWeakPtr(), *test_form(), 72 nullptr, &client_, driver_.AsWeakPtr(), *test_form(),
(...skipping 22 matching lines...) Expand all
84 const char* histogram) { 95 const char* histogram) {
85 // Ensure that everything has been properly recorded before pulling samples. 96 // Ensure that everything has been properly recorded before pulling samples.
86 content::RunAllPendingInMessageLoop(); 97 content::RunAllPendingInMessageLoop();
87 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram); 98 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram);
88 } 99 }
89 100
90 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() { 101 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() {
91 return PasswordsClientUIDelegateFromWebContents( 102 return PasswordsClientUIDelegateFromWebContents(
92 browser()->tab_strip_model()->GetActiveWebContents()); 103 browser()->tab_strip_model()->GetActiveWebContents());
93 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698