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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 bookmarks_helper::FROM_UI); | 222 bookmarks_helper::FROM_UI); |
223 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 223 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
224 ASSERT_TRUE(AllModelsMatchVerifier()); | 224 ASSERT_TRUE(AllModelsMatchVerifier()); |
225 | 225 |
226 SetFavicon(0, bookmark0, icon_url2, CreateFavicon(SK_ColorGREEN), | 226 SetFavicon(0, bookmark0, icon_url2, CreateFavicon(SK_ColorGREEN), |
227 bookmarks_helper::FROM_UI); | 227 bookmarks_helper::FROM_UI); |
228 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 228 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
229 ASSERT_TRUE(AllModelsMatchVerifier()); | 229 ASSERT_TRUE(AllModelsMatchVerifier()); |
230 } | 230 } |
231 | 231 |
| 232 // When two bookmarks use the same icon URL, the favicon for both bookmarks is |
| 233 // stored in the same row in the favicons database. Test that when the favicon |
| 234 // is updated for one bookmark it is also updated for the other bookmark. This |
| 235 // ensures that sync has the most up to date data and prevents sync from |
| 236 // reverting the newly updated bookmark favicon back to the old favicon. |
| 237 // crbug.com/485657 |
| 238 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 239 SC_SetFaviconTwoBookmarksSameIconURL) { |
| 240 const GURL page_url1("http://www.google.com/a"); |
| 241 const GURL page_url2("http://www.google.com/b"); |
| 242 const GURL icon_url("http://www.google.com/favicon.ico"); |
| 243 |
| 244 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 245 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 246 |
| 247 const BookmarkNode* bookmark01 = AddURL(0, kGenericURLTitle, page_url1); |
| 248 ASSERT_TRUE(bookmark01 != nullptr); |
| 249 const BookmarkNode* bookmark02 = AddURL(0, kGenericURLTitle, page_url2); |
| 250 ASSERT_TRUE(bookmark02 != nullptr); |
| 251 |
| 252 SetFavicon(0, bookmark01, icon_url, CreateFavicon(SK_ColorWHITE), |
| 253 bookmarks_helper::FROM_UI); |
| 254 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 255 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 256 |
| 257 // Set |page_url2| to use a blue favicon and the same icon URL as |
| 258 // |page_url1|. The favicon for |page_url1| should also become blue. |
| 259 SetFavicon(0, bookmark02, icon_url, CreateFavicon(SK_ColorBLUE), |
| 260 bookmarks_helper::FROM_UI); |
| 261 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 262 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 263 |
| 264 // Set the title for |page_url1|. This should not revert either of the |
| 265 // bookmark favicons back to white. |
| 266 const char kNewTitle[] = "New Title"; |
| 267 ASSERT_STRNE(kGenericURLTitle, kNewTitle); |
| 268 const BookmarkNode* bookmark11 = GetUniqueNodeByURL(1, page_url1); |
| 269 SetTitle(1, bookmark11, std::string(kNewTitle)); |
| 270 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 271 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 272 } |
| 273 |
232 // Test Scribe ID - 370560. | 274 // Test Scribe ID - 370560. |
233 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { | 275 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, SC_AddNonHTTPBMs) { |
234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 276 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
235 ASSERT_TRUE(AllModelsMatchVerifier()); | 277 ASSERT_TRUE(AllModelsMatchVerifier()); |
236 | 278 |
237 ASSERT_TRUE(AddURL( | 279 ASSERT_TRUE(AddURL( |
238 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); | 280 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL); |
239 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); | 281 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL); |
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 282 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
241 ASSERT_TRUE(AllModelsMatchVerifier()); | 283 ASSERT_TRUE(AllModelsMatchVerifier()); |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 | 2167 |
2126 // Verify that the managed bookmark exists in the local model of the first | 2168 // Verify that the managed bookmark exists in the local model of the first |
2127 // Profile, and has a child node. | 2169 // Profile, and has a child node. |
2128 ASSERT_EQ(1, managed_node0->child_count()); | 2170 ASSERT_EQ(1, managed_node0->child_count()); |
2129 ASSERT_TRUE(managed_node0->IsVisible()); | 2171 ASSERT_TRUE(managed_node0->IsVisible()); |
2130 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); | 2172 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0->GetChild(0)->url()); |
2131 | 2173 |
2132 // Verify that the second Profile didn't get this node. | 2174 // Verify that the second Profile didn't get this node. |
2133 ASSERT_EQ(0, managed_node1->child_count()); | 2175 ASSERT_EQ(0, managed_node1->child_count()); |
2134 } | 2176 } |
OLD | NEW |