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

Unified Diff: chrome/browser/task_manager/task_manager_browsertest.cc

Issue 7537045: Revert 95015 - WebUI TaskManager: make it default on Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/task_manager/task_manager_browsertest.cc
===================================================================
--- chrome/browser/task_manager/task_manager_browsertest.cc (revision 95017)
+++ chrome/browser/task_manager/task_manager_browsertest.cc (working copy)
@@ -18,7 +18,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/tabs/tab_strip_model.h"
-#include "chrome/browser/task_manager/task_manager_browsertest_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
@@ -47,6 +46,58 @@
const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
+class ResourceChangeObserver : public TaskManagerModelObserver {
+ public:
+ ResourceChangeObserver(const TaskManagerModel* model,
+ int target_resource_count)
+ : model_(model),
+ target_resource_count_(target_resource_count) {
+ }
+
+ virtual void OnModelChanged() {
+ OnResourceChange();
+ }
+
+ virtual void OnItemsChanged(int start, int length) {
+ OnResourceChange();
+ }
+
+ virtual void OnItemsAdded(int start, int length) {
+ OnResourceChange();
+ }
+
+ virtual void OnItemsRemoved(int start, int length) {
+ OnResourceChange();
+ }
+
+ private:
+ void OnResourceChange() {
+ if (model_->ResourceCount() == target_resource_count_)
+ MessageLoopForUI::current()->Quit();
+ }
+
+ const TaskManagerModel* model_;
+ const int target_resource_count_;
+};
+
+// Helper class used to wait for a BackgroundContents to finish loading.
+class BackgroundContentsListener : public NotificationObserver {
+ public:
+ explicit BackgroundContentsListener(Profile* profile) {
+ registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED,
+ Source<Profile>(profile));
+ }
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ // Quit once the BackgroundContents has been loaded.
+ if (type == chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED)
+ MessageLoopForUI::current()->Quit();
+ }
+ private:
+ NotificationRegistrar registrar_;
+};
+
} // namespace
class TaskManagerBrowserTest : public ExtensionBrowserTest {
@@ -56,12 +107,18 @@
}
void WaitForResourceChange(int target_count) {
- TaskManagerBrowserTestUtil::WaitForResourceChange(target_count);
+ if (model()->ResourceCount() == target_count)
+ return;
+ ResourceChangeObserver observer(model(), target_count);
+ model()->AddObserver(&observer);
+ ui_test_utils::RunMessageLoop();
+ model()->RemoveObserver(&observer);
}
// Wait for any pending BackgroundContents to finish starting up.
void WaitForBackgroundContents() {
- TaskManagerBrowserTestUtil::WaitForBackgroundContents(browser());
+ BackgroundContentsListener listener(browser()->profile());
+ ui_test_utils::RunMessageLoop();
}
};
« no previous file with comments | « chrome/browser/prerender/prerender_browsertest.cc ('k') | chrome/browser/task_manager/task_manager_browsertest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698