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..013e2ef5351183eee2e09aeb5a85304c6622c3b1 100644 |
--- a/chrome/test/test_tab_strip_model_observer.cc |
+++ b/chrome/test/test_tab_strip_model_observer.cc |
@@ -6,25 +6,13 @@ |
#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) { |
+ TestTabStripModelObserver::JsInjectionReadyObserver* |
+ js_injection_ready_observer) |
+ : TestNavigationObserver(js_injection_ready_observer, 1), |
+ tab_strip_model_(tab_strip_model) { |
tab_strip_model_->AddObserver(this); |
} |
@@ -32,41 +20,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->controller()); |
} |