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

Side by Side Diff: chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm

Issue 10870022: Change FaviconData to be able to return data for multiple bitmaps for same icon URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 TabNavigation(0, url, content::Referrer(), title, std::string(), 97 TabNavigation(0, url, content::Referrer(), title, std::string(),
98 content::PAGE_TRANSITION_LINK)); 98 content::PAGE_TRANSITION_LINK));
99 return tab; 99 return tab;
100 } 100 }
101 101
102 void GetFaviconForHistoryItem(HistoryMenuBridge::HistoryItem* item) { 102 void GetFaviconForHistoryItem(HistoryMenuBridge::HistoryItem* item) {
103 bridge_->GetFaviconForHistoryItem(item); 103 bridge_->GetFaviconForHistoryItem(item);
104 } 104 }
105 105
106 void GotFaviconData(FaviconService::Handle handle, 106 void GotFaviconData(FaviconService::Handle handle,
107 history::FaviconData favicon) { 107 history::FaviconData favicon_data) {
108 bridge_->GotFaviconData(handle, favicon); 108 bridge_->GotFaviconData(handle, favicon_data);
109 } 109 }
110 110
111 CancelableRequestConsumerTSimple<HistoryMenuBridge::HistoryItem*>& 111 CancelableRequestConsumerTSimple<HistoryMenuBridge::HistoryItem*>&
112 favicon_consumer() { 112 favicon_consumer() {
113 return bridge_->favicon_consumer_; 113 return bridge_->favicon_consumer_;
114 } 114 }
115 115
116 scoped_ptr<MockBridge> bridge_; 116 scoped_ptr<MockBridge> bridge_;
117 }; 117 };
118 118
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // make icons look pretty. 363 // make icons look pretty.
364 std::vector<unsigned char> raw; 364 std::vector<unsigned char> raw;
365 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); 365 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw);
366 366
367 // Set up the HistoryItem. 367 // Set up the HistoryItem.
368 HistoryMenuBridge::HistoryItem item; 368 HistoryMenuBridge::HistoryItem item;
369 item.menu_item.reset([[NSMenuItem alloc] init]); 369 item.menu_item.reset([[NSMenuItem alloc] init]);
370 GetFaviconForHistoryItem(&item); 370 GetFaviconForHistoryItem(&item);
371 371
372 // Pretend to be called back. 372 // Pretend to be called back.
373 history::FaviconData favicon; 373 history::FaviconBitmapData favicon_bitmap_data;
374 favicon.known_icon = true; 374 favicon_bitmap_data.expired = false;
375 favicon.image_data = new base::RefCountedBytes(raw); 375 favicon_bitmap_data.bitmap_data = new base::RefCountedBytes(raw);
376 favicon.expired = false; 376 favicon_bitmap_data.pixel_size = gfx::Size();
377 favicon.icon_url = GURL(); 377
378 favicon.icon_type = history::FAVICON; 378 FaviconData favicon_data;
379 GotFaviconData(item.icon_handle, favicon); 379 favicon_data.icon_type = history::FAVICON;
380 favicon_data.icon_url = GURL();
381 favicon_data.bitmaps.push_back(favicon_bitmap_data);
382 favicon_data.sizes.push_back(gfx::Size());
383 GotFaviconData(item.icon_handle, favicon_data);
380 384
381 // Make sure the callback works. 385 // Make sure the callback works.
382 EXPECT_FALSE(item.icon_requested); 386 EXPECT_FALSE(item.icon_requested);
383 EXPECT_TRUE(item.icon.get()); 387 EXPECT_TRUE(item.icon.get());
384 EXPECT_TRUE([item.menu_item image]); 388 EXPECT_TRUE([item.menu_item image]);
385 } 389 }
386 390
387 } // namespace 391 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698