I have developed a Flutter chat. Now I am trying to do test with UI automator but setText method for Edit Text not work.
UI Automator Viewer app
This is for a Windows 10 with Android Studio.
I have a class where I define the objects
public class ChatAppObjects {
public static UiObject ICON_CHATAPP = new UiObject(new UiSelector().className("android.widget.TextView").text("ChatApp"));
public static UiObject TXT_MESSAGE = new UiObject(new UiSelector().className("android.widget.EditText"));
public static UiObject BTN_SEND = new UiObject(new UiSelector().className("android.widget.Button"));
}
And this is the test
public void test1() throws UiObjectNotFoundException, InterruptedException {
UiDevice mDevice = UiDevice.getInstance();
mDevice.pressHome();
ChatAppObjects.ICON_CHATAPP.clickAndWaitForNewWindow();
ChatAppObjects.TXT_MESSAGE.click();
ChatAppObjects.TXT_MESSAGE.clearTextField();
ChatAppObjects.TXT_MESSAGE.setText("Prueba");
ChatAppObjects.BTN_SEND.click();
}
Test run successful but not write "Prueba" into textbox
Flutter apps do not work with UiAutomator. The only way to run integration tests on them right now is with flutter's own testing utility. You can read about getting started with it here.
I have a common shape that renders some HTML code to display an error dialog.
The HTML code needs to be included only once throughout the whole web site. For scripts and styles Orchard provides the Script.Include() and Style.Include() methods.
I wonder whether there is something similar for HTML code, any ideas?
So many options to do this
Can you add your code to Layout.cshtml in the theme
Create a new widget and attach the shape field then create it on the default layer (so on all pages) with the name of your shape in the shape field
Add the shape in a filter, or anywhere else you have access to the WorkContext :)
Code written from memory, may not compile
using System.Linq;
using System.Web.Mvc;
using Orchard;
using Orchard.DisplayManagement;
using Orchard.Mvc.Filters;
using Orchard.UI.Admin;
public class MyFilter : FilterProvider, IResultProvider {
private readonly dynamic _shapeFactory;
private readonly WorkContext _workContext;
public MyFilter(WorkContext workContext, IShapeFactory shapeFactory)
{
_workContext = workContext;
_shapeFactory = shapeFactory;
}
public void OnResultExecuting(ResultExecutingContext filterContext)
{
// should only run on a full view rendering result
if (!(filterContext.Result is ViewResult)) return;
// front end only
if (AdminFilter.IsApplied(new RequestContext(_workContext.HttpContext, new RouteData()))) return;
var body = _workContext.Layout.Body;
body.Add(_shapeFactory.MyShape());
}
public void OnResultExecuted(ResultExecutedContext filterContext) {}
}
I'm trying to add generic content while embedding my game assets but came up with nothing so far. What I usually do is:
public final class AssetsManager
{
[Embed(source="../assets/game1/icon.png", mimeType = "image/png")]
private static const Icon:Class;
}
However, I want to do something like this:
public final class AssetsManager(gameName:String)
{
[Embed(source="../assets/"+gameName+"/icon.png", mimeType = "image/png")]
private static const Icon:Class;
}
I'm not able to transfer params via the class, so I believe there's another way.
Embedding happens at compile-time so this isn't possible. Instead, you can load in assets at runtime, for example using a URLLoader as a ByteArray, or Loader as Bitmap, or a Flex Image control.
Does anyone know why the getDefinitionByName function works with "com.foo.Bar" and gives error with "com.foo.Rab"?
My only clue is that the class com.foo.Bar was created before importing the project to Flash Builder 4.5 for PHP (4.5.1 namely).
My question is very specific, in fact you could try for yourself if you had FB4.5.1, a prior version of the same program, and a lot of time. Obviously I’m hoping to find someone who have experienced this particular issue or any related issue with similar functions.
I'm porting a card game from pure Flash/AS3 to Flex 4.5 and in the original app I was using getDefinitionByName to load card MovieClips from the library dynamically:
var sprite:Sprite = new (getDefinitionByName(spriteName) as Class);
But in my Flex app I don't use it anymore. Instead I have this class - Assets.as:
package {
public class Assets {
[Embed('assets/Pref.swf', symbol='spades_Q')]
public static const SPADES_Q:Class;
[Embed('assets/Pref.swf', symbol='clubs_Q')]
public static const CLUBS_Q:Class;
[Embed('assets/Pref.swf', symbol='diamonds_Q')]
public static const DIAMONDS_Q:Class;
[Embed('assets/Pref.swf', symbol='hearts_Q')]
public static const HEARTS_Q:Class;
....
and then in my main class I use:
var sprite:Sprite = new Assets[spriteName];
for example:
var sprite:Sprite = new Assets['HEARTS_Q'];
Maybe this helps you?
getDefinitionByName can only import classes that are already present in the current ApplicationDomain. Your app must import com.foo.Rab in the normal fashion earlier in the execution or it will not work.
I'm creating a game where a lot of images are being used in Actionscript / Flex 3 (Flash). Now that I've reached the designer stage, I have to work out a structural way of using embedded images (which have to be manipulated with rotation, color, etc.).
Unfortunately, after investigating a bit, it looks like you have to manually embed images before you can use them. I currently have it setup like this:
Resource.as class file:
package
{
public final class Resource
{
[Embed (source="/assets/ships/1.gif" )]
public static const SHIPS_1:Class;
}
}
So, just for one ship I so for have to:
Put the image in the correct folder with the correct name
Name it in the same way in the Resource.as file
Create the constant with the same name in the Resource.as file
Even though this should all be possible by simply putting the file in a specified folder.
To make things even worse, I still have to call it using:
var test:Bitmap = new Resource.SHIPS_1();
There must be better ways to handle resources when creating very huge applications? Imagine I need thousands of images, this system simply wouldn't fit.
If you need to handle a large number of resources you can follow these 3 steps:
Place them in an uncompressed zip archive
Embed the zip file as binary data:
[Embed(source = 'resources.zip', mimeType = 'application/octet-stream')]
Access the resources using FZip
If you choose a different method that involves loading external files be aware that some flash game websites require the games they host to be contained within a single swf file.
instead of
var test:Bitmap = new Resource.SHIPS_1();
Use
myImage.source = Resource.SHIPS_1;
The embedding is correct. :D the way you use it is wrong :)
Adrian
This is really what Flash CS4 is for. Your way seems fine to me though - although I wouldn't use all caps for a class name even if it is a constant. Just put your head down and get copy-pasting!
Alternatively you could load the files at runtime.
This is old but since I stumbled across it searching for something different I'll write here for future generations : )
I use a different approach. I create a swf movie with flash professional and import all graphics in it and then mark them all for "Export for ActionScript".
Compile the swf and in your main project embed only the swf and access all the graphics through it...
I find this approach much more organized. Why write the whole resources class when you can make it by importing files right? ;)
I just watched this great tutorial on the Starling framework:
http://www.hsharma.com/tutorials/starting-with-starling-ep-3-sprite-sheets/
It sounds like spritesheets are exactly what you're looking for:
You bundle all your individual textures into one big texture that is called spritesheet and create an xml file that contains information where the textures are within the spritesheet. In order to do that you can use this tool:
http://www.codeandweb.com/texturepacker
I'm not sure if you can use it for commercial projects and the amount of textures you're speaking of doesn't sound like you're doing this just as a hobby, so you might want to check the license. There's a pro version available, too.
Texturepacker creates two files: spritesheet.png and spritesheet.xml. You just copy them into your project.
Then you add this code to one of your classes.
private static var gameTextureAtlas:TextureAtlas;
[Embed(source="../media/graphics/mySpriteSheet.png")]
public static const AtlasTextureGame:Class;
[Embed(source="../media/graphics/mySpritesheet.xml", mimeType="application/octet-stream")]
public static const AtlasXmlGame:Class;
public static function getAtlas():TextureAtlas
{
if(gameTextureAtlas==null)
{
var texture:Texture=getTexture("AtlasTextureGame");
var xml:XML=XML(new AtlasXmlGame());
gameTextureAtlas=new TextureAtlas(texture,xml);
}
return gameTextureAtlas;
}
Now you can access all the textures of the spritesheet by calling
YourClass.getAtlas().getTexture("name");
It's simply awesome. When you're using texturepacker the filename of each of the sprites you bundled into the spritesheet becomes its texturename.
This is probably too late to help you, but I hope that future visitors can profit from this elegant solution.
I would like to emphasize that this answer is basically an excerpt from sharma's tutorial. I even felt free to reproduce the code he used in his screencast. All the credit goes to him
It depends how big your individual images are but you could put them all in one image like a spritesheet. If you want to draw a particular ship use the correct xy offset in the image for that ship and use copyPixels to draw it to your bitmap.
package
{
public final class Resource
{
[Embed (source="/assets/ships/1.gif" )]
public static const SHIPS_1:Class;
}
}
[Embed (source="/assets/ships/1.gif" )]
public static const SHIPS_1:Class;
I like to do my Library classes like this.
I took GSkinners code for the singleton: http://gskinner.com/blog/archives/2006/07/as3_singletons.html
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
public class Lib
{
/*
Make this an Singleton, so you only load all the images only Once
*/
private static var instance:Lib;
public static function getInstance():Lib {
if (instance == null) {
instance = new Lib(new SingletonBlocker());
}
return instance;
}
public function Lib(p_key:SingletonBlocker):void {
// this shouldn't be necessary unless they fake out the compiler:
if (p_key == null) {
throw new Error("Error: Instantiation failed: Use Singleton.getInstance() instead of new.");
}
}
/*
The actual embedding
*/
[Embed(source="assets/images/someImage.png")]
private var ImageClass:Class;
private var _imageClass:Bitmap = new ImageClass() as Bitmap;
[Embed(source="assets/images/someOtherImage.png")]
private var OtherImageClass:Class;
private var _otherImageClass:Bitmap = new ImageClass() as Bitmap;
public function get imgClass():Bitmap{
return _imageClass;
}
public function get imgClassData():BitmapData{
return _imageClass.BitmapData;
}
public function get otherImageClass():Bitmap{
return _otherImageClass;
}
public function get otherImageClassData():BitmapData{
return _otherImageClass.BitmapData;
}
}
}
internal class SingletonBlocker {}
[Embed (source="/assets/images/123.png" )]
public static const className:Class;
Good idea, lhk
That is nice solution like Source-Engine with vtf and vmt
vtf = image
vmt = script ( like xml or javascript )
Good i would like to suggest for TexturePacker, TexturePath or TextureTarget :P
Thanky ou for tip.
For example:
mytexture.js:
xml or javascript:
function mytexture(){ basedir = "/assets/mytexture.png", normalmap =
"/assets/mytexture_bump.png", normalcube ) [ 1, 1, 1 ] };
I don't think because default texture gets error somewhere mytexture.png doesn't exists than it happens again :)
[Embed(source="../assets/editors/error_texture.png")] public static
const ERROR_TEX:Class; ...
How do i know because Actionscript 3 should "read" to javascript like jsBirdge or ExternalInterface.call();
Is it possible?