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

Unified Diff: chrome/browser/thumbnails/thumbnailing_context_unittest.cc

Issue 1348833003: Fix NTP thumbnail generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/thumbnails/thumbnailing_context.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/thumbnails/thumbnailing_context_unittest.cc
diff --git a/chrome/browser/thumbnails/thumbnailing_context_unittest.cc b/chrome/browser/thumbnails/thumbnailing_context_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..535aa4284c15fe6b4e95cb68d48ad6b8f50bb0c4
--- /dev/null
+++ b/chrome/browser/thumbnails/thumbnailing_context_unittest.cc
@@ -0,0 +1,70 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+#include "chrome/browser/thumbnails/thumbnailing_context.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace thumbnails {
+
+typedef testing::Test ThumbnailingContextTest;
+
+TEST_F(ThumbnailingContextTest, TestClipResult) {
+ scoped_refptr<ThumbnailingContext> context(
+ ThumbnailingContext::CreateThumbnailingContextForTest());
+
+ // Set it to something.
+ context->set_clip_result(CLIP_RESULT_SOURCE_IS_SMALLER);
+ EXPECT_EQ(CLIP_RESULT_SOURCE_IS_SMALLER, context->clip_result());
+
+ // Make sure it's possible to change it.
+ context->set_clip_result(CLIP_RESULT_TALLER_THAN_WIDE);
+ EXPECT_EQ(CLIP_RESULT_TALLER_THAN_WIDE, context->clip_result());
+}
+
+TEST_F(ThumbnailingContextTest, TestRequestedCopySize) {
+ scoped_refptr<ThumbnailingContext> context(
+ ThumbnailingContext::CreateThumbnailingContextForTest());
+
+ // Set it to a size.
+ gfx::Size the_size(25, 50);
+ context->set_requested_copy_size(the_size);
+ EXPECT_EQ(the_size, context->requested_copy_size());
+
+ // Try changing to a new size.
+ the_size.set_height(500);
+ context->set_requested_copy_size(the_size);
+ EXPECT_EQ(the_size, context->requested_copy_size());
+}
+
+TEST_F(ThumbnailingContextTest, TestBoringScore) {
+ scoped_refptr<ThumbnailingContext> context(
+ ThumbnailingContext::CreateThumbnailingContextForTest());
+
+ // Set it to something.
+ double boring_score = 50.0;
+ context->SetBoringScore(boring_score);
+ EXPECT_EQ(boring_score, context->score().boring_score);
+
+ // Try changing it.
+ boring_score = 25.0;
+ context->SetBoringScore(boring_score);
+ EXPECT_EQ(boring_score, context->score().boring_score);
+}
+
+TEST_F(ThumbnailingContextTest, TestGoodClipping) {
+ scoped_refptr<ThumbnailingContext> context(
+ ThumbnailingContext::CreateThumbnailingContextForTest());
+
+ // Set to true.
+ context->SetGoodClipping(true);
+ EXPECT_TRUE(context->score().good_clipping);
+
+ // Try changing to false.
+ context->SetGoodClipping(false);
+ EXPECT_FALSE(context->score().good_clipping);
+}
+
+} // namespace thumbnails
« no previous file with comments | « chrome/browser/thumbnails/thumbnailing_context.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698