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

Side by Side Diff: chrome/browser/ui/views/profiles/forced_reauthentication_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: nit Created 3 years, 6 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 "chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/browser/ui/test/test_browser_dialog.h"
14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "components/signin/core/browser/signin_manager.h"
16 #include "ui/base/ui_base_types.h"
17
18 class ForcedReauthenticationDialogBrowserTest : public DialogBrowserTest {
19 public:
20 ForcedReauthenticationDialogBrowserTest() {}
21
22 // override DialogBrowserTest
23 void ShowDialog(const std::string& name) override {
24 Profile* profile = browser()->profile();
25 SigninManager* manager = SigninManagerFactory::GetForProfile(profile);
26 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com");
27 ForcedReauthenticationDialog::ShowDialog(profile, manager,
28 base::TimeDelta::FromSeconds(60));
29 }
30
31 // An integer represents the buttons of dialog.
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialogBrowserTest);
35 };
36
37 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest,
38 InvokeDialog_default) {
39 RunDialog();
40 }
41
42 // Dialog will not be display if there is no valid browser window.
43 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest,
44 NotOpenDialogDueToNoBrowser) {
45 Profile* profile = browser()->profile();
46 CloseBrowserSynchronously(browser());
47 EXPECT_EQ(nullptr, ForcedReauthenticationDialog::ShowDialog(
48 profile, SigninManagerFactory::GetForProfile(profile),
49 base::TimeDelta::FromSeconds(60)));
50 }
51
52 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest,
53 NotOpenDialogDueToNoTabs) {
54 Profile* profile = browser()->profile();
55 TabStripModel* model = browser()->tab_strip_model();
56 ASSERT_EQ(1, model->count());
57 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
58 ASSERT_TRUE(model->empty());
59 EXPECT_EQ(nullptr, ForcedReauthenticationDialog::ShowDialog(
60 profile, SigninManagerFactory::GetForProfile(profile),
61 base::TimeDelta::FromSeconds(60)));
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698