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

Unified Diff: chrome/browser/lifetime/browser_close_manager_browsertest.cc

Issue 648833004: Componentize app_modal_dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: git cl try Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/lifetime/browser_close_manager_browsertest.cc
diff --git a/chrome/browser/lifetime/browser_close_manager_browsertest.cc b/chrome/browser/lifetime/browser_close_manager_browsertest.cc
index dd5fae9afc853f984e99b1a9f32b2cac52489eff..49eb321971b1d2fb255d76bc8c4a93f1441790d5 100644
--- a/chrome/browser/lifetime/browser_close_manager_browsertest.cc
+++ b/chrome/browser/lifetime/browser_close_manager_browsertest.cc
@@ -21,8 +21,6 @@
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
-#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_iterator.h"
@@ -32,6 +30,8 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/app_modal_dialogs/javascript_app_modal_dialog.h"
+#include "components/app_modal_dialogs/native_app_modal_dialog.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
@@ -53,44 +53,24 @@ class AppModalDialogObserver {
public:
AppModalDialogObserver() {}
- void Start() {
- observer_.reset(new content::WindowedNotificationObserver(
- chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
- content::NotificationService::AllSources()));
- }
-
void AcceptClose() {
- NativeAppModalDialog* dialog = GetNextDialog();
- ASSERT_TRUE(dialog);
- dialog->AcceptAppModalDialog();
+ GetNextDialog()->AcceptAppModalDialog();
}
void CancelClose() {
- NativeAppModalDialog* dialog = GetNextDialog();
- ASSERT_TRUE(dialog);
- dialog->CancelAppModalDialog();
+ GetNextDialog()->CancelAppModalDialog();
}
private:
NativeAppModalDialog* GetNextDialog() {
- DCHECK(observer_);
- observer_->Wait();
- if (observer_->source() == content::NotificationService::AllSources())
- return NULL;
-
- AppModalDialog* dialog =
- content::Source<AppModalDialog>(observer_->source()).ptr();
+ AppModalDialog* dialog = ui_test_utils::WaitForAppModalDialog();
EXPECT_TRUE(dialog->IsJavaScriptModalDialog());
JavaScriptAppModalDialog* js_dialog =
static_cast<JavaScriptAppModalDialog*>(dialog);
- observer_.reset(new content::WindowedNotificationObserver(
- chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
- content::NotificationService::AllSources()));
+ CHECK(js_dialog->native_dialog());
return js_dialog->native_dialog();
}
- scoped_ptr<content::WindowedNotificationObserver> observer_;
-
DISALLOW_COPY_AND_ASSIGN(AppModalDialogObserver);
};
@@ -242,7 +222,6 @@ class BrowserCloseManagerBrowserTest
SessionStartupPref::SetStartupPref(
browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
browsers_.push_back(browser());
- dialogs_.Start();
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,

Powered by Google App Engine
This is Rietveld 408576698