{"id":13744124,"url":"https://github.com/honzabrecka/Screenshot","last_synced_at":"2025-05-09T02:32:40.414Z","repository":{"id":12763622,"uuid":"15436957","full_name":"honzabrecka/Screenshot","owner":"honzabrecka","description":"Screenshot is an ActionScript 3 util for integration testing of UI components. It perfectly works with FlexUnit testing flow and Flex Framework UI components.","archived":false,"fork":false,"pushed_at":"2015-03-06T11:11:53.000Z","size":1352,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-06T16:16:40.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"ActionScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/honzabrecka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-25T15:25:26.000Z","updated_at":"2021-11-16T13:32:30.000Z","dependencies_parsed_at":"2022-09-15T06:11:52.873Z","dependency_job_id":null,"html_url":"https://github.com/honzabrecka/Screenshot","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honzabrecka%2FScreenshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honzabrecka%2FScreenshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honzabrecka%2FScreenshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honzabrecka%2FScreenshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/honzabrecka","download_url":"https://codeload.github.com/honzabrecka/Screenshot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253177839,"owners_count":21866405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:03.453Z","updated_at":"2025-05-09T02:32:40.097Z","avatar_url":"https://github.com/honzabrecka.png","language":"ActionScript","readme":"Screenshot [![Build Status](https://travis-ci.org/honzabrecka/Screenshot.svg?branch=master)](https://travis-ci.org/honzabrecka/Screenshot)\n==========\n\nScreenshot is an ActionScript 3 util for integration testing of UI components. It perfectly works with FlexUnit testing flow and Flex Framework UI components.\n\n\u003e Flash has one special ability - output always looks the same.\n\nFast, lightweight and easy to use\n---------------------------------\n\n```as3\n[Test(async, ui)]\npublic function defaultColor():void\n{\n\tvar component:Square = new Square();\n\tAsync.proceedOnEvent(this, component, Event.ADDED);\n    UIImpersonator.addChild(component);\n\t\n\t// this is the line!\n\tassertTrue(Screenshot.compare(\"SquareTest.defaultColor\", component));\n}\n```\n\nSetup\n-----\n\nAt first of all you have to set the `ScreenShot.dictionary` property, which is a simple key value storage. It includes fixtures (expected states of your UI components). You can fill it manually:\n\n```as3\n[Embed(source=\"SquareTest.defaultColor.png\")]\nprivate var SquareWithDefaultColor:Class;\n...\nScreenshot.dictionary = {};\nScreenshot.dictionary[\"SquareTest.defaultColor\"] = Bitmap(new SquareWithDefaultColor()).bitmapData;\n```\n\nor, which is much better and prefered way, use the `LoadQueue` class and load fixtures at runtime:\n\n```as3\nvar queue:LoadQueue = new LoadQueue(\"../fixtures/\");\n\tqueue.addEventListener(Event.COMPLETE, function(event:Event):void\n\t{\n\t\tScreenshot.dictionary = queue.dictionary;\n\t});\n\t// list of fixtures, which will be loaded (name is without any extension!)\n\tqueue.load(new \u003cString\u003e[\"SquareTest.defaultColor\"]);\n```\n\nThen you have to set the `Screenshot.save` property to a new instance of the `Upload` class to be able to upload a screenshot of an actual state of your UI component to the server:\n\n```as3\nScreenshot.save = new Upload(\"http://127.0.0.1:4000/upload.php\");\n```\n\n\u003e Server can be started by `$ php -S 127.0.0.1:4000`\n\nNow if you run your test case it should fail, but the `SquareTest.defaultColor-actual.png` file should appear in your fixtures directory. If it looks as you expected, you can mark it as a valid fixture by removing the `-actual` suffix from its name.\n\nYou've covered your ass, now!\n\n\u003e `Screenshot.save` is also used for saving a \"diff between an actual and an expected state\". It's really useful for debugging.\n\nKnown issues\n------------\n\nPure ActionScript projects may throw \"VerifyError: Error #1014: Class mx.graphics.codec::IImageEncoder could not be found.\" error when you run your test suite. To solve this, just link the `flex_sdk_location/frameworks/libs/framework.swc`.\n\nSometimes you can see \"Adobe Flash Player has stopped a potentially unsafe operation.\" error message when you run your test suite. To solve this, just add the swf file location to the trusted list in Adobe FlashPlayer Settings Manager in order to allow a local swf connect the internet.\n\nBest practices\n--------------\n\n### Naming\n\nThe best is the following format `\u003cTestClassName\u003e.\u003cTestMethodName\u003e`\n\n### Resizing\n\nIf you have to test sizable components (let's say bigger than 100px in any way), you should use `Resizer`, which resizes them to smaller version. It can save a lot of time needed by pixel by pixel comparison:\n\n```as3\nScreenshot.resizer = new Resizer(100);\n```\n\n### Custom assertion\n\nAt `com.jx.screenshot` directory create the `assertScreenshot.as` file with the following content:\n\n```as3\npackage com.jx.screenshot\n{\n\timport flash.display.DisplayObject;\n\timport org.flexunit.Assert;\n\n\tpublic function assertScreenshot(fixtureName:String, component:DisplayObject, includeBounds:Boolean=false):void\n\t{\n\t\tAssert.assertTrue(Screenshot.compare(fixtureName, component, includeBounds));\n\t}\n}\n```\n\nSo instead of `assertTrue(Screenshot.compare(\"SquareTest.defaultColor\", component));` you'll write just `assertScreenshot(\"SquareTest.defaultColor\", component)`.\n\n### .gitignore\n\n```\n*-actual.png\n*-diff.png\n```\n","funding_links":[],"categories":["Frameworks"],"sub_categories":["Unit Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhonzabrecka%2FScreenshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhonzabrecka%2FScreenshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhonzabrecka%2FScreenshot/lists"}