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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 // Convert it to raw PNG bytes. We totally ignore color order here because | 363 // Convert it to raw PNG bytes. We totally ignore color order here because |
364 // we just want to test the roundtrip through the Bridge, not that we can | 364 // we just want to test the roundtrip through the Bridge, not that we can |
365 // make icons look pretty. | 365 // make icons look pretty. |
366 std::vector<unsigned char> raw; | 366 std::vector<unsigned char> raw; |
367 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); | 367 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); |
368 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(raw)); | 368 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(raw)); |
369 | 369 |
370 // Set up the HistoryItem. | 370 // Set up the HistoryItem. |
371 HistoryMenuBridge::HistoryItem item; | 371 HistoryMenuBridge::HistoryItem item; |
372 scoped_nsobject<NSMenuItem> menu_item([[NSMenuItem alloc] init]); | 372 item.menu_item.reset([[NSMenuItem alloc] init]); |
373 item.menu_item = menu_item.get(); | |
374 GetFaviconForHistoryItem(&item); | 373 GetFaviconForHistoryItem(&item); |
375 | 374 |
376 // Pretend to be called back. | 375 // Pretend to be called back. |
377 GotFaviconData(item.icon_handle, true, bytes, false, GURL()); | 376 GotFaviconData(item.icon_handle, true, bytes, false, GURL()); |
378 | 377 |
379 // Make sure the callback works. | 378 // Make sure the callback works. |
380 EXPECT_EQ(false, item.icon_requested); | 379 EXPECT_EQ(false, item.icon_requested); |
381 EXPECT_TRUE(item.icon.get()); | 380 EXPECT_TRUE(item.icon.get()); |
382 EXPECT_TRUE([item.menu_item image]); | 381 EXPECT_TRUE([item.menu_item image]); |
383 } | 382 } |
384 | 383 |
385 } // namespace | 384 } // namespace |
OLD | NEW |