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

Unified Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view_interactive_uitest.cc

Issue 2808823002: MacViews: Allows the toolkit-views Manage Passwords Dialog to be used (Closed)
Patch Set: MacViews: Allows the toolkit-views Manage Passwords Dialog to be used (rebase) Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8c6868c3beb31685870929b8f5b8e1d9595970c1 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,7 +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/views/test/widget_test.h"
+#include "ui/base/ui_base_switches.h"
+#include "ui/base/ui_features.h"
using testing::Eq;
using testing::Field;
@@ -63,9 +65,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 +92,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 +113,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 +126,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 +192,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 +348,24 @@ 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();
content::RunAllPendingInMessageLoop();
- views::test::WidgetActivationWaiter active_waiter(widget, true);
- active_waiter.Wait();
+ ui_test_utils::BrowserActivationWaiter waiter(browser());
+ waiter.WaitForActivation();
+
+// Sign-in dialogs opened for inactive browser windows do not auto-close on
+// MacOS. This matches existing Cocoa bubble behavior.
+// TODO(varkha): Remove the limitation as part of http://crbug/671916 .
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
EXPECT_FALSE(IsBubbleShowing());
+#else
+ EXPECT_TRUE(IsBubbleShowing());
+#endif
}
« no previous file with comments | « chrome/browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698