| 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/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/cancelable_request.h" | 14 #include "chrome/browser/cancelable_request.h" |
| 15 #include "chrome/browser/sessions/tab_restore_service.h" | 15 #include "chrome/browser/sessions/tab_restore_service.h" |
| 16 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 16 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 17 #include "chrome/browser/ui/cocoa/history_menu_bridge.h" | 17 #include "chrome/browser/ui/cocoa/history_menu_bridge.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #import "testing/gtest_mac.h" | 20 #import "testing/gtest_mac.h" |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
| 22 #include "ui/gfx/codec/png_codec.h" | 22 #include "ui/gfx/codec/png_codec.h" |
| 23 #include "ui/gfx/favicon_size.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 class MockTRS : public TabRestoreService { | 27 class MockTRS : public TabRestoreService { |
| 27 public: | 28 public: |
| 28 MockTRS(Profile* profile) : TabRestoreService(profile, NULL) {} | 29 MockTRS(Profile* profile) : TabRestoreService(profile, NULL) {} |
| 29 MOCK_CONST_METHOD0(entries, const TabRestoreService::Entries&()); | 30 MOCK_CONST_METHOD0(entries, const TabRestoreService::Entries&()); |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 class MockBridge : public HistoryMenuBridge { | 33 class MockBridge : public HistoryMenuBridge { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); | 366 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &raw); |
| 366 | 367 |
| 367 // Set up the HistoryItem. | 368 // Set up the HistoryItem. |
| 368 HistoryMenuBridge::HistoryItem item; | 369 HistoryMenuBridge::HistoryItem item; |
| 369 item.menu_item.reset([[NSMenuItem alloc] init]); | 370 item.menu_item.reset([[NSMenuItem alloc] init]); |
| 370 GetFaviconForHistoryItem(&item); | 371 GetFaviconForHistoryItem(&item); |
| 371 | 372 |
| 372 // Pretend to be called back. | 373 // Pretend to be called back. |
| 373 history::FaviconData favicon; | 374 history::FaviconData favicon; |
| 374 favicon.known_icon = true; | 375 favicon.known_icon = true; |
| 375 favicon.image_data = new base::RefCountedBytes(raw); | 376 favicon.bitmap_data = new base::RefCountedBytes(raw); |
| 377 favicon.requested_size = gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); |
| 376 favicon.expired = false; | 378 favicon.expired = false; |
| 377 favicon.icon_url = GURL(); | 379 favicon.icon_url = GURL(); |
| 378 favicon.icon_type = history::FAVICON; | 380 favicon.icon_type = history::FAVICON; |
| 379 GotFaviconData(item.icon_handle, favicon); | 381 GotFaviconData(item.icon_handle, favicon); |
| 380 | 382 |
| 381 // Make sure the callback works. | 383 // Make sure the callback works. |
| 382 EXPECT_FALSE(item.icon_requested); | 384 EXPECT_FALSE(item.icon_requested); |
| 383 EXPECT_TRUE(item.icon.get()); | 385 EXPECT_TRUE(item.icon.get()); |
| 384 EXPECT_TRUE([item.menu_item image]); | 386 EXPECT_TRUE([item.menu_item image]); |
| 385 } | 387 } |
| 386 | 388 |
| 387 } // namespace | 389 } // namespace |
| OLD | NEW |