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

Unified Diff: chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc

Issue 2862653002: If force-sign-in policy is enabled, popup warning dialog before window closing if auth token becom… (Closed)
Patch Set: cr and rebase from master 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc
diff --git a/chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc b/chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bbed7a40dbe53dd02f465543452ba030e183a816
--- /dev/null
+++ b/chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc
@@ -0,0 +1,82 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/memory/ptr_util.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/test/test_browser_dialog.h"
+#include "chrome/browser/ui/views/profiles/force_signout_dialog.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "components/signin/core/browser/signin_manager.h"
+#include "ui/base/ui_base_types.h"
+
+namespace {
+void FakeFunction(bool flag) {}
+} // namespace
+
+class ForceSignoutDialogBrowserTest : public DialogBrowserTest {
+ public:
+ ForceSignoutDialogBrowserTest() {}
+
+ void SetUp() override {
+ DialogBrowserTest::SetUp();
+ buttons_ = -1;
+ }
+
+ // override DialogBrowserTest
+ void ShowDialog(const std::string& name) override {
+ Profile* profile = browser()->profile();
+ SigninManager* manager = SigninManagerFactory::GetForProfile(profile);
+ manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com");
+ buttons_ =
+ ForceSignoutDialog::ShowDialog(
+ profile, manager, base::Bind(&FakeFunction), name != "nodelay")
+ ->GetDialogButtons();
+ }
+
+ // An integer represents the buttons of dialog.
+ int buttons_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ForceSignoutDialogBrowserTest);
+};
+
+IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, InvokeDialog_default) {
+ RunDialog();
+ ASSERT_EQ(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, buttons_);
+}
+
+IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, InvokeDialog_nodelay) {
+ RunDialog();
+ ASSERT_EQ(ui::DIALOG_BUTTON_OK, buttons_);
+}
+
+// Dialog will not be display if there is no valid browser window.
+
+IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest,
+ NotOpenDialogDueToNoBrowser) {
+ ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
+ Profile* profile = browser()->profile();
+ CloseBrowserSynchronously(browser());
+ ForceSignoutDialog::ShowDialog(profile,
+ SigninManagerFactory::GetForProfile(profile),
+ base::Bind(&FakeFunction), true);
+ ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
+}
+
+IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest,
+ NotOpenDialogDueToNoTabs) {
+ ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
+ Profile* profile = browser()->profile();
+ TabStripModel* model = browser()->tab_strip_model();
+ ASSERT_EQ(1, model->count());
+ model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
+ ASSERT_TRUE(model->empty());
+ ForceSignoutDialog::ShowDialog(profile,
+ SigninManagerFactory::GetForProfile(profile),
+ base::Bind(&FakeFunction), true);
+ ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
+}

Powered by Google App Engine
This is Rietveld 408576698