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 #include "base/mac/scoped_nsobject.h" |
| 6 #import "ios/chrome/browser/ui/ntp/most_visited_cell.h" |
| 7 #include "testing/platform_test.h" |
| 8 |
| 9 static NSString* title = @"Most Visited Cell Title"; |
| 10 const GURL URL = GURL("http://example.com"); |
| 11 |
| 12 // Fixture to test MostVisitedCell. |
| 13 class MostVisitedCellTest : public PlatformTest { |
| 14 protected: |
| 15 base::scoped_nsobject<MostVisitedCell> cell_; |
| 16 }; |
| 17 |
| 18 TEST_F(MostVisitedCellTest, TestConstructor) { |
| 19 CGRect rect = CGRectMake(0, 0, 100, 100); |
| 20 cell_.reset([[MostVisitedCell alloc] initWithFrame:rect]); |
| 21 [cell_ setURL:URL]; |
| 22 EXPECT_TRUE(cell_.get()); |
| 23 UIGraphicsBeginImageContext([cell_ bounds].size); |
| 24 [cell_ drawRect:[cell_ bounds]]; |
| 25 UIGraphicsEndImageContext(); |
| 26 EXPECT_EQ(URL, [cell_ URL]); |
| 27 } |
| 28 |
| 29 TEST_F(MostVisitedCellTest, ValidateTitle) { |
| 30 CGRect rect = CGRectMake(0, 0, 100, 100); |
| 31 cell_.reset([[MostVisitedCell alloc] initWithFrame:rect]); |
| 32 [cell_ setText:title]; |
| 33 EXPECT_EQ(title, [cell_ accessibilityLabel]); |
| 34 } |
OLD | NEW |