OLD | NEW |
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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // Create a fake item. | 331 // Create a fake item. |
332 HistoryMenuBridge::HistoryItem item; | 332 HistoryMenuBridge::HistoryItem item; |
333 item.title = base::ASCIIToUTF16("Title"); | 333 item.title = base::ASCIIToUTF16("Title"); |
334 item.url = GURL("http://google.com"); | 334 item.url = GURL("http://google.com"); |
335 | 335 |
336 // Request the icon. | 336 // Request the icon. |
337 GetFaviconForHistoryItem(&item); | 337 GetFaviconForHistoryItem(&item); |
338 | 338 |
339 // Make sure the item was modified properly. | 339 // Make sure the item was modified properly. |
340 EXPECT_TRUE(item.icon_requested); | 340 EXPECT_TRUE(item.icon_requested); |
341 EXPECT_NE(CancelableTaskTracker::kBadTaskId, item.icon_task_id); | 341 EXPECT_NE(base::CancelableTaskTracker::kBadTaskId, item.icon_task_id); |
342 } | 342 } |
343 | 343 |
344 TEST_F(HistoryMenuBridgeTest, GotFaviconData) { | 344 TEST_F(HistoryMenuBridgeTest, GotFaviconData) { |
345 // Create a dummy bitmap. | 345 // Create a dummy bitmap. |
346 SkBitmap bitmap; | 346 SkBitmap bitmap; |
347 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 25, 25); | 347 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 25, 25); |
348 bitmap.allocPixels(); | 348 bitmap.allocPixels(); |
349 bitmap.eraseRGB(255, 0, 0); | 349 bitmap.eraseRGB(255, 0, 0); |
350 | 350 |
351 // Set up the HistoryItem. | 351 // Set up the HistoryItem. |
352 HistoryMenuBridge::HistoryItem item; | 352 HistoryMenuBridge::HistoryItem item; |
353 item.menu_item.reset([[NSMenuItem alloc] init]); | 353 item.menu_item.reset([[NSMenuItem alloc] init]); |
354 GetFaviconForHistoryItem(&item); | 354 GetFaviconForHistoryItem(&item); |
355 | 355 |
356 // Pretend to be called back. | 356 // Pretend to be called back. |
357 chrome::FaviconImageResult image_result; | 357 chrome::FaviconImageResult image_result; |
358 image_result.image = gfx::Image::CreateFrom1xBitmap(bitmap); | 358 image_result.image = gfx::Image::CreateFrom1xBitmap(bitmap); |
359 GotFaviconData(&item, image_result); | 359 GotFaviconData(&item, image_result); |
360 | 360 |
361 // Make sure the callback works. | 361 // Make sure the callback works. |
362 EXPECT_FALSE(item.icon_requested); | 362 EXPECT_FALSE(item.icon_requested); |
363 EXPECT_TRUE(item.icon.get()); | 363 EXPECT_TRUE(item.icon.get()); |
364 EXPECT_TRUE([item.menu_item image]); | 364 EXPECT_TRUE([item.menu_item image]); |
365 } | 365 } |
366 | 366 |
367 } // namespace | 367 } // namespace |
OLD | NEW |