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

Unified Diff: chrome/renderer/searchbox/searchbox_unittest.cc

Issue 18344010: Completing high dpi support for Instant Extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 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
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/searchbox/searchbox_unittest.cc
diff --git a/chrome/renderer/searchbox/searchbox_unittest.cc b/chrome/renderer/searchbox/searchbox_unittest.cc
index bfc73842a01ac1903bd1f429bb1acd051b414438..3cd31087019c655b41b65f66176ac0aaef3d0ce0 100644
--- a/chrome/renderer/searchbox/searchbox_unittest.cc
+++ b/chrome/renderer/searchbox/searchbox_unittest.cc
@@ -9,10 +9,16 @@
namespace internal {
-// Defined in searchbox_extension.cc
-bool GetInstantRestrictedIDFromURL(int render_view_id,
+// Defined in searchbox.cc
+bool GetRestrictedIDFromThumbnailUrl(int render_view_id,
+ const GURL& url,
+ InstantRestrictedID* id);
+
+// Defined in searchbox.cc
+bool GetRestrictedIDFromFaviconUrl(int render_view_id,
const GURL& url,
- InstantRestrictedID* id);
+ std::string* favicon_params,
+ InstantRestrictedID* rid);
TEST(SearchBoxUtilTest, GetInstantRestrictedIDFromTransientURL) {
const int kInvalidRenderViewID = 920;
@@ -49,7 +55,7 @@ TEST(SearchBoxUtilTest, GetInstantRestrictedIDFromTransientURL) {
InstantRestrictedID rid = 0;
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- bool return_val = GetInstantRestrictedIDFromURL(
+ bool return_val = GetRestrictedIDFromThumbnailUrl(
test_cases[i].render_view_id, test_cases[i].transient_url, &rid);
EXPECT_EQ(test_cases[i].expected_return_val, return_val);
EXPECT_EQ(test_cases[i].expected_rid, rid);
@@ -57,4 +63,171 @@ TEST(SearchBoxUtilTest, GetInstantRestrictedIDFromTransientURL) {
}
}
+TEST(SearchBoxUtilTest, ParseRestrictedFaviconTransientUrl) {
+ const int kInvalidRenderViewID = 920;
+ const int kValidRenderViewID = 1;
+
+ const struct {
+ int render_view_id;
+ GURL transient_url;
+ std::string expected_favicon_params;
+ InstantRestrictedID expected_rid;
+ bool expected_return_val;
+ } test_cases[] = {
+ // RenderView ID matches the view id specified in the transient url.
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/1/2"),
+ "",
+ 2,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x/1/2"),
+ "size/16@2x/",
+ 2,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/largest/1/2"),
+ "largest/",
+ 2,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/origin/1/2"),
+ "origin/",
+ 2,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/iconurl/1/2"),
+ "iconurl/",
+ 2,
+ true
+ },
+
+ // RenderView ID does not match the view id specified in the transient url.
+ {
+ kInvalidRenderViewID,
+ GURL("chrome-search://favicon/1/2"),
+ "",
+ 0,
+ true
+ },
+ {
+ kInvalidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x/1/2"),
+ "size/16@2x/",
+ 0,
+ true
+ },
+ {
+ kInvalidRenderViewID,
+ GURL("chrome-search://favicon/largest/1/2"),
+ "largest/",
+ 0,
+ true
+ },
+ {
+ kInvalidRenderViewID,
+ GURL("chrome-search://favicon/origin/1/2"),
+ "origin/",
+ 0,
+ true
+ },
+ {
+ kInvalidRenderViewID,
+ GURL("chrome-search://favicon/iconurl/1/2"),
+ "iconurl/",
+ 0,
+ true
+ },
+
+ // Invalid transient urls.
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon"),
+ "",
+ 0,
+ false
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/"),
+ "",
+ 0,
+ false
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x"),
+ "",
+ 0,
+ false
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size"),
+ "",
+ 0,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x/123"),
+ "size/16@2x/",
+ 0,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x/xyz"),
+ "size/16@2x/",
+ 0,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x/123/"),
+ "size/16@2x/",
+ 0,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/size/16@2x/123/xyz"),
+ "size/16@2x/",
+ 0,
+ true
+ },
+ {
+ kValidRenderViewID,
+ GURL("chrome-search://favicon/invalidparameter/16@2x/1/2"),
+ "",
+ 0,
+ true
+ }
+ };
+
+ std::string favicon_params = "";
+ InstantRestrictedID rid = 0;
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
+ bool return_val = GetRestrictedIDFromFaviconUrl(
+ test_cases[i].render_view_id,
+ test_cases[i].transient_url,
+ &favicon_params,
+ &rid);
+ EXPECT_EQ(test_cases[i].expected_return_val, return_val);
+ EXPECT_EQ(test_cases[i].expected_favicon_params, favicon_params);
+ EXPECT_EQ(test_cases[i].expected_rid, rid);
+ favicon_params = "";
+ rid = 0;
+ }
+}
+
} // namespace internal
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698