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

Unified Diff: a.c

Issue 2696423002: FaviconHandlerTest dream
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: a.c
diff --git a/a.c b/a.c
new file mode 100644
index 0000000000000000000000000000000000000000..d46f186f638a9cd152fa885d11965e6855434894
--- /dev/null
+++ b/a.c
@@ -0,0 +1,40 @@
+void RunAllPending(TestFaviconService* favicon_service, TestWebContents* web_contents) {
+ while (favicon_service->HasPending() || web_contents->HasPending()) {
+ favicon_service->RunAllPending();
+ web_contents->RunAllPending();
+ }
+}
+
+void OnUpdateFaviconUrl(FaviconHandler* favicon_handler, const GURL& page_url, const GURL& icon_url) {
+ std::vector<FaviconURL> urls;
+ urls.push_back(
+ FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
+ handler->OnUpdateFaviconURL(page_url, urls);
+}
+
+TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) {
+ const GURL page_url("http://www.google.com");
+ const GURL icon_url("http://www.google.com/favicon");
+
+ TestFaviconService service;
+ service.Store(page_url, Icon(icon_url, gfx::kFaviconSize, new base::RefCountedBytes()));
+ TestWebContents web_contents = GetTestWebContents();
+ web_contents->SetImage(icon_url, CreateSolidColorBitmap(SK_ColorBLUE));
+
+ FaviconHandler handler;
+ handler.FetchFavicon(page_url);
+ OnUpdateFaviconURL(&handler, page_url, icon_url);
+
+ RunAllPending(favicon_service, web_contents);
+
+ std::vector<Icon> stored_icons = handler.stored_icons();
+ ASSERT_EQ(1u, stored_icons.size());
+ EXPECT_EQ(icon_url, stored_icons[0].icon_url);
+ EXPECT_LT(0u, stored_icons[0].data.size());
+
+ // Verify NavigationEntry.
+ EXPECT_EQ(1u, driver.num_notifications());
+ EXPECT_EQ(icon_url, driver.icon_url());
+ EXPECT_FALSE(driver.image().IsEmpty());
+ EXPECT_EQ(gfx::kFaviconSize, driver.image().Width());
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698