OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ref_counted_memory.h" | 8 #include "base/ref_counted_memory.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 TabNavigation(0, url, GURL(), title, std::string(), | 96 TabNavigation(0, url, GURL(), title, std::string(), |
97 PageTransition::LINK)); | 97 PageTransition::LINK)); |
98 return tab; | 98 return tab; |
99 } | 99 } |
100 | 100 |
101 void GetFaviconForHistoryItem(HistoryMenuBridge::HistoryItem* item) { | 101 void GetFaviconForHistoryItem(HistoryMenuBridge::HistoryItem* item) { |
102 bridge_->GetFaviconForHistoryItem(item); | 102 bridge_->GetFaviconForHistoryItem(item); |
103 } | 103 } |
104 | 104 |
105 void GotFaviconData(FaviconService::Handle handle, | 105 void GotFaviconData(FaviconService::Handle handle, |
106 bool know_favicon, | 106 history::FaviconData favicon) { |
107 scoped_refptr<RefCountedBytes> data, | 107 bridge_->GotFaviconData(handle, favicon); |
108 bool expired, | |
109 GURL url) { | |
110 bridge_->GotFaviconData(handle, know_favicon, data, expired, url); | |
111 } | 108 } |
112 | 109 |
113 CancelableRequestConsumerTSimple<HistoryMenuBridge::HistoryItem*>& | 110 CancelableRequestConsumerTSimple<HistoryMenuBridge::HistoryItem*>& |
114 favicon_consumer() { | 111 favicon_consumer() { |
115 return bridge_->favicon_consumer_; | 112 return bridge_->favicon_consumer_; |
116 } | 113 } |
117 | 114 |
118 BrowserTestHelper browser_test_helper_; | 115 BrowserTestHelper browser_test_helper_; |
119 scoped_ptr<MockBridge> bridge_; | 116 scoped_ptr<MockBridge> bridge_; |
120 }; | 117 }; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 SkBitmap bitmap; | 356 SkBitmap bitmap; |
360 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 25, 25); | 357 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 25, 25); |
361 bitmap.allocPixels(); | 358 bitmap.allocPixels(); |
362 bitmap.eraseRGB(255, 0, 0); | 359 bitmap.eraseRGB(255, 0, 0); |
363 | 360 |
364 // Convert it to raw PNG bytes. We totally ignore color order here because | 361 // Convert it to raw PNG bytes. We totally ignore color order here because |
365 // we just want to test the roundtrip through the Bridge, not that we can | 362 // we just want to test the roundtrip through the Bridge, not that we can |
366 // make icons look pretty. | 363 // make icons look pretty. |
367 std::vector<unsigned char> raw; | 364 std::vector<unsigned char> raw; |
368 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); | 365 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); |
369 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(raw)); | 366 scoped_refptr<RefCountedBytes> bytes(); |
370 | 367 |
371 // Set up the HistoryItem. | 368 // Set up the HistoryItem. |
372 HistoryMenuBridge::HistoryItem item; | 369 HistoryMenuBridge::HistoryItem item; |
373 item.menu_item.reset([[NSMenuItem alloc] init]); | 370 item.menu_item.reset([[NSMenuItem alloc] init]); |
374 GetFaviconForHistoryItem(&item); | 371 GetFaviconForHistoryItem(&item); |
375 | 372 |
376 // Pretend to be called back. | 373 // Pretend to be called back. |
377 GotFaviconData(item.icon_handle, true, bytes, false, GURL()); | 374 history::FaviconData favicon; |
| 375 favicon.known_icon = true; |
| 376 favicon.image_data = new RefCountedBytes(raw); |
| 377 favicon.expired = false; |
| 378 favicon.icon_url = GURL(); |
| 379 favicon.icon_type = history::FAVICON; |
| 380 GotFaviconData(item.icon_handle, favicon); |
378 | 381 |
379 // Make sure the callback works. | 382 // Make sure the callback works. |
380 EXPECT_FALSE(item.icon_requested); | 383 EXPECT_FALSE(item.icon_requested); |
381 EXPECT_TRUE(item.icon.get()); | 384 EXPECT_TRUE(item.icon.get()); |
382 EXPECT_TRUE([item.menu_item image]); | 385 EXPECT_TRUE([item.menu_item image]); |
383 } | 386 } |
384 | 387 |
385 } // namespace | 388 } // namespace |
OLD | NEW |