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

Unified Diff: chrome/renderer/searchbox/search_bouncer_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/renderer/searchbox/search_bouncer.cc ('k') | content/public/renderer/content_renderer_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/searchbox/search_bouncer_unittest.cc
diff --git a/chrome/renderer/searchbox/search_bouncer_unittest.cc b/chrome/renderer/searchbox/search_bouncer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bcb3a4c225c04113e4919db9d2240b7055e8ed94
--- /dev/null
+++ b/chrome/renderer/searchbox/search_bouncer_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/searchbox/search_bouncer.h"
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/render_messages.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+class SearchBouncerTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ bouncer_.reset(new SearchBouncer);
+ std::vector<GURL> search_urls;
+ search_urls.push_back(GURL("http://example.com/search"));
+ search_urls.push_back(GURL("http://example.com/search2"));
+ bouncer_->OnSetSearchURLs(search_urls, GURL("http://example.com/newtab"));
+ }
+
+ scoped_ptr<SearchBouncer> bouncer_;
+};
+
+TEST_F(SearchBouncerTest, ShouldFork) {
+ EXPECT_FALSE(bouncer_->ShouldFork(GURL()));
+ EXPECT_FALSE(bouncer_->ShouldFork(GURL("http://notsearch.example.com")));
+ EXPECT_TRUE(bouncer_->ShouldFork(GURL("http://example.com/search?q=foo")));
+ EXPECT_TRUE(bouncer_->ShouldFork(GURL("http://example.com/search2#q=foo")));
+ EXPECT_TRUE(bouncer_->ShouldFork(GURL("http://example.com/newtab")));
+}
+
+TEST_F(SearchBouncerTest, IsNewTabPage) {
+ EXPECT_FALSE(bouncer_->IsNewTabPage(GURL("http://example.com/foo")));
+ EXPECT_TRUE(bouncer_->IsNewTabPage(GURL("http://example.com/newtab")));
+}
+
+TEST_F(SearchBouncerTest, SetSearchURLs) {
+ std::vector<GURL> search_urls;
+ search_urls.push_back(GURL("http://other.example.com/search"));
+ const GURL new_tab_page_url(GURL("http://other.example.com/newtab"));
+ EXPECT_TRUE(bouncer_->OnControlMessageReceived(
+ ChromeViewMsg_SetSearchURLs(search_urls, new_tab_page_url)));
+ EXPECT_EQ(search_urls, bouncer_->search_urls_);
+ EXPECT_EQ(new_tab_page_url, bouncer_->new_tab_page_url_);
+}
« no previous file with comments | « chrome/renderer/searchbox/search_bouncer.cc ('k') | content/public/renderer/content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698