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

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

Issue 4749003: Provide sync integration tests with a way to set a favicon for a bookmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. 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
diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.h b/chrome/test/live_sync/live_bookmarks_sync_test.h
index e34bf4df4cec3bafd42be301359f1f0e8bd153f7..b3ac273ebfb2a05e5c1b9b789983ea7517a4aaab 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 |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