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

Side by Side Diff: cc/tiles/mipmap_util_unittest.cc

Issue 2105903003: Remove error handling from MipmapUtil and add DCHECKs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fixdrt
Patch Set: rebase Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « cc/tiles/mipmap_util.cc ('k') | cc/tiles/software_image_decode_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/tiles/mipmap_util.h" 5 #include "cc/tiles/mipmap_util.h"
6 6
7 #include "cc/test/geometry_test_utils.h" 7 #include "cc/test/geometry_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace cc { 10 namespace cc {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 EXPECT_SIZE_EQ(target_size_smaller, 109 EXPECT_SIZE_EQ(target_size_smaller,
110 MipMapUtil::GetSizeForLevel(src_size, target_level_smaller)); 110 MipMapUtil::GetSizeForLevel(src_size, target_level_smaller));
111 EXPECT_FLOAT_SIZE_EQ( 111 EXPECT_FLOAT_SIZE_EQ(
112 expected_scale_larger, 112 expected_scale_larger,
113 MipMapUtil::GetScaleAdjustmentForSize(src_size, target_size_larger)); 113 MipMapUtil::GetScaleAdjustmentForSize(src_size, target_size_larger));
114 EXPECT_FLOAT_SIZE_EQ( 114 EXPECT_FLOAT_SIZE_EQ(
115 expected_scale_smaller, 115 expected_scale_smaller,
116 MipMapUtil::GetScaleAdjustmentForSize(src_size, target_size_smaller)); 116 MipMapUtil::GetScaleAdjustmentForSize(src_size, target_size_smaller));
117 } 117 }
118 118
119 // Ensures that we return invalid values correctly.
120 TEST(MipMapUtilTest, Invalid) {
121 const gfx::Size valid_size(1024, 1024);
122 const gfx::Size invalid_size(0, 1024);
123 const gfx::Size invalid_result_size(-1, -1);
124 const SkSize invalid_float_result_size = SkSize::Make(-1, -1);
125 const int invalid_result_level = -1;
126
127 EXPECT_EQ(invalid_result_level,
128 MipMapUtil::GetLevelForSize(valid_size, invalid_size));
129 EXPECT_EQ(invalid_result_level,
130 MipMapUtil::GetLevelForSize(invalid_size, valid_size));
131 EXPECT_FLOAT_SIZE_EQ(
132 invalid_float_result_size,
133 MipMapUtil::GetScaleAdjustmentForSize(valid_size, invalid_size));
134 EXPECT_FLOAT_SIZE_EQ(
135 invalid_float_result_size,
136 MipMapUtil::GetScaleAdjustmentForSize(invalid_size, valid_size));
137 EXPECT_SIZE_EQ(invalid_result_size,
138 MipMapUtil::GetSizeForLevel(valid_size, invalid_result_level));
139 EXPECT_SIZE_EQ(invalid_result_size,
140 MipMapUtil::GetSizeForLevel(invalid_size, 0));
141 EXPECT_FLOAT_SIZE_EQ(invalid_float_result_size,
142 MipMapUtil::GetScaleAdjustmentForLevel(invalid_size, 0));
143 EXPECT_FLOAT_SIZE_EQ(
144 invalid_float_result_size,
145 MipMapUtil::GetScaleAdjustmentForLevel(valid_size, invalid_result_level));
146 }
147
148 } // namespace 119 } // namespace
149 } // namespace cc 120 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/mipmap_util.cc ('k') | cc/tiles/software_image_decode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698