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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
10 #include "chrome/browser/sync/test/integration/sync_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
11 #include "components/bookmarks/browser/bookmark_model.h" | 11 #include "components/bookmarks/browser/bookmark_model.h" |
12 #include "components/bookmarks/browser/bookmark_service.h" | |
13 #include "sync/test/fake_server/bookmark_entity_builder.h" | 12 #include "sync/test/fake_server/bookmark_entity_builder.h" |
14 #include "sync/test/fake_server/entity_builder_factory.h" | 13 #include "sync/test/fake_server/entity_builder_factory.h" |
15 #include "sync/test/fake_server/fake_server_verifier.h" | 14 #include "sync/test/fake_server/fake_server_verifier.h" |
16 #include "ui/base/layout.h" | 15 #include "ui/base/layout.h" |
17 | 16 |
18 using bookmarks_helper::AddFolder; | 17 using bookmarks_helper::AddFolder; |
19 using bookmarks_helper::AddURL; | 18 using bookmarks_helper::AddURL; |
20 using bookmarks_helper::CountBookmarksWithTitlesMatching; | 19 using bookmarks_helper::CountBookmarksWithTitlesMatching; |
21 using bookmarks_helper::Create1xFaviconFromPNGFile; | 20 using bookmarks_helper::Create1xFaviconFromPNGFile; |
22 using bookmarks_helper::GetBookmarkBarNode; | 21 using bookmarks_helper::GetBookmarkBarNode; |
(...skipping 18 matching lines...) Expand all Loading... |
41 // verified. | 40 // verified. |
42 void VerifyBookmarkModelMatchesFakeServer(int index); | 41 void VerifyBookmarkModelMatchesFakeServer(int index); |
43 | 42 |
44 private: | 43 private: |
45 DISALLOW_COPY_AND_ASSIGN(SingleClientBookmarksSyncTest); | 44 DISALLOW_COPY_AND_ASSIGN(SingleClientBookmarksSyncTest); |
46 }; | 45 }; |
47 | 46 |
48 void SingleClientBookmarksSyncTest::VerifyBookmarkModelMatchesFakeServer( | 47 void SingleClientBookmarksSyncTest::VerifyBookmarkModelMatchesFakeServer( |
49 int index) { | 48 int index) { |
50 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer()); | 49 fake_server::FakeServerVerifier fake_server_verifier(GetFakeServer()); |
51 std::vector<BookmarkService::URLAndTitle> local_bookmarks; | 50 std::vector<BookmarkModel::URLAndTitle> local_bookmarks; |
52 GetBookmarkModel(index)->GetBookmarks(&local_bookmarks); | 51 GetBookmarkModel(index)->GetBookmarks(&local_bookmarks); |
53 | 52 |
54 // Verify that the number of local bookmarks matches the number in the | 53 // Verify that the number of local bookmarks matches the number in the |
55 // server. | 54 // server. |
56 ASSERT_TRUE(fake_server_verifier.VerifyEntityCountByType( | 55 ASSERT_TRUE(fake_server_verifier.VerifyEntityCountByType( |
57 local_bookmarks.size(), | 56 local_bookmarks.size(), |
58 syncer::BOOKMARKS)); | 57 syncer::BOOKMARKS)); |
59 | 58 |
60 // Verify that all local bookmark titles exist once on the server. | 59 // Verify that all local bookmark titles exist once on the server. |
61 std::vector<BookmarkService::URLAndTitle>::const_iterator it; | 60 std::vector<BookmarkModel::URLAndTitle>::const_iterator it; |
62 for (it = local_bookmarks.begin(); it != local_bookmarks.end(); ++it) { | 61 for (it = local_bookmarks.begin(); it != local_bookmarks.end(); ++it) { |
63 ASSERT_TRUE(fake_server_verifier.VerifyEntityCountByTypeAndName( | 62 ASSERT_TRUE(fake_server_verifier.VerifyEntityCountByTypeAndName( |
64 1, | 63 1, |
65 syncer::BOOKMARKS, | 64 syncer::BOOKMARKS, |
66 base::UTF16ToUTF8(it->title))); | 65 base::UTF16ToUTF8(it->title))); |
67 } | 66 } |
68 } | 67 } |
69 | 68 |
70 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, Sanity) { | 69 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, Sanity) { |
71 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 70 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 285 |
287 // Remove all bookmarks and wait for sync completion. | 286 // Remove all bookmarks and wait for sync completion. |
288 RemoveAll(0); | 287 RemoveAll(0); |
289 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 288 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
290 // Verify other node has no children now. | 289 // Verify other node has no children now. |
291 EXPECT_EQ(0, GetOtherNode(0)->child_count()); | 290 EXPECT_EQ(0, GetOtherNode(0)->child_count()); |
292 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count()); | 291 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count()); |
293 // Verify model matches verifier. | 292 // Verify model matches verifier. |
294 ASSERT_TRUE(ModelMatchesVerifier(0)); | 293 ASSERT_TRUE(ModelMatchesVerifier(0)); |
295 } | 294 } |
OLD | NEW |