Chromium Code Reviews| Index: chrome/test/live_sync/live_bookmarks_sync_test.h |
| diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.h b/chrome/test/live_sync/live_bookmarks_sync_test.h |
| index e34bf4df4cec3bafd42be301359f1f0e8bd153f7..0574fddef1015a80949553568eb4a5e9efaa254e 100644 |
| --- a/chrome/test/live_sync/live_bookmarks_sync_test.h |
| +++ b/chrome/test/live_sync/live_bookmarks_sync_test.h |
| @@ -14,8 +14,10 @@ |
| #include "chrome/test/live_sync/bookmark_model_verifier.h" |
| #include "chrome/test/live_sync/live_sync_test.h" |
| #include "chrome/test/ui_test_utils.h" |
| +#include "gfx/codec/png_codec.h" |
| #include "googleurl/src/gurl.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| class LiveBookmarksSyncTest : public LiveSyncTest { |
| public: |
| @@ -140,6 +142,20 @@ class LiveBookmarksSyncTest : public LiveSyncTest { |
| GetBookmarkModel(profile), node, WideToUTF16(new_title)); |
| } |
| + // Sets the favicon of the node |node| (of type BookmarkNode::URL) in the |
| + // bookmark model of profile |profile| using the data in |icon_bytes_vector|. |
| + void SetFavicon(int profile, |
| + const BookmarkNode* node, |
| + const std::vector<unsigned char>& icon_bytes_vector) { |
| + ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node) |
| + << "Node " << node->GetTitle() << " does not belong to " |
| + << "Profile " << profile; |
| + ASSERT_EQ(BookmarkNode::URL, node->type()) |
| + << "Node " << node->GetTitle() << " must be a url."; |
| + verifier_helper_->SetFavicon( |
| + GetBookmarkModel(profile), node, icon_bytes_vector); |
| + } |
| + |
| // Changes the url of the node |node| in the bookmark model of profile |
| // |profile| to |new_url|. Returns a pointer to the node with the changed url. |
| const BookmarkNode* SetURL(int profile, |
| @@ -278,6 +294,25 @@ class LiveBookmarksSyncTest : public LiveSyncTest { |
| GetBookmarkModel(profile), BookmarkNode::FOLDER, WideToUTF16(title)); |
| } |
| + // Creates a unique favicon using index |i|. |
|
tim (not reviewing)
2010/11/11 19:25:34
maybe |seed| is a better name?
Raghu Simha
2010/11/11 19:39:45
Done.
|
| + static std::vector<unsigned char> CreateFavicon(int i) { |
| + const int w = 16; |
| + const int h = 16; |
| + SkBitmap bmp; |
| + bmp.setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| + bmp.allocPixels(); |
| + uint32_t* src_data = bmp.getAddr32(0, 0); |
| + for (int j = 0; j < w * h; ++j) { |
| + src_data[j] = SkPreMultiplyARGB((i + j) % 255, |
| + (i + j) % 250, |
| + (i + j) % 245, |
| + (i + j) % 240); |
| + } |
| + std::vector<unsigned char> favicon; |
| + gfx::PNGCodec::EncodeBGRASkBitmap(bmp, false, &favicon); |
| + return favicon; |
| + } |
| + |
| private: |
| // Helper object that has the functionality to verify changes made to the |
| // bookmarks of individual profiles. |