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> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "components/prefs/pref_registry_simple.h" | 30 #include "components/prefs/pref_registry_simple.h" |
31 #include "components/prefs/testing_pref_service.h" | 31 #include "components/prefs/testing_pref_service.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
33 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
35 | 35 |
36 namespace history { | 36 namespace history { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // Key for URL blacklist. | |
41 const char kAcceptLanguages[] = "en-US,en"; | |
42 | |
43 const char kApplicationScheme[] = "application"; | 40 const char kApplicationScheme[] = "application"; |
44 const char kPrepopulatedPageURL[] = | 41 const char kPrepopulatedPageURL[] = |
45 "http://www.google.com/int/chrome/welcome.html"; | 42 "http://www.google.com/int/chrome/welcome.html"; |
46 | 43 |
47 // Returns whether |url| can be added to history. | 44 // Returns whether |url| can be added to history. |
48 bool MockCanAddURLToHistory(const GURL& url) { | 45 bool MockCanAddURLToHistory(const GURL& url) { |
49 return url.is_valid() && !url.SchemeIs(kApplicationScheme); | 46 return url.is_valid() && !url.SchemeIs(kApplicationScheme); |
50 } | 47 } |
51 | 48 |
52 // Used by WaitForHistory, see it for details. | 49 // Used by WaitForHistory, see it for details. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 public: | 137 public: |
141 TopSitesImplTest() {} | 138 TopSitesImplTest() {} |
142 | 139 |
143 void SetUp() override { | 140 void SetUp() override { |
144 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); | 141 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
145 pref_service_.reset(new TestingPrefServiceSimple); | 142 pref_service_.reset(new TestingPrefServiceSimple); |
146 TopSitesImpl::RegisterPrefs(pref_service_->registry()); | 143 TopSitesImpl::RegisterPrefs(pref_service_->registry()); |
147 history_service_.reset( | 144 history_service_.reset( |
148 new HistoryService(nullptr, scoped_ptr<VisitDelegate>())); | 145 new HistoryService(nullptr, scoped_ptr<VisitDelegate>())); |
149 ASSERT_TRUE(history_service_->Init( | 146 ASSERT_TRUE(history_service_->Init( |
150 kAcceptLanguages, | |
151 TestHistoryDatabaseParamsForPath(scoped_temp_dir_.path()))); | 147 TestHistoryDatabaseParamsForPath(scoped_temp_dir_.path()))); |
152 ResetTopSites(); | 148 ResetTopSites(); |
153 WaitTopSitesLoaded(); | 149 WaitTopSitesLoaded(); |
154 } | 150 } |
155 | 151 |
156 void TearDown() override { | 152 void TearDown() override { |
157 DestroyTopSites(); | 153 DestroyTopSites(); |
158 history_service_->Shutdown(); | 154 history_service_->Shutdown(); |
159 history_service_.reset(); | 155 history_service_.reset(); |
160 pref_service_.reset(); | 156 pref_service_.reset(); |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 EXPECT_EQ("http://forced/5", querier.urls()[5].url.spec()); | 1654 EXPECT_EQ("http://forced/5", querier.urls()[5].url.spec()); |
1659 EXPECT_EQ(6000u, querier.urls()[5].last_forced_time.ToJsTime()); | 1655 EXPECT_EQ(6000u, querier.urls()[5].last_forced_time.ToJsTime()); |
1660 scoped_refptr<base::RefCountedMemory> thumbnail_data; | 1656 scoped_refptr<base::RefCountedMemory> thumbnail_data; |
1661 ASSERT_TRUE(top_sites()->GetPageThumbnail(GURL("http://forced/5"), false, | 1657 ASSERT_TRUE(top_sites()->GetPageThumbnail(GURL("http://forced/5"), false, |
1662 &thumbnail_data)); | 1658 &thumbnail_data)); |
1663 ASSERT_TRUE( | 1659 ASSERT_TRUE( |
1664 ThumbnailsAreEqual(orig_thumbnail_data.get(), thumbnail_data.get())); | 1660 ThumbnailsAreEqual(orig_thumbnail_data.get(), thumbnail_data.get())); |
1665 } | 1661 } |
1666 | 1662 |
1667 } // namespace history | 1663 } // namespace history |
OLD | NEW |