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

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: remove timer 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, 60);
28 }
29
30 // An integer represents the buttons of dialog.
31
32 private:
33 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialogBrowserTest);
34 };
35
36 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest,
37 InvokeDialog_default) {
38 RunDialog();
39 }
40
41 // Dialog will not be display if there is no valid browser window.
42 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest,
43 NotOpenDialogDueToNoBrowser) {
44 Profile* profile = browser()->profile();
45 CloseBrowserSynchronously(browser());
46 EXPECT_EQ(nullptr,
47 ForcedReauthenticationDialog::ShowDialog(
48 profile, SigninManagerFactory::GetForProfile(profile), 60));
49 }
50
51 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest,
52 NotOpenDialogDueToNoTabs) {
53 Profile* profile = browser()->profile();
54 TabStripModel* model = browser()->tab_strip_model();
55 ASSERT_EQ(1, model->count());
56 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
57 ASSERT_TRUE(model->empty());
58 EXPECT_EQ(nullptr,
59 ForcedReauthenticationDialog::ShowDialog(
60 profile, SigninManagerFactory::GetForProfile(profile), 60));
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698