Chromium Code Reviews| 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. | |
| 236 // (http://crbug.com/481414) | |
| 237 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, | |
| 238 SC_UpdatingTitleDoesNotUpdateFaviconLastUpdatedTime) { | |
| 239 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
| 240 | |
| 241 std::vector<ui::ScaleFactor> supported_scale_factors; | |
| 242 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); | |
| 243 ui::SetSupportedScaleFactors(supported_scale_factors); | |
| 244 | |
| 245 const GURL page_url(kGenericURL); | |
| 246 const GURL icon_url("http://www.google.com/favicon.ico"); | |
| 247 | |
| 248 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 249 ASSERT_TRUE(AllModelsMatchVerifier()); | |
| 250 | |
| 251 const BookmarkNode* bookmark0 = AddURL(0, kGenericURLTitle, page_url); | |
| 252 ASSERT_TRUE(bookmark0 != nullptr); | |
|
Nicolas Zea
2015/05/14 04:08:23
nit: ASSERT_NE?
pkotwicz
2015/05/14 14:54:36
Done.
| |
| 253 gfx::Image favicon0 = CreateFavicon(SK_ColorBLUE); | |
| 254 ASSERT_FALSE(favicon0.IsEmpty()); | |
| 255 SetFavicon(0, bookmark0, icon_url, favicon0, bookmarks_helper::FROM_UI); | |
| 256 | |
| 257 // Expire the favicon (e.g. as a result of the user "clearing browsing | |
|
Nicolas Zea
2015/05/14 04:08:23
Could you explain why we need to expire the favico
pkotwicz
2015/05/14 14:54:36
SetFavicon() on line 255 adds an unexpired favicon
| |
| 258 // history from the beginning of time") | |
| 259 ExpireFavicon(0, bookmark0); | |
| 260 CheckFaviconExpired(0, icon_url); | |
| 261 | |
| 262 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
| 263 ASSERT_TRUE(AllModelsMatchVerifier()); | |
| 264 | |
| 265 // Change the bookmark's title for profile 1. Changing the title will cause | |
| 266 // the bookmark's favicon data to be synced from profile 1 to profile 0 even | |
| 267 // though the favicon data did not change. | |
| 268 const std::string kNewTitle = "New Title"; | |
| 269 ASSERT_NE(kNewTitle, kGenericURLTitle); | |
| 270 const BookmarkNode* bookmark1 = GetUniqueNodeByURL(1, page_url); | |
| 271 SetTitle(1, bookmark1, kNewTitle); | |
| 272 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
| 273 ASSERT_TRUE(AllModelsMatchVerifier()); | |
| 274 | |
| 275 // The favicon for profile 0 should still be expired. | |
| 276 CheckFaviconExpired(0, icon_url); | |
| 277 } | |
| 278 | |
| 232 // Test Scribe ID - 370560. | 279 // Test Scribe ID - 370560. |
| 233 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { | 280 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { |
| 234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 281 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 235 ASSERT_TRUE(AllModelsMatchVerifier()); | 282 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 236 | 283 |
| 237 ASSERT_TRUE(AddURL( | 284 ASSERT_TRUE(AddURL( |
| 238 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); | 285 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); |
| 239 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); | 286 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); |
| 240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 287 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 241 ASSERT_TRUE(AllModelsMatchVerifier()); | 288 ASSERT_TRUE(AllModelsMatchVerifier()); |
| (...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2125 | 2172 |
| 2126 // Verify that the managed bookmark exists in the local model of the first | 2173 // Verify that the managed bookmark exists in the local model of the first |
| 2127 // Profile, and has a child node. | 2174 // Profile, and has a child node. |
| 2128 ASSERT_EQ(1, managed_node0->child_count()); | 2175 ASSERT_EQ(1, managed_node0->child_count()); |
| 2129 ASSERT_TRUE(managed_node0->IsVisible()); | 2176 ASSERT_TRUE(managed_node0->IsVisible()); |
| 2130 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); | 2177 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); |
| 2131 | 2178 |
| 2132 // Verify that the second Profile didn't get this node. | 2179 // Verify that the second Profile didn't get this node. |
| 2133 ASSERT_EQ(0, managed_node1->child_count()); | 2180 ASSERT_EQ(0, managed_node1->child_count()); |
| 2134 } | 2181 } |
| OLD | NEW |