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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ 5 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
6 #define CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ 6 #define CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "chrome/browser/bookmarks/bookmark_model.h" 13 #include "chrome/browser/bookmarks/bookmark_model.h"
14 #include "chrome/test/live_sync/bookmark_model_verifier.h" 14 #include "chrome/test/live_sync/bookmark_model_verifier.h"
15 #include "chrome/test/live_sync/live_sync_test.h" 15 #include "chrome/test/live_sync/live_sync_test.h"
16 #include "chrome/test/ui_test_utils.h" 16 #include "chrome/test/ui_test_utils.h"
17 #include "gfx/codec/png_codec.h"
17 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/skia/include/core/SkBitmap.h"
19 21
20 class LiveBookmarksSyncTest : public LiveSyncTest { 22 class LiveBookmarksSyncTest : public LiveSyncTest {
21 public: 23 public:
22 explicit LiveBookmarksSyncTest(TestType test_type) 24 explicit LiveBookmarksSyncTest(TestType test_type)
23 : LiveSyncTest(test_type) {} 25 : LiveSyncTest(test_type) {}
24 26
25 virtual ~LiveBookmarksSyncTest() {} 27 virtual ~LiveBookmarksSyncTest() {}
26 28
27 // Sets up sync profiles and clients and initializes the bookmark verifier. 29 // Sets up sync profiles and clients and initializes the bookmark verifier.
28 virtual bool SetupClients() WARN_UNUSED_RESULT { 30 virtual bool SetupClients() WARN_UNUSED_RESULT {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void SetTitle(int profile, 135 void SetTitle(int profile,
134 const BookmarkNode* node, 136 const BookmarkNode* node,
135 const std::wstring& new_title) { 137 const std::wstring& new_title) {
136 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node) 138 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node)
137 << "Node " << node->GetTitle() << " does not belong to " 139 << "Node " << node->GetTitle() << " does not belong to "
138 << "Profile " << profile; 140 << "Profile " << profile;
139 verifier_helper_->SetTitle( 141 verifier_helper_->SetTitle(
140 GetBookmarkModel(profile), node, WideToUTF16(new_title)); 142 GetBookmarkModel(profile), node, WideToUTF16(new_title));
141 } 143 }
142 144
145 // Sets the favicon of the node |node| (of type BookmarkNode::URL) in the
146 // bookmark model of profile |profile| using the data in |icon_bytes_vector|.
147 void SetFavicon(int profile,
148 const BookmarkNode* node,
149 const std::vector<unsigned char>& icon_bytes_vector) {
150 ASSERT_EQ(GetBookmarkModel(profile)->GetNodeByID(node->id()), node)
151 << "Node " << node->GetTitle() << " does not belong to "
152 << "Profile " << profile;
153 ASSERT_EQ(BookmarkNode::URL, node->type())
154 << "Node " << node->GetTitle() << " must be a url.";
155 verifier_helper_->SetFavicon(
156 GetBookmarkModel(profile), node, icon_bytes_vector);
157 }
158
143 // Changes the url of the node |node| in the bookmark model of profile 159 // Changes the url of the node |node| in the bookmark model of profile
144 // |profile| to |new_url|. Returns a pointer to the node with the changed url. 160 // |profile| to |new_url|. Returns a pointer to the node with the changed url.
145 const BookmarkNode* SetURL(int profile, 161 const BookmarkNode* SetURL(int profile,
146 const BookmarkNode* node, 162 const BookmarkNode* node,
147 const GURL& new_url) WARN_UNUSED_RESULT { 163 const GURL& new_url) WARN_UNUSED_RESULT {
148 if (GetBookmarkModel(profile)->GetNodeByID(node->id()) != node) { 164 if (GetBookmarkModel(profile)->GetNodeByID(node->id()) != node) {
149 LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to " 165 LOG(ERROR) << "Node " << node->GetTitle() << " does not belong to "
150 << "Profile " << profile; 166 << "Profile " << profile;
151 return NULL; 167 return NULL;
152 } 168 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const BookmarkNode* GetUniqueNodeByURL(int profile, 271 const BookmarkNode* GetUniqueNodeByURL(int profile,
256 const GURL& url) WARN_UNUSED_RESULT { 272 const GURL& url) WARN_UNUSED_RESULT {
257 std::vector<const BookmarkNode*> nodes; 273 std::vector<const BookmarkNode*> nodes;
258 GetBookmarkModel(profile)->GetNodesByURL(url, &nodes); 274 GetBookmarkModel(profile)->GetNodesByURL(url, &nodes);
259 EXPECT_EQ(1U, nodes.size()); 275 EXPECT_EQ(1U, nodes.size());
260 if (nodes.empty()) 276 if (nodes.empty())
261 return NULL; 277 return NULL;
262 return nodes[0]; 278 return nodes[0];
263 } 279 }
264 280
281 // Creates a unique favicon using |seed|.
282 static std::vector<unsigned char> CreateFavicon(int seed) {
283 const int w = 16;
284 const int h = 16;
285 SkBitmap bmp;
286 bmp.setConfig(SkBitmap::kARGB_8888_Config, w, h);
287 bmp.allocPixels();
288 uint32_t* src_data = bmp.getAddr32(0, 0);
289 for (int i = 0; i < w * h; ++i) {
290 src_data[i] = SkPreMultiplyARGB((seed + i) % 255,
291 (seed + i) % 250,
292 (seed + i) % 245,
293 (seed + i) % 240);
294 }
295 std::vector<unsigned char> favicon;
296 gfx::PNGCodec::EncodeBGRASkBitmap(bmp, false, &favicon);
297 return favicon;
298 }
299
265 private: 300 private:
266 // Helper object that has the functionality to verify changes made to the 301 // Helper object that has the functionality to verify changes made to the
267 // bookmarks of individual profiles. 302 // bookmarks of individual profiles.
268 scoped_ptr<BookmarkModelVerifier> verifier_helper_; 303 scoped_ptr<BookmarkModelVerifier> verifier_helper_;
269 304
270 DISALLOW_COPY_AND_ASSIGN(LiveBookmarksSyncTest); 305 DISALLOW_COPY_AND_ASSIGN(LiveBookmarksSyncTest);
271 }; 306 };
272 307
273 class SingleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { 308 class SingleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
274 public: 309 public:
(...skipping 29 matching lines...) Expand all
304 public: 339 public:
305 ManyClientLiveBookmarksSyncTest() 340 ManyClientLiveBookmarksSyncTest()
306 : LiveBookmarksSyncTest(MANY_CLIENT) {} 341 : LiveBookmarksSyncTest(MANY_CLIENT) {}
307 ~ManyClientLiveBookmarksSyncTest() {} 342 ~ManyClientLiveBookmarksSyncTest() {}
308 343
309 private: 344 private:
310 DISALLOW_COPY_AND_ASSIGN(ManyClientLiveBookmarksSyncTest); 345 DISALLOW_COPY_AND_ASSIGN(ManyClientLiveBookmarksSyncTest);
311 }; 346 };
312 347
313 #endif // CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_ 348 #endif // CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
OLDNEW
« 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