OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #import "third_party/ocmock/OCMock/OCMock.h" |
| 9 #import "third_party/ocmock/ocmock_extensions.h" |
| 10 #include "ui/base/l10n/l10n_util_mac.h" |
| 11 |
| 12 @protocol MockTarget |
| 13 - (void)doSomething; |
| 14 @end |
| 15 |
| 16 namespace { |
| 17 |
| 18 TEST(ChromeIconTest, NonNilIcons) { |
| 19 EXPECT_TRUE([ChromeIcon backIcon]); |
| 20 EXPECT_TRUE([ChromeIcon closeIcon]); |
| 21 EXPECT_TRUE([ChromeIcon infoIcon]); |
| 22 EXPECT_TRUE([ChromeIcon searchIcon]); |
| 23 } |
| 24 |
| 25 TEST(ChromeIconTest, Accessibility) { |
| 26 EXPECT_TRUE([ChromeIcon backIcon].accessibilityIdentifier); |
| 27 EXPECT_TRUE([ChromeIcon backIcon].accessibilityLabel); |
| 28 |
| 29 EXPECT_TRUE([ChromeIcon closeIcon].accessibilityIdentifier); |
| 30 EXPECT_TRUE([ChromeIcon closeIcon].accessibilityLabel); |
| 31 |
| 32 EXPECT_TRUE([ChromeIcon infoIcon].accessibilityIdentifier); |
| 33 EXPECT_TRUE([ChromeIcon infoIcon].accessibilityLabel); |
| 34 |
| 35 EXPECT_TRUE([ChromeIcon searchIcon].accessibilityIdentifier); |
| 36 EXPECT_TRUE([ChromeIcon searchIcon].accessibilityLabel); |
| 37 } |
| 38 |
| 39 TEST(ChromeIcontTest, RTL) { |
| 40 EXPECT_TRUE([ChromeIcon backIcon].flipsForRightToLeftLayoutDirection); |
| 41 EXPECT_FALSE([ChromeIcon searchIcon].flipsForRightToLeftLayoutDirection); |
| 42 } |
| 43 |
| 44 TEST(ChromeIconTest, TemplateBarButtonItem) { |
| 45 UIImage* image = [UIImage imageNamed:@"ic_close"]; |
| 46 image.accessibilityIdentifier = @"identifier"; |
| 47 image.accessibilityLabel = @"label"; |
| 48 id mockTarget = [OCMockObject mockForProtocol:@protocol(MockTarget)]; |
| 49 [[mockTarget expect] doSomething]; |
| 50 |
| 51 UIBarButtonItem* barButtonItem = |
| 52 [ChromeIcon templateBarButtonItemWithImage:image |
| 53 target:mockTarget |
| 54 action:@selector(doSomething)]; |
| 55 |
| 56 EXPECT_EQ(@"identifier", barButtonItem.accessibilityIdentifier); |
| 57 EXPECT_EQ(@"label", barButtonItem.accessibilityLabel); |
| 58 EXPECT_EQ(image.size.width, barButtonItem.image.size.width); |
| 59 EXPECT_EQ(image.size.height, barButtonItem.image.size.height); |
| 60 EXPECT_EQ(image.scale, barButtonItem.image.scale); |
| 61 EXPECT_EQ(image.capInsets.top, barButtonItem.image.capInsets.top); |
| 62 EXPECT_EQ(image.capInsets.left, barButtonItem.image.capInsets.left); |
| 63 EXPECT_EQ(image.capInsets.bottom, barButtonItem.image.capInsets.bottom); |
| 64 EXPECT_EQ(image.capInsets.right, barButtonItem.image.capInsets.right); |
| 65 EXPECT_EQ(image.flipsForRightToLeftLayoutDirection, |
| 66 barButtonItem.image.flipsForRightToLeftLayoutDirection); |
| 67 EXPECT_EQ(UIImageRenderingModeAlwaysTemplate, |
| 68 barButtonItem.image.renderingMode); |
| 69 } |
| 70 |
| 71 } // namespace |
OLD | NEW |