diff options
author | tejasshah@google.com <tejasshah@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 18:22:12 +0000 |
---|---|---|
committer | tejasshah@google.com <tejasshah@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 18:22:12 +0000 |
commit | 0e4dd7eb25e6e005d1027504bc5f239d337a8f67 (patch) | |
tree | e4a4ddf91b2252b7513dbab0ca2ce142c4893193 | |
parent | 38b1503bd0d90f090744bd0a875a7d6975401aff (diff) | |
download | chromium_src-0e4dd7eb25e6e005d1027504bc5f239d337a8f67.zip chromium_src-0e4dd7eb25e6e005d1027504bc5f239d337a8f67.tar.gz chromium_src-0e4dd7eb25e6e005d1027504bc5f239d337a8f67.tar.bz2 |
Original Changelist being moved to this new location. Refer Original CL # 1109011 (Internal Review)
Added 2 new test cases + Code to handle favicon loading, copying History and
Favicon verification.
Fixed all the comments.Fixed jcampan's comments about removing virtual method for setting user-data-dir.
Review URL: http://codereview.chromium.org/165277
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23986 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/in_process_browser_test.cc | 3 | ||||
-rw-r--r-- | chrome/test/in_process_browser_test.h | 3 | ||||
-rw-r--r-- | chrome/test/live_sync/bookmark_model_verifier.cc | 28 | ||||
-rw-r--r-- | chrome/test/live_sync/bookmark_model_verifier.h | 9 | ||||
-rw-r--r-- | chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc | 136 |
5 files changed, 166 insertions, 13 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 0c58c55..50d66ed 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -54,9 +54,6 @@ InProcessBrowserTest::InProcessBrowserTest() } void InProcessBrowserTest::SetUp() { - // This method does nothing in default case. But can be overridden - // to set user data dir for test. - SetUpUserDataDirForTest(); // Cleanup the user data dir. FilePath user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h index 250c52e..f229277 100644 --- a/chrome/test/in_process_browser_test.h +++ b/chrome/test/in_process_browser_test.h @@ -52,9 +52,6 @@ class InProcessBrowserTest : public testing::Test { // Restores state configured in SetUp. virtual void TearDown(); - // This method can be overridden to set user data directory for test. - virtual void SetUpUserDataDirForTest() {} - // This method is used to decide if user data dir // needs to be deleted or not. virtual bool ShouldDeleteProfile() { return true; } diff --git a/chrome/test/live_sync/bookmark_model_verifier.cc b/chrome/test/live_sync/bookmark_model_verifier.cc index 290086d..6b31eff 100644 --- a/chrome/test/live_sync/bookmark_model_verifier.cc +++ b/chrome/test/live_sync/bookmark_model_verifier.cc @@ -14,6 +14,7 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/test/live_sync/live_bookmarks_sync_test.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/skia/include/core/SkBitmap.h" // static void BookmarkModelVerifier::ExpectBookmarkInfoMatch( @@ -41,8 +42,8 @@ void BookmarkModelVerifier::ExpectMatch(BookmarkModel* actual) { } // static -void BookmarkModelVerifier::ExpectModelsMatch( - BookmarkModel* expected, BookmarkModel* actual) { +void BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon( + BookmarkModel* expected, BookmarkModel* actual, bool compare_favicon) { TreeNodeIterator<const BookmarkNode> e_iterator(expected->root_node()); TreeNodeIterator<const BookmarkNode> a_iterator(actual->root_node()); @@ -52,6 +53,23 @@ void BookmarkModelVerifier::ExpectModelsMatch( ASSERT_TRUE(a_iterator.has_next()); const BookmarkNode* a_node = a_iterator.Next(); ExpectBookmarkInfoMatch(e_node, a_node); + // Get Favicon and compare if compare_favicon flag is true. + if (compare_favicon) { + const SkBitmap& e_node_favicon = expected->GetFavIcon(e_node); + const SkBitmap& a_node_favicon = actual->GetFavIcon(a_node); + EXPECT_GT(e_node_favicon.getSize(), (size_t) 0); + EXPECT_EQ(e_node_favicon.getSize(), a_node_favicon.getSize()); + EXPECT_EQ(e_node_favicon.width(), a_node_favicon.width()); + EXPECT_EQ(e_node_favicon.height(), a_node_favicon.height()); + SkAutoLockPixels bitmap_lock_e(e_node_favicon); + SkAutoLockPixels bitmap_lock_a(a_node_favicon); + void* e_node_pixel_addr = e_node_favicon.getPixels(); + ASSERT_TRUE(e_node_pixel_addr); + void* a_node_pixel_addr = a_node_favicon.getPixels(); + ASSERT_TRUE(a_node_pixel_addr); + EXPECT_EQ(memcmp(e_node_pixel_addr, a_node_pixel_addr, + e_node_favicon.getSize()), 0); + } } ASSERT_FALSE(a_iterator.has_next()); } @@ -61,7 +79,7 @@ void BookmarkModelVerifier::FindNodeInVerifier(BookmarkModel* foreign_model, const BookmarkNode** result) { // Climb the tree. std::stack<int> path; - const BookmarkNode* walker = foreign_node; + const BookmarkNode* walker = foreign_node; while (walker != foreign_model->root_node()) { path.push(walker->GetParent()->IndexOfChild(walker)); walker = walker->GetParent(); @@ -69,7 +87,7 @@ void BookmarkModelVerifier::FindNodeInVerifier(BookmarkModel* foreign_model, // Swing over to the other tree. walker = verifier_->root_node(); - + // Climb down. while (!path.empty()) { ASSERT_TRUE(walker->is_folder()); @@ -112,7 +130,7 @@ const BookmarkNode* BookmarkModelVerifier::AddURL(BookmarkModel* model, } void BookmarkModelVerifier::SetTitle(BookmarkModel* model, - const BookmarkNode* node, + const BookmarkNode* node, const string16& title) { const BookmarkNode* v_node = NULL; FindNodeInVerifier(model, node, &v_node); diff --git a/chrome/test/live_sync/bookmark_model_verifier.h b/chrome/test/live_sync/bookmark_model_verifier.h index 889ab71..c1ef0fe 100644 --- a/chrome/test/live_sync/bookmark_model_verifier.h +++ b/chrome/test/live_sync/bookmark_model_verifier.h @@ -72,7 +72,14 @@ class BookmarkModelVerifier { // Asserts that the two hierarchies are equivalent in terms of the data model. // (e.g some peripheral fields like creation times are allowed to mismatch). - static void ExpectModelsMatch(BookmarkModel* expected, BookmarkModel* actual); + static void ExpectModelsMatch(BookmarkModel* expected, + BookmarkModel* actual) { + ExpectModelsMatchIncludingFavicon(expected, actual, false); + } + + static void ExpectModelsMatchIncludingFavicon(BookmarkModel* expected, + BookmarkModel* actual, + bool compare_favicon); private: BookmarkModelVerifier(); diff --git a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc index f9c8454..690738e 100644 --- a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc @@ -33,6 +33,9 @@ class TwoClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { profile2_.get(), username_, password_)); return client1_->SetupSync() && client2_->SetupSync(); } + virtual bool ShouldDeleteProfile() { + return false; + } ProfileSyncServiceTestHarness* client1() { return client1_.get(); } ProfileSyncServiceTestHarness* client2() { return client2_.get(); } @@ -52,6 +55,45 @@ class TwoClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest { DISALLOW_COPY_AND_ASSIGN(TwoClientLiveBookmarksSyncTest); }; +class LiveSyncTest_PrePopulatedHistory1K + : public TwoClientLiveBookmarksSyncTest { + public: + LiveSyncTest_PrePopulatedHistory1K() {} + virtual ~LiveSyncTest_PrePopulatedHistory1K() {} + + virtual void SetUp() { + FilePath dest_user_data_dir; + PathService::Get(chrome::DIR_USER_DATA, &dest_user_data_dir); + dest_user_data_dir = dest_user_data_dir.Append( + FILE_PATH_LITERAL("Default")); + file_util::CreateDirectoryW(dest_user_data_dir); + FilePath sync_data_source; + PathService::Get(base::DIR_SOURCE_ROOT, &sync_data_source); + sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("chrome")); + sync_data_source = sync_data_source.Append( + FILE_PATH_LITERAL("personalization")); + sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("test")); + sync_data_source = sync_data_source.Append( + FILE_PATH_LITERAL("live_sync_data")); + sync_data_source = sync_data_source.Append( + FILE_PATH_LITERAL("1K_url_visit_history")); + sync_data_source = sync_data_source.Append(FILE_PATH_LITERAL("Default")); + ASSERT_TRUE(file_util::PathExists(sync_data_source)); + file_util::FileEnumerator sync_data( + sync_data_source, false, file_util::FileEnumerator::FILES); + FilePath source_file = sync_data.Next(); + while (!source_file.empty()) { + FilePath dest_file = dest_user_data_dir.Append(source_file.BaseName()); + ASSERT_TRUE(file_util::CopyFileW(source_file, dest_file)); + source_file = sync_data.Next(); + } + LiveBookmarksSyncTest::SetUp(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(LiveSyncTest_PrePopulatedHistory1K); +}; + // Test case Naming Convention: // SC/MC - SingleClient / MultiClient. // Suffix Number - Indicates test scribe testcase ID. @@ -224,6 +266,30 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, Cleanup(); } +IN_PROC_BROWSER_TEST_F(LiveSyncTest_PrePopulatedHistory1K, + SC_CleanAccount_AddFirstBMWithFavicon_370489) { + + ASSERT_TRUE(SetupSync()) << "Failed to SetupSync"; + scoped_ptr<BookmarkModelVerifier> verifier(BookmarkModelVerifier::Create()); + BookmarkModel* model_one = profile1()->GetBookmarkModel(); + BookmarkModel* model_two = profile2()->GetBookmarkModel(); + const BookmarkNode* bbn_one = model_one->GetBookmarkBarNode(); + + verifier->ExpectMatch(model_one); + verifier->ExpectMatch(model_two); + + // Let's add first bookmark(with favicon) + { + const BookmarkNode* nofavicon_bm = verifier->AddURL(model_one, bbn_one, 0, + L"Welcome to Facebook! | Facebook", GURL("http://www.facebook.com")); + } + ASSERT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); + verifier->ExpectMatch(model_one); + BookmarkModelVerifier::ExpectModelsMatchIncludingFavicon(model_one, + model_two, true); + Cleanup(); +} + IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_CleanAccount_AddNonHTTPBMs_370560) { @@ -920,6 +986,73 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, } IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, + SC_DeleteBMFolderWithBMs_NonEmptyAccountAfterDelete_371879) { + + ASSERT_TRUE(SetupSync()) << "Failed to SetupSync"; + scoped_ptr<BookmarkModelVerifier> verifier(BookmarkModelVerifier::Create()); + BookmarkModel* model_one = profile1()->GetBookmarkModel(); + BookmarkModel* model_two = profile2()->GetBookmarkModel(); + const BookmarkNode* bbn_one = model_one->GetBookmarkBarNode(); + const BookmarkNode* other_bm_one = model_one->other_node(); + + verifier->ExpectMatch(model_one); + verifier->ExpectMatch(model_two); + // Let's add bookmark and bookmark folder to client1 + const BookmarkNode* yahoo = verifier->AddURL(model_one, bbn_one, 0, + L"Yahoo!", GURL("http://www.yahoo.com")); + const BookmarkNode* bm_folder_one = + verifier->AddGroup(model_one, bbn_one, 1, L"TestFolder"); + // Let's add some bookmarks(without favicon) and folders to + // bookmark bar + for (int index = 2; index < 10; index++) { + int random_int = base::RandInt(1, 100); + // To create randomness in order, 40% of time add bookmarks + if (random_int > 60) { + string16 title(L"BB - TestBookmark"); + string16 url(L"http://www.nofaviconurl"); + string16 index_str = IntToString16(index); + title.append(index_str); + url.append(index_str); + url.append(L".com"); + const BookmarkNode* nofavicon_bm = verifier->AddURL(model_one, bbn_one, + index, title, GURL(url)); + } else { + // Remaining % of time - Add Bookmark folders + string16 title(L"BB - TestBMFolder"); + string16 index_str = IntToString16(index); + title.append(index_str); + const BookmarkNode* bm_folder = verifier->AddGroup(model_one, bbn_one, + index, title); + } + } + + // Let's add some bookmarks(without favicon) to bm_folder_one ('TestFolder') + for (int index = 0; index < 15; index++) { + string16 title(L"Level2 - TestBookmark"); + string16 url(L"http://www.nofaviconurl"); + string16 index_str = IntToString16(index); + title.append(index_str); + url.append(index_str); + url.append(L".com"); + const BookmarkNode* nofavicon_bm = verifier->AddURL(model_one, + bm_folder_one, index, title, GURL(url)); + } + ASSERT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); + verifier->ExpectMatch(model_one); + verifier->ExpectMatch(model_two); + + // Let's delete the bookmark folder (bm_folder_one) + verifier->Remove(model_one, bbn_one, 1); + + ASSERT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); + verifier->ExpectMatch(model_one); + verifier->ExpectMatch(model_two); + + Cleanup(); +} + + +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, SC_DelBMFoldWithBMsAndBMFolds_NonEmptyACAfterDelete_371880) { ASSERT_TRUE(SetupSync()) << "Failed to SetupSync"; @@ -1014,7 +1147,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, verifier->ExpectMatch(model_two); // Let's delete the bookmark folder (bm_folder_one) - verifier->Remove(model_one, bm_folder_one, 0); + verifier->Remove(model_one, bbn_one, 1); + ASSERT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); verifier->ExpectMatch(model_one); |