{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/comments/40101051","id":40101051,"diff_hunk":"@@ -0,0 +1,147 @@\n+package org.jenkinsci.test.acceptance.recorder;\n+\n+import org.junit.rules.TestWatcher;\n+import org.junit.runner.Description;\n+import org.monte.media.Format;\n+import org.monte.media.FormatKeys;\n+import org.monte.media.VideoFormatKeys;\n+import org.monte.media.math.Rational;\n+import org.monte.screenrecorder.ScreenRecorder;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.awt.GraphicsEnvironment;\n+import java.awt.GraphicsConfiguration;\n+import java.awt.Dimension;\n+import java.awt.AWTException;\n+import java.io.File;\n+import java.io.IOException;\n+import java.util.concurrent.TimeUnit;\n+\n+/**\n+ * JUnit Rule that before executing a test it starts a recording current screen\n+ * and after the test is executed, it stops recording.\n+ */\n+public class TestRecorderRule extends TestWatcher {\n+\n+    private static final Logger logger = LoggerFactory.getLogger(TestRecorderRule.class);\n+\n+    private static final int MAX_RECORDING_TIME_SECS = 120000;\n+    private static final int FRAME_RATE_PER_SEC = 60;\n+    private static final int BIT_DEPTH = 16;\n+    private static final float QUALITY_RATIO = 0.97f;\n+    public static final String TARGET = \"target\";\n+\n+    private JUnitScreenRecorder screenRecorder;\n+\n+    @Override\n+    protected void starting(Description description) {\n+        if (!isRecorderDisabled()) {\n+            startRecording(description);\n+        }\n+    }\n+\n+    private void startRecording(Description des) {\n+        GraphicsConfiguration gc = GraphicsEnvironment\n+                .getLocalGraphicsEnvironment()\n+                .getDefaultScreenDevice()\n+                .getDefaultConfiguration();\n+\n+        File movieFolder = new File(TARGET);\n+\n+        String mimeType = FormatKeys.MIME_QUICKTIME;\n+        String videoFormatName = VideoFormatKeys.ENCODING_QUICKTIME_ANIMATION;\n+        String compressorName = VideoFormatKeys.COMPRESSOR_NAME_QUICKTIME_ANIMATION;\n+        Dimension outputDimension = gc.getBounds().getSize();\n+        int bitDepth = BIT_DEPTH;\n+        float quality = QUALITY_RATIO;\n+        int screenRate = FRAME_RATE_PER_SEC;\n+        long maxRecordingTime = MAX_RECORDING_TIME_SECS;\n+\n+        Format outputFormatForScreenCapture = getOutputFormatForScreenCapture(videoFormatName,\n+                compressorName, outputDimension,\n+                bitDepth, quality, screenRate);\n+\n+        try {\n+            this.screenRecorder = new JUnitScreenRecorder\n+                    (gc, gc.getBounds(), getFileFormat(mimeType),\n+                            outputFormatForScreenCapture, null, null, movieFolder, des);\n+            this.screenRecorder.start();\n+        } catch (IOException e) {\n+            logger.warn(\"Exception starting test recording {}\", e);\n+        } catch (AWTException e) {\n+            logger.warn(\"Exception starting test recording {}\", e);\n+        }\n+    }\n+\n+    @Override\n+    protected void succeeded(Description description) {\n+        if (this.screenRecorder != null) {\n+            if (saveAllExecutions()) {\n+                stopRecordingWithFinalWaiting();\n+            } else {\n+                stopRecording();\n+                this.screenRecorder.removeMovieFile();\n+            }\n+        }\n+    }\n+\n+    @Override\n+    protected void finished(Description description) {\n+        stopRecordingWithFinalWaiting();\n+    }\n+\n+    private boolean isRecorderDisabled() {\n+        return Boolean.getBoolean(\"RECORDER_DISABLED\");\n+    }\n+\n+    private boolean saveAllExecutions() {\n+        return Boolean.getBoolean(\"RECORDER_SAVE_ALL\");","path":"src/main/java/org/jenkinsci/test/acceptance/recorder/TestRecorderRule.java","position":99,"original_position":99,"commit_id":"36c3d49178d69c479558f5be8152a0a5a8701d20","original_commit_id":"36c3d49178d69c479558f5be8152a0a5a8701d20","user":{"login":"jglick","id":154109,"avatar_url":"https://avatars.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"body":"For properties like these, prefer `System.getenv`. Then you need to use [this trick](https://github.com/jenkinsci/acceptance-test-harness/blob/935342b6b6da2bfe2bc257e5fbccbfc8a03771a5/pom.xml#L604-L623) to let people customize the value in a Maven profile.","created_at":"2015-09-22T15:31:10Z","updated_at":"2015-09-22T15:31:10Z","html_url":"https://github.com/jenkinsci/acceptance-test-harness/pull/39#discussion_r40101051","pull_request_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/comments/40101051"},"html":{"href":"https://github.com/jenkinsci/acceptance-test-harness/pull/39#discussion_r40101051"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39","id":45556179,"html_url":"https://github.com/jenkinsci/acceptance-test-harness/pull/39","diff_url":"https://github.com/jenkinsci/acceptance-test-harness/pull/39.diff","patch_url":"https://github.com/jenkinsci/acceptance-test-harness/pull/39.patch","issue_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues/39","number":39,"state":"open","locked":false,"title":"adds screen recorder capabilities.","user":{"login":"lordofthejars","id":1517153,"avatar_url":"https://avatars.githubusercontent.com/u/1517153?v=3","gravatar_id":"","url":"https://api.github.com/users/lordofthejars","html_url":"https://github.com/lordofthejars","followers_url":"https://api.github.com/users/lordofthejars/followers","following_url":"https://api.github.com/users/lordofthejars/following{/other_user}","gists_url":"https://api.github.com/users/lordofthejars/gists{/gist_id}","starred_url":"https://api.github.com/users/lordofthejars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordofthejars/subscriptions","organizations_url":"https://api.github.com/users/lordofthejars/orgs","repos_url":"https://api.github.com/users/lordofthejars/repos","events_url":"https://api.github.com/users/lordofthejars/events{/privacy}","received_events_url":"https://api.github.com/users/lordofthejars/received_events","type":"User","site_admin":false},"body":"@reviewbybees ","created_at":"2015-09-21T14:37:47Z","updated_at":"2015-09-22T15:31:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9ffc0739e14d6be4b8d2ed0ba32db8eb8ed7502","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues/39/comments","statuses_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/statuses/36c3d49178d69c479558f5be8152a0a5a8701d20","head":{"label":"lordofthejars:master","ref":"master","sha":"36c3d49178d69c479558f5be8152a0a5a8701d20","user":{"login":"lordofthejars","id":1517153,"avatar_url":"https://avatars.githubusercontent.com/u/1517153?v=3","gravatar_id":"","url":"https://api.github.com/users/lordofthejars","html_url":"https://github.com/lordofthejars","followers_url":"https://api.github.com/users/lordofthejars/followers","following_url":"https://api.github.com/users/lordofthejars/following{/other_user}","gists_url":"https://api.github.com/users/lordofthejars/gists{/gist_id}","starred_url":"https://api.github.com/users/lordofthejars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordofthejars/subscriptions","organizations_url":"https://api.github.com/users/lordofthejars/orgs","repos_url":"https://api.github.com/users/lordofthejars/repos","events_url":"https://api.github.com/users/lordofthejars/events{/privacy}","received_events_url":"https://api.github.com/users/lordofthejars/received_events","type":"User","site_admin":false},"repo":{"id":40872046,"name":"acceptance-test-harness","full_name":"lordofthejars/acceptance-test-harness","owner":{"login":"lordofthejars","id":1517153,"avatar_url":"https://avatars.githubusercontent.com/u/1517153?v=3","gravatar_id":"","url":"https://api.github.com/users/lordofthejars","html_url":"https://github.com/lordofthejars","followers_url":"https://api.github.com/users/lordofthejars/followers","following_url":"https://api.github.com/users/lordofthejars/following{/other_user}","gists_url":"https://api.github.com/users/lordofthejars/gists{/gist_id}","starred_url":"https://api.github.com/users/lordofthejars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordofthejars/subscriptions","organizations_url":"https://api.github.com/users/lordofthejars/orgs","repos_url":"https://api.github.com/users/lordofthejars/repos","events_url":"https://api.github.com/users/lordofthejars/events{/privacy}","received_events_url":"https://api.github.com/users/lordofthejars/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lordofthejars/acceptance-test-harness","description":"Attempted port from selenium-tests to Java","fork":true,"url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness","forks_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/forks","keys_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/teams","hooks_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/hooks","issue_events_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/issues/events{/number}","events_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/events","assignees_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/assignees{/user}","branches_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/branches{/branch}","tags_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/tags","blobs_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/git/refs{/sha}","trees_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/statuses/{sha}","languages_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/languages","stargazers_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/stargazers","contributors_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/contributors","subscribers_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/subscribers","subscription_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/subscription","commits_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/commits{/sha}","git_commits_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/git/commits{/sha}","comments_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/comments{/number}","issue_comment_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/issues/comments{/number}","contents_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/contents/{+path}","compare_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/merges","archive_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/downloads","issues_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/issues{/number}","pulls_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/pulls{/number}","milestones_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/milestones{/number}","notifications_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/labels{/name}","releases_url":"https://api.github.com/repos/lordofthejars/acceptance-test-harness/releases{/id}","created_at":"2015-08-17T07:01:50Z","updated_at":"2015-08-17T07:01:51Z","pushed_at":"2015-09-22T09:48:30Z","git_url":"git://github.com/lordofthejars/acceptance-test-harness.git","ssh_url":"git@github.com:lordofthejars/acceptance-test-harness.git","clone_url":"https://github.com/lordofthejars/acceptance-test-harness.git","svn_url":"https://github.com/lordofthejars/acceptance-test-harness","homepage":null,"size":7707,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"ba5885b7bcc734a83ffeae3984b3732439de2907","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":17294237,"name":"acceptance-test-harness","full_name":"jenkinsci/acceptance-test-harness","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/acceptance-test-harness","description":"Attempted port from selenium-tests to Java","fork":false,"url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness","forks_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/forks","keys_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/teams","hooks_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/events","assignees_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/tags","blobs_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/subscription","commits_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/merges","archive_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/downloads","issues_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/releases{/id}","created_at":"2014-02-28T17:39:55Z","updated_at":"2015-08-14T08:00:09Z","pushed_at":"2015-09-22T09:48:30Z","git_url":"git://github.com/jenkinsci/acceptance-test-harness.git","ssh_url":"git@github.com:jenkinsci/acceptance-test-harness.git","clone_url":"https://github.com/jenkinsci/acceptance-test-harness.git","svn_url":"https://github.com/jenkinsci/acceptance-test-harness","homepage":null,"size":10480,"stargazers_count":30,"watchers_count":30,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":2,"forks":49,"open_issues":2,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39"},"html":{"href":"https://github.com/jenkinsci/acceptance-test-harness/pull/39"},"issue":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues/39"},"comments":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/acceptance-test-harness/statuses/36c3d49178d69c479558f5be8152a0a5a8701d20"}}}}