| Index: chrome/renderer/searchbox/searchbox_unittest.cc
|
| diff --git a/chrome/renderer/searchbox/searchbox_unittest.cc b/chrome/renderer/searchbox/searchbox_unittest.cc
|
| index 26dcc77d176112dc4442ef4977fe8af5358c031a..481f0e417526754843ca142f4ee8a00700b63d29 100644
|
| --- a/chrome/renderer/searchbox/searchbox_unittest.cc
|
| +++ b/chrome/renderer/searchbox/searchbox_unittest.cc
|
| @@ -14,6 +14,12 @@ bool GetInstantRestrictedIDFromURL(int render_view_id,
|
| const GURL& url,
|
| InstantRestrictedID* id);
|
|
|
| +// Defined in searchbox_extension.cc
|
| +bool ParseRestrictedFaviconUrl(int render_view_id,
|
| + const GURL& url,
|
| + std::string* favicon_params,
|
| + InstantRestrictedID* rid);
|
| +
|
| TEST(SearchBoxUtilTest, GetInstantRestrictedIDFromTransientURL) {
|
| const int kInvalidRenderViewID = 920;
|
| const int kValidRenderViewID = 1;
|
| @@ -57,4 +63,168 @@ 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,
|
| + false
|
| + },
|
| + {
|
| + kInvalidRenderViewID,
|
| + GURL("chrome-search://favicon/size/16@2x/1/2"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kInvalidRenderViewID,
|
| + GURL("chrome-search://favicon/largest/1/2"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kInvalidRenderViewID,
|
| + GURL("chrome-search://favicon/origin/1/2"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kInvalidRenderViewID,
|
| + GURL("chrome-search://favicon/iconurl/1/2"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| +
|
| + // Invalid transient urls.
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/size"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/size/16@2x"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/size/16@2x/123"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/size/16@2x/xyz"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/size/16@2x/123/"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/size/16@2x/123/xyz"),
|
| + "",
|
| + 0,
|
| + false
|
| + },
|
| + {
|
| + kValidRenderViewID,
|
| + GURL("chrome-search://favicon/invalidparameter/16@2x/1/2"),
|
| + "",
|
| + 0,
|
| + false
|
| + }
|
| + };
|
| +
|
| + std::string favicon_params = "";
|
| + InstantRestrictedID rid = 0;
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
| + bool return_val = ParseRestrictedFaviconUrl(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
|
|
|