| 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/uikit_ui_util.h" | 5 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | |
| 8 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 9 #import "ios/chrome/browser/ui/ui_util.h" | 8 #import "ios/chrome/browser/ui/ui_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #import "third_party/ocmock/OCMock/OCMock.h" | 10 #import "third_party/ocmock/OCMock/OCMock.h" |
| 12 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 13 namespace { | 16 namespace { |
| 14 | 17 |
| 15 void ExpectInterpolatedColor(UIColor* firstColor, | 18 void ExpectInterpolatedColor(UIColor* firstColor, |
| 16 UIColor* secondColor, | 19 UIColor* secondColor, |
| 17 CGFloat percentage, | 20 CGFloat percentage, |
| 18 CGFloat expectedValue) { | 21 CGFloat expectedValue) { |
| 19 UIColor* interpolatedColor = | 22 UIColor* interpolatedColor = |
| 20 InterpolateFromColorToColor(firstColor, secondColor, percentage); | 23 InterpolateFromColorToColor(firstColor, secondColor, percentage); |
| 21 CGFloat r, g, b, a; | 24 CGFloat r, g, b, a; |
| 22 [interpolatedColor getRed:&r green:&g blue:&b alpha:&a]; | 25 [interpolatedColor getRed:&r green:&g blue:&b alpha:&a]; |
| 23 EXPECT_FLOAT_EQ(expectedValue, r); | 26 EXPECT_FLOAT_EQ(expectedValue, r); |
| 24 EXPECT_FLOAT_EQ(expectedValue, g); | 27 EXPECT_FLOAT_EQ(expectedValue, g); |
| 25 EXPECT_FLOAT_EQ(expectedValue, b); | 28 EXPECT_FLOAT_EQ(expectedValue, b); |
| 26 EXPECT_FLOAT_EQ(1.0, a); | 29 EXPECT_FLOAT_EQ(1.0, a); |
| 27 } | 30 } |
| 28 | 31 |
| 29 // Verify the assumption about UIViewController that on iPad all orientations | 32 // Verify the assumption about UIViewController that on iPad all orientations |
| 30 // are supported, and all orientations but Portrait Upside-Down on iPhone and | 33 // are supported, and all orientations but Portrait Upside-Down on iPhone and |
| 31 // iPod Touch. | 34 // iPod Touch. |
| 32 TEST(UIKitUIUtilTest, UIViewControllerSupportedOrientationsTest) { | 35 TEST(UIKitUIUtilTest, UIViewControllerSupportedOrientationsTest) { |
| 33 base::scoped_nsobject<UIViewController> viewController( | 36 UIViewController* viewController = |
| 34 [[UIViewController alloc] initWithNibName:nil bundle:nil]); | 37 [[UIViewController alloc] initWithNibName:nil bundle:nil]; |
| 35 if (IsIPadIdiom()) { | 38 if (IsIPadIdiom()) { |
| 36 EXPECT_EQ(UIInterfaceOrientationMaskAll, | 39 EXPECT_EQ(UIInterfaceOrientationMaskAll, |
| 37 [viewController supportedInterfaceOrientations]); | 40 [viewController supportedInterfaceOrientations]); |
| 38 } else { | 41 } else { |
| 39 EXPECT_EQ(UIInterfaceOrientationMaskAllButUpsideDown, | 42 EXPECT_EQ(UIInterfaceOrientationMaskAllButUpsideDown, |
| 40 [viewController supportedInterfaceOrientations]); | 43 [viewController supportedInterfaceOrientations]); |
| 41 } | 44 } |
| 42 } | 45 } |
| 43 | 46 |
| 44 TEST(UIKitUIUtilTest, TestGetUiFont) { | 47 TEST(UIKitUIUtilTest, TestGetUiFont) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 ASSERT_EQ(kCGColorSpaceModelMonochrome, | 159 ASSERT_EQ(kCGColorSpaceModelMonochrome, |
| 157 CGColorSpaceGetModel(CGColorGetColorSpace(black.CGColor))); | 160 CGColorSpaceGetModel(CGColorGetColorSpace(black.CGColor))); |
| 158 | 161 |
| 159 // Interpolate between monochrome and rgb. | 162 // Interpolate between monochrome and rgb. |
| 160 ExpectInterpolatedColor(black, rgb, 0.5, 0.1); | 163 ExpectInterpolatedColor(black, rgb, 0.5, 0.1); |
| 161 // Interpolate between two monochrome colors. | 164 // Interpolate between two monochrome colors. |
| 162 ExpectInterpolatedColor(black, white, 0.3, 0.3); | 165 ExpectInterpolatedColor(black, white, 0.3, 0.3); |
| 163 } | 166 } |
| 164 | 167 |
| 165 } // namespace | 168 } // namespace |
| OLD | NEW |