forked from jessesquires/JSQMessagesViewController
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea3b8cc
commit 395b134
Showing
9 changed files
with
243 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// Created by Jesse Squires | ||
// http://www.jessesquires.com | ||
// | ||
// | ||
// MIT License | ||
// Copyright (c) 2014 Jesse Squires | ||
// http://opensource.org/licenses/MIT | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import "JSQLocationMediaItem.h" | ||
|
||
|
||
@interface JSQLocationMediaItemTests : XCTestCase | ||
|
||
@property (strong, nonatomic) CLLocation *location; | ||
|
||
@end | ||
|
||
|
||
@implementation JSQLocationMediaItemTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
self.location = [[CLLocation alloc] initWithLatitude:37.795313 longitude:-122.393757]; | ||
} | ||
|
||
- (void)tearDown | ||
{ | ||
self.location = nil; | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testLocationItemInit | ||
{ | ||
JSQLocationMediaItem *item = [[JSQLocationMediaItem alloc] initWithLocation:self.location]; | ||
XCTAssertNotNil(item); | ||
} | ||
|
||
- (void)testMediaDataProtocol | ||
{ | ||
JSQLocationMediaItem *item = [[JSQLocationMediaItem alloc] init]; | ||
|
||
XCTAssertTrue(!CGSizeEqualToSize([item mediaViewDisplaySize], CGSizeZero)); | ||
XCTAssertNotNil([item mediaPlaceholderView]); | ||
XCTAssertNil([item mediaView], @"Media view should be nil if location is nil"); | ||
|
||
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__]]; | ||
|
||
[item setLocation:self.location withCompletionHandler:^{ | ||
[expectation fulfill]; | ||
}]; | ||
|
||
[self waitForExpectationsWithTimeout:5 handler:^(NSError *error) { | ||
XCTAssertNil(error, @"Expectation should not error"); | ||
}]; | ||
|
||
XCTAssertNotNil([item mediaView], @"Media view should NOT be nil once item has media data"); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// Created by Jesse Squires | ||
// http://www.jessesquires.com | ||
// | ||
// | ||
// MIT License | ||
// Copyright (c) 2014 Jesse Squires | ||
// http://opensource.org/licenses/MIT | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import "JSQPhotoMediaItem.h" | ||
|
||
|
||
@interface JSQPhotoMediaItemTests : XCTestCase | ||
|
||
@end | ||
|
||
|
||
@implementation JSQPhotoMediaItemTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
} | ||
|
||
- (void)tearDown | ||
{ | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testPhotoItemInit | ||
{ | ||
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage new]]; | ||
XCTAssertNotNil(item); | ||
} | ||
|
||
- (void)testPhotoItemIsEqual | ||
{ | ||
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage imageNamed:@"demo_avatar_jobs"]]; | ||
|
||
JSQPhotoMediaItem *copy = [item copy]; | ||
|
||
XCTAssertEqualObjects(item, copy, @"Copied items should be equal"); | ||
|
||
XCTAssertEqual([item hash], [copy hash], @"Copied item hashes should be equal"); | ||
|
||
XCTAssertEqualObjects(item, item, @"Item should be equal to itself"); | ||
} | ||
|
||
- (void)testPhotoItemArchiving | ||
{ | ||
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:[UIImage new]]; | ||
|
||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:item]; | ||
|
||
JSQPhotoMediaItem *unarchivedItem = [NSKeyedUnarchiver unarchiveObjectWithData:data]; | ||
|
||
XCTAssertEqualObjects(item, unarchivedItem); | ||
} | ||
|
||
- (void)testMediaDataProtocol | ||
{ | ||
JSQPhotoMediaItem *item = [[JSQPhotoMediaItem alloc] initWithImage:nil]; | ||
|
||
XCTAssertTrue(!CGSizeEqualToSize([item mediaViewDisplaySize], CGSizeZero)); | ||
XCTAssertNotNil([item mediaPlaceholderView]); | ||
XCTAssertNil([item mediaView], @"Media view should be nil if image is nil"); | ||
|
||
item.image = [UIImage imageNamed:@"demo_avatar_jobs"]; | ||
|
||
XCTAssertNotNil([item mediaView], @"Media view should NOT be nil once item has media data"); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Created by Jesse Squires | ||
// http://www.jessesquires.com | ||
// | ||
// | ||
// MIT License | ||
// Copyright (c) 2014 Jesse Squires | ||
// http://opensource.org/licenses/MIT | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import "JSQVideoMediaItem.h" | ||
|
||
|
||
@interface JSQVideoMediaItemTests : XCTestCase | ||
|
||
@end | ||
|
||
|
||
@implementation JSQVideoMediaItemTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
} | ||
|
||
- (void)tearDown | ||
{ | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testVideoMediaItemInit | ||
{ | ||
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] initWithFileURL:[NSURL URLWithString:@"file://"] isReadyToPlay:NO]; | ||
XCTAssertNotNil(item); | ||
} | ||
|
||
- (void)testVideoItemIsEqual | ||
{ | ||
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] initWithFileURL:[NSURL URLWithString:@"file://"] isReadyToPlay:YES]; | ||
|
||
JSQVideoMediaItem *copy = [item copy]; | ||
|
||
XCTAssertEqualObjects(item, copy, @"Copied items should be equal"); | ||
|
||
XCTAssertEqual([item hash], [copy hash], @"Copied item hashes should be equal"); | ||
|
||
XCTAssertEqualObjects(item, item, @"Item should be equal to itself"); | ||
} | ||
|
||
- (void)testVideoItemArchiving | ||
{ | ||
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] initWithFileURL:[NSURL URLWithString:@"file://"] isReadyToPlay:YES]; | ||
|
||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:item]; | ||
|
||
JSQVideoMediaItem *unarchivedItem = [NSKeyedUnarchiver unarchiveObjectWithData:data]; | ||
|
||
XCTAssertEqualObjects(item, unarchivedItem); | ||
} | ||
|
||
- (void)testMediaDataProtocol | ||
{ | ||
JSQVideoMediaItem *item = [[JSQVideoMediaItem alloc] init]; | ||
|
||
XCTAssertTrue(!CGSizeEqualToSize([item mediaViewDisplaySize], CGSizeZero)); | ||
XCTAssertNotNil([item mediaPlaceholderView]); | ||
XCTAssertNil([item mediaView], @"Media view should be nil if fileURL is nil, and readyToPlay is NO"); | ||
|
||
item.fileURL = [NSURL URLWithString:@"file://"]; | ||
item.isReadyToPlay = YES; | ||
|
||
XCTAssertNotNil([item mediaView], @"Media view should NOT be nil once item has media data"); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters