OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ui/base/test/ios/ui_image_test_utils.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace ui { |
| 10 namespace test { |
| 11 |
| 12 // Test the creation of UIImages. |
| 13 TEST(UIImageTestUtilsTest, TestImageCreation) { |
| 14 CGSize size = CGSizeMake(10, 10); |
| 15 UIImage* image = |
| 16 uiimage_utils::UIImageWithSizeAndSolidColor(size, [UIColor redColor]); |
| 17 EXPECT_TRUE(CGSizeEqualToSize(size, image.size)); |
| 18 } |
| 19 |
| 20 // Test the detection of identical UIImages. |
| 21 TEST(UIImageTestUtilsTest, TestImageEquality) { |
| 22 CGSize size10x10 = CGSizeMake(10, 10); |
| 23 CGSize size5x20 = CGSizeMake(5, 20); |
| 24 UIColor* green = [UIColor greenColor]; |
| 25 UIColor* blue = [UIColor blueColor]; |
| 26 |
| 27 UIImage* imageblue10x10 = |
| 28 uiimage_utils::UIImageWithSizeAndSolidColor(size10x10, blue); |
| 29 UIImage* imageblue5x20 = |
| 30 uiimage_utils::UIImageWithSizeAndSolidColor(size5x20, blue); |
| 31 UIImage* imageGreen10x10 = |
| 32 uiimage_utils::UIImageWithSizeAndSolidColor(size10x10, green); |
| 33 UIImage* imageGreen10x10Bis = |
| 34 uiimage_utils::UIImageWithSizeAndSolidColor(size10x10, green); |
| 35 |
| 36 // Test with |nil| parameters. |
| 37 EXPECT_TRUE(uiimage_utils::UIImagesAreEqual(nil, nil)); |
| 38 EXPECT_FALSE(uiimage_utils::UIImagesAreEqual(nil, imageblue10x10)); |
| 39 EXPECT_FALSE(uiimage_utils::UIImagesAreEqual(imageblue10x10, nil)); |
| 40 |
| 41 // Test with images with different sizes (but same amount of pixels), same |
| 42 // color. |
| 43 EXPECT_FALSE(uiimage_utils::UIImagesAreEqual(imageblue10x10, imageblue5x20)); |
| 44 |
| 45 // Test with images with same size, different color. |
| 46 EXPECT_FALSE( |
| 47 uiimage_utils::UIImagesAreEqual(imageblue10x10, imageGreen10x10)); |
| 48 |
| 49 // Test with images with same size, same color. |
| 50 EXPECT_TRUE( |
| 51 uiimage_utils::UIImagesAreEqual(imageGreen10x10, imageGreen10x10Bis)); |
| 52 } |
| 53 |
| 54 } // namespace test |
| 55 } // namespace ui |
OLD | NEW |