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" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 ASSERT_NE(kNewTitle, kGenericURLTitle); | 272 ASSERT_NE(kNewTitle, kGenericURLTitle); |
273 const BookmarkNode* bookmark1 = GetUniqueNodeByURL(1, page_url); | 273 const BookmarkNode* bookmark1 = GetUniqueNodeByURL(1, page_url); |
274 SetTitle(1, bookmark1, kNewTitle); | 274 SetTitle(1, bookmark1, kNewTitle); |
275 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 275 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
276 ASSERT_TRUE(AllModelsMatchVerifier()); | 276 ASSERT_TRUE(AllModelsMatchVerifier()); |
277 | 277 |
278 // The favicon for profile 0 should still be expired. | 278 // The favicon for profile 0 should still be expired. |
279 CheckFaviconExpired(0, icon_url); | 279 CheckFaviconExpired(0, icon_url); |
280 } | 280 } |
281 | 281 |
| 282 // When two bookmarks use the same icon URL, both bookmarks use the same row |
| 283 // in the favicons table in the Favicons database. Test that when the favicon |
| 284 // is updated for one bookmark it is also updated for the other bookmark. This |
| 285 // ensures that sync has the most up to date data and prevents sync from |
| 286 // reverting the newly updated bookmark favicon back to the old favicon. |
| 287 // crbug.com/485657 |
| 288 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 289 SC_SetFaviconTwoBookmarksSameIconURL) { |
| 290 const GURL page_url1("http://www.google.com/a"); |
| 291 const GURL page_url2("http://www.google.com/b"); |
| 292 const GURL icon_url("http://www.google.com/favicon.ico"); |
| 293 |
| 294 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 295 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 296 |
| 297 const BookmarkNode* bookmark01 = AddURL(0, kGenericURLTitle, page_url1); |
| 298 ASSERT_TRUE(bookmark01 != nullptr); |
| 299 const BookmarkNode* bookmark02 = AddURL(0, kGenericURLTitle, page_url2); |
| 300 ASSERT_TRUE(bookmark02 != nullptr); |
| 301 |
| 302 SetFavicon(0, bookmark01, icon_url, CreateFavicon(SK_ColorWHITE), |
| 303 bookmarks_helper::FROM_UI); |
| 304 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 305 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 306 |
| 307 // Set |page_url2| with the new (blue) favicon at |icon_url|. The sync favicon |
| 308 // for both |page_url1| and |page_url2| should be updated to the blue one. |
| 309 SetFavicon(0, bookmark02, icon_url, CreateFavicon(SK_ColorBLUE), |
| 310 bookmarks_helper::FROM_UI); |
| 311 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 312 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 313 |
| 314 // Set the title for |page_url1|. This should not revert either of the |
| 315 // bookmark favicons back to white. |
| 316 const char kNewTitle[] = "New Title"; |
| 317 ASSERT_STRNE(kGenericURLTitle, kNewTitle); |
| 318 const BookmarkNode* bookmark11 = GetUniqueNodeByURL(1, page_url1); |
| 319 SetTitle(1, bookmark11, std::string(kNewTitle)); |
| 320 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 321 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 322 } |
| 323 |
282 // Test Scribe ID - 370560. | 324 // Test Scribe ID - 370560. |
283 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { | 325 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { |
284 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 326 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
285 ASSERT_TRUE(AllModelsMatchVerifier()); | 327 ASSERT_TRUE(AllModelsMatchVerifier()); |
286 | 328 |
287 ASSERT_TRUE(AddURL( | 329 ASSERT_TRUE(AddURL( |
288 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); | 330 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); |
289 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); | 331 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); |
290 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 332 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
291 ASSERT_TRUE(AllModelsMatchVerifier()); | 333 ASSERT_TRUE(AllModelsMatchVerifier()); |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 | 2217 |
2176 // Verify that the managed bookmark exists in the local model of the first | 2218 // Verify that the managed bookmark exists in the local model of the first |
2177 // Profile, and has a child node. | 2219 // Profile, and has a child node. |
2178 ASSERT_EQ(1, managed_node0->child_count()); | 2220 ASSERT_EQ(1, managed_node0->child_count()); |
2179 ASSERT_TRUE(managed_node0->IsVisible()); | 2221 ASSERT_TRUE(managed_node0->IsVisible()); |
2180 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); | 2222 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); |
2181 | 2223 |
2182 // Verify that the second Profile didn't get this node. | 2224 // Verify that the second Profile didn't get this node. |
2183 ASSERT_EQ(0, managed_node1->child_count()); | 2225 ASSERT_EQ(0, managed_node1->child_count()); |
2184 } | 2226 } |
OLD | NEW |