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 "chrome/browser/thumbnails/thumbnail_service_impl.h" | 5 #include "chrome/browser/thumbnails/thumbnail_service_impl.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 scoped_refptr<MockTopSites> mock_top_sites_; | 69 scoped_refptr<MockTopSites> mock_top_sites_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(MockProfile); | 71 DISALLOW_COPY_AND_ASSIGN(MockProfile); |
72 }; | 72 }; |
73 | 73 |
74 TEST_F(ThumbnailServiceTest, ShouldUpdateThumbnail) { | 74 TEST_F(ThumbnailServiceTest, ShouldUpdateThumbnail) { |
75 const GURL kGoodURL("http://www.google.com/"); | 75 const GURL kGoodURL("http://www.google.com/"); |
76 const GURL kBadURL("chrome://newtab"); | 76 const GURL kBadURL("chrome://newtab"); |
77 | 77 |
78 // Set up the mock profile along with mock top sites. | 78 // Set up the mock profile along with mock top sites. |
79 ScopedTempDir temp_dir; | 79 base::ScopedTempDir temp_dir; |
80 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 80 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
81 MockProfile profile; | 81 MockProfile profile; |
82 | 82 |
83 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service( | 83 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service( |
84 new thumbnails::ThumbnailServiceImpl(&profile)); | 84 new thumbnails::ThumbnailServiceImpl(&profile)); |
85 | 85 |
86 // Should be false because it's a bad URL. | 86 // Should be false because it's a bad URL. |
87 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kBadURL)); | 87 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kBadURL)); |
88 | 88 |
89 // Should be true, as it's a good URL. | 89 // Should be true, as it's a good URL. |
(...skipping 22 matching lines...) Expand all Loading... |
112 good_score.at_top = true; | 112 good_score.at_top = true; |
113 good_score.good_clipping = true; | 113 good_score.good_clipping = true; |
114 good_score.boring_score = 0.0; | 114 good_score.boring_score = 0.0; |
115 good_score.load_completed = true; | 115 good_score.load_completed = true; |
116 profile.AddKnownURL(kGoodURL, good_score); | 116 profile.AddKnownURL(kGoodURL, good_score); |
117 | 117 |
118 // Should be false, as the existing thumbnail is good enough (i.e. don't | 118 // Should be false, as the existing thumbnail is good enough (i.e. don't |
119 // need to replace the existing thumbnail which is new and good). | 119 // need to replace the existing thumbnail which is new and good). |
120 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); | 120 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); |
121 } | 121 } |
OLD | NEW |