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/bookmarks/browser/bookmark_node.h" |
16 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 16 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
17 #include "components/policy/core/common/policy_map.h" | 17 #include "components/policy/core/common/policy_map.h" |
18 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
19 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 19 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "ui/base/layout.h" | 21 #include "ui/base/layout.h" |
22 | 22 |
23 using bookmarks::BookmarkNode; | 23 using bookmarks::BookmarkNode; |
24 using bookmarks_helper::AddFolder; | 24 using bookmarks_helper::AddFolder; |
25 using bookmarks_helper::AddURL; | 25 using bookmarks_helper::AddURL; |
26 using bookmarks_helper::AllModelsMatch; | 26 using bookmarks_helper::AllModelsMatch; |
27 using bookmarks_helper::AllModelsMatchVerifier; | 27 using bookmarks_helper::AllModelsMatchVerifier; |
| 28 using bookmarks_helper::CheckFaviconExpired; |
28 using bookmarks_helper::ContainsDuplicateBookmarks; | 29 using bookmarks_helper::ContainsDuplicateBookmarks; |
29 using bookmarks_helper::CountBookmarksWithTitlesMatching; | 30 using bookmarks_helper::CountBookmarksWithTitlesMatching; |
30 using bookmarks_helper::CreateFavicon; | 31 using bookmarks_helper::CreateFavicon; |
| 32 using bookmarks_helper::ExpireFavicon; |
31 using bookmarks_helper::GetBookmarkBarNode; | 33 using bookmarks_helper::GetBookmarkBarNode; |
32 using bookmarks_helper::GetManagedNode; | 34 using bookmarks_helper::GetManagedNode; |
33 using bookmarks_helper::GetOtherNode; | 35 using bookmarks_helper::GetOtherNode; |
34 using bookmarks_helper::GetSyncedBookmarksNode; | 36 using bookmarks_helper::GetSyncedBookmarksNode; |
35 using bookmarks_helper::GetUniqueNodeByURL; | 37 using bookmarks_helper::GetUniqueNodeByURL; |
36 using bookmarks_helper::HasNodeWithURL; | 38 using bookmarks_helper::HasNodeWithURL; |
37 using bookmarks_helper::IndexedFolderName; | 39 using bookmarks_helper::IndexedFolderName; |
38 using bookmarks_helper::IndexedSubfolderName; | 40 using bookmarks_helper::IndexedSubfolderName; |
39 using bookmarks_helper::IndexedSubsubfolderName; | 41 using bookmarks_helper::IndexedSubsubfolderName; |
40 using bookmarks_helper::IndexedURL; | 42 using bookmarks_helper::IndexedURL; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 bookmarks_helper::FROM_UI); | 224 bookmarks_helper::FROM_UI); |
223 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 225 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
224 ASSERT_TRUE(AllModelsMatchVerifier()); | 226 ASSERT_TRUE(AllModelsMatchVerifier()); |
225 | 227 |
226 SetFavicon(0, bookmark0, icon_url2, CreateFavicon(SK_ColorGREEN), | 228 SetFavicon(0, bookmark0, icon_url2, CreateFavicon(SK_ColorGREEN), |
227 bookmarks_helper::FROM_UI); | 229 bookmarks_helper::FROM_UI); |
228 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 230 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
229 ASSERT_TRUE(AllModelsMatchVerifier()); | 231 ASSERT_TRUE(AllModelsMatchVerifier()); |
230 } | 232 } |
231 | 233 |
| 234 // Test that if sync does not modify a favicon bitmap's data that it does not |
| 235 // modify the favicon bitmap's "last updated time" either. This is important |
| 236 // because the last updated time is used to determine whether a bookmark's |
| 237 // favicon should be redownloaded when the web when the bookmark is visited. |
| 238 // If sync prevents the "last updated time" from expiring, the favicon is |
| 239 // never redownloaded from the web. (http://crbug.com/481414) |
| 240 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 241 SC_UpdatingTitleDoesNotUpdateFaviconLastUpdatedTime) { |
| 242 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| 243 |
| 244 std::vector<ui::ScaleFactor> supported_scale_factors; |
| 245 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); |
| 246 ui::SetSupportedScaleFactors(supported_scale_factors); |
| 247 |
| 248 const GURL page_url(kGenericURL); |
| 249 const GURL icon_url("http://www.google.com/favicon.ico"); |
| 250 |
| 251 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 252 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 253 |
| 254 const BookmarkNode* bookmark0 = AddURL(0, kGenericURLTitle, page_url); |
| 255 ASSERT_NE(bookmark0, nullptr); |
| 256 gfx::Image favicon0 = CreateFavicon(SK_ColorBLUE); |
| 257 ASSERT_FALSE(favicon0.IsEmpty()); |
| 258 SetFavicon(0, bookmark0, icon_url, favicon0, bookmarks_helper::FROM_UI); |
| 259 |
| 260 // Expire the favicon (e.g. as a result of the user "clearing browsing |
| 261 // history from the beginning of time") |
| 262 ExpireFavicon(0, bookmark0); |
| 263 CheckFaviconExpired(0, icon_url); |
| 264 |
| 265 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 266 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 267 |
| 268 // Change the bookmark's title for profile 1. Changing the title will cause |
| 269 // the bookmark's favicon data to be synced from profile 1 to profile 0 even |
| 270 // though the favicon data did not change. |
| 271 const std::string kNewTitle = "New Title"; |
| 272 ASSERT_NE(kNewTitle, kGenericURLTitle); |
| 273 const BookmarkNode* bookmark1 = GetUniqueNodeByURL(1, page_url); |
| 274 SetTitle(1, bookmark1, kNewTitle); |
| 275 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 276 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 277 |
| 278 // The favicon for profile 0 should still be expired. |
| 279 CheckFaviconExpired(0, icon_url); |
| 280 } |
| 281 |
232 // Test Scribe ID - 370560. | 282 // Test Scribe ID - 370560. |
233 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { | 283 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { |
234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 284 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
235 ASSERT_TRUE(AllModelsMatchVerifier()); | 285 ASSERT_TRUE(AllModelsMatchVerifier()); |
236 | 286 |
237 ASSERT_TRUE(AddURL( | 287 ASSERT_TRUE(AddURL( |
238 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); | 288 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); |
239 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); | 289 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); |
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 290 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
241 ASSERT_TRUE(AllModelsMatchVerifier()); | 291 ASSERT_TRUE(AllModelsMatchVerifier()); |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 | 2175 |
2126 // Verify that the managed bookmark exists in the local model of the first | 2176 // Verify that the managed bookmark exists in the local model of the first |
2127 // Profile, and has a child node. | 2177 // Profile, and has a child node. |
2128 ASSERT_EQ(1, managed_node0->child_count()); | 2178 ASSERT_EQ(1, managed_node0->child_count()); |
2129 ASSERT_TRUE(managed_node0->IsVisible()); | 2179 ASSERT_TRUE(managed_node0->IsVisible()); |
2130 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); | 2180 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); |
2131 | 2181 |
2132 // Verify that the second Profile didn't get this node. | 2182 // Verify that the second Profile didn't get this node. |
2133 ASSERT_EQ(0, managed_node1->child_count()); | 2183 ASSERT_EQ(0, managed_node1->child_count()); |
2134 } | 2184 } |
OLD | NEW |