| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h" | |
| 6 | |
| 7 #include "chrome/app/chrome_command_ids.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/browser_command_controller.h" | |
| 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller_mock
.h" | |
| 11 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 14 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | |
| 15 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | |
| 16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | |
| 17 #include "chrome/test/base/in_process_browser_test.h" | |
| 18 #include "chrome/test/base/interactive_test_utils.h" | |
| 19 #include "components/autofill/core/common/password_form.h" | |
| 20 #include "components/password_manager/core/browser/mock_password_manager_driver.
h" | |
| 21 #include "components/password_manager/core/browser/password_form_manager.h" | |
| 22 #include "components/password_manager/core/browser/password_manager_driver.h" | |
| 23 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | |
| 24 #include "components/password_manager/core/browser/stub_password_manager_client.
h" | |
| 25 #include "testing/gtest/include/gtest/gtest.h" | |
| 26 | |
| 27 void ManagePasswordsViewTest::SetUpOnMainThread() { | |
| 28 // Create the test UIController here so that it's bound to the currently | |
| 29 // active WebContents. | |
| 30 new ManagePasswordsBubbleUIControllerMock( | |
| 31 browser()->tab_strip_model()->GetActiveWebContents()); | |
| 32 } | |
| 33 | |
| 34 ManagePasswordsBubbleUIControllerMock* ManagePasswordsViewTest::controller() { | |
| 35 return static_cast<ManagePasswordsBubbleUIControllerMock*>( | |
| 36 ManagePasswordsBubbleUIController::FromWebContents( | |
| 37 browser()->tab_strip_model()->GetActiveWebContents())); | |
| 38 } | |
| 39 | |
| 40 ManagePasswordsIconView* ManagePasswordsViewTest::view() { | |
| 41 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); | |
| 42 return browser_view->GetToolbarView()->location_bar()-> | |
| 43 manage_passwords_icon_view(); | |
| 44 } | |
| 45 | |
| 46 void ManagePasswordsViewTest::ExecuteManagePasswordsCommand() { | |
| 47 CommandUpdater* updater = browser()->command_controller()->command_updater(); | |
| 48 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE)); | |
| 49 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE)); | |
| 50 } | |
| 51 | |
| 52 void ManagePasswordsViewTest::SetupManagingPasswords() { | |
| 53 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); | |
| 54 autofill::PasswordFormMap map; | |
| 55 map[kTestUsername] = test_form(); | |
| 56 controller()->OnPasswordAutofilled(map); | |
| 57 controller()->UpdateIconAndBubbleState(view()); | |
| 58 } | |
| 59 | |
| 60 void ManagePasswordsViewTest::SetupPendingPassword() { | |
| 61 password_manager::StubPasswordManagerClient client; | |
| 62 password_manager::MockPasswordManagerDriver driver; | |
| 63 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( | |
| 64 new password_manager::PasswordFormManager( | |
| 65 NULL, &client, &driver, *test_form(), false)); | |
| 66 controller()->OnPasswordSubmitted(test_form_manager.release()); | |
| 67 controller()->UpdateIconAndBubbleState(view()); | |
| 68 } | |
| 69 | |
| 70 void ManagePasswordsViewTest::SetupBlackistedPassword() { | |
| 71 controller()->OnBlacklistBlockedAutofill(); | |
| 72 controller()->UpdateIconAndBubbleState(view()); | |
| 73 } | |
| OLD | NEW |