Chromium Code Reviews| Index: chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc |
| diff --git a/chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc b/chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e2108a4c872b374357b23fdcf592b77f3b31bbd1 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/profiles/force_signout_dialog_browsertest.cc |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/memory/ptr_util.h" |
| +#include "chrome/browser/signin/force_signout_timer.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/browser/ui/views/profiles/force_signout_dialog.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "components/app_modal/app_modal_dialog_queue.h" |
| +#include "components/app_modal/native_app_modal_dialog.h" |
| +#include "components/signin/core/browser/signin_manager.h" |
| +#include "ui/base/ui_base_types.h" |
| + |
| +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
|
| + |
| +IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, OpenDialog) { |
| + app_modal::AppModalDialogQueue* queue = |
| + app_modal::AppModalDialogQueue::GetInstance(); |
| + ASSERT_FALSE(queue->HasActiveDialog()); |
| + Profile* profile = browser()->profile(); |
| + SigninManager* manager = SigninManagerFactory::GetForProfile(profile); |
| + manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com"); |
| + ForceSignoutTimer timer; |
| + ForceSignoutDialog::ShowDialog(profile, manager, &timer); |
| + ASSERT_TRUE(queue->HasActiveDialog()); |
| + ASSERT_EQ(reinterpret_cast<void*>(profile), |
| + reinterpret_cast<void*>( |
| + queue->active_dialog()->web_contents()->GetBrowserContext())); |
| + ASSERT_EQ( |
| + ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| + queue->active_dialog()->native_dialog()->GetAppModalDialogButtons()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, |
| + NotOpenDialogDueToNoBrowser) { |
| + app_modal::AppModalDialogQueue* queue = |
| + app_modal::AppModalDialogQueue::GetInstance(); |
| + ASSERT_FALSE(queue->HasActiveDialog()); |
| + Profile* profile = browser()->profile(); |
| + CloseBrowserSynchronously(browser()); |
| + ForceSignoutDialog::ShowDialog( |
| + profile, SigninManagerFactory::GetForProfile(profile), nullptr); |
| + ASSERT_FALSE(queue->HasActiveDialog()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, |
| + NotOpenDialogDueToNoTabs) { |
| + app_modal::AppModalDialogQueue* queue = |
| + app_modal::AppModalDialogQueue::GetInstance(); |
| + ASSERT_FALSE(queue->HasActiveDialog()); |
| + Profile* profile = browser()->profile(); |
| + TabStripModel* model = browser()->tab_strip_model(); |
| + ASSERT_EQ(1, model->count()); |
| + model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); |
| + ASSERT_TRUE(model->empty()); |
| + ForceSignoutDialog::ShowDialog( |
| + profile, SigninManagerFactory::GetForProfile(profile), nullptr); |
| + ASSERT_FALSE(queue->HasActiveDialog()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(ForceSignoutDialogBrowserTest, |
| + OpenDialogWithDelayForbidden) { |
| + app_modal::AppModalDialogQueue* queue = |
| + app_modal::AppModalDialogQueue::GetInstance(); |
| + ASSERT_FALSE(queue->HasActiveDialog()); |
| + Profile* profile = browser()->profile(); |
| + SigninManager* manager = SigninManagerFactory::GetForProfile(profile); |
| + manager->SetAuthenticatedAccountInfo("test1", "test@xyz.com"); |
| + ForceSignoutDialog::ShowDialog(profile, manager, nullptr); |
| + ASSERT_TRUE(queue->HasActiveDialog()); |
| + ASSERT_EQ( |
| + ui::DIALOG_BUTTON_OK, |
| + queue->active_dialog()->native_dialog()->GetAppModalDialogButtons()); |
| +} |