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/memory/ptr_util.h" | |
| 6 #include "chrome/browser/signin/force_signout_timer.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/views/profiles/force_signout_dialog.h" | |
| 11 #include "chrome/test/base/in_process_browser_test.h" | |
| 12 #include "components/app_modal/app_modal_dialog_queue.h" | |
| 13 #include "components/app_modal/native_app_modal_dialog.h" | |
| 14 #include "components/signin/core/browser/signin_manager.h" | |
| 15 #include "ui/base/ui_base_types.h" | |
| 16 | |
| 17 class ForceSignoutDialogBrowserTest : public InProcessBrowserTest {}; | |
|
sky
2017/05/04 03:45:11
This code should follow the details here: https://
zmin
2017/05/04 23:13:52
Will do
| |
| 18 | |
| 19 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, OpenDialog) { | |
| 20 app_modal::AppModalDialogQueue* queue = | |
| 21 app_modal::AppModalDialogQueue::GetInstance(); | |
| 22 ASSERT_FALSE(queue->HasActiveDialog()); | |
| 23 Profile* profile = browser()->profile(); | |
| 24 SigninManager* manager = SigninManagerFactory::GetForProfile(profile); | |
| 25 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com"); | |
| 26 ForceSignoutTimer timer; | |
| 27 ForceSignoutDialog::ShowDialog(profile, manager, &timer); | |
| 28 ASSERT_TRUE(queue->HasActiveDialog()); | |
| 29 ASSERT_EQ(reinterpret_cast<void*>(profile), | |
| 30 reinterpret_cast<void*>( | |
| 31 queue->active_dialog()->web_contents()->GetBrowserContext())); | |
| 32 ASSERT_EQ( | |
| 33 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, | |
| 34 queue->active_dialog()->native_dialog()->GetAppModalDialogButtons()); | |
| 35 } | |
| 36 | |
| 37 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, | |
| 38 NotOpenDialogDueToNoBrowser) { | |
| 39 app_modal::AppModalDialogQueue* queue = | |
| 40 app_modal::AppModalDialogQueue::GetInstance(); | |
| 41 ASSERT_FALSE(queue->HasActiveDialog()); | |
| 42 Profile* profile = browser()->profile(); | |
| 43 CloseBrowserSynchronously(browser()); | |
| 44 ForceSignoutDialog::ShowDialog( | |
| 45 profile, SigninManagerFactory::GetForProfile(profile), nullptr); | |
| 46 ASSERT_FALSE(queue->HasActiveDialog()); | |
| 47 } | |
| 48 | |
| 49 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, | |
| 50 NotOpenDialogDueToNoTabs) { | |
| 51 app_modal::AppModalDialogQueue* queue = | |
| 52 app_modal::AppModalDialogQueue::GetInstance(); | |
| 53 ASSERT_FALSE(queue->HasActiveDialog()); | |
| 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 ForceSignoutDialog::ShowDialog( | |
| 60 profile, SigninManagerFactory::GetForProfile(profile), nullptr); | |
| 61 ASSERT_FALSE(queue->HasActiveDialog()); | |
| 62 } | |
| 63 | |
| 64 IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, | |
| 65 OpenDialogWithDelayForbidden) { | |
| 66 app_modal::AppModalDialogQueue* queue = | |
| 67 app_modal::AppModalDialogQueue::GetInstance(); | |
| 68 ASSERT_FALSE(queue->HasActiveDialog()); | |
| 69 Profile* profile = browser()->profile(); | |
| 70 SigninManager* manager = SigninManagerFactory::GetForProfile(profile); | |
| 71 manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com"); | |
| 72 ForceSignoutDialog::ShowDialog(profile, manager, nullptr); | |
| 73 ASSERT_TRUE(queue->HasActiveDialog()); | |
| 74 ASSERT_EQ( | |
| 75 ui::DIALOG_BUTTON_OK, | |
| 76 queue->active_dialog()->native_dialog()->GetAppModalDialogButtons()); | |
| 77 } | |
| OLD | NEW |