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

Side by Side Diff: chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view_browsertest.cc

Issue 2944713003: After signin token check failed, show force reauth dialog and start window closing countdown. (Closed)
Patch Set: nit Created 3 years, 5 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h" 5 #include "chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/browser/ui/test/test_browser_dialog.h" 13 #include "chrome/browser/ui/test/test_browser_dialog.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "components/signin/core/browser/signin_manager.h" 15 #include "components/signin/core/browser/signin_manager.h"
16 #include "ui/base/ui_base_types.h" 16 #include "ui/base/ui_base_types.h"
17 17
18 class ForcedReauthenticationDialogBrowserTest : public DialogBrowserTest { 18 class ForcedReauthenticationDialogViewBrowserTest : public DialogBrowserTest {
19 public: 19 public:
20 ForcedReauthenticationDialogBrowserTest() {} 20 ForcedReauthenticationDialogViewBrowserTest() {}
21 21
22 // override DialogBrowserTest 22 // override DialogBrowserTest
23 void ShowDialog(const std::string& name) override { 23 void ShowDialog(const std::string& name) override {
24 Profile* profile = browser()->profile(); 24 Profile* profile = browser()->profile();
25 SigninManager* manager = SigninManagerFactory::GetForProfile(profile); 25 SigninManager* manager = SigninManagerFactory::GetForProfile(profile);
26 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com"); 26 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com");
27 ForcedReauthenticationDialog::ShowDialog(profile, manager, 27 ForcedReauthenticationDialogView::ShowDialog(
28 base::TimeDelta::FromSeconds(60)); 28 profile, manager, base::TimeDelta::FromSeconds(60));
29 } 29 }
30 30
31 // An integer represents the buttons of dialog. 31 // An integer represents the buttons of dialog.
32 32
33 private: 33 private:
34 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialogBrowserTest); 34 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialogViewBrowserTest);
35 }; 35 };
36 36
37 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest, 37 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogViewBrowserTest,
38 InvokeDialog_default) { 38 InvokeDialog_default) {
39 RunDialog(); 39 RunDialog();
40 } 40 }
41 41
42 // Dialog will not be display if there is no valid browser window. 42 // Dialog will not be display if there is no valid browser window.
43 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest, 43 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogViewBrowserTest,
44 NotOpenDialogDueToNoBrowser) { 44 NotOpenDialogDueToNoBrowser) {
45 Profile* profile = browser()->profile(); 45 Profile* profile = browser()->profile();
46 CloseBrowserSynchronously(browser()); 46 CloseBrowserSynchronously(browser());
47 EXPECT_EQ(nullptr, ForcedReauthenticationDialog::ShowDialog( 47 EXPECT_EQ(nullptr, ForcedReauthenticationDialogView::ShowDialog(
48 profile, SigninManagerFactory::GetForProfile(profile), 48 profile, SigninManagerFactory::GetForProfile(profile),
49 base::TimeDelta::FromSeconds(60))); 49 base::TimeDelta::FromSeconds(60)));
50 } 50 }
51 51
52 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogBrowserTest, 52 IN_PROC_BROWSER_TEST_F(ForcedReauthenticationDialogViewBrowserTest,
53 NotOpenDialogDueToNoTabs) { 53 NotOpenDialogDueToNoTabs) {
54 Profile* profile = browser()->profile(); 54 Profile* profile = browser()->profile();
55 TabStripModel* model = browser()->tab_strip_model(); 55 TabStripModel* model = browser()->tab_strip_model();
56 ASSERT_EQ(1, model->count()); 56 ASSERT_EQ(1, model->count());
57 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); 57 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE);
58 ASSERT_TRUE(model->empty()); 58 ASSERT_TRUE(model->empty());
59 EXPECT_EQ(nullptr, ForcedReauthenticationDialog::ShowDialog( 59 EXPECT_EQ(nullptr, ForcedReauthenticationDialogView::ShowDialog(
60 profile, SigninManagerFactory::GetForProfile(profile), 60 profile, SigninManagerFactory::GetForProfile(profile),
61 base::TimeDelta::FromSeconds(60))); 61 base::TimeDelta::FromSeconds(60)));
62 } 62 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/forced_reauthentication_dialog_view.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698