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

Unified Diff: chrome/test/test_tab_strip_model_observer.cc

Issue 7237030: Added options browser_tests using the generator and js handler framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent & commenting capitalization. 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/test/test_tab_strip_model_observer.cc
diff --git a/chrome/test/test_tab_strip_model_observer.cc b/chrome/test/test_tab_strip_model_observer.cc
index 9a209c690d76889455fa9a97d84b9ebd5e871720..a8666c67fda4b22c9d25335d5e33180e548a8bda 100644
--- a/chrome/test/test_tab_strip_model_observer.cc
+++ b/chrome/test/test_tab_strip_model_observer.cc
@@ -5,26 +5,12 @@
#include "chrome/test/test_tab_strip_model_observer.h"
#include "chrome/browser/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/test/ui_test_utils.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-TestTabStripModelObserver::LoadStartObserver::LoadStartObserver() {
-}
-
-TestTabStripModelObserver::LoadStartObserver::~LoadStartObserver() {
-}
TestTabStripModelObserver::TestTabStripModelObserver(
TabStripModel* tab_strip_model,
TestTabStripModelObserver::LoadStartObserver* load_start_observer)
- : navigation_started_(false),
- navigations_completed_(0),
- number_of_navigations_(1),
- tab_strip_model_(tab_strip_model),
- load_start_observer_(load_start_observer),
- done_(false),
- running_(false) {
+ : TestNavigationObserver(load_start_observer),
+ tab_strip_model_(tab_strip_model) {
tab_strip_model_->AddObserver(this);
}
@@ -32,41 +18,7 @@ TestTabStripModelObserver::~TestTabStripModelObserver() {
tab_strip_model_->RemoveObserver(this);
}
-void TestTabStripModelObserver::WaitForObservation() {
- if (!done_) {
- EXPECT_FALSE(running_);
- running_ = true;
- ui_test_utils::RunMessageLoop();
- }
-}
-
void TestTabStripModelObserver::TabInsertedAt(
TabContentsWrapper* contents, int index, bool foreground) {
- NavigationController* controller = &contents->controller();
- registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- Source<NavigationController>(controller));
- registrar_.Add(this, content::NOTIFICATION_LOAD_START,
- Source<NavigationController>(controller));
- registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
- Source<NavigationController>(controller));
-}
-
-void TestTabStripModelObserver::Observe(
- int type, const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED ||
- type == content::NOTIFICATION_LOAD_START) {
- if (!navigation_started_) {
- load_start_observer_->OnLoadStart();
- navigation_started_ = true;
- }
- } else if (type == content::NOTIFICATION_LOAD_STOP) {
- if (navigation_started_ &&
- ++navigations_completed_ == number_of_navigations_) {
- navigation_started_ = false;
- done_ = true;
- if (running_)
- MessageLoopForUI::current()->Quit();
- }
- }
+ RegisterAsObserver(contents);
}

Powered by Google App Engine
This is Rietveld 408576698