Chromium Code Reviews| 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..bffda65cd1a6bd2b9c4847f0ecb5d15bca7422f6 |
| --- /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(context->clip_result(), CLIP_RESULT_SOURCE_IS_SMALLER); |
| + |
| + // Make sure it's possible to change it. |
| + context->set_clip_result(CLIP_RESULT_TALLER_THAN_WIDE); |
| + EXPECT_EQ(context->clip_result(), CLIP_RESULT_TALLER_THAN_WIDE); |
| +} |
| + |
| +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_TRUE(context->requested_copy_size() == the_size); |
| + |
| + // Try changing to a new size. |
| + the_size.set_height(500); |
| + context->set_requested_copy_size(the_size); |
| + EXPECT_TRUE(context->requested_copy_size() == the_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_TRUE(context->score().boring_score == boring_score); |
|
Lei Zhang
2015/11/02 22:41:30
EXPECT_EQ(expected, actual);
Ditto all around.
shrike
2015/11/03 18:36:23
Acknowledged.
Lei Zhang
2015/11/03 18:59:24
You've written EXPECT_EQ(actual, expected). In thi
shrike
2015/11/03 19:10:49
Thank you for catching that.
|
| + |
| + // Try changing it. |
| + boring_score = 25.0; |
| + context->SetBoringScore(boring_score); |
| + EXPECT_TRUE(context->score().boring_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 |