| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 int number_of_callbacks_; | 101 int number_of_callbacks_; |
| 102 bool waiting_; | 102 bool waiting_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(TopSitesQuerier); | 104 DISALLOW_COPY_AND_ASSIGN(TopSitesQuerier); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 // Extracts the data from |t1| into a SkBitmap. This is intended for usage of | 107 // Extracts the data from |t1| into a SkBitmap. This is intended for usage of |
| 108 // thumbnail data, which is stored as jpgs. | 108 // thumbnail data, which is stored as jpgs. |
| 109 SkBitmap ExtractThumbnail(const RefCountedBytes& t1) { | 109 SkBitmap ExtractThumbnail(const RefCountedBytes& t1) { |
| 110 scoped_ptr<SkBitmap> image(gfx::JPEGCodec::Decode(t1.front(), | 110 scoped_ptr<SkBitmap> image(gfx::JPEGCodec::Decode(t1.front(), |
| 111 t1.data.size())); | 111 t1.size())); |
| 112 return image.get() ? *image : SkBitmap(); | 112 return image.get() ? *image : SkBitmap(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Returns true if t1 and t2 contain the same data. | 115 // Returns true if t1 and t2 contain the same data. |
| 116 bool ThumbnailsAreEqual(RefCountedBytes* t1, RefCountedBytes* t2) { | 116 bool ThumbnailsAreEqual(RefCountedBytes* t1, RefCountedBytes* t2) { |
| 117 if (!t1 || !t2) | 117 if (!t1 || !t2) |
| 118 return false; | 118 return false; |
| 119 if (t1->data.size() != t2->data.size()) | 119 if (t1->size() != t2->size()) |
| 120 return false; | 120 return false; |
| 121 return std::equal(t1->data.begin(), | 121 return std::equal(t1->data()->begin(), |
| 122 t1->data.end(), | 122 t1->data()->end(), |
| 123 t2->data.begin()); | 123 t2->data()->begin()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace | 126 } // namespace |
| 127 | 127 |
| 128 class TopSitesTest : public HistoryUnitTestBase { | 128 class TopSitesTest : public HistoryUnitTestBase { |
| 129 public: | 129 public: |
| 130 TopSitesTest() | 130 TopSitesTest() |
| 131 : ui_thread_(BrowserThread::UI, &message_loop_), | 131 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 132 db_thread_(BrowserThread::DB, &message_loop_), | 132 db_thread_(BrowserThread::DB, &message_loop_), |
| 133 original_command_line_(*CommandLine::ForCurrentProcess()) { | 133 original_command_line_(*CommandLine::ForCurrentProcess()) { |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 WaitForTopSites(); | 1334 WaitForTopSites(); |
| 1335 EXPECT_FALSE(IsTopSitesLoaded()); | 1335 EXPECT_FALSE(IsTopSitesLoaded()); |
| 1336 | 1336 |
| 1337 // Load history, which should make TopSites finish loading too. | 1337 // Load history, which should make TopSites finish loading too. |
| 1338 profile()->CreateHistoryService(false, false); | 1338 profile()->CreateHistoryService(false, false); |
| 1339 profile()->BlockUntilTopSitesLoaded(); | 1339 profile()->BlockUntilTopSitesLoaded(); |
| 1340 EXPECT_TRUE(IsTopSitesLoaded()); | 1340 EXPECT_TRUE(IsTopSitesLoaded()); |
| 1341 } | 1341 } |
| 1342 | 1342 |
| 1343 } // namespace history | 1343 } // namespace history |
| OLD | NEW |