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

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

Issue 23455047: InstantExtended: Send search URLs to renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More browsertest fixes Created 7 years, 3 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 | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/search/instant_unittest_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/instant_service_unittest.cc
diff --git a/chrome/browser/search/instant_service_unittest.cc b/chrome/browser/search/instant_service_unittest.cc
index 1ae497ebb257b48188c77383fb02e4f41e291041..bc33eb6f56a09aaf63a2ff8a465b423c7f434258 100644
--- a/chrome/browser/search/instant_service_unittest.cc
+++ b/chrome/browser/search/instant_service_unittest.cc
@@ -6,6 +6,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
+#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_observer.h"
@@ -14,13 +15,17 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/common/render_messages.h"
+#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"
#include "testing/gmock/include/gmock/gmock.h"
-
-namespace chrome {
-
-namespace {
+#include "url/gurl.h"
class MockInstantServiceObserver : public InstantServiceObserver {
public:
@@ -48,6 +53,8 @@ class InstantServiceTest : public InstantUnitTestBase {
protected:
virtual void SetUp() OVERRIDE {
InstantUnitTestBase::SetUp();
+ field_trial_list_.reset(new base::FieldTrialList(
+ new metrics::SHA1EntropyProvider("42")));
instant_service_observer_.reset(new MockInstantServiceObserver());
instant_service_->AddObserver(instant_service_observer_.get());
@@ -65,6 +72,7 @@ class InstantServiceTest : public InstantUnitTestBase {
scoped_ptr<MockInstantServiceObserver> instant_service_observer_;
scoped_ptr<MockWebContentsObserver> instant_ntp_contents_observer_;
+ scoped_ptr<base::FieldTrialList> field_trial_list_;
};
TEST_F(InstantServiceTest, DispatchDefaultSearchProviderChanged) {
@@ -96,6 +104,24 @@ TEST_F(InstantServiceTest, DispatchGoogleURLUpdated) {
EXPECT_TRUE(StartsWithASCII(new_ntp_url.spec(), new_base_url, true));
}
-} // namespace
-
-} // namespace chrome
+TEST_F(InstantServiceTest, SendsSearchURLsToRenderer) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
+ "Group1 use_cacheable_ntp:1"));
+ scoped_ptr<content::MockRenderProcessHost> rph(
+ new content::MockRenderProcessHost(profile()));
+ rph->sink().ClearMessages();
+ instant_service_->Observe(
+ content::NOTIFICATION_RENDERER_PROCESS_CREATED,
+ content::Source<content::MockRenderProcessHost>(rph.get()),
+ content::NotificationService::NoDetails());
+ EXPECT_EQ(1U, rph->sink().message_count());
+ const IPC::Message* msg = rph->sink().GetMessageAt(0);
+ ASSERT_TRUE(msg);
+ std::vector<GURL> search_urls;
+ GURL new_tab_page_url;
+ ChromeViewMsg_SetSearchURLs::Read(msg, &search_urls, &new_tab_page_url);
+ EXPECT_EQ(2U, search_urls.size());
+ EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec());
+ EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec());
+ EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec());
+}
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/search/instant_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698