OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/payments/cells/page_info_item.h" | 5 #import "ios/chrome/browser/payments/cells/page_info_item.h" |
6 | 6 |
7 #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" | 7 #import "ios/chrome/browser/ui/collection_view/cells/test_utils.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "testing/gtest_mac.h" | 9 #include "testing/gtest_mac.h" |
10 | 10 |
11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
13 #endif | 13 #endif |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Tests that the labels and image are set properly after a call to | 17 // Tests that the labels and image are set properly after a call to |
18 // |configureCell:|. | 18 // |configureCell:|. |
19 TEST(PaymentRequestPageInfoItemTest, TextLabels) { | 19 TEST(PaymentRequestPageInfoItemTest, TextLabels) { |
20 PageInfoItem* item = [[PageInfoItem alloc] initWithType:0]; | 20 PageInfoItem* item = [[PageInfoItem alloc] init]; |
21 | 21 |
22 UIImage* pageFavicon = ios_internal::CollectionViewTestImage(); | 22 UIImage* pageFavicon = ios_internal::CollectionViewTestImage(); |
23 NSString* pageTitle = @"The Greatest Website Ever"; | 23 NSString* pageTitle = @"The Greatest Website Ever"; |
24 NSString* pageHost = @"www.greatest.example.com"; | 24 NSString* pageHost = @"www.greatest.example.com"; |
25 | 25 |
26 item.pageFavicon = pageFavicon; | 26 item.pageFavicon = pageFavicon; |
27 item.pageTitle = pageTitle; | 27 item.pageTitle = pageTitle; |
28 item.pageHost = pageHost; | 28 item.pageHost = pageHost; |
29 | 29 |
30 id cell = [[[item cellClass] alloc] init]; | 30 id cell = [[[item cellClass] alloc] init]; |
31 ASSERT_TRUE([cell isMemberOfClass:[PageInfoCell class]]); | 31 ASSERT_TRUE([cell isMemberOfClass:[PageInfoCell class]]); |
32 | 32 |
33 PageInfoCell* pageInfoCell = cell; | 33 PageInfoCell* pageInfoCell = cell; |
34 EXPECT_FALSE(pageInfoCell.pageTitleLabel.text); | 34 EXPECT_FALSE(pageInfoCell.pageTitleLabel.text); |
35 EXPECT_FALSE(pageInfoCell.pageHostLabel.text); | 35 EXPECT_FALSE(pageInfoCell.pageHostLabel.text); |
36 EXPECT_FALSE(pageInfoCell.pageFaviconView.image); | 36 EXPECT_FALSE(pageInfoCell.pageFaviconView.image); |
37 | 37 |
38 [item configureCell:pageInfoCell]; | 38 [item configureCell:pageInfoCell]; |
39 EXPECT_NSEQ(pageTitle, pageInfoCell.pageTitleLabel.text); | 39 EXPECT_NSEQ(pageTitle, pageInfoCell.pageTitleLabel.text); |
40 EXPECT_NSEQ(pageHost, pageInfoCell.pageHostLabel.text); | 40 EXPECT_NSEQ(pageHost, pageInfoCell.pageHostLabel.text); |
41 EXPECT_NSEQ(pageFavicon, pageInfoCell.pageFaviconView.image); | 41 EXPECT_NSEQ(pageFavicon, pageInfoCell.pageFaviconView.image); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
OLD | NEW |