Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/browser/ui/views/profiles/force_signout_dialog_view.h" | |
| 13 #include "chrome/test/base/in_process_browser_test.h" | |
| 14 #include "components/signin/core/browser/signin_manager.h" | |
| 15 #include "ui/base/ui_base_types.h" | |
| 16 | |
| 17 namespace { | |
| 18 void FakeFunction() {} | |
| 19 } // namespace | |
| 20 | |
| 21 class ForceSignoutDialogBrowserTest : public DialogBrowserTest { | |
| 22 public: | |
| 23 void SetUp() override { | |
| 24 DialogBrowserTest::SetUp(); | |
| 25 buttons = -1; | |
| 26 } | |
| 27 | |
| 28 // DialogBrowserTest | |
| 29 void ShowDialog(const std::string& name) override { | |
| 30 Profile* profile = browser()->profile(); | |
| 31 SigninManager* manager = SigninManagerFactory::GetForProfile(profile); | |
| 32 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com"); | |
| 33 base::Closure callback = base::Bind(&FakeFunction); | |
| 34 if (name == "nodelay") | |
| 35 callback = base::Closure(); | |
| 36 ForceSignoutDialog* dialog = | |
| 37 ForceSignoutDialog::ShowDialog(profile, manager, callback); | |
| 38 buttons = dialog->GetDialogViewForTesting()->GetDialogButtons(); | |
| 39 } | |
| 40 | |
| 41 int buttons; | |
|
sky
2017/05/17 18:03:18
buttons_ (and document what it is).
zmin
2017/05/18 03:31:18
Done.
| |
| 42 }; | |
|
sky
2017/05/17 18:03:18
DISALLOW...
zmin
2017/05/18 03:31:18
Done.
| |
| 43 | |
| 44 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, InvokeDialog_default) { | |
| 45 RunDialog(); | |
| 46 ASSERT_EQ(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, buttons); | |
| 47 } | |
| 48 | |
| 49 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, InvokeDialog_nodelay) { | |
| 50 RunDialog(); | |
| 51 ASSERT_EQ(ui::DIALOG_BUTTON_OK, buttons); | |
| 52 } | |
| 53 | |
| 54 // Dialog will not be display if there is no valid browser window. | |
| 55 | |
| 56 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, | |
| 57 NotOpenDialogDueToNoBrowser) { | |
| 58 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing()); | |
| 59 Profile* profile = browser()->profile(); | |
| 60 CloseBrowserSynchronously(browser()); | |
| 61 ForceSignoutDialog::ShowDialog( | |
| 62 profile, SigninManagerFactory::GetForProfile(profile), base::Closure()); | |
| 63 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing()); | |
| 64 } | |
| 65 | |
| 66 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, | |
| 67 NotOpenDialogDueToNoTabs) { | |
| 68 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing()); | |
| 69 Profile* profile = browser()->profile(); | |
| 70 TabStripModel* model = browser()->tab_strip_model(); | |
| 71 ASSERT_EQ(1, model->count()); | |
| 72 model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); | |
| 73 ASSERT_TRUE(model->empty()); | |
| 74 ForceSignoutDialog::ShowDialog( | |
| 75 profile, SigninManagerFactory::GetForProfile(profile), base::Closure()); | |
| 76 ASSERT_FALSE(BrowserModalDialogList::GetInstance()->IsShowing()); | |
| 77 } | |
| OLD | NEW |