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

Side by Side Diff: chrome/test/live_sync/bookmark_model_verifier.cc

Issue 6351001: Debugging updates for sync integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Favicon size Created 9 years, 11 months 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
« no previous file with comments | « no previous file | chrome/test/live_sync/live_sync_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/test/live_sync/bookmark_model_verifier.h" 5 #include "chrome/test/live_sync/bookmark_model_verifier.h"
6 6
7 #include <vector> 7 #include <vector>
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 DISALLOW_COPY_AND_ASSIGN(FaviconLoadObserver); 64 DISALLOW_COPY_AND_ASSIGN(FaviconLoadObserver);
65 }; 65 };
66 66
67 } 67 }
68 68
69 // static 69 // static
70 bool BookmarkModelVerifier::NodesMatch(const BookmarkNode* node_a, 70 bool BookmarkModelVerifier::NodesMatch(const BookmarkNode* node_a,
71 const BookmarkNode* node_b) { 71 const BookmarkNode* node_b) {
72 if (node_a == NULL || node_b == NULL) 72 if (node_a == NULL || node_b == NULL)
73 return node_a == node_b; 73 return node_a == node_b;
74 bool ret_val = true; 74 if (node_a->is_folder() != node_b->is_folder()) {
75 ret_val = ret_val && (node_a->GetTitle() == node_b->GetTitle()); 75 LOG(ERROR) << "Cannot compare folder with bookmark";
76 ret_val = ret_val && (node_a->is_folder() == node_b->is_folder()); 76 return false;
77 ret_val = ret_val && (node_a->GetURL() == node_b->GetURL()); 77 }
78 ret_val = ret_val && (node_a->GetParent()->IndexOfChild(node_a) == 78 if (node_a->GetTitle() != node_b->GetTitle()) {
79 node_b->GetParent()->IndexOfChild(node_b)); 79 LOG(ERROR) << "Title mismatch: " << node_a->GetTitle() << " vs. "
80 return ret_val; 80 << node_b->GetTitle();
81 return false;
82 }
83 if (node_a->GetURL() != node_b->GetURL()) {
84 LOG(ERROR) << "URL mismatch: " << node_a->GetURL() << " vs. "
85 << node_b->GetURL();
86 return false;
87 }
88 if (node_a->GetParent()->IndexOfChild(node_a) !=
89 node_b->GetParent()->IndexOfChild(node_b)) {
90 LOG(ERROR) << "Index mismatch: "
91 << node_a->GetParent()->IndexOfChild(node_a) << " vs. "
92 << node_b->GetParent()->IndexOfChild(node_b);
93 return false;
94 }
95 return true;
81 } 96 }
82 97
83 // static 98 // static
84 bool BookmarkModelVerifier::ModelsMatch(BookmarkModel* model_a, 99 bool BookmarkModelVerifier::ModelsMatch(BookmarkModel* model_a,
85 BookmarkModel* model_b) { 100 BookmarkModel* model_b) {
86 bool ret_val = true; 101 bool ret_val = true;
87 ui::TreeNodeIterator<const BookmarkNode> iterator_a(model_a->root_node()); 102 ui::TreeNodeIterator<const BookmarkNode> iterator_a(model_a->root_node());
88 ui::TreeNodeIterator<const BookmarkNode> iterator_b(model_b->root_node()); 103 ui::TreeNodeIterator<const BookmarkNode> iterator_b(model_b->root_node());
89 while (iterator_a.has_next()) { 104 while (iterator_a.has_next()) {
90 const BookmarkNode* node_a = iterator_a.Next(); 105 const BookmarkNode* node_a = iterator_a.Next();
91 EXPECT_TRUE(iterator_b.has_next()); 106 EXPECT_TRUE(iterator_b.has_next());
92 const BookmarkNode* node_b = iterator_b.Next(); 107 const BookmarkNode* node_b = iterator_b.Next();
93 ret_val = ret_val && NodesMatch(node_a, node_b); 108 ret_val = ret_val && NodesMatch(node_a, node_b);
94 const SkBitmap& bitmap_a = model_a->GetFavIcon(node_a); 109 const SkBitmap& bitmap_a = model_a->GetFavIcon(node_a);
95 const SkBitmap& bitmap_b = model_b->GetFavIcon(node_b); 110 const SkBitmap& bitmap_b = model_b->GetFavIcon(node_b);
96 ret_val = ret_val && FaviconsMatch(bitmap_a, bitmap_b); 111 ret_val = ret_val && FaviconsMatch(bitmap_a, bitmap_b);
97 } 112 }
98 ret_val = ret_val && (!iterator_b.has_next()); 113 ret_val = ret_val && (!iterator_b.has_next());
99 return ret_val; 114 return ret_val;
100 } 115 }
101 116
102 bool BookmarkModelVerifier::FaviconsMatch(const SkBitmap& bitmap_a, 117 bool BookmarkModelVerifier::FaviconsMatch(const SkBitmap& bitmap_a,
103 const SkBitmap& bitmap_b) { 118 const SkBitmap& bitmap_b) {
104 if (bitmap_a.getSize() == 0U && bitmap_a.getSize() == 0U) 119 if (bitmap_a.getSize() == 0U && bitmap_a.getSize() == 0U)
105 return true; 120 return true;
106 if ((bitmap_a.getSize() != bitmap_b.getSize()) || 121 if ((bitmap_a.getSize() != bitmap_b.getSize()) ||
107 (bitmap_a.width() != bitmap_b.width()) || 122 (bitmap_a.width() != bitmap_b.width()) ||
108 (bitmap_a.height() != bitmap_b.height())) 123 (bitmap_a.height() != bitmap_b.height())) {
124 LOG(ERROR) << "Favicon size mismatch: " << bitmap_a.getSize() << " ("
125 << bitmap_a.width() << "x" << bitmap_a.height() << ") vs. "
126 << bitmap_b.getSize() << " (" << bitmap_b.width() << "x"
127 << bitmap_b.height() << ")";
109 return false; 128 return false;
129 }
110 SkAutoLockPixels bitmap_lock_a(bitmap_a); 130 SkAutoLockPixels bitmap_lock_a(bitmap_a);
111 SkAutoLockPixels bitmap_lock_b(bitmap_b); 131 SkAutoLockPixels bitmap_lock_b(bitmap_b);
112 void* node_pixel_addr_a = bitmap_a.getPixels(); 132 void* node_pixel_addr_a = bitmap_a.getPixels();
113 EXPECT_TRUE(node_pixel_addr_a); 133 EXPECT_TRUE(node_pixel_addr_a);
114 void* node_pixel_addr_b = bitmap_b.getPixels(); 134 void* node_pixel_addr_b = bitmap_b.getPixels();
115 EXPECT_TRUE(node_pixel_addr_b); 135 EXPECT_TRUE(node_pixel_addr_b);
116 return (memcmp(node_pixel_addr_a, 136 if (memcmp(node_pixel_addr_a, node_pixel_addr_b, bitmap_a.getSize()) != 0) {
117 node_pixel_addr_b, 137 LOG(ERROR) << "Favicon bitmap mismatch";
118 bitmap_a.getSize()) == 0); 138 return false;
139 } else {
140 return true;
141 }
119 } 142 }
120 143
121 bool BookmarkModelVerifier::ContainsDuplicateBookmarks(BookmarkModel* model) { 144 bool BookmarkModelVerifier::ContainsDuplicateBookmarks(BookmarkModel* model) {
122 ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); 145 ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node());
123 while (iterator.has_next()) { 146 while (iterator.has_next()) {
124 const BookmarkNode* node = iterator.Next(); 147 const BookmarkNode* node = iterator.Next();
125 if (node->type() != BookmarkNode::URL) 148 if (node->type() != BookmarkNode::URL)
126 continue; 149 continue;
127 std::vector<const BookmarkNode*> nodes; 150 std::vector<const BookmarkNode*> nodes;
128 model->GetNodesByURL(node->GetURL(), &nodes); 151 model->GetNodesByURL(node->GetURL(), &nodes);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 const BookmarkNode* v_node = NULL; 329 const BookmarkNode* v_node = NULL;
307 FindNodeInVerifier(model, node, &v_node); 330 FindNodeInVerifier(model, node, &v_node);
308 bookmark_utils::ApplyEditsWithNoGroupChange( 331 bookmark_utils::ApplyEditsWithNoGroupChange(
309 verifier_model_, v_node->GetParent(), 332 verifier_model_, v_node->GetParent(),
310 BookmarkEditor::EditDetails(v_node), v_node->GetTitle(), new_url); 333 BookmarkEditor::EditDetails(v_node), v_node->GetTitle(), new_url);
311 } 334 }
312 return bookmark_utils::ApplyEditsWithNoGroupChange( 335 return bookmark_utils::ApplyEditsWithNoGroupChange(
313 model, node->GetParent(), BookmarkEditor::EditDetails(node), 336 model, node->GetParent(), BookmarkEditor::EditDetails(node),
314 node->GetTitle(), new_url); 337 node->GetTitle(), new_url);
315 } 338 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/live_sync/live_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698