| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/history/top_sites.h" | 5 #include "chrome/browser/history/top_sites.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
| 8 | 8 |
| 9 namespace history { | 9 namespace history { |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 mv.redirects.push_back(url1b); | 153 mv.redirects.push_back(url1b); |
| 154 list.push_back(mv); | 154 list.push_back(mv); |
| 155 | 155 |
| 156 // Save our most visited data containing that one site. | 156 // Save our most visited data containing that one site. |
| 157 StoreMostVisited(&list); | 157 StoreMostVisited(&list); |
| 158 | 158 |
| 159 // Create a dummy thumbnail. | 159 // Create a dummy thumbnail. |
| 160 SkBitmap thumbnail; | 160 SkBitmap thumbnail; |
| 161 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); | 161 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); |
| 162 thumbnail.allocPixels(); | 162 thumbnail.allocPixels(); |
| 163 thumbnail.eraseRGB(0x00, 0x00, 0x00); |
| 163 | 164 |
| 164 base::Time now = base::Time::Now(); | 165 base::Time now = base::Time::Now(); |
| 165 ThumbnailScore low_score(1.0, true, true, now); | 166 ThumbnailScore low_score(1.0, true, true, now); |
| 166 ThumbnailScore medium_score(0.5, true, true, now); | 167 ThumbnailScore medium_score(0.5, true, true, now); |
| 167 ThumbnailScore high_score(0.0, true, true, now); | 168 ThumbnailScore high_score(0.0, true, true, now); |
| 168 | 169 |
| 169 // Setting the thumbnail for nonexistant pages should fail. | 170 // Setting the thumbnail for nonexistant pages should fail. |
| 170 EXPECT_FALSE(top_sites().SetPageThumbnail(nonexistant_url, | 171 EXPECT_FALSE(top_sites().SetPageThumbnail(nonexistant_url, |
| 171 thumbnail, medium_score)); | 172 thumbnail, medium_score)); |
| 172 | 173 |
| 173 // Setting the thumbnail for url2 should succeed, lower scores shouldn't | 174 // Setting the thumbnail for url2 should succeed, lower scores shouldn't |
| 174 // replace it, higher scores should. | 175 // replace it, higher scores should. |
| 175 EXPECT_TRUE(top_sites().SetPageThumbnail(url2, thumbnail, medium_score)); | 176 EXPECT_TRUE(top_sites().SetPageThumbnail(url2, thumbnail, medium_score)); |
| 176 EXPECT_FALSE(top_sites().SetPageThumbnail(url2, thumbnail, low_score)); | 177 EXPECT_FALSE(top_sites().SetPageThumbnail(url2, thumbnail, low_score)); |
| 177 EXPECT_TRUE(top_sites().SetPageThumbnail(url2, thumbnail, high_score)); | 178 EXPECT_TRUE(top_sites().SetPageThumbnail(url2, thumbnail, high_score)); |
| 178 | 179 |
| 179 // Set on the redirect source should succeed. It should be replacable by | 180 // Set on the redirect source should succeed. It should be replacable by |
| 180 // the same score on the redirect destination, which in turn should not | 181 // the same score on the redirect destination, which in turn should not |
| 181 // be replaced by the source again. | 182 // be replaced by the source again. |
| 182 EXPECT_TRUE(top_sites().SetPageThumbnail(url1a, thumbnail, medium_score)); | 183 EXPECT_TRUE(top_sites().SetPageThumbnail(url1a, thumbnail, medium_score)); |
| 183 EXPECT_TRUE(top_sites().SetPageThumbnail(url1b, thumbnail, medium_score)); | 184 EXPECT_TRUE(top_sites().SetPageThumbnail(url1b, thumbnail, medium_score)); |
| 184 EXPECT_FALSE(top_sites().SetPageThumbnail(url1a, thumbnail, medium_score)); | 185 EXPECT_FALSE(top_sites().SetPageThumbnail(url1a, thumbnail, medium_score)); |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace history | 188 } // namespace history |
| OLD | NEW |