PageRenderTime 38ms CodeModel.GetById 19ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/iPhone/GTMFadeTruncatingLabelTest.m

http://macfuse.googlecode.com/
Objective C | 67 lines | 40 code | 9 blank | 18 comment | 0 complexity | 91703453fef0495cd5223f640aa47b0f MD5 | raw file
 1//
 2//  GTMFadeTruncatingLabelTest.m
 3//
 4//  Copyright 2011 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9//
10//  http://www.apache.org/licenses/LICENSE-2.0
11//
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18#import "GTMNSObject+UnitTesting.h"
19#import "GTMSenTestCase.h"
20#import "GTMFadeTruncatingLabel.h"
21
22@interface GTMFadeTruncatingLabelTest : GTMTestCase
23@end
24
25
26@implementation GTMFadeTruncatingLabelTest
27
28- (void)testFadeTruncatingLabelRight {
29  GTMFadeTruncatingLabel* label = [[[GTMFadeTruncatingLabel alloc]
30                                    initWithFrame:CGRectMake(0, 0, 200, 25)]
31                                   autorelease];
32  label.text = @"A very long string that won't fit";
33  GTMAssertObjectImageEqualToImageNamed(label,
34                                        @"GTMFadeTruncatingLabelTest1",
35                                        @"Mismatched image.");
36  label.text = @"A short string";
37  GTMAssertObjectImageEqualToImageNamed(label,
38                                        @"GTMFadeTruncatingLabelTest2",
39                                        @"Mismatched image.");
40
41  // Dark background, light text.
42  label.backgroundColor = [UIColor blackColor];
43  [label setTextColor:[UIColor whiteColor]];
44
45  label.text = @"A very long string that won't fit";
46  GTMAssertObjectImageEqualToImageNamed(label,
47                                        @"GTMFadeTruncatingLabelTest3",
48                                        @"Mismatched image.");
49  label.text = @"A short string";
50  GTMAssertObjectImageEqualToImageNamed(label,
51                                        @"GTMFadeTruncatingLabelTest4",
52                                        @"Mismatched image.");
53}
54
55- (void)testFadeTruncatingLabelLeftAndRight {
56  GTMFadeTruncatingLabel* label = [[[GTMFadeTruncatingLabel alloc]
57                                    initWithFrame:CGRectMake(0, 0, 200, 25)]
58                                   autorelease];
59  label.truncateMode = GTMFadeTruncatingHeadAndTail;
60
61  label.text = @"Fade on both left and right";
62  GTMAssertObjectImageEqualToImageNamed(label,
63                                        @"GTMFadeTruncatingLabelTest5",
64                                        @"Mismatched image.");
65}
66
67@end