blob: 0d89b53b033ef0d6fff42a2db962c0e51cd05744 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#import <Quick/Quick.h>
#import <Nimble/Nimble.h>
#import "SDLArtwork.h"
#import "SDLImage.h"
#import "SDLSoftButton.h"
#import "SDLSoftButtonState.h"
QuickSpecBegin(SDLSoftButtonStateSpec)
describe(@"soft button state", ^{
__block SDLSoftButtonState *testState = nil;
__block NSString *testStateName = @"Test State Name";
__block NSString *testStateText = @"Test State Text";
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
__block UIImage *testStateImage = [[UIImage alloc] initWithContentsOfFile:[testBundle pathForResource:@"testImageJPEG" ofType:@"jpeg"]];
it(@"should properly create with an image with defaults", ^{
testState = [[SDLSoftButtonState alloc] initWithStateName:testStateName text:testStateText image:testStateImage];
expect(testState.name).to(equal(testStateName));
expect(testState.text).to(equal(testStateText));
expect(testState.highlighted).to(beFalsy());
expect(testState.systemAction).to(equal(SDLSystemActionDefaultAction));
expect(testState.artwork.persistent).to(beTruthy());
expect(testState.artwork.fileType).to(equal(SDLFileTypePNG));
// The rest should be tested in SDLArtwork
});
context(@"when created with an artwork", ^{
__block SDLArtwork *testArtwork = nil;
__block NSString *testArtworkName = @"Test Artwork Name";
beforeEach(^{
testArtwork = [[SDLArtwork alloc] initWithImage:testStateImage name:testArtworkName persistent:YES asImageFormat:SDLArtworkImageFormatPNG];
testState = [[SDLSoftButtonState alloc] initWithStateName:testStateName text:testStateText artwork:testArtwork];
});
it(@"should properly create", ^{
expect(testState.name).to(equal(testStateName));
expect(testState.text).to(equal(testStateText));
expect(testState.highlighted).to(beFalsy());
expect(testState.systemAction).to(equal(SDLSystemActionDefaultAction));
expect(testState.artwork.persistent).to(beTruthy());
expect(testState.artwork.fileType).to(equal(SDLFileTypePNG));
});
it(@"should properly create a soft button", ^{
SDLSoftButton *testSoftButton = testState.softButton;
expect(testSoftButton.type).to(equal(SDLSoftButtonTypeBoth));
expect((id)testSoftButton.handler).to(beNil());
expect(testSoftButton.softButtonID).to(equal(0));
expect(testSoftButton.isHighlighted).to(beFalsy());
expect(testSoftButton.systemAction).to(equal(SDLSystemActionDefaultAction));
expect(testSoftButton.text).to(equal(testStateText));
expect(testSoftButton.image.imageType).to(equal(SDLImageTypeDynamic));
expect(testSoftButton.image.value).to(equal(testArtworkName));
});
});
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
context(@"when created invalid", ^{
it(@"should assert", ^{
expectAction(^{
[[SDLSoftButtonState alloc] initWithStateName:testStateName text:nil image:nil];
}).to(raiseException());
});
});
#pragma clang diagnostic pop
});
QuickSpecEnd
|