From 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801 Mon Sep 17 00:00:00 2001 From: Kristian Monsen Date: Tue, 31 May 2011 20:30:28 +0100 Subject: Merge Chromium.org at r11.0.672.0: Initial merge by git. Change-Id: I8b4aaf611a2a405fe3fe10e8a94ea7658645c192 --- chrome/browser/history/history_unittest.cc | 84 +----------------------------- 1 file changed, 1 insertion(+), 83 deletions(-) (limited to 'chrome/browser/history/history_unittest.cc') diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc index e139cdd..7bc76da 100644 --- a/chrome/browser/history/history_unittest.cc +++ b/chrome/browser/history/history_unittest.cc @@ -45,16 +45,14 @@ #include "chrome/browser/history/in_memory_database.h" #include "chrome/browser/history/in_memory_history_backend.h" #include "chrome/browser/history/page_usage_data.h" -#include "chrome/browser/history/top_sites.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_source.h" #include "chrome/common/thumbnail_score.h" #include "chrome/tools/profiles/thumbnail-inl.h" -#include "gfx/codec/jpeg_codec.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/gfx/codec/jpeg_codec.h" using base::Time; using base::TimeDelta; @@ -114,19 +112,6 @@ class HistoryTest : public testing::Test { ~HistoryTest() { } - // Thumbnail callback: we save the data and exit the message loop so the - // unit test can read the data - void OnThumbnailDataAvailable( - HistoryService::Handle request_handle, - scoped_refptr jpeg_data) { - got_thumbnail_callback_ = true; - if (jpeg_data.get()) { - std::copy(jpeg_data->data.begin(), jpeg_data->data.end(), - std::back_inserter(thumbnail_data_)); - } - MessageLoop::current()->Quit(); - } - // Creates the HistoryBackend and HistoryDatabase on the current thread, // assigning the values to backend_ and db_. void CreateBackendAndDatabase() { @@ -683,73 +668,6 @@ TEST_F(HistoryTest, Segments) { EXPECT_GT(page_usage_data_[0]->GetScore(), 5.0); } -// This just tests history system -> thumbnail database integration, the actual -// thumbnail tests are in its own file. -TEST_F(HistoryTest, Thumbnails) { - if (history::TopSites::IsEnabled()) - return; // TopSitesTest replaces this. - - scoped_refptr history(new HistoryService); - history_service_ = history; - ASSERT_TRUE(history->Init(history_dir_, NULL)); - - scoped_ptr thumbnail( - gfx::JPEGCodec::Decode(kGoogleThumbnail, sizeof(kGoogleThumbnail))); - static const double boringness = 0.25; - - const GURL url("http://www.google.com/thumbnail_test/"); - // Must be visited before adding a thumbnail. - history->AddPage(url, history::SOURCE_BROWSED); - history->SetPageThumbnail(url, *thumbnail, - ThumbnailScore(boringness, true, true)); - - // Make sure we get the correct thumbnail data. - EXPECT_TRUE(history->GetPageThumbnail(url, &consumer_, - NewCallback(static_cast(this), - &HistoryTest::OnThumbnailDataAvailable))); - thumbnail_data_.clear(); - MessageLoop::current()->Run(); - // Make sure we got a valid JPEG back. This isn't equivalent to - // being correct, but when we're roundtripping through JPEG - // compression and we don't have a similarity measure. - EXPECT_TRUE(thumbnail_data_.size()); - scoped_ptr decoded_thumbnail( - gfx::JPEGCodec::Decode(&thumbnail_data_[0], thumbnail_data_.size())); - EXPECT_TRUE(decoded_thumbnail.get()); - - // Request a nonexistent thumbnail and make sure we get - // a callback and no data. - EXPECT_TRUE(history->GetPageThumbnail(GURL("http://asdfasdf.com/"), - &consumer_, - NewCallback(static_cast(this), - &HistoryTest::OnThumbnailDataAvailable))); - thumbnail_data_.clear(); - MessageLoop::current()->Run(); - EXPECT_EQ(0U, thumbnail_data_.size()); - - // Request the thumbnail and cancel the request.. - got_thumbnail_callback_ = false; - thumbnail_data_.clear(); - HistoryService::Handle handle = history->GetPageThumbnail(url, &consumer_, - NewCallback(static_cast(this), - &HistoryTest::OnThumbnailDataAvailable)); - EXPECT_TRUE(handle); - - history->CancelRequest(handle); - - // We create a task with a timeout so we can make sure we don't get and - // data in that time. - class QuitMessageLoop : public Task { - public: - virtual void Run() { - MessageLoop::current()->Quit(); - } - }; - MessageLoop::current()->PostDelayedTask(FROM_HERE, new QuitMessageLoop, 2000); - MessageLoop::current()->Run(); - EXPECT_FALSE(got_thumbnail_callback_); -} - TEST_F(HistoryTest, MostVisitedURLs) { scoped_refptr history(new HistoryService); history_service_ = history; -- cgit v1.1