OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <stack> | 5 #include <stack> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 int64 f2 = adds.AddFolder(L"Server Folder A", bookmark_bar_id(), f1); | 540 int64 f2 = adds.AddFolder(L"Server Folder A", bookmark_bar_id(), f1); |
541 int64 u1 = adds.AddURL(L"Some old site", "ftp://nifty.andrew.cmu.edu/", | 541 int64 u1 = adds.AddURL(L"Some old site", "ftp://nifty.andrew.cmu.edu/", |
542 bookmark_bar_id(), f2); | 542 bookmark_bar_id(), f2); |
543 int64 u2 = adds.AddURL(L"Nifty", "ftp://nifty.andrew.cmu.edu/", f1, 0); | 543 int64 u2 = adds.AddURL(L"Nifty", "ftp://nifty.andrew.cmu.edu/", f1, 0); |
544 // u3 is a duplicate URL | 544 // u3 is a duplicate URL |
545 int64 u3 = adds.AddURL(L"Nifty2", "ftp://nifty.andrew.cmu.edu/", f1, u2); | 545 int64 u3 = adds.AddURL(L"Nifty2", "ftp://nifty.andrew.cmu.edu/", f1, u2); |
546 // u4 is a duplicate title, different URL. | 546 // u4 is a duplicate title, different URL. |
547 adds.AddURL(L"Some old site", "http://slog.thestranger.com/", | 547 adds.AddURL(L"Some old site", "http://slog.thestranger.com/", |
548 bookmark_bar_id(), u1); | 548 bookmark_bar_id(), u1); |
549 // u5 tests an empty-string title. | 549 // u5 tests an empty-string title. |
550 std::string javascript_url("javascript:(function(){var w=window.open(" \ | 550 std::string javascript_url( |
551 "'about:blank','gnotesWin','location=0,menubar=0,"
\ | 551 "javascript:(function(){var w=window.open(" \ |
552 "scrollbars=0,status=0,toolbar=0,width=300," \ | 552 "'about:blank','gnotesWin','location=0,menubar=0," \ |
553 "height=300,resizable');});"); | 553 "scrollbars=0,status=0,toolbar=0,width=300," \ |
| 554 "height=300,resizable');});"); |
554 adds.AddURL(L"", javascript_url, other_bookmarks_id(), 0); | 555 adds.AddURL(L"", javascript_url, other_bookmarks_id(), 0); |
555 | 556 |
556 vector<sync_api::SyncManager::ChangeRecord>::const_iterator it; | 557 vector<sync_api::SyncManager::ChangeRecord>::const_iterator it; |
557 // The bookmark model shouldn't yet have seen any of the nodes of |adds|. | 558 // The bookmark model shouldn't yet have seen any of the nodes of |adds|. |
558 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) | 559 for (it = adds.changes().begin(); it != adds.changes().end(); ++it) |
559 ExpectBrowserNodeUnknown(it->id); | 560 ExpectBrowserNodeUnknown(it->id); |
560 | 561 |
561 adds.ApplyPendingChanges(change_processor()); | 562 adds.ApplyPendingChanges(change_processor()); |
562 | 563 |
563 // Make sure the bookmark model received all of the nodes in |adds|. | 564 // Make sure the bookmark model received all of the nodes in |adds|. |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); | 1266 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); |
1266 WriteTestDataToBookmarkModel(); | 1267 WriteTestDataToBookmarkModel(); |
1267 StartSyncService(); | 1268 StartSyncService(); |
1268 ExpectModelMatch(); | 1269 ExpectModelMatch(); |
1269 // Force the sync service to shut down and write itself to disk. | 1270 // Force the sync service to shut down and write itself to disk. |
1270 StopSyncService(SAVE_TO_STORAGE); | 1271 StopSyncService(SAVE_TO_STORAGE); |
1271 // Change the bookmark model before restarting sync service to simulate | 1272 // Change the bookmark model before restarting sync service to simulate |
1272 // the situation where bookmark model is different from sync model and | 1273 // the situation where bookmark model is different from sync model and |
1273 // make sure model associator correctly rebuilds associations. | 1274 // make sure model associator correctly rebuilds associations. |
1274 const BookmarkNode* bookmark_bar_node = model_->GetBookmarkBarNode(); | 1275 const BookmarkNode* bookmark_bar_node = model_->GetBookmarkBarNode(); |
1275 model_->AddURL(bookmark_bar_node, 0, L"xtra", GURL("http://www.xtra.com")); | 1276 model_->AddURL(bookmark_bar_node, 0, ASCIIToUTF16("xtra"), |
| 1277 GURL("http://www.xtra.com")); |
1276 // Now restart the sync service. This time it will try to use the persistent | 1278 // Now restart the sync service. This time it will try to use the persistent |
1277 // associations and realize that they are invalid and hence will rebuild | 1279 // associations and realize that they are invalid and hence will rebuild |
1278 // associations. | 1280 // associations. |
1279 StartSyncService(); | 1281 StartSyncService(); |
1280 ExpectModelMatch(); | 1282 ExpectModelMatch(); |
1281 } | 1283 } |
1282 | 1284 |
1283 TEST_F(ProfileSyncServiceTestWithData, SortChildren) { | 1285 TEST_F(ProfileSyncServiceTestWithData, SortChildren) { |
1284 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); | 1286 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); |
1285 StartSyncService(); | 1287 StartSyncService(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 ASSERT_TRUE(file_util::PathExists(sync_file1)); | 1394 ASSERT_TRUE(file_util::PathExists(sync_file1)); |
1393 std::string file1text; | 1395 std::string file1text; |
1394 file_util::ReadFileToString(sync_file1, &file1text); | 1396 file_util::ReadFileToString(sync_file1, &file1text); |
1395 ASSERT_FALSE(file1text.compare(nonsense1) == 0); | 1397 ASSERT_FALSE(file1text.compare(nonsense1) == 0); |
1396 | 1398 |
1397 ASSERT_TRUE(file_util::PathExists(sync_file2)); | 1399 ASSERT_TRUE(file_util::PathExists(sync_file2)); |
1398 std::string file2text; | 1400 std::string file2text; |
1399 file_util::ReadFileToString(sync_file2, &file2text); | 1401 file_util::ReadFileToString(sync_file2, &file2text); |
1400 ASSERT_FALSE(file2text.compare(nonsense2) == 0); | 1402 ASSERT_FALSE(file2text.compare(nonsense2) == 0); |
1401 } | 1403 } |
OLD | NEW |