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/rand_util.h" | 5 #include "base/rand_util.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 8 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
11 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 11 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
12 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 12 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
14 #include "chrome/browser/sync/test/integration/sync_test.h" | 14 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 15 #include "components/bookmarks/browser/bookmark_node.h" |
15 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 16 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
16 #include "components/policy/core/common/policy_map.h" | 17 #include "components/policy/core/common/policy_map.h" |
17 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
18 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 19 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "ui/base/layout.h" | 21 #include "ui/base/layout.h" |
21 | 22 |
| 23 using bookmarks::BookmarkNode; |
22 using bookmarks_helper::AddFolder; | 24 using bookmarks_helper::AddFolder; |
23 using bookmarks_helper::AddURL; | 25 using bookmarks_helper::AddURL; |
24 using bookmarks_helper::AllModelsMatch; | 26 using bookmarks_helper::AllModelsMatch; |
25 using bookmarks_helper::AllModelsMatchVerifier; | 27 using bookmarks_helper::AllModelsMatchVerifier; |
26 using bookmarks_helper::ContainsDuplicateBookmarks; | 28 using bookmarks_helper::ContainsDuplicateBookmarks; |
27 using bookmarks_helper::CountBookmarksWithTitlesMatching; | 29 using bookmarks_helper::CountBookmarksWithTitlesMatching; |
28 using bookmarks_helper::CreateFavicon; | 30 using bookmarks_helper::CreateFavicon; |
29 using bookmarks_helper::GetBookmarkBarNode; | 31 using bookmarks_helper::GetBookmarkBarNode; |
30 using bookmarks_helper::GetManagedNode; | 32 using bookmarks_helper::GetManagedNode; |
31 using bookmarks_helper::GetOtherNode; | 33 using bookmarks_helper::GetOtherNode; |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 const BookmarkNode* folder = GetBookmarkBarNode(0); | 1136 const BookmarkNode* folder = GetBookmarkBarNode(0); |
1135 const BookmarkNode* folder_L5 = NULL; | 1137 const BookmarkNode* folder_L5 = NULL; |
1136 for (int level = 0; level < 6; ++level) { | 1138 for (int level = 0; level < 6; ++level) { |
1137 int num_bookmarks = base::RandInt(0, 9); | 1139 int num_bookmarks = base::RandInt(0, 9); |
1138 for (int i = 0; i < num_bookmarks; ++i) { | 1140 for (int i = 0; i < num_bookmarks; ++i) { |
1139 std::string title = IndexedURLTitle(i); | 1141 std::string title = IndexedURLTitle(i); |
1140 GURL url = GURL(IndexedURL(i)); | 1142 GURL url = GURL(IndexedURL(i)); |
1141 ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); | 1143 ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); |
1142 } | 1144 } |
1143 std::string title = IndexedFolderName(level); | 1145 std::string title = IndexedFolderName(level); |
1144 folder = AddFolder( | 1146 folder = AddFolder(0, folder, folder->child_count(), title); |
1145 0, folder, folder->child_count(), title); | |
1146 ASSERT_TRUE(folder != NULL); | 1147 ASSERT_TRUE(folder != NULL); |
1147 if (level == 5) folder_L5 = folder; | 1148 if (level == 5) folder_L5 = folder; |
1148 } | 1149 } |
1149 folder = AddFolder( | 1150 folder = AddFolder( |
1150 0, folder_L5, folder_L5->child_count(), kGenericFolderName); | 1151 0, folder_L5, folder_L5->child_count(), kGenericFolderName); |
1151 ASSERT_TRUE(folder != NULL); | 1152 ASSERT_TRUE(folder != NULL); |
1152 for (int i = 0; i < 10; ++i) { | 1153 for (int i = 0; i < 10; ++i) { |
1153 std::string title = IndexedURLTitle(i); | 1154 std::string title = IndexedURLTitle(i); |
1154 GURL url = GURL(IndexedURL(i)); | 1155 GURL url = GURL(IndexedURL(i)); |
1155 ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); | 1156 ASSERT_TRUE(AddURL(0, folder, i, title, url) != NULL); |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 | 2125 |
2125 // Verify that the managed bookmark exists in the local model of the first | 2126 // Verify that the managed bookmark exists in the local model of the first |
2126 // Profile, and has a child node. | 2127 // Profile, and has a child node. |
2127 ASSERT_EQ(1, managed_node0->child_count()); | 2128 ASSERT_EQ(1, managed_node0->child_count()); |
2128 ASSERT_TRUE(managed_node0->IsVisible()); | 2129 ASSERT_TRUE(managed_node0->IsVisible()); |
2129 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); | 2130 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); |
2130 | 2131 |
2131 // Verify that the second Profile didn't get this node. | 2132 // Verify that the second Profile didn't get this node. |
2132 ASSERT_EQ(0, managed_node1->child_count()); | 2133 ASSERT_EQ(0, managed_node1->child_count()); |
2133 } | 2134 } |
OLD | NEW |