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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); | 260 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); |
261 | 261 |
262 FaviconChangeObserver observer(model, node); | 262 FaviconChangeObserver observer(model, node); |
263 favicon::FaviconService* favicon_service = | 263 favicon::FaviconService* favicon_service = |
264 FaviconServiceFactory::GetForProfile(profile, | 264 FaviconServiceFactory::GetForProfile(profile, |
265 ServiceAccessType::EXPLICIT_ACCESS); | 265 ServiceAccessType::EXPLICIT_ACCESS); |
266 if (favicon_source == bookmarks_helper::FROM_UI) { | 266 if (favicon_source == bookmarks_helper::FROM_UI) { |
267 favicon_service->SetFavicons(node->url(), icon_url, favicon_base::FAVICON, | 267 favicon_service->SetFavicons(node->url(), icon_url, favicon_base::FAVICON, |
268 image); | 268 image); |
269 } else { | 269 } else { |
270 ProfileSyncService* pss = | 270 browser_sync::ProfileSyncService* pss = |
271 ProfileSyncServiceFactory::GetForProfile(profile); | 271 ProfileSyncServiceFactory::GetForProfile(profile); |
272 sync_bookmarks::BookmarkChangeProcessor::ApplyBookmarkFavicon( | 272 sync_bookmarks::BookmarkChangeProcessor::ApplyBookmarkFavicon( |
273 node, pss->GetSyncClient(), icon_url, image.As1xPNGBytes()); | 273 node, pss->GetSyncClient(), icon_url, image.As1xPNGBytes()); |
274 } | 274 } |
275 | 275 |
276 // Wait for the favicon for |node| to be invalidated. | 276 // Wait for the favicon for |node| to be invalidated. |
277 observer.WaitForSetFavicon(); | 277 observer.WaitForSetFavicon(); |
278 // Wait for the BookmarkModel to fetch the updated favicon and for the new | 278 // Wait for the BookmarkModel to fetch the updated favicon and for the new |
279 // favicon to be sent to BookmarkChangeProcessor. | 279 // favicon to be sent to BookmarkChangeProcessor. |
280 GetFaviconData(model, node); | 280 GetFaviconData(model, node); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 return !checker.TimedOut(); | 822 return !checker.TimedOut(); |
823 } | 823 } |
824 | 824 |
825 namespace { | 825 namespace { |
826 | 826 |
827 // TODO(pvalenzuela): Remove this class and instead use | 827 // TODO(pvalenzuela): Remove this class and instead use |
828 // AwaitMatchStatusChangeChecker. | 828 // AwaitMatchStatusChangeChecker. |
829 class CountBookmarksWithTitlesMatchingChecker | 829 class CountBookmarksWithTitlesMatchingChecker |
830 : public SingleClientStatusChangeChecker { | 830 : public SingleClientStatusChangeChecker { |
831 public: | 831 public: |
832 CountBookmarksWithTitlesMatchingChecker(ProfileSyncService* service, | 832 CountBookmarksWithTitlesMatchingChecker( |
833 int profile_index, | 833 browser_sync::ProfileSyncService* service, |
834 const std::string& title, | 834 int profile_index, |
835 int expected_count) | 835 const std::string& title, |
| 836 int expected_count) |
836 : SingleClientStatusChangeChecker(service), | 837 : SingleClientStatusChangeChecker(service), |
837 profile_index_(profile_index), | 838 profile_index_(profile_index), |
838 title_(title), | 839 title_(title), |
839 expected_count_(expected_count) { | 840 expected_count_(expected_count) { |
840 DCHECK_GE(expected_count, 0) << "expected_count must be non-negative."; | 841 DCHECK_GE(expected_count, 0) << "expected_count must be non-negative."; |
841 } | 842 } |
842 | 843 |
843 bool IsExitConditionSatisfied() override { | 844 bool IsExitConditionSatisfied() override { |
844 int actual_count = CountBookmarksWithTitlesMatching(profile_index_, title_); | 845 int actual_count = CountBookmarksWithTitlesMatching(profile_index_, title_); |
845 return expected_count_ == actual_count; | 846 return expected_count_ == actual_count; |
846 } | 847 } |
847 | 848 |
848 std::string GetDebugMessage() const override { | 849 std::string GetDebugMessage() const override { |
849 return "Waiting for bookmark count to match"; | 850 return "Waiting for bookmark count to match"; |
850 } | 851 } |
851 | 852 |
852 private: | 853 private: |
853 const int profile_index_; | 854 const int profile_index_; |
854 const std::string title_; | 855 const std::string title_; |
855 const int expected_count_; | 856 const int expected_count_; |
856 }; | 857 }; |
857 | 858 |
858 } // namespace | 859 } // namespace |
859 | 860 |
860 bool AwaitCountBookmarksWithTitlesMatching(int profile, | 861 bool AwaitCountBookmarksWithTitlesMatching(int profile, |
861 const std::string& title, | 862 const std::string& title, |
862 int expected_count) { | 863 int expected_count) { |
863 ProfileSyncService* service = | 864 browser_sync::ProfileSyncService* service = |
864 sync_datatype_helper::test()->GetSyncService(profile); | 865 sync_datatype_helper::test()->GetSyncService(profile); |
865 CountBookmarksWithTitlesMatchingChecker checker(service, | 866 CountBookmarksWithTitlesMatchingChecker checker(service, |
866 profile, | 867 profile, |
867 title, | 868 title, |
868 expected_count); | 869 expected_count); |
869 checker.Wait(); | 870 checker.Wait(); |
870 return !checker.TimedOut(); | 871 return !checker.TimedOut(); |
871 } | 872 } |
872 | 873 |
873 | 874 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 1004 |
1004 std::string IndexedSubfolderName(int i) { | 1005 std::string IndexedSubfolderName(int i) { |
1005 return base::StringPrintf("Subfolder Name %d", i); | 1006 return base::StringPrintf("Subfolder Name %d", i); |
1006 } | 1007 } |
1007 | 1008 |
1008 std::string IndexedSubsubfolderName(int i) { | 1009 std::string IndexedSubsubfolderName(int i) { |
1009 return base::StringPrintf("Subsubfolder Name %d", i); | 1010 return base::StringPrintf("Subsubfolder Name %d", i); |
1010 } | 1011 } |
1011 | 1012 |
1012 } // namespace bookmarks_helper | 1013 } // namespace bookmarks_helper |
OLD | NEW |