{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/comments/48477202","id":48477202,"diff_hunk":"@@ -0,0 +1,34 @@\n+/*\n+ *  Copyright (c) 2013, Facebook, Inc.\n+ *  All rights reserved.\n+ *\n+ *  This source code is licensed under the BSD-style license found in the\n+ *  LICENSE file in the root directory of this source tree. An additional grant\n+ *  of patent rights can be found in the PATENTS file in the same directory.\n+ *\n+ */\n+\n+#import <FBSnapshotTestCase/FBSnapshotTestCase.h>\n+\n+@interface FBSnapshotTestCaseDeviceAgnosticTests : FBSnapshotTestCase\n+\n+@end\n+\n+@implementation FBSnapshotTestCaseDeviceAgnosticTests\n+\n+- (void)setUp\n+{\n+    [super setUp];\n+    self.deviceAgnostic = YES;\n+    self.recordMode = NO;\n+}\n+\n+- (void)testViewSnapshot\n+{\n+    UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];\n+    redView.backgroundColor = [UIColor redColor];\n+    FBSnapshotVerifyView(redView, nil);","path":"FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDeviceAgnosticTests.m","position":30,"original_position":30,"commit_id":"1bdc45196e3fa398087339bb81b5e887a5398e7e","original_commit_id":"7f188bcf8f73f8620f1187e2d1c0e97eda276523","user":{"login":"bgerstle","id":444217,"avatar_url":"https://avatars.githubusercontent.com/u/444217?v=3","gravatar_id":"","url":"https://api.github.com/users/bgerstle","html_url":"https://github.com/bgerstle","followers_url":"https://api.github.com/users/bgerstle/followers","following_url":"https://api.github.com/users/bgerstle/following{/other_user}","gists_url":"https://api.github.com/users/bgerstle/gists{/gist_id}","starred_url":"https://api.github.com/users/bgerstle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgerstle/subscriptions","organizations_url":"https://api.github.com/users/bgerstle/orgs","repos_url":"https://api.github.com/users/bgerstle/repos","events_url":"https://api.github.com/users/bgerstle/events{/privacy}","received_events_url":"https://api.github.com/users/bgerstle/received_events","type":"User","site_admin":false},"body":"@nscoding yeah, sorry I didn't respond, but better late than never:\r\n\r\n> The build script that I added on travis is building and testing both iPhone 5 and iPhone 6, so we have to record the image for both of these devices.\r\n\r\nI already figured that out when Travis failed and downloaded/recorded the proper screenshots.\r\n\r\n> testFailedImageWithDeviceAgnosticShouldHaveModelOnName. These tests don't have an application associated with, so we hit the assertion. \r\n\r\nThose tests are in the Demo project, which does have a host application (see above screenshot).  I _think_ the problem was that `UIImage+Snapshot` was causing issues when installing a \"dummy\" window when given a view without a window.  This somehow caused the `keyWindow` to return `nil` when device-agnostic tests were run—which I determined after seeing each test pass in isolation.  As a result, I've modified `UIImage+Snapshot` to use the application's `keyWindow` if the given view doesn't have a window (or if it isn't a window itself).  Let me know if you think this is acceptable.\r\n\r\n> Maybe we can make the window a parameter and simply write tests to make sure that FBDeviceAgnosticNormalizedFileName is working as expected.\r\n\r\nThat could be useful for verifying the formatting of test names (to prevent unintended regressions and thus break tests for users), but doesn't address the problems targeted by this PR.\r\n","created_at":"2015-12-28T12:42:26Z","updated_at":"2015-12-28T12:42:26Z","html_url":"https://github.com/facebook/ios-snapshot-test-case/pull/137#discussion_r48477202","pull_request_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137","_links":{"self":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/comments/48477202"},"html":{"href":"https://github.com/facebook/ios-snapshot-test-case/pull/137#discussion_r48477202"},"pull_request":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137","id":53076205,"html_url":"https://github.com/facebook/ios-snapshot-test-case/pull/137","diff_url":"https://github.com/facebook/ios-snapshot-test-case/pull/137.diff","patch_url":"https://github.com/facebook/ios-snapshot-test-case/pull/137.patch","issue_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues/137","number":137,"state":"open","locked":false,"title":"add device agnostic tests & add helpful assertion for device agnostic tests","user":{"login":"bgerstle","id":444217,"avatar_url":"https://avatars.githubusercontent.com/u/444217?v=3","gravatar_id":"","url":"https://api.github.com/users/bgerstle","html_url":"https://github.com/bgerstle","followers_url":"https://api.github.com/users/bgerstle/followers","following_url":"https://api.github.com/users/bgerstle/following{/other_user}","gists_url":"https://api.github.com/users/bgerstle/gists{/gist_id}","starred_url":"https://api.github.com/users/bgerstle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgerstle/subscriptions","organizations_url":"https://api.github.com/users/bgerstle/orgs","repos_url":"https://api.github.com/users/bgerstle/repos","events_url":"https://api.github.com/users/bgerstle/events{/privacy}","received_events_url":"https://api.github.com/users/bgerstle/received_events","type":"User","site_admin":false},"body":"Our app doesn't have a window when run as a test host, which results in `keyWindow` being `nil`.  This could also happen if your test target is a \"Logic Test\", and not an \"Application Test.\"\r\n\r\n```\r\n$ ls -1 WikipediaUnitTests/ReferenceImages_64/NSAttributedString_WMFModifyTests\r\ntest0ReferenceOutput_iPhone_Simulator8_4_0x0@2x.png\r\ntestChangeGreenBackgroundColorsToBlue_iPhone_Simulator8_4_0x0@2x.png\r\ntestChangeReduceLineSpacing_iPhone_Simulator8_4_0x0@2x.png\r\ntestRemoveAllStrikeThroughs_iPhone_Simulator8_4_0x0@2x.png\r\ntestRemovingLink_iPhone_Simulator8_4_0x0@2x.png\r\n```\r\n\r\nI've added an assertion so others can get clearer feedback about what's going wrong and how to fix it.  FBSnapshotTestCase could arguably create a `keyWindow` implicitly, but I figured it's better to let users set up their test host properly instead of implicitly relying on the library to do it for them.","created_at":"2015-12-09T04:44:30Z","updated_at":"2015-12-28T12:42:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a19c7651c4b746aa6999065cdc3c30101c8787cc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137/commits","review_comments_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137/comments","review_comment_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues/137/comments","statuses_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/statuses/1bdc45196e3fa398087339bb81b5e887a5398e7e","head":{"label":"bgerstle:master","ref":"master","sha":"1bdc45196e3fa398087339bb81b5e887a5398e7e","user":{"login":"bgerstle","id":444217,"avatar_url":"https://avatars.githubusercontent.com/u/444217?v=3","gravatar_id":"","url":"https://api.github.com/users/bgerstle","html_url":"https://github.com/bgerstle","followers_url":"https://api.github.com/users/bgerstle/followers","following_url":"https://api.github.com/users/bgerstle/following{/other_user}","gists_url":"https://api.github.com/users/bgerstle/gists{/gist_id}","starred_url":"https://api.github.com/users/bgerstle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgerstle/subscriptions","organizations_url":"https://api.github.com/users/bgerstle/orgs","repos_url":"https://api.github.com/users/bgerstle/repos","events_url":"https://api.github.com/users/bgerstle/events{/privacy}","received_events_url":"https://api.github.com/users/bgerstle/received_events","type":"User","site_admin":false},"repo":{"id":47668080,"name":"ios-snapshot-test-case","full_name":"bgerstle/ios-snapshot-test-case","owner":{"login":"bgerstle","id":444217,"avatar_url":"https://avatars.githubusercontent.com/u/444217?v=3","gravatar_id":"","url":"https://api.github.com/users/bgerstle","html_url":"https://github.com/bgerstle","followers_url":"https://api.github.com/users/bgerstle/followers","following_url":"https://api.github.com/users/bgerstle/following{/other_user}","gists_url":"https://api.github.com/users/bgerstle/gists{/gist_id}","starred_url":"https://api.github.com/users/bgerstle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgerstle/subscriptions","organizations_url":"https://api.github.com/users/bgerstle/orgs","repos_url":"https://api.github.com/users/bgerstle/repos","events_url":"https://api.github.com/users/bgerstle/events{/privacy}","received_events_url":"https://api.github.com/users/bgerstle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bgerstle/ios-snapshot-test-case","description":"Snapshot view unit tests for iOS","fork":true,"url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case","forks_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/forks","keys_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/teams","hooks_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/hooks","issue_events_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/issues/events{/number}","events_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/events","assignees_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/assignees{/user}","branches_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/branches{/branch}","tags_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/tags","blobs_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/git/refs{/sha}","trees_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/statuses/{sha}","languages_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/languages","stargazers_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/stargazers","contributors_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/contributors","subscribers_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/subscribers","subscription_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/subscription","commits_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/commits{/sha}","git_commits_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/git/commits{/sha}","comments_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/comments{/number}","issue_comment_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/issues/comments{/number}","contents_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/contents/{+path}","compare_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/merges","archive_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/downloads","issues_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/issues{/number}","pulls_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/pulls{/number}","milestones_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/milestones{/number}","notifications_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/labels{/name}","releases_url":"https://api.github.com/repos/bgerstle/ios-snapshot-test-case/releases{/id}","created_at":"2015-12-09T04:17:47Z","updated_at":"2015-12-09T04:17:49Z","pushed_at":"2015-12-28T03:01:47Z","git_url":"git://github.com/bgerstle/ios-snapshot-test-case.git","ssh_url":"git@github.com:bgerstle/ios-snapshot-test-case.git","clone_url":"https://github.com/bgerstle/ios-snapshot-test-case.git","svn_url":"https://github.com/bgerstle/ios-snapshot-test-case","homepage":null,"size":723,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"e3b9da96653eb38efcef2abe62f06a6d3af4a8ad","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":13236289,"name":"ios-snapshot-test-case","full_name":"facebook/ios-snapshot-test-case","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/ios-snapshot-test-case","description":"Snapshot view unit tests for iOS","fork":false,"url":"https://api.github.com/repos/facebook/ios-snapshot-test-case","forks_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/forks","keys_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/teams","hooks_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/hooks","issue_events_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/events","assignees_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/tags","blobs_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/languages","stargazers_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/stargazers","contributors_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/contributors","subscribers_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/subscribers","subscription_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/subscription","commits_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/merges","archive_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/downloads","issues_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/labels{/name}","releases_url":"https://api.github.com/repos/facebook/ios-snapshot-test-case/releases{/id}","created_at":"2013-10-01T06:15:56Z","updated_at":"2015-12-28T03:22:04Z","pushed_at":"2015-12-28T06:42:32Z","git_url":"git://github.com/facebook/ios-snapshot-test-case.git","ssh_url":"git@github.com:facebook/ios-snapshot-test-case.git","clone_url":"https://github.com/facebook/ios-snapshot-test-case.git","svn_url":"https://github.com/facebook/ios-snapshot-test-case","homepage":null,"size":913,"stargazers_count":1563,"watchers_count":1563,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":138,"mirror_url":null,"open_issues_count":3,"forks":138,"open_issues":3,"watchers":1563,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137"},"html":{"href":"https://github.com/facebook/ios-snapshot-test-case/pull/137"},"issue":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues/137"},"comments":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/issues/137/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/pulls/137/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/ios-snapshot-test-case/statuses/1bdc45196e3fa398087339bb81b5e887a5398e7e"}}}}