Chromium Code Reviews| 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* | |
| 35 ManagePasswordsViewTest::controller() { | |
| 36 return static_cast<ManagePasswordsBubbleUIControllerMock*>( | |
| 37 ManagePasswordsBubbleUIController::FromWebContents( | |
| 38 browser()->tab_strip_model()->GetActiveWebContents())); | |
| 39 } | |
| 40 | |
| 41 ManagePasswordsIconView* ManagePasswordsViewTest::view() const { | |
| 42 BrowserView* browser_view = reinterpret_cast<BrowserView*>( | |
|
vabr (Chromium)
2014/04/25 15:26:17
nit: This is casting a class to its subclass, and
Peter Kasting
2014/04/25 22:12:02
Indeed, a cast between different points of an inhe
Mike West
2014/04/28 10:52:56
Done.
| |
| 43 browser()->window()); | |
| 44 return browser_view->GetToolbarView() | |
| 45 ->location_bar() | |
|
Peter Kasting
2014/04/25 22:12:02
Nit: Can go on previous line.
Also, put operators
Mike West
2014/04/28 10:52:56
Done.
| |
| 46 ->manage_passwords_icon_view(); | |
| 47 } | |
| 48 | |
| 49 void ManagePasswordsViewTest::ExecuteManagePasswordsCommand( | |
| 50 Expectation expectation) { | |
| 51 CommandUpdater* updater = | |
| 52 browser()->command_controller()->command_updater(); | |
| 53 EXPECT_EQ(expectation == EXPECT_SUCCESS, | |
| 54 updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE)); | |
| 55 EXPECT_EQ(expectation == EXPECT_SUCCESS, | |
| 56 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE)); | |
| 57 } | |
| 58 | |
| 59 void ManagePasswordsViewTest::SetupManagingPasswords() { | |
| 60 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); | |
| 61 autofill::PasswordFormMap map; | |
| 62 map[kTestUsername] = &test_form(); | |
| 63 controller()->OnPasswordAutofilled(map); | |
| 64 controller()->UpdateIconAndBubbleState(view()); | |
| 65 } | |
| 66 | |
| 67 void ManagePasswordsViewTest::SetupPendingPassword() { | |
| 68 password_manager::StubPasswordManagerClient client; | |
| 69 password_manager::MockPasswordManagerDriver driver; | |
| 70 password_manager::PasswordFormManager* test_form_manager = | |
|
Peter Kasting
2014/04/25 22:12:02
If the call below takes ownership of this (not 100
| |
| 71 new password_manager::PasswordFormManager( | |
| 72 NULL, &client, &driver, test_form_, false); | |
| 73 controller()->OnPasswordSubmitted(test_form_manager); | |
| 74 controller()->UpdateIconAndBubbleState(view()); | |
| 75 } | |
| OLD | NEW |