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

Unified Diff: trunk/src/chrome/browser/search/instant_service_unittest.cc

Issue 135903002: Revert 244407 "InstantExtended: remove dead code related to the ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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
« no previous file with comments | « trunk/src/chrome/browser/search/instant_service.cc ('k') | trunk/src/chrome/browser/search/search.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/chrome/browser/search/instant_service_unittest.cc
===================================================================
--- trunk/src/chrome/browser/search/instant_service_unittest.cc (revision 244428)
+++ trunk/src/chrome/browser/search/instant_service_unittest.cc (working copy)
@@ -20,6 +20,8 @@
#include "components/variations/entropy_provider.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/mock_render_process_host.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_test_sink.h"
@@ -32,6 +34,22 @@
MOCK_METHOD0(GoogleURLUpdated, void());
};
+class MockWebContentsObserver : public content::WebContentsObserver {
+ public:
+ MOCK_METHOD1(WebContentsDestroyed, void(content::WebContents*));
+
+ // Dumb override to make MSVC happy.
+ void Observe_(content::WebContents* contents) {
+ content::WebContentsObserver::Observe(contents);
+ }
+
+ protected:
+ friend class InstantServiceTest;
+ FRIEND_TEST_ALL_PREFIXES(InstantServiceTest,
+ DispatchDefaultSearchProviderChanged);
+ FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, DispatchGoogleURLUpdated);
+};
+
class InstantServiceTest : public InstantUnitTestBase {
protected:
virtual void SetUp() OVERRIDE {
@@ -39,10 +57,15 @@
instant_service_observer_.reset(new MockInstantServiceObserver());
instant_service_->AddObserver(instant_service_observer_.get());
+
+ instant_ntp_contents_observer_.reset(new MockWebContentsObserver());
+ instant_ntp_contents_observer_->Observe_(
+ instant_service_->GetNTPContents());
}
virtual void TearDown() OVERRIDE {
instant_service_->RemoveObserver(instant_service_observer_.get());
+ instant_ntp_contents_observer_->Observe_(NULL);
InstantUnitTestBase::TearDown();
}
@@ -51,21 +74,36 @@
}
scoped_ptr<MockInstantServiceObserver> instant_service_observer_;
+ scoped_ptr<MockWebContentsObserver> instant_ntp_contents_observer_;
};
TEST_F(InstantServiceTest, DispatchDefaultSearchProviderChanged) {
EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
.Times(1);
+ EXPECT_CALL(*instant_ntp_contents_observer_.get(),
+ WebContentsDestroyed(instant_service_->GetNTPContents()))
+ .Times(1);
+ GURL ntp_url = instant_service_->GetNTPContents()->GetURL();
const std::string& new_base_url = "https://bar.com/";
SetDefaultSearchProvider(new_base_url);
+ GURL new_ntp_url = instant_service_->GetNTPContents()->GetURL();
+ EXPECT_NE(ntp_url, new_ntp_url);
+ EXPECT_TRUE(StartsWithASCII(new_ntp_url.spec(), new_base_url, true));
}
TEST_F(InstantServiceTest, DispatchGoogleURLUpdated) {
EXPECT_CALL(*instant_service_observer_.get(), GoogleURLUpdated()).Times(1);
+ EXPECT_CALL(*instant_ntp_contents_observer_.get(),
+ WebContentsDestroyed(instant_service_->GetNTPContents()))
+ .Times(1);
+ GURL ntp_url = instant_service_->GetNTPContents()->GetURL();
const std::string& new_base_url = "https://www.google.es/";
NotifyGoogleBaseURLUpdate(new_base_url);
+ GURL new_ntp_url = instant_service_->GetNTPContents()->GetURL();
+ EXPECT_NE(ntp_url, new_ntp_url);
+ EXPECT_TRUE(StartsWithASCII(new_ntp_url.spec(), new_base_url, true));
}
TEST_F(InstantServiceTest, SendsSearchURLsToRenderer) {
« no previous file with comments | « trunk/src/chrome/browser/search/instant_service.cc ('k') | trunk/src/chrome/browser/search/search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698