Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Commit

Permalink
Merge branch 'stabilize_tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
pietbrauer committed Mar 26, 2015
2 parents b06b13b + 22e3722 commit f5d2bc3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 25 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 24 additions & 21 deletions Example/ExampleTests/SnapshotTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ - (void) setUp {
}

- (void)testPlainText {
FBSnapshotVerifyView([self textViewForMarkdownStringWithDefaultAttributesFromFile:@"plaintext_utf8.txt"], nil);
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"plaintext_utf8.txt"], nil);
}

- (void)testHeaders {
FBSnapshotVerifyView([self textViewForMarkdownStringWithDefaultAttributesFromFile:@"headers.txt"], nil);
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"headers.txt"], nil);
}

- (void)testLinks {
FBSnapshotVerifyView([self textViewForMarkdownStringWithDefaultAttributesFromFile:@"links.txt"], nil);
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"links.txt"], nil);
}

- (void)testTextStyles {
FBSnapshotVerifyView([self textViewForMarkdownStringWithDefaultAttributesFromFile:@"text_styles.txt"], nil);
FBSnapshotVerifyView([self labelForMarkdownStringWithDefaultAttributesFromFile:@"text_styles.txt"], nil);
}

- (void)testFontChange {
Expand All @@ -41,11 +41,11 @@ - (void)testFontChange {
forHeader:XNGMarkdownParserHeader1];
NSAttributedString * attr = [parser attributedStringFromMarkdownString:markdown];

FBSnapshotVerifyView([self defaultTextViewWithAttributedString:attr], nil);
FBSnapshotVerifyView([self defaultLabelWithAttributedString:attr], nil);
}

- (void)testParagraphAttributes {
UITextView *textView = [self defaultTextView];
UILabel *label = [self defaultTextLabel];
NSString * markdown = [self markdownFromFile:@"paragraph_1.txt"];

XNGMarkdownParser *parser = [[XNGMarkdownParser alloc] init];
Expand All @@ -58,39 +58,42 @@ - (void)testParagraphAttributes {
NSShadowAttributeName : shadow,
NSParagraphStyleAttributeName : paragraphStyle,
};
textView.attributedText = [parser attributedStringFromMarkdownString:markdown];
label.attributedText = [parser attributedStringFromMarkdownString:markdown];

FBSnapshotVerifyView(textView, nil);
FBSnapshotVerifyView(label, nil);
}

#pragma mark - Helper methods

- (UITextView*) textViewForMarkdownStringWithDefaultAttributesFromFile:(NSString*)fileName {
UITextView *textView = [self defaultTextView];
- (UILabel*)labelForMarkdownStringWithDefaultAttributesFromFile:(NSString*)fileName {
UILabel *label = [self defaultTextLabel];
NSAttributedString * attrString = [self parseWithDefaultAttributes:[self markdownFromFile:fileName]];
[self setAttributedTextAndResizeAutomatically:attrString
inTextView:textView];
return textView;
inLabel:label];
return label;
}

- (UITextView*) defaultTextViewWithAttributedString:(NSAttributedString*)attr {
UITextView * textView = [self defaultTextView];
[self setAttributedTextAndResizeAutomatically:attr inTextView:textView];
return textView;
- (UILabel*)defaultLabelWithAttributedString:(NSAttributedString*)attr {
UILabel *label = [self defaultTextLabel];
[self setAttributedTextAndResizeAutomatically:attr inLabel:label];
return label;
}

- (void)setAttributedTextAndResizeAutomatically:(NSAttributedString*)attrString
inTextView:(UITextView*)view
inLabel:(UILabel*)view
{
view.attributedText = attrString;
CGSize size = [view sizeThatFits:CGSizeMake(320, CGFLOAT_MAX)];
view.frame = CGRectMake(0, 0, size.width, size.height);
[view setNeedsLayout];
[view layoutIfNeeded];
}

- (UITextView *)defaultTextView {
UITextView *tv = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
tv.editable = NO;
return tv;
- (UILabel *)defaultTextLabel {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
label.numberOfLines = 0;
label.backgroundColor = [UIColor whiteColor];
return label;
}

- (NSString *)markdownFromFile:(NSString *)name {
Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Expecta (0.3.1)
- FBSnapshotTestCase (1.4)
- Expecta (0.3.2)
- FBSnapshotTestCase (1.6)
- XNGMarkdownParser (0.3.0)

DEPENDENCIES:
Expand All @@ -13,8 +13,8 @@ EXTERNAL SOURCES:
:path: ..

SPEC CHECKSUMS:
Expecta: 03aabd0a89d8dea843baecb19a7fd7466a69a31d
FBSnapshotTestCase: f9f225b5ba11c8d8c09075590490df16314e4d62
Expecta: ee641011fe10aa1855d487b40e4976dac50ec342
FBSnapshotTestCase: 9d5fe43b29ae3a0ed8fc829477971b281038f748
XNGMarkdownParser: 8ad6d21f972f2b2301637d842da2f7942faed5a0

COCOAPODS: 0.36.0

0 comments on commit f5d2bc3

Please sign in to comment.