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 "components/history/core/browser/top_sites_impl.h" | 5 #include "components/history/core/browser/top_sites_impl.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
11 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
12 #include "base/prefs/testing_pref_service.h" | 16 #include "base/prefs/testing_pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
14 #include "base/task/cancelable_task_tracker.h" | 18 #include "base/task/cancelable_task_tracker.h" |
| 19 #include "build/build_config.h" |
15 #include "components/history/core/browser/history_client.h" | 20 #include "components/history/core/browser/history_client.h" |
16 #include "components/history/core/browser/history_constants.h" | 21 #include "components/history/core/browser/history_constants.h" |
17 #include "components/history/core/browser/history_database_params.h" | 22 #include "components/history/core/browser/history_database_params.h" |
18 #include "components/history/core/browser/history_db_task.h" | 23 #include "components/history/core/browser/history_db_task.h" |
19 #include "components/history/core/browser/history_types.h" | 24 #include "components/history/core/browser/history_types.h" |
20 #include "components/history/core/browser/top_sites.h" | 25 #include "components/history/core/browser/top_sites.h" |
21 #include "components/history/core/browser/top_sites_cache.h" | 26 #include "components/history/core/browser/top_sites_cache.h" |
22 #include "components/history/core/browser/top_sites_observer.h" | 27 #include "components/history/core/browser/top_sites_observer.h" |
23 #include "components/history/core/browser/visit_delegate.h" | 28 #include "components/history/core/browser/visit_delegate.h" |
24 #include "components/history/core/test/history_unittest_base.h" | 29 #include "components/history/core/test/history_unittest_base.h" |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 querier.QueryTopSites(top_sites(), false); | 964 querier.QueryTopSites(top_sites(), false); |
960 | 965 |
961 ASSERT_EQ(GetPrepopulatedPages().size(), querier.urls().size()); | 966 ASSERT_EQ(GetPrepopulatedPages().size(), querier.urls().size()); |
962 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 0)); | 967 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 0)); |
963 } | 968 } |
964 } | 969 } |
965 | 970 |
966 // Makes sure GetUpdateDelay is updated appropriately. | 971 // Makes sure GetUpdateDelay is updated appropriately. |
967 TEST_F(TopSitesImplTest, GetUpdateDelay) { | 972 TEST_F(TopSitesImplTest, GetUpdateDelay) { |
968 #if defined(OS_IOS) | 973 #if defined(OS_IOS) |
969 const int64 kExpectedUpdateDelayInSecondEmpty = 30; | 974 const int64_t kExpectedUpdateDelayInSecondEmpty = 30; |
970 const int64 kExpectedUpdateDelayInSecond0Changed = 5; | 975 const int64_t kExpectedUpdateDelayInSecond0Changed = 5; |
971 const int64 kExpectedUpdateDelayInSecond3Changed = 5; | 976 const int64_t kExpectedUpdateDelayInSecond3Changed = 5; |
972 const int64 kExpectedUpdateDelayInSecond20Changed = 1; | 977 const int64_t kExpectedUpdateDelayInSecond20Changed = 1; |
973 #else | 978 #else |
974 const int64 kExpectedUpdateDelayInSecondEmpty = 30; | 979 const int64_t kExpectedUpdateDelayInSecondEmpty = 30; |
975 const int64 kExpectedUpdateDelayInSecond0Changed = 60; | 980 const int64_t kExpectedUpdateDelayInSecond0Changed = 60; |
976 const int64 kExpectedUpdateDelayInSecond3Changed = 52; | 981 const int64_t kExpectedUpdateDelayInSecond3Changed = 52; |
977 const int64 kExpectedUpdateDelayInSecond20Changed = 1; | 982 const int64_t kExpectedUpdateDelayInSecond20Changed = 1; |
978 #endif | 983 #endif |
979 | 984 |
980 SetLastNumUrlsChanged(0); | 985 SetLastNumUrlsChanged(0); |
981 EXPECT_EQ(kExpectedUpdateDelayInSecondEmpty, GetUpdateDelay().InSeconds()); | 986 EXPECT_EQ(kExpectedUpdateDelayInSecondEmpty, GetUpdateDelay().InSeconds()); |
982 | 987 |
983 MostVisitedURLList url_list; | 988 MostVisitedURLList url_list; |
984 url_list.resize(20); | 989 url_list.resize(20); |
985 GURL tmp_url(GURL("http://x")); | 990 GURL tmp_url(GURL("http://x")); |
986 for (size_t i = 0; i < url_list.size(); ++i) { | 991 for (size_t i = 0; i < url_list.size(); ++i) { |
987 url_list[i].url = tmp_url; | 992 url_list[i].url = tmp_url; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 EXPECT_EQ("http://forced/5", querier.urls()[5].url.spec()); | 1658 EXPECT_EQ("http://forced/5", querier.urls()[5].url.spec()); |
1654 EXPECT_EQ(6000u, querier.urls()[5].last_forced_time.ToJsTime()); | 1659 EXPECT_EQ(6000u, querier.urls()[5].last_forced_time.ToJsTime()); |
1655 scoped_refptr<base::RefCountedMemory> thumbnail_data; | 1660 scoped_refptr<base::RefCountedMemory> thumbnail_data; |
1656 ASSERT_TRUE(top_sites()->GetPageThumbnail(GURL("http://forced/5"), false, | 1661 ASSERT_TRUE(top_sites()->GetPageThumbnail(GURL("http://forced/5"), false, |
1657 &thumbnail_data)); | 1662 &thumbnail_data)); |
1658 ASSERT_TRUE( | 1663 ASSERT_TRUE( |
1659 ThumbnailsAreEqual(orig_thumbnail_data.get(), thumbnail_data.get())); | 1664 ThumbnailsAreEqual(orig_thumbnail_data.get(), thumbnail_data.get())); |
1660 } | 1665 } |
1661 | 1666 |
1662 } // namespace history | 1667 } // namespace history |
OLD | NEW |