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

Side by Side Diff: chrome/test/live_sync/bookmark_model_verifier.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: "" 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_BOOKMARK_MODEL_VERIFIER_H_ 5 #ifndef CHROME_TEST_LIVE_SYNC_BOOKMARK_MODEL_VERIFIER_H_
6 #define CHROME_TEST_LIVE_SYNC_BOOKMARK_MODEL_VERIFIER_H_ 6 #define CHROME_TEST_LIVE_SYNC_BOOKMARK_MODEL_VERIFIER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 13 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "chrome/browser/profile.h" 14 #include "chrome/browser/profile.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
16 17
17 // Helper class that performs operations on a bookmark model and echoes the 18 // Helper class that performs operations on a bookmark model and echoes the
18 // changes in a verifier model that can be used as an expected hierarchy to 19 // changes in a verifier model that can be used as an expected hierarchy to
19 // compare against. 20 // compare against.
20 // Note: When we refer to the "same" node in |model| and |verifier_model_|, 21 // Note: When we refer to the "same" node in |model| and |verifier_model_|,
21 // we mean the same canonical bookmark entity, because |verifier_model_| is 22 // we mean the same canonical bookmark entity, because |verifier_model_| is
22 // expected to be a replica of |model|. 23 // expected to be a replica of |model|.
23 class BookmarkModelVerifier { 24 class BookmarkModelVerifier {
24 public: 25 public:
25 explicit BookmarkModelVerifier(BookmarkModel* model) 26 explicit BookmarkModelVerifier(BookmarkModel* model)
26 : verifier_model_(model), 27 : verifier_model_(model),
27 use_verifier_model_(true) {} 28 use_verifier_model_(true) {}
28 29
29 ~BookmarkModelVerifier() {} 30 ~BookmarkModelVerifier() {}
30 31
31 // Checks if the hierarchies in |model_a| and |model_b| are equivalent in 32 // Checks if the hierarchies in |model_a| and |model_b| are equivalent in
32 // terms of the data model. Compares favicons if |compare_favicons| is true. 33 // terms of the data model and favicon. Returns true if they both match.
33 // Returns true if they match.
34 // Note: Some peripheral fields like creation times are allowed to mismatch. 34 // Note: Some peripheral fields like creation times are allowed to mismatch.
35 static bool ModelsMatch(BookmarkModel* model_a, 35 static bool ModelsMatch(BookmarkModel* model_a,
36 BookmarkModel* model_b, 36 BookmarkModel* model_b) WARN_UNUSED_RESULT;
37 bool compare_favicons) WARN_UNUSED_RESULT;
38
39 // Same as the above method, but does not check if the favicons match.
40 static bool ModelsMatch(BookmarkModel* model_a,
41 BookmarkModel* model_b) WARN_UNUSED_RESULT {
42 return ModelsMatch(model_a, model_b, false);
43 }
44 37
45 // Checks if |model| contains any instances of two bookmarks with the same URL 38 // Checks if |model| contains any instances of two bookmarks with the same URL
46 // under the same parent folder. Returns true if even one instance is found. 39 // under the same parent folder. Returns true if even one instance is found.
47 static bool ContainsDuplicateBookmarks(BookmarkModel* model); 40 static bool ContainsDuplicateBookmarks(BookmarkModel* model);
48 41
49 // Checks if the favicon data in |bitmap_a| and |bitmap_b| are equivalent. 42 // Checks if the favicon data in |bitmap_a| and |bitmap_b| are equivalent.
50 // Returns true if they match. 43 // Returns true if they match.
51 static bool FaviconsMatch(const SkBitmap& bitmap_a, const SkBitmap& bitmap_b); 44 static bool FaviconsMatch(const SkBitmap& bitmap_a, const SkBitmap& bitmap_b);
52 45
53 // Adds the same bookmark to |model| and |verifier_model_|. See 46 // Adds the same bookmark to |model| and |verifier_model_|. See
(...skipping 10 matching lines...) Expand all
64 const BookmarkNode* parent, 57 const BookmarkNode* parent,
65 int index, 58 int index,
66 const string16& title); 59 const string16& title);
67 60
68 // Sets the title of the same node in |model| and |verifier_model_|. See 61 // Sets the title of the same node in |model| and |verifier_model_|. See
69 // BookmarkModel::SetTitle for details. 62 // BookmarkModel::SetTitle for details.
70 void SetTitle(BookmarkModel* model, 63 void SetTitle(BookmarkModel* model,
71 const BookmarkNode* node, 64 const BookmarkNode* node,
72 const string16& title); 65 const string16& title);
73 66
67 // Sets the favicon of the same node in |model| and |verifier_model_| using
68 // the data in |icon_bytes_vector|.
69 // See BookmarkChangeProcessor::ApplyBookmarkFavicon for details.
70 void SetFavicon(BookmarkModel* model,
71 const BookmarkNode* node,
72 const std::vector<unsigned char>& icon_bytes_vector);
73
74 // Moves the same node to the same position in both |model| and 74 // Moves the same node to the same position in both |model| and
75 // |verifier_model_|. See BookmarkModel::Move for details. 75 // |verifier_model_|. See BookmarkModel::Move for details.
76 void Move(BookmarkModel* model, 76 void Move(BookmarkModel* model,
77 const BookmarkNode* node, 77 const BookmarkNode* node,
78 const BookmarkNode* new_parent, 78 const BookmarkNode* new_parent,
79 int index); 79 int index);
80 80
81 // Removes the same node from |model| and |verifier_model_|. See 81 // Removes the same node from |model| and |verifier_model_|. See
82 // BookmarkModel::Remove for details. 82 // BookmarkModel::Remove for details.
83 void Remove(BookmarkModel* model, const BookmarkNode* parent, int index); 83 void Remove(BookmarkModel* model, const BookmarkNode* parent, int index);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 BookmarkModel* verifier_model_; 122 BookmarkModel* verifier_model_;
123 123
124 // A flag that indicates whether bookmark operations should also update the 124 // A flag that indicates whether bookmark operations should also update the
125 // verifier model or not. 125 // verifier model or not.
126 bool use_verifier_model_; 126 bool use_verifier_model_;
127 127
128 DISALLOW_COPY_AND_ASSIGN(BookmarkModelVerifier); 128 DISALLOW_COPY_AND_ASSIGN(BookmarkModelVerifier);
129 }; 129 };
130 130
131 #endif // CHROME_TEST_LIVE_SYNC_BOOKMARK_MODEL_VERIFIER_H_ 131 #endif // CHROME_TEST_LIVE_SYNC_BOOKMARK_MODEL_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698