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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 "base/bind.h"
6 #include "base/memory/ptr_util.h"
7 #include "chrome/browser/signin/signin_manager_factory.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/test/test_browser_dialog.h"
11 #include "chrome/browser/ui/views/profiles/force_signout_dialog.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "components/signin/core/browser/signin_manager.h"
14 #include "ui/base/ui_base_types.h"
15
16 namespace {
17 void FakeFunction(bool flag) {}
18 } // namespace
19
20 class ForceSignoutDialogBrowserTest : public DialogBrowserTest {
21 public:
22 ForceSignoutDialogBrowserTest() {}
23
24 void SetUp() override {
25 DialogBrowserTest::SetUp();
26 buttons_ = -1;
27 }
28
29 // override DialogBrowserTest
30 void ShowDialog(const std::string& name) override {
31 Profile* profile = browser()->profile();
32 SigninManager* manager = SigninManagerFactory::GetForProfile(profile);
33 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com");
34 buttons_ =
35 ForceSignoutDialog::ShowDialog(
36 profile, manager, base::Bind(&FakeFunction), name != "nodelay")
37 ->GetDialogButtons();
38 }
39
40 // An integer represents the buttons of dialog.
41 int buttons_;
42
43 private:
44 DISALLOW_COPY_AND_ASSIGN(ForceSignoutDialogBrowserTest);
45 };
46
47 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, InvokeDialog_default) {
48 RunDialog();
49 ASSERT_EQ(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, buttons_);
50 }
51
52 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, InvokeDialog_nodelay) {
53 RunDialog();
54 ASSERT_EQ(ui::DIALOG_BUTTON_OK, buttons_);
55 }
56
57 // Dialog will not be display if there is no valid browser window.
58
59 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest,
60 NotOpenDialogDueToNoBrowser) {
61 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
62 Profile* profile = browser()->profile();
63 CloseBrowserSynchronously(browser());
64 ForceSignoutDialog::ShowDialog(profile,
65 SigninManagerFactory::GetForProfile(profile),
66 base::Bind(&FakeFunction), true);
67 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
68 }
69
70 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest,
71 NotOpenDialogDueToNoTabs) {
72 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
73 Profile* profile = browser()->profile();
74 TabStripModel* model = browser()->tab_strip_model();
75 ASSERT_EQ(1, model->count());
76 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
77 ASSERT_TRUE(model->empty());
78 ForceSignoutDialog::ShowDialog(profile,
79 SigninManagerFactory::GetForProfile(profile),
80 base::Bind(&FakeFunction), true);
81 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing());
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698