Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Unified Diff: chrome/test/live_sync/live_bookmarks_sync_test.h

Issue 5149001: Merge 65840 - Provide sync integration tests with a way to set a favicon for ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552d/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/live_sync/live_bookmarks_sync_test.h
===================================================================
--- chrome/test/live_sync/live_bookmarks_sync_test.h (revision 66375)
+++ chrome/test/live_sync/live_bookmarks_sync_test.h (working copy)
@@ -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 @@
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,
@@ -262,6 +278,25 @@
return nodes[0];
}
+ // Creates a unique favicon using |seed|.
+ static std::vector<unsigned char> CreateFavicon(int seed) {
+ 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 i = 0; i < w * h; ++i) {
+ src_data[i] = SkPreMultiplyARGB((seed + i) % 255,
+ (seed + i) % 250,
+ (seed + i) % 245,
+ (seed + i) % 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.
« no previous file with comments | « chrome/test/live_sync/bookmark_model_verifier.cc ('k') | chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698