Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: chrome/browser/history/top_sites_unittest.cc

Issue 264024: Fix Valgrind UMR errors by initializing thumbnail pixels.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698