| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/sync/test/integration/bookmarks_helper.h" | 5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 while (iterator.has_next()) { | 144 while (iterator.has_next()) { |
| 145 const BookmarkNode* node = iterator.Next(); | 145 const BookmarkNode* node = iterator.Next(); |
| 146 if ((node->type() == node_type) && (node->GetTitle() == title)) | 146 if ((node->type() == node_type) && (node->GetTitle() == title)) |
| 147 ++count; | 147 ++count; |
| 148 } | 148 } |
| 149 return count; | 149 return count; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Checks if the favicon data in |bitmap_a| and |bitmap_b| are equivalent. | 152 // Checks if the favicon data in |bitmap_a| and |bitmap_b| are equivalent. |
| 153 // Returns true if they match. | 153 // Returns true if they match. |
| 154 bool FaviconBitmapsMatch(const SkBitmap& bitmap_a, const SkBitmap& bitmap_b) { | 154 bool FaviconRawBitmapsMatch(const SkBitmap& bitmap_a, |
| 155 const SkBitmap& bitmap_b) { |
| 155 if (bitmap_a.getSize() == 0U && bitmap_b.getSize() == 0U) | 156 if (bitmap_a.getSize() == 0U && bitmap_b.getSize() == 0U) |
| 156 return true; | 157 return true; |
| 157 if ((bitmap_a.getSize() != bitmap_b.getSize()) || | 158 if ((bitmap_a.getSize() != bitmap_b.getSize()) || |
| 158 (bitmap_a.width() != bitmap_b.width()) || | 159 (bitmap_a.width() != bitmap_b.width()) || |
| 159 (bitmap_a.height() != bitmap_b.height())) { | 160 (bitmap_a.height() != bitmap_b.height())) { |
| 160 LOG(ERROR) << "Favicon size mismatch: " << bitmap_a.getSize() << " (" | 161 LOG(ERROR) << "Favicon size mismatch: " << bitmap_a.getSize() << " (" |
| 161 << bitmap_a.width() << "x" << bitmap_a.height() << ") vs. " | 162 << bitmap_a.width() << "x" << bitmap_a.height() << ") vs. " |
| 162 << bitmap_b.getSize() << " (" << bitmap_b.width() << "x" | 163 << bitmap_b.getSize() << " (" << bitmap_b.width() << "x" |
| 163 << bitmap_b.height() << ")"; | 164 << bitmap_b.height() << ")"; |
| 164 return false; | 165 return false; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return true; // Two empty images are equivalent. | 295 return true; // Two empty images are equivalent. |
| 295 | 296 |
| 296 if (image_a.IsEmpty() != image_b.IsEmpty()) | 297 if (image_a.IsEmpty() != image_b.IsEmpty()) |
| 297 return false; | 298 return false; |
| 298 | 299 |
| 299 // Compare only the 1x bitmaps as only those are synced. | 300 // Compare only the 1x bitmaps as only those are synced. |
| 300 SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation( | 301 SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation( |
| 301 1.0f).sk_bitmap(); | 302 1.0f).sk_bitmap(); |
| 302 SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation( | 303 SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation( |
| 303 1.0f).sk_bitmap(); | 304 1.0f).sk_bitmap(); |
| 304 return FaviconBitmapsMatch(bitmap_a, bitmap_b); | 305 return FaviconRawBitmapsMatch(bitmap_a, bitmap_b); |
| 305 } | 306 } |
| 306 | 307 |
| 307 // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|. | 308 // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|. |
| 308 // Returns true if they are all equal. | 309 // Returns true if they are all equal. |
| 309 bool NodesMatch(const BookmarkNode* node_a, const BookmarkNode* node_b) { | 310 bool NodesMatch(const BookmarkNode* node_a, const BookmarkNode* node_b) { |
| 310 if (node_a == NULL || node_b == NULL) | 311 if (node_a == NULL || node_b == NULL) |
| 311 return node_a == node_b; | 312 return node_a == node_b; |
| 312 if (node_a->is_folder() != node_b->is_folder()) { | 313 if (node_a->is_folder() != node_b->is_folder()) { |
| 313 LOG(ERROR) << "Cannot compare folder with bookmark"; | 314 LOG(ERROR) << "Cannot compare folder with bookmark"; |
| 314 return false; | 315 return false; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 814 |
| 814 std::string IndexedSubfolderName(int i) { | 815 std::string IndexedSubfolderName(int i) { |
| 815 return base::StringPrintf("Subfolder Name %d", i); | 816 return base::StringPrintf("Subfolder Name %d", i); |
| 816 } | 817 } |
| 817 | 818 |
| 818 std::string IndexedSubsubfolderName(int i) { | 819 std::string IndexedSubsubfolderName(int i) { |
| 819 return base::StringPrintf("Subsubfolder Name %d", i); | 820 return base::StringPrintf("Subsubfolder Name %d", i); |
| 820 } | 821 } |
| 821 | 822 |
| 822 } // namespace bookmarks_helper | 823 } // namespace bookmarks_helper |
| OLD | NEW |