Chromium Code Reviews| Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view_interactive_uitest.cc |
| diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_interactive_uitest.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_interactive_uitest.cc |
| index 1579d11594006ac20772438262888c2444e7c8bc..891fab17a198a76ca9159251e9297e0abdc8e05b 100644 |
| --- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_interactive_uitest.cc |
| +++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view_interactive_uitest.cc |
| @@ -16,6 +16,7 @@ |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/passwords/manage_passwords_test.h" |
| #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
| +#include "chrome/browser/ui/tab_dialogs.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/views/frame/browser_view.h" |
| #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
| @@ -26,6 +27,8 @@ |
| #include "content/public/common/content_features.h" |
| #include "net/url_request/test_url_fetcher_factory.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| +#include "ui/base/ui_base_switches.h" |
| +#include "ui/base/ui_features.h" |
| #include "ui/views/test/widget_test.h" |
|
msw
2017/04/19 18:23:17
nit: remove if no longer needed
varkha
2017/04/20 04:14:20
Done.
|
| using testing::Eq; |
| @@ -63,9 +66,24 @@ bool IsBubbleShowing() { |
| namespace metrics_util = password_manager::metrics_util; |
| -using ManagePasswordsBubbleViewTest = ManagePasswordsTest; |
| +class ManagePasswordsBubbleViewTest : public ManagePasswordsTest { |
| + public: |
| + ManagePasswordsBubbleViewTest() {} |
| + ~ManagePasswordsBubbleViewTest() override {} |
| + |
| + // content::BrowserTestBase: |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| +#if defined(OS_MACOSX) |
| + command_line->AppendSwitch(switches::kExtendMdToSecondaryUi); |
| +#endif |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleViewTest); |
| +}; |
| IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, BasicOpenAndClose) { |
| + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| EXPECT_FALSE(IsBubbleShowing()); |
| SetupPendingPassword(); |
| EXPECT_TRUE(IsBubbleShowing()); |
| @@ -75,11 +93,15 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, BasicOpenAndClose) { |
| EXPECT_FALSE(bubble->GetFocusManager()->GetFocusedView()); |
| ManagePasswordsBubbleView::CloseCurrentBubble(); |
| EXPECT_FALSE(IsBubbleShowing()); |
| + // Drain message pump to ensure the bubble view is cleared so that it can be |
| + // created again (it is checked on Mac to prevent re-opening the bubble when |
| + // clicking the location bar button repeatedly). |
| + content::RunAllPendingInMessageLoop(); |
| // And, just for grins, ensure that we can re-open the bubble. |
| - ManagePasswordsBubbleView::ShowBubble( |
| - browser()->tab_strip_model()->GetActiveWebContents(), |
| - ManagePasswordsBubbleView::USER_GESTURE); |
| + TabDialogs::FromWebContents( |
| + browser()->tab_strip_model()->GetActiveWebContents()) |
| + ->ShowManagePasswordsBubble(true /* user_action */); |
| EXPECT_TRUE(IsBubbleShowing()); |
| bubble = ManagePasswordsBubbleView::manage_password_bubble(); |
| EXPECT_TRUE(bubble->initially_focused_view()); |
| @@ -92,6 +114,7 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, BasicOpenAndClose) { |
| // Same as 'BasicOpenAndClose', but use the command rather than the static |
| // method directly. |
| IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, CommandControlsBubble) { |
| + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| // The command only works if the icon is visible, so get into management mode. |
| SetupManagingPasswords(); |
| EXPECT_FALSE(IsBubbleShowing()); |
| @@ -104,6 +127,10 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, CommandControlsBubble) { |
| bubble->GetFocusManager()->GetFocusedView()); |
| ManagePasswordsBubbleView::CloseCurrentBubble(); |
| EXPECT_FALSE(IsBubbleShowing()); |
| + // Drain message pump to ensure the bubble view is cleared so that it can be |
| + // created again (it is checked on Mac to prevent re-opening the bubble when |
| + // clicking the location bar button repeatedly). |
| + content::RunAllPendingInMessageLoop(); |
| // And, just for grins, ensure that we can re-open the bubble. |
| ExecuteManagePasswordsCommand(); |
| @@ -166,6 +193,11 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, |
| SetupPendingPassword(); |
| EXPECT_TRUE(IsBubbleShowing()); |
| ManagePasswordsBubbleView::CloseCurrentBubble(); |
| + // Drain message pump to ensure the bubble view is cleared so that it can be |
| + // created again (it is checked on Mac to prevent re-opening the bubble when |
| + // clicking the location bar button repeatedly). |
| + content::RunAllPendingInMessageLoop(); |
| + |
| // This opening should be measured as manual. |
| ExecuteManagePasswordsCommand(); |
| EXPECT_TRUE(IsBubbleShowing()); |
| @@ -317,24 +349,20 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, AutoSigninNoFocus) { |
| // Open another window with focus. |
| Browser* focused_window = CreateBrowser(browser()->profile()); |
| ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(focused_window)); |
| - content::RunAllPendingInMessageLoop(); |
| - gfx::NativeWindow window = browser()->window()->GetNativeWindow(); |
| - views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| - ASSERT_NE(nullptr, widget); |
| - |
| - views::test::WidgetActivationWaiter inactive_waiter(widget, false); |
| - inactive_waiter.Wait(); |
| ManagePasswordsBubbleView::set_auto_signin_toast_timeout(0); |
| SetupAutoSignin(std::move(local_credentials)); |
| - content::RunAllPendingInMessageLoop(); |
| EXPECT_TRUE(IsBubbleShowing()); |
| // Bring the first window back. The toast closes by timeout. |
| - focused_window->window()->Close(); |
| - browser()->window()->Activate(); |
| + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| content::RunAllPendingInMessageLoop(); |
| - views::test::WidgetActivationWaiter active_waiter(widget, true); |
| - active_waiter.Wait(); |
| + |
| +// Auto-close of the auto-sign-in dialog is not implemented for a Cocoa |
|
msw
2017/04/19 18:23:17
ditto: should it be implemented or is not auto-clo
varkha
2017/04/20 04:14:20
Done.
|
| +// browser. |
| +#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| EXPECT_FALSE(IsBubbleShowing()); |
| +#else |
| + EXPECT_TRUE(IsBubbleShowing()); |
| +#endif |
| } |