Commit e835ae29 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Remove dead utils

This CL removes dead code.

Bug: none
Change-Id: I35604f094924f30b6f342979369f8bbd8e089f3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424250
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarDavid Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815085}
parent d701950a
......@@ -9,8 +9,6 @@ source_set("cells") {
"collection_view_account_item.h",
"collection_view_account_item.mm",
"collection_view_cell_constants.h",
"collection_view_footer_item.h",
"collection_view_footer_item.mm",
"collection_view_item.h",
"collection_view_item.mm",
"collection_view_switch_item.h",
......@@ -53,7 +51,6 @@ source_set("unit_tests") {
sources = [
"MDCCollectionViewCell+Chrome_unittest.mm",
"collection_view_account_item_unittest.mm",
"collection_view_footer_item_unittest.mm",
"collection_view_item_unittest.mm",
"collection_view_switch_item_unittest.mm",
]
......
......@@ -4,7 +4,6 @@
#import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
......@@ -46,16 +45,4 @@ TEST_F(MDCCollectionViewCellChrome, PreferredHeightCallsConfigureCell) {
EXPECT_EQ(1, item.configureCount);
}
TEST_F(MDCCollectionViewCellChrome, PreferredHeight) {
CollectionViewFooterItem* footerItem =
[[CollectionViewFooterItem alloc] initWithType:0];
footerItem.text = @"This is a pretty lengthy sentence.";
CGFloat (^heightForWidth)(CGFloat width) = ^(CGFloat width) {
return [MDCCollectionViewCell cr_preferredHeightForWidth:width
forItem:footerItem];
};
EXPECT_NEAR(heightForWidth(300), 50, 5);
EXPECT_NEAR(heightForWidth(100), 115, 5);
}
} // namespace
// Copyright 2016 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.
#ifndef IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_COLLECTION_VIEW_FOOTER_ITEM_H_
#define IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_COLLECTION_VIEW_FOOTER_ITEM_H_
#import <UIKit/UIKit.h>
#import <MaterialComponents/MaterialCollectionCells.h>
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#include "url/gurl.h"
@class CollectionViewFooterCell;
@protocol CollectionViewFooterLinkDelegate<NSObject>
// Notifies the delegate that the link corresponding to |URL| was tapped in
// |cell|.
- (void)cell:(CollectionViewFooterCell*)cell didTapLinkURL:(GURL)URL;
@end
// CollectionViewFooterItem is the model class corresponding to
// CollectionViewFooterCell.
@interface CollectionViewFooterItem : CollectionViewItem
// TODO(crbug.com/891299) remove when all collection and table views are fixed
// for dynamic types.
// Set to YES to use dynamic font types.
@property(nonatomic, assign) BOOL useScaledFont;
// The main text string.
@property(nonatomic, copy) NSString* text;
// The URL to open when the link in |text| is tapped.
@property(nonatomic, assign) GURL linkURL;
// The delegate to notify when the link in |text| is tapped.
@property(nonatomic, weak) id<CollectionViewFooterLinkDelegate> linkDelegate;
// The image to show.
@property(nonatomic, strong) UIImage* image;
@end
// CollectionViewFooterCell implements a UICollectionViewCell subclass
// containing a single text label. The label is laid to fill the full width of
// the cell and is wrapped as needed to fit in the cell.
@interface CollectionViewFooterCell : MDCCollectionViewCell
// UILabels corresponding to |text| from the item.
@property(nonatomic, readonly, strong) UILabel* textLabel;
// UIImageView corresponding to |image| from the item.
@property(nonatomic, readonly, strong) UIImageView* imageView;
// Padding on leading and trailing edges of cell.
@property(nonatomic, assign) CGFloat horizontalPadding;
@end
#endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_COLLECTION_VIEW_FOOTER_ITEM_H_
// Copyright 2016 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.
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
#import <MaterialComponents/MaterialTypography.h>
#include "ios/chrome/browser/ui/collection_view/cells/collection_view_cell_constants.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/string_util.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Padding used on the leading and trailing edges of the cell.
const CGFloat kDefaultHorizontalPadding = 24;
// Padding used on the leading edge for the text when the cell has an image.
const CGFloat kImageRightMargin = 10;
// Padding used on the top and bottom edges of the cell.
const CGFloat kVerticalPadding = 16;
} // namespace
@interface CollectionViewFooterCell ()
// Delegate to notify when the link in |textLabel| is tapped.
@property(nonatomic, weak) id<CollectionViewFooterLinkDelegate> linkDelegate;
// Sets the URL to load when the link in |textLabel| is tapped.
- (void)setLabelLinkURL:(const GURL&)URL;
// Updates the cell's fonts and colors and uses dynamic types if they are
// available (iOS 11+).
- (void)updateWithFontScaling:(BOOL)withFontScaling;
@end
@implementation CollectionViewFooterItem
@synthesize text = _text;
@synthesize linkURL = _linkURL;
@synthesize linkDelegate = _linkDelegate;
@synthesize image = _image;
@synthesize useScaledFont = _useScaledFont;
- (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type];
if (self) {
self.cellClass = [CollectionViewFooterCell class];
_linkURL = GURL();
}
return self;
}
#pragma mark CollectionViewItem
- (void)configureCell:(CollectionViewFooterCell*)cell {
[super configureCell:cell];
// Update fonts and colors before setting the link label URL.
[cell updateWithFontScaling:_useScaledFont];
cell.textLabel.text = _text;
[cell setLabelLinkURL:_linkURL];
cell.linkDelegate = _linkDelegate;
cell.imageView.image = _image;
}
@end
@interface CollectionViewFooterCell () {
LabelLinkController* _linkController;
NSLayoutConstraint* _textLeadingAnchorConstraint;
NSLayoutConstraint* _imageLeadingAnchorConstraint;
}
@end
@implementation CollectionViewFooterCell
@synthesize textLabel = _textLabel;
@synthesize imageView = _imageView;
@synthesize linkDelegate = _linkDelegate;
@synthesize horizontalPadding = _horizontalPadding;
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.isAccessibilityElement = YES;
self.allowsCellInteractionsWhileEditing = YES;
_textLabel = [[UILabel alloc] init];
_textLabel.translatesAutoresizingMaskIntoConstraints = NO;
_textLabel.backgroundColor = [UIColor clearColor];
_textLabel.numberOfLines = 0;
_textLabel.lineBreakMode = NSLineBreakByWordWrapping;
[self.contentView addSubview:_textLabel];
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_imageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_imageView];
_horizontalPadding = kDefaultHorizontalPadding;
_textLeadingAnchorConstraint = [_textLabel.leadingAnchor
constraintEqualToAnchor:_imageView.trailingAnchor];
_imageLeadingAnchorConstraint = [_imageView.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:_horizontalPadding];
[NSLayoutConstraint activateConstraints:@[
[_textLabel.topAnchor constraintEqualToAnchor:self.contentView.topAnchor
constant:kVerticalPadding],
[_textLabel.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kVerticalPadding],
[_imageView.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
_textLeadingAnchorConstraint,
_imageLeadingAnchorConstraint,
]];
}
return self;
}
- (void)setLabelLinkURL:(const GURL&)URL {
_linkController = nil;
if (!URL.is_valid()) {
return;
}
NSRange range;
NSString* text = _textLabel.text;
_textLabel.text = ParseStringWithLink(text, &range);
if (range.location != NSNotFound && range.length != 0) {
__weak CollectionViewFooterCell* weakSelf = self;
_linkController = [[LabelLinkController alloc]
initWithLabel:_textLabel
action:^(const GURL& URL) {
[weakSelf.linkDelegate cell:weakSelf didTapLinkURL:URL];
}];
[_linkController setLinkColor:[UIColor colorNamed:kBlueColor]];
[_linkController addLinkWithRange:range url:URL];
}
}
- (void)updateWithFontScaling:(BOOL)withFontScaling {
self.textLabel.shadowOffset = CGSizeMake(1.f, 0.f);
self.textLabel.shadowColor = [UIColor whiteColor];
self.textLabel.textColor = [UIColor colorNamed:kTextPrimaryColor];
MaybeSetUILabelScaledFont(withFontScaling, self.textLabel,
[[MDCTypography fontLoader] mediumFontOfSize:14]);
}
- (void)layoutSubviews {
[super layoutSubviews];
_imageLeadingAnchorConstraint.constant = _horizontalPadding;
// Adjust the text label preferredMaxLayoutWidth when the parent's width
// changes, for instance on screen rotation.
CGFloat parentWidth = self.contentView.frame.size.width;
if (_imageView.image) {
_textLabel.preferredMaxLayoutWidth =
parentWidth - 2.f * _imageLeadingAnchorConstraint.constant -
kImageRightMargin - _imageView.image.size.width;
_textLeadingAnchorConstraint.constant = kImageRightMargin;
} else {
_textLabel.preferredMaxLayoutWidth =
parentWidth - 2.f * _imageLeadingAnchorConstraint.constant;
_textLeadingAnchorConstraint.constant = 0;
}
// Re-layout with the new preferred width to allow the label to adjust its
// height.
[super layoutSubviews];
}
- (void)prepareForReuse {
[super prepareForReuse];
self.textLabel.text = nil;
self.imageView.image = nil;
[self setLabelLinkURL:GURL()];
self.horizontalPadding = kDefaultHorizontalPadding;
_linkController = nil;
_linkDelegate = nil;
}
#pragma mark - Accessibility
- (BOOL)isAccessibilityElement {
return NO; // Accessibility for this element is handled in
// LabelLinkController's TransparentLinkButton objects.
}
@end
// Copyright 2016 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.
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest_mac.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
using CollectionViewFooterItemTest = PlatformTest;
// Tests that the text label and the image are set properly after a call to
// |configureCell:|.
TEST_F(CollectionViewFooterItemTest, ConfigureCell) {
CollectionViewFooterItem* item =
[[CollectionViewFooterItem alloc] initWithType:0];
NSString* text = @"Test Footer";
item.text = text;
UIImage* image = CollectionViewTestImage();
item.image = image;
CollectionViewFooterCell* cell = [[[item cellClass] alloc] init];
ASSERT_TRUE([cell isMemberOfClass:[CollectionViewFooterCell class]]);
EXPECT_FALSE(cell.textLabel.text);
EXPECT_FALSE(cell.imageView.image);
[item configureCell:cell];
EXPECT_NSEQ(text, cell.textLabel.text);
EXPECT_NSEQ(image, cell.imageView.image);
}
} // namespace
......@@ -61,17 +61,6 @@ class CollectionViewControllerTest : public BlockCleanupTest {
// |expected_title_id|.
void CheckSectionHeaderWithId(int expected_title_id, int section);
// Verifies that the section footer at |section| matches the |expected_text|.
// TODO(crbug.com/650424): Until the bug in MDC is fixed, footers are simple
// items in a dedicated section.
void CheckSectionFooter(NSString* expected_text, int section);
// Verifies that the section footer at |section| matches the l10n string for
// |expected_text_id|.
// TODO(crbug.com/650424): Until the bug in MDC is fixed, footers are simple
// items in a dedicated section.
void CheckSectionFooterWithId(int expected_text_id, int section);
// Verifies that the text cell at |item| in |section| has a text property
// which matches |expected_title|.
void CheckTextCellText(NSString* expected_text, int section, int item);
......
......@@ -7,7 +7,6 @@
#include "base/check.h"
#import "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_account_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
......@@ -99,21 +98,6 @@ void CollectionViewControllerTest::CheckSectionHeaderWithId(
CheckSectionHeader(l10n_util::GetNSString(expected_title_id), section);
}
void CollectionViewControllerTest::CheckSectionFooter(NSString* expected_text,
int section) {
ASSERT_EQ(1, NumberOfItemsInSection(section));
CollectionViewFooterItem* footer_item =
base::mac::ObjCCastStrict<CollectionViewFooterItem>(
GetCollectionViewItem(section, 0));
EXPECT_NSEQ(expected_text, footer_item.text);
}
void CollectionViewControllerTest::CheckSectionFooterWithId(
int expected_text_id,
int section) {
return CheckSectionFooter(l10n_util::GetNSString(expected_text_id), section);
}
void CollectionViewControllerTest::CheckTextCellText(NSString* expected_text,
int section,
int item) {
......
......@@ -65,8 +65,6 @@ enum ClearBrowsingDataItemType {
// The manager's consumer.
@property(nonatomic, weak) id<ClearBrowsingDataConsumer> consumer;
// Reference to the LinkDelegate for CollectionViewFooterItem.
@property(nonatomic, weak) id<CollectionViewFooterLinkDelegate> linkDelegate;
// Default init method. |browserState| can't be nil.
- (instancetype)initWithBrowserState:(ChromeBrowserState*)browserState;
......
......@@ -35,7 +35,6 @@
#include "ios/chrome/browser/signin/identity_manager_factory.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
......@@ -143,7 +142,6 @@ static NSDictionary* _imageNamesByItemTypes = @{
@implementation ClearBrowsingDataManager
@synthesize browserState = _browserState;
@synthesize consumer = _consumer;
@synthesize linkDelegate = _linkDelegate;
@synthesize shouldShowNoticeAboutOtherFormsOfBrowsingHistory =
_shouldShowNoticeAboutOtherFormsOfBrowsingHistory;
@synthesize shouldPopupDialogAboutOtherFormsOfBrowsingHistory =
......
......@@ -17,9 +17,6 @@ bool IsIPadIdiom();
// Enum for arrays by UI idiom.
enum InterfaceIdiom { IPHONE_IDIOM, IPAD_IDIOM, INTERFACE_IDIOM_COUNT };
// Array of widths for device idioms in portrait orientation.
extern const CGFloat kPortraitWidth[INTERFACE_IDIOM_COUNT];
// Returns the height of the screen in the current orientation.
CGFloat CurrentScreenHeight();
......@@ -48,9 +45,6 @@ CGRect AlignRectToPixel(CGRect rect);
// origin, and ui::AlignSizeToUpperPixel() to the size.
CGRect AlignRectOriginAndSizeToPixels(CGRect rect);
// Makes a copy of |rect| with a new origin specified by |x| and |y|.
CGRect CGRectCopyWithOrigin(CGRect rect, CGFloat x, CGFloat y);
// Returns a square CGRect centered at |x|, |y| with a width of |width|.
// Both the position and the size of the CGRect will be aligned to points.
CGRect CGRectMakeAlignedAndCenteredAt(CGFloat x, CGFloat y, CGFloat width);
......
......@@ -23,11 +23,6 @@ bool IsIPadIdiom() {
return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET;
}
const CGFloat kPortraitWidth[INTERFACE_IDIOM_COUNT] = {
320, // IPHONE_IDIOM
768 // IPAD_IDIOM
};
CGFloat CurrentScreenHeight() {
return [UIScreen mainScreen].bounds.size.height;
}
......@@ -67,10 +62,6 @@ CGRect AlignRectOriginAndSizeToPixels(CGRect rect) {
return rect;
}
CGRect CGRectCopyWithOrigin(CGRect rect, CGFloat x, CGFloat y) {
return CGRectMake(x, y, rect.size.width, rect.size.height);
}
CGRect CGRectMakeAlignedAndCenteredAt(CGFloat x, CGFloat y, CGFloat width) {
return AlignRectOriginAndSizeToPixels(
CGRectMake(x - width / 2.0, y - width / 2.0, width, width));
......
......@@ -29,14 +29,6 @@ void SetA11yLabelAndUiAutomationName(
int idsAccessibilityLabel,
NSString* englishUiAutomationName);
// Sets the given |button|'s width to exactly fit its image and text. Does not
// modify the button's height.
void GetSizeButtonWidthToFit(UIButton* button);
// Translates the given |view|'s frame. Sets a new frame instead of applying a
// transform to the existing frame.
void TranslateFrame(UIView* view, UIOffset offset);
// Returns a UIFont. |fontFace| is one of the defined enumerated values
// to avoid spelling mistakes.
UIFont* GetUIFont(int fontFace, bool isBold, CGFloat fontSize);
......@@ -51,12 +43,6 @@ void MaybeSetUITextFieldScaledFont(BOOL maybe,
UITextField* textField,
UIFont* font);
// Adds a border shadow around |view|.
void AddBorderShadow(UIView* view, CGFloat offset, UIColor* color);
// Adds a rounded-rectangle border shadow around a view.
void AddRoundedBorderShadow(UIView* view, CGFloat radius, UIColor* color);
enum CaptureViewOption {
kNoCaptureOption, // Equivalent to calling CaptureView without options.
kAfterScreenUpdate, // Require a synchronization with CA process which can
......@@ -92,13 +78,6 @@ UIImage* CaptureView(UIView* view, CGFloat scale);
// Converts input image and returns a grey scaled version.
UIImage* GreyImage(UIImage* image);
// Returns the color that should be used for the background of all Settings
// pages.
UIColor* GetSettingsBackgroundColor();
// Returns the color used as the main color for primary action buttons.
UIColor* GetPrimaryActionButtonColor();
// Returns an UIColor with |rgb| and |alpha|. The caller should pass the RGB
// value in hexadecimal as this is the typical way they are provided by UX.
// For example a call to |UIColorFromRGB(0xFF7D40, 1.0)| returns an orange
......@@ -110,11 +89,6 @@ inline UIColor* UIColorFromRGB(int rgb, CGFloat alpha = 1.0) {
alpha:alpha];
}
// Returns whether an image contains an alpha channel. If yes, displaying the
// image will require blending.
// Intended for use in debug.
BOOL ImageHasAlphaChannel(UIImage* image);
// Returns the image from the shared resource bundle with the image id
// |imageID|. If |reversable| is YES and RTL layout is in use, the image
// will be flipped for RTL.
......@@ -150,22 +124,6 @@ UIImage* ResizeImage(UIImage* image,
ProjectionMode projectionMode,
BOOL opaque);
// Returns a slightly blurred image darkened enough to provide contrast for
// white text to be readable.
UIImage* DarkenImage(UIImage* image);
// Applies various effects to an image. This method can apply a blur over a
// |radius|, superimpose a |tintColor| (an alpha of 0.6 on the color is a good
// approximation to look like iOS tint colors) or saturate the image colors by
// applying a |saturationDeltaFactor| (negative to desaturate, positive to
// saturate). The optional |maskImage| is used to limit the effect of the blur
// and/or saturation to a portion of the image.
UIImage* BlurImage(UIImage* image,
CGFloat blurRadius,
UIColor* tintColor,
CGFloat saturationDeltaFactor,
UIImage* maskImage);
// Returns an output image where each pixel has RGB values equal to a color and
// the alpha value sampled from the given image. The RGB values of the image are
// ignored. If the color has alpha value of less than one, then the entire
......@@ -176,9 +134,6 @@ UIImage* TintImage(UIImage* image, UIColor* color);
// the subtree is the first responder.
UIView* GetFirstResponderSubview(UIView* view);
// Returns a cropped image using |cropRect| on |image|.
UIImage* CropImage(UIImage* image, const CGRect& cropRect);
// Returns the interface orientation of the given window in the app.
UIInterfaceOrientation GetInterfaceOrientation(UIWindow* window);
......@@ -192,13 +147,6 @@ UIImage* ImageWithColor(UIColor* color);
// down. If the source image is not square, the image is first cropped.
UIImage* CircularImageFromImage(UIImage* image, CGFloat width);
// Returns the linear interpolated color from |firstColor| to |secondColor| by
// the given |fraction|. Requires that both colors are in RGB or monochrome
// color space. |fraction| is a decimal value between 0.0 and 1.0.
UIColor* InterpolateFromColorToColor(UIColor* firstColor,
UIColor* secondColor,
CGFloat fraction);
// Returns true if the window is in portrait orientation or if orientation is
// unknown.
bool IsPortrait(UIWindow* window);
......
This diff is collapsed.
......@@ -17,20 +17,6 @@
namespace {
void ExpectInterpolatedColor(UIColor* firstColor,
UIColor* secondColor,
CGFloat percentage,
CGFloat expectedValue) {
UIColor* interpolatedColor =
InterpolateFromColorToColor(firstColor, secondColor, percentage);
CGFloat r, g, b, a;
[interpolatedColor getRed:&r green:&g blue:&b alpha:&a];
EXPECT_FLOAT_EQ(expectedValue, r);
EXPECT_FLOAT_EQ(expectedValue, g);
EXPECT_FLOAT_EQ(expectedValue, b);
EXPECT_FLOAT_EQ(1.0, a);
}
using UIKitUIUtilTest = PlatformTest;
// Verify the assumption about UIViewController that on iPad and iOS 13 all
......@@ -103,12 +89,10 @@ TEST_F(UIKitUIUtilTest, TestResizeImageOpacity) {
actual =
ResizeImage(image, CGSizeMake(50, 50), ProjectionMode::kAspectFit, YES);
EXPECT_TRUE(actual);
EXPECT_FALSE(ImageHasAlphaChannel(actual));
actual =
ResizeImage(image, CGSizeMake(50, 50), ProjectionMode::kAspectFit, NO);
EXPECT_TRUE(actual);
EXPECT_TRUE(ImageHasAlphaChannel(actual));
}
TEST_F(UIKitUIUtilTest, TestResizeImageInvalidInput) {
......@@ -142,46 +126,4 @@ TEST_F(UIKitUIUtilTest, TintImageKeepsImageProperties) {
tintedImage.flipsForRightToLeftLayoutDirection);
}
TEST_F(UIKitUIUtilTest, TestInterpolateFromColorToColor) {
CGFloat colorOne = 50.0f / 255.0f;
CGFloat colorTwo = 100.0f / 255.0f;
CGFloat expectedOne = 50.0f / 255.0f;
CGFloat expectedTwo = 55.0f / 255.0f;
CGFloat expectedThree = 75.0f / 255.0f;
CGFloat expectedFour = 100.0f / 255.0f;
UIColor* firstColor =
[UIColor colorWithRed:colorOne green:colorOne blue:colorOne alpha:1.0];
UIColor* secondColor =
[UIColor colorWithRed:colorTwo green:colorTwo blue:colorTwo alpha:1.0];
ExpectInterpolatedColor(firstColor, secondColor, 0.0f, expectedOne);
ExpectInterpolatedColor(firstColor, secondColor, 0.1f, expectedTwo);
ExpectInterpolatedColor(firstColor, secondColor, 0.5f, expectedThree);
ExpectInterpolatedColor(firstColor, secondColor, 1.0f, expectedFour);
}
// Tests that InterpolateFromColorToColor() works for monochrome colors.
TEST_F(UIKitUIUtilTest, TestInterpolateFromColorToColorMonochrome) {
CGFloat kRGBComponent = 0.2;
UIColor* rgb = [UIColor colorWithRed:kRGBComponent
green:kRGBComponent
blue:kRGBComponent
alpha:1.0];
ASSERT_EQ(kCGColorSpaceModelRGB,
CGColorSpaceGetModel(CGColorGetColorSpace(rgb.CGColor)));
UIColor* white = [UIColor whiteColor];
ASSERT_EQ(kCGColorSpaceModelMonochrome,
CGColorSpaceGetModel(CGColorGetColorSpace(white.CGColor)));
UIColor* black = [UIColor blackColor];
ASSERT_EQ(kCGColorSpaceModelMonochrome,
CGColorSpaceGetModel(CGColorGetColorSpace(black.CGColor)));
// Interpolate between monochrome and rgb.
ExpectInterpolatedColor(black, rgb, 0.5, 0.1);
// Interpolate between two monochrome colors.
ExpectInterpolatedColor(black, white, 0.3, 0.3);
}
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment