OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/chrome/browser/ui/ui_util.h" | 5 #import "ios/chrome/browser/ui/ui_util.h" |
6 | 6 |
| 7 #include <stddef.h> |
7 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
8 | 9 |
9 #include "base/basictypes.h" | 10 #include "base/macros.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/gtest_mac.h" | 12 #include "testing/gtest_mac.h" |
12 | 13 |
13 TEST(UIUtilTest, AlignToPixel) { | 14 TEST(UIUtilTest, AlignToPixel) { |
14 CGFloat scale = [[UIScreen mainScreen] scale]; | 15 CGFloat scale = [[UIScreen mainScreen] scale]; |
15 // Pick a few interesting values: already aligned, aligned on retina, and | 16 // Pick a few interesting values: already aligned, aligned on retina, and |
16 // some unaligned values that would round differently. Ensure that all are | 17 // some unaligned values that would round differently. Ensure that all are |
17 // "integer" values within <1 of the original value in the scaled space. | 18 // "integer" values within <1 of the original value in the scaled space. |
18 CGFloat test_values[] = {10.0, 55.5, 3.14159, 2.71828}; | 19 CGFloat test_values[] = {10.0, 55.5, 3.14159, 2.71828}; |
19 const CGFloat kMaxAlignDelta = 0.9999; | 20 const CGFloat kMaxAlignDelta = 0.9999; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 originalSize = CGSizeMake(50, 100); | 267 originalSize = CGSizeMake(50, 100); |
267 targetSize = CGSizeMake(40, 60); | 268 targetSize = CGSizeMake(40, 60); |
268 expectedProjection = CGRectMake(0, 0, 40, 80); | 269 expectedProjection = CGRectMake(0, 0, 40, 80); |
269 expectedRevisedSize = expectedProjection.size; | 270 expectedRevisedSize = expectedProjection.size; |
270 CalculateProjection(originalSize, targetSize, | 271 CalculateProjection(originalSize, targetSize, |
271 ProjectionMode::kAspectFillNoClipping, revisedSize, | 272 ProjectionMode::kAspectFillNoClipping, revisedSize, |
272 projection); | 273 projection); |
273 EXPECT_EQ_RECT(expectedProjection, projection); | 274 EXPECT_EQ_RECT(expectedProjection, projection); |
274 EXPECT_EQ_SIZE(expectedRevisedSize, revisedSize); | 275 EXPECT_EQ_SIZE(expectedRevisedSize, revisedSize); |
275 } | 276 } |
OLD | NEW |