forked from TimOliver/TORoundedButton
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTORoundedButtonExampleTests.m
More file actions
60 lines (47 loc) · 1.69 KB
/
Copy pathTORoundedButtonExampleTests.m
File metadata and controls
60 lines (47 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// TORoundedButtonExampleTests.m
// TORoundedButtonExampleTests
//
// Created by Tim Oliver on 21/4/19.
// Copyright © 2019 Tim Oliver. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "TORoundedButton.h"
@interface TORoundedButtonExampleTests : XCTestCase
@end
@implementation TORoundedButtonExampleTests
- (void)testDefaultValues
{
TORoundedButton *button = [[TORoundedButton alloc] initWithText:@"Test"];
XCTAssertNotNil(button);
XCTAssertEqual(button.text, @"Test");
XCTAssertEqual(button.cornerRadius, 12.0f);
XCTAssertEqual(button.textColor, [UIColor whiteColor]);
XCTAssertEqual(button.tappedTextAlpha, 1.0f);
XCTAssertEqual(button.tappedTintColorBrightnessOffset, -0.1f);
XCTAssertEqual(button.tappedButtonScale, 0.97f);
}
- (void)testMinimimumWidth
{
TORoundedButton *button = [[TORoundedButton alloc] initWithText:@"Long Button Name"];
// Manually
UILabel *titleLabel = nil;
for (UIView *subview in button.subviews.firstObject.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
titleLabel = (UILabel *)subview;
break;
}
}
XCTAssert(button.minimumWidth > 0.0f);
XCTAssertEqual(titleLabel.frame.size.width, button.minimumWidth);
}
- (void)testButtonInteraction
{
TORoundedButton *button = [[TORoundedButton alloc] initWithText:@"Long Button Name"];
XCTestExpectation *expectation = [[XCTestExpectation alloc] initWithDescription:@"Button was tapped"];
button.tappedHandler = ^{ [expectation fulfill]; };
// Simulate button tap
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
[self waitForExpectations:@[expectation] timeout:0.5f];
}
@end