| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/history/history_database.h" | 22 #include "chrome/browser/history/history_database.h" |
| 23 #include "chrome/browser/history/history_notifications.h" | 23 #include "chrome/browser/history/history_notifications.h" |
| 24 #include "chrome/browser/history/thumbnail_database.h" | 24 #include "chrome/browser/history/thumbnail_database.h" |
| 25 #include "chrome/browser/history/top_sites.h" | 25 #include "chrome/browser/history/top_sites.h" |
| 26 #include "chrome/common/thumbnail_score.h" | 26 #include "chrome/common/thumbnail_score.h" |
| 27 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
| 28 #include "chrome/tools/profiles/thumbnail-inl.h" | 28 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 29 #include "components/bookmarks/core/browser/bookmark_model.h" | 29 #include "components/bookmarks/core/browser/bookmark_model.h" |
| 30 #include "components/bookmarks/core/browser/bookmark_utils.h" | 30 #include "components/bookmarks/core/browser/bookmark_utils.h" |
| 31 #include "components/bookmarks/core/test/test_bookmark_client.h" | 31 #include "components/bookmarks/core/test/test_bookmark_client.h" |
| 32 #include "components/history/core/browser/test_history_client.h" |
| 32 #include "content/public/test/test_browser_thread.h" | 33 #include "content/public/test/test_browser_thread.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
| 35 #include "ui/gfx/codec/jpeg_codec.h" | 36 #include "ui/gfx/codec/jpeg_codec.h" |
| 36 | 37 |
| 37 using base::Time; | 38 using base::Time; |
| 38 using base::TimeDelta; | 39 using base::TimeDelta; |
| 39 using base::TimeTicks; | 40 using base::TimeTicks; |
| 40 using content::BrowserThread; | 41 using content::BrowserThread; |
| 41 | 42 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 | 54 |
| 54 // ExpireHistoryTest ----------------------------------------------------------- | 55 // ExpireHistoryTest ----------------------------------------------------------- |
| 55 | 56 |
| 56 class ExpireHistoryTest : public testing::Test, | 57 class ExpireHistoryTest : public testing::Test, |
| 57 public BroadcastNotificationDelegate { | 58 public BroadcastNotificationDelegate { |
| 58 public: | 59 public: |
| 59 ExpireHistoryTest() | 60 ExpireHistoryTest() |
| 60 : bookmark_model_(bookmark_client_.CreateModel(false)), | 61 : bookmark_model_(bookmark_client_.CreateModel(false)), |
| 61 ui_thread_(BrowserThread::UI, &message_loop_), | 62 ui_thread_(BrowserThread::UI, &message_loop_), |
| 62 db_thread_(BrowserThread::DB, &message_loop_), | 63 db_thread_(BrowserThread::DB, &message_loop_), |
| 63 expirer_(this, bookmark_model_.get()), | 64 expirer_(this, &history_client_), |
| 64 now_(Time::Now()) {} | 65 now_(Time::Now()) {} |
| 65 | 66 |
| 66 protected: | 67 protected: |
| 67 // Called by individual tests when they want data populated. | 68 // Called by individual tests when they want data populated. |
| 68 void AddExampleData(URLID url_ids[3], Time visit_times[4]); | 69 void AddExampleData(URLID url_ids[3], Time visit_times[4]); |
| 69 // Add visits with source information. | 70 // Add visits with source information. |
| 70 void AddExampleSourceData(const GURL& url, URLID* id); | 71 void AddExampleSourceData(const GURL& url, URLID* id); |
| 71 | 72 |
| 72 // Returns true if the given favicon/thumanil has an entry in the DB. | 73 // Returns true if the given favicon/thumanil has an entry in the DB. |
| 73 bool HasFavicon(favicon_base::FaviconID favicon_id); | 74 bool HasFavicon(favicon_base::FaviconID favicon_id); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 } | 96 } |
| 96 | 97 |
| 97 static bool IsStringInFile(const base::FilePath& filename, const char* str); | 98 static bool IsStringInFile(const base::FilePath& filename, const char* str); |
| 98 | 99 |
| 99 // Returns the path the db files are created in. | 100 // Returns the path the db files are created in. |
| 100 const base::FilePath& path() const { return tmp_dir_.path(); } | 101 const base::FilePath& path() const { return tmp_dir_.path(); } |
| 101 | 102 |
| 102 // This must be destroyed last. | 103 // This must be destroyed last. |
| 103 base::ScopedTempDir tmp_dir_; | 104 base::ScopedTempDir tmp_dir_; |
| 104 | 105 |
| 106 TestHistoryClient history_client_; |
| 105 test::TestBookmarkClient bookmark_client_; | 107 test::TestBookmarkClient bookmark_client_; |
| 106 scoped_ptr<BookmarkModel> bookmark_model_; | 108 scoped_ptr<BookmarkModel> bookmark_model_; |
| 107 | 109 |
| 108 base::MessageLoopForUI message_loop_; | 110 base::MessageLoopForUI message_loop_; |
| 109 content::TestBrowserThread ui_thread_; | 111 content::TestBrowserThread ui_thread_; |
| 110 content::TestBrowserThread db_thread_; | 112 content::TestBrowserThread db_thread_; |
| 111 | 113 |
| 112 ExpireHistoryBackend expirer_; | 114 ExpireHistoryBackend expirer_; |
| 113 | 115 |
| 114 scoped_ptr<HistoryDatabase> main_db_; | 116 scoped_ptr<HistoryDatabase> main_db_; |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 main_db_->GetVisitsForURL(url_id, &archived_visits); | 953 main_db_->GetVisitsForURL(url_id, &archived_visits); |
| 952 EXPECT_EQ(0U, archived_visits.size()); | 954 EXPECT_EQ(0U, archived_visits.size()); |
| 953 } | 955 } |
| 954 | 956 |
| 955 // TODO(brettw) add some visits with no URL to make sure everything is updated | 957 // TODO(brettw) add some visits with no URL to make sure everything is updated |
| 956 // properly. Have the visits also refer to nonexistent FTS rows. | 958 // properly. Have the visits also refer to nonexistent FTS rows. |
| 957 // | 959 // |
| 958 // Maybe also refer to invalid favicons. | 960 // Maybe also refer to invalid favicons. |
| 959 | 961 |
| 960 } // namespace history | 962 } // namespace history |
| OLD | NEW |