| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_bar_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/history/history_backend.h" | 9 #include "chrome/browser/history/history_backend.h" |
| 10 #include "chrome/browser/history/in_memory_history_backend.h" | 10 #include "chrome/browser/history/in_memory_history_backend.h" |
| 11 #include "chrome/browser/history/in_memory_database.h" | 11 #include "chrome/browser/history/in_memory_database.h" |
| 12 #include "chrome/common/jpeg_codec.h" | 12 #include "chrome/common/jpeg_codec.h" |
| 13 #include "chrome/common/thumbnail_score.h" | 13 #include "chrome/common/thumbnail_score.h" |
| 14 #include "chrome/tools/profiles/thumbnail-inl.h" | 14 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 // This file only tests functionality where it is most convenient to call the | 17 // This file only tests functionality where it is most convenient to call the |
| 18 // backend directly. Most of the history backend functions are tested by the | 18 // backend directly. Most of the history backend functions are tested by the |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 int int_scope = 1; | 62 int int_scope = 1; |
| 63 void* scope = 0; | 63 void* scope = 0; |
| 64 memcpy(&scope, &int_scope, sizeof(int_scope)); | 64 memcpy(&scope, &int_scope, sizeof(int_scope)); |
| 65 scoped_refptr<history::HistoryAddPageArgs> request( | 65 scoped_refptr<history::HistoryAddPageArgs> request( |
| 66 new history::HistoryAddPageArgs( | 66 new history::HistoryAddPageArgs( |
| 67 redirects.back(), Time::Now(), scope, page_id, GURL(), | 67 redirects.back(), Time::Now(), scope, page_id, GURL(), |
| 68 redirects, PageTransition::LINK)); | 68 redirects, PageTransition::LINK)); |
| 69 backend_->AddPage(request); | 69 backend_->AddPage(request); |
| 70 } | 70 } |
| 71 | 71 |
| 72 BookmarkBarModel bookmark_model_; | 72 BookmarkModel bookmark_model_; |
| 73 | 73 |
| 74 protected: | 74 protected: |
| 75 bool loaded_; | 75 bool loaded_; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 friend HistoryBackendTestDelegate; | 78 friend HistoryBackendTestDelegate; |
| 79 | 79 |
| 80 // testing::Test | 80 // testing::Test |
| 81 virtual void SetUp() { | 81 virtual void SetUp() { |
| 82 if (!file_util::CreateNewTempDirectory(L"BackendTest", &test_dir_)) | 82 if (!file_util::CreateNewTempDirectory(L"BackendTest", &test_dir_)) |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 VisitVector visits; | 308 VisitVector visits; |
| 309 backend_->db_->GetVisitsForURL(row2_id, &visits); | 309 backend_->db_->GetVisitsForURL(row2_id, &visits); |
| 310 EXPECT_EQ(0, visits.size()); | 310 EXPECT_EQ(0, visits.size()); |
| 311 // The favicon should still be valid. | 311 // The favicon should still be valid. |
| 312 EXPECT_EQ(favicon2, | 312 EXPECT_EQ(favicon2, |
| 313 backend_->thumbnail_db_->GetFavIconIDForFavIconURL(favicon_url2)); | 313 backend_->thumbnail_db_->GetFavIconIDForFavIconURL(favicon_url2)); |
| 314 | 314 |
| 315 // Unstar row2. | 315 // Unstar row2. |
| 316 bookmark_model_.SetURLStarred(row2.url(), std::wstring(), false); | 316 bookmark_model_.SetURLStarred(row2.url(), std::wstring(), false); |
| 317 // Tell the backend it was unstarred. We have to explicitly do this as | 317 // Tell the backend it was unstarred. We have to explicitly do this as |
| 318 // BookmarkBarModel isn't wired up to the backend during testing. | 318 // BookmarkModel isn't wired up to the backend during testing. |
| 319 std::set<GURL> unstarred_urls; | 319 std::set<GURL> unstarred_urls; |
| 320 unstarred_urls.insert(row2.url()); | 320 unstarred_urls.insert(row2.url()); |
| 321 backend_->URLsNoLongerBookmarked(unstarred_urls); | 321 backend_->URLsNoLongerBookmarked(unstarred_urls); |
| 322 | 322 |
| 323 // The URL should no longer exist. | 323 // The URL should no longer exist. |
| 324 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &tmp_url_row)); | 324 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &tmp_url_row)); |
| 325 // And the favicon should be deleted. | 325 // And the favicon should be deleted. |
| 326 EXPECT_EQ(0, | 326 EXPECT_EQ(0, |
| 327 backend_->thumbnail_db_->GetFavIconIDForFavIconURL(favicon_url2)); | 327 backend_->thumbnail_db_->GetFavIconIDForFavIconURL(favicon_url2)); |
| 328 | 328 |
| 329 // Unstar row 1. | 329 // Unstar row 1. |
| 330 bookmark_model_.SetURLStarred(row1.url(), std::wstring(), false); | 330 bookmark_model_.SetURLStarred(row1.url(), std::wstring(), false); |
| 331 // Tell the backend it was unstarred. We have to explicitly do this as | 331 // Tell the backend it was unstarred. We have to explicitly do this as |
| 332 // BookmarkBarModel isn't wired up to the backend during testing. | 332 // BookmarkModel isn't wired up to the backend during testing. |
| 333 unstarred_urls.clear(); | 333 unstarred_urls.clear(); |
| 334 unstarred_urls.insert(row1.url()); | 334 unstarred_urls.insert(row1.url()); |
| 335 backend_->URLsNoLongerBookmarked(unstarred_urls); | 335 backend_->URLsNoLongerBookmarked(unstarred_urls); |
| 336 | 336 |
| 337 // The URL should still exist (because there were visits). | 337 // The URL should still exist (because there were visits). |
| 338 EXPECT_EQ(row1_id, backend_->db_->GetRowForURL(row1.url(), NULL)); | 338 EXPECT_EQ(row1_id, backend_->db_->GetRowForURL(row1.url(), NULL)); |
| 339 | 339 |
| 340 // There should still be visits. | 340 // There should still be visits. |
| 341 visits.clear(); | 341 visits.clear(); |
| 342 backend_->db_->GetVisitsForURL(row1_id, &visits); | 342 backend_->db_->GetVisitsForURL(row1_id, &visits); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // distracted by the second chain and should return the thumbnail | 379 // distracted by the second chain and should return the thumbnail |
| 380 // attached to thumbnail_url_. | 380 // attached to thumbnail_url_. |
| 381 scoped_refptr<RefCountedBytes> data; | 381 scoped_refptr<RefCountedBytes> data; |
| 382 backend_->GetPageThumbnailDirectly(GURL(base_url), &data); | 382 backend_->GetPageThumbnailDirectly(GURL(base_url), &data); |
| 383 | 383 |
| 384 EXPECT_TRUE(data.get()); | 384 EXPECT_TRUE(data.get()); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace history | 387 } // namespace history |
| 388 | 388 |
| OLD | NEW |