//>>built
define("doh/plugins/android-webdriver-robot",["dojo/has","dojo/_base/xhr","doh/runner","dojo/sniff","dojo/dom-geometry","doh/plugins/remoteRobot"],function(_1,_2,_3,_4,_5,_6){var _7=window.parent?window.parent:window;var _8=[];var _9=false;function _a(_b){var _c=_b.commandString;var _d=_b.deferred;var _e=_b.immediate;if(_e||!_9){_9=true;_2(_b.method,{url:_6+"/"+_c,headers:{"Content-Type":"application/json"},postData:_b.postData,load:function(_f){_9=false;if(_d){_d.callback(_f);}if(_8.length){_a(_8.shift());}},error:function(_10){console.error("failure sending webdriver command: ",_10);}});}else{_8.push(_b);}};var _11=0;var _12=0;var _13=null;var _14={};if(window["dojo"]){_14[dojo.keys.END]=57360;_14[dojo.keys.HOME]=57361;_14[dojo.keys.LEFT_ARROW]=57362;_14[dojo.keys.UP_ARROW]=57363;_14[dojo.keys.RIGHT_ARROW]=57364;_14[dojo.keys.DOWN_ARROW]=57365;_14[dojo.keys.F1]=57393;_14[dojo.keys.F2]=57394;_14[dojo.keys.F3]=57395;_14[dojo.keys.F4]=57396;_14[dojo.keys.F5]=57397;_14[dojo.keys.F6]=57398;_14[dojo.keys.F7]=57399;_14[dojo.keys.F8]=57400;_14[dojo.keys.F9]=57401;_14[dojo.keys.F10]=57402;_14[dojo.keys.F11]=57403;_14[dojo.keys.F12]=57404;}var _15={node:null,reference:""};_robot={_setKey:function(sec){_3.robot._onKeyboard();},_callLoaded:function(sec){},_initKeyboard:function(sec){},_initWheel:function(sec){},setDocumentBounds:function(sec,_16,_17,_18,_19){},_spaceReceived:function(){},_notified:function(sec,_1a){},_nextKeyGroupACK:function(sec){},typeKey:function(sec,_1b,_1c,alt,_1d,_1e,_1f,_20,_21){var _22=new dojo.Deferred();_22.then(function(_23){_23=_23.replace(/\{/g,"({").replace(/\}/g,"})");_23=_23.replace(/[^ -~]/g,"");var _24=dojo.fromJson(_23);var _25=_24.value.ELEMENT;var _26=(_1d?"\""+String.fromCharCode(dojo.keys.CTRL)+"\",":"")+(_1e?"\""+String.fromCharCode(dojo.keys.SHIFT)+"\",":"");if(_1c in _14){_26+="\""+String.fromCharCode(_14[_1c])+"\"";}else{if(_1c){_26+="\""+String.fromCharCode(_1c)+"\"";}else{_26+="\""+String.fromCharCode(_1b)+"\"";}}_a({method:"POST",commandString:"element/"+_25+"/value",postData:"{\"value\":["+_26+"]}",deferred:null,immediate:false});});_a({method:"POST",commandString:"execute",postData:"{\"script\":\"return document.activeElement;\",\"args\":[]}",deferred:_22,immediate:false});},upKey:function(sec,_27,_28,_29){},downKey:function(sec,_2a,_2b,_2c){},moveMouse:function(sec,x,y,_2d,_2e){x=Math.round(x);y=Math.round(y);if(!_13){_13=dojo.doc.createElement("div");dojo.style(_13,{position:"fixed",left:"0px",top:"0px",width:"5px",height:"5px","background-color":"red"});dojo.body().appendChild(_13);}_11=x-_7.scrollX;_12=y-_7.scrollY;_13.style.left=(x+5)+"px";_13.style.top=(y+5)+"px";_a({method:"POST",commandString:"touch/move",postData:"{\"x\":"+_11+",\"y\":"+_11+"}",deferred:null,immediate:false});},pressMouse:function(sec,_2f,_30,_31,_32){var _33=new dojo.Deferred();_33.then(function(){_13.style.backgroundColor="yellow";});_a({method:"POST",commandString:"touch/down",postData:"{\"x\":"+(_11)+",\"y\":"+(_12)+"}",deferred:_33,immediate:false});},releaseMouse:function(sec,_34,_35,_36,_37){var _38=new dojo.Deferred();_38.then(function(){_13.style.backgroundColor="red";});_a({method:"POST",commandString:"touch/up",postData:"{\"x\":"+(_11+1)+",\"y\":"+(_12+1)+"}",deferred:_38,immediate:false});},typeKeys:function(_39,_3a,_3b){var _3c=new dojo.Deferred();_3c.then(function(_3d){_3d=_3d.replace(/\{/g,"({").replace(/\}/g,"})");_3d=_3d.replace(/[^ -~]/g,"");var _3e=dojo.fromJson(_3d);var _3f=_3e.value.ELEMENT;var _40=new dojo.Deferred();_40.then(function(){_15={node:dojo.doc.activeElement,reference:_3f};});_a({method:"POST",commandString:"element/"+_3f+"/value",postData:"{\"value\":[\""+_39+"\"]}",deferred:_40,immediate:false});});if(dojo.doc.activeElement!=_15.node){_15={node:dojo.doc.activeElement,reference:null};_a({method:"POST",commandString:"execute",postData:"{script:'return document.activeElement;',args:[]}",deferred:_3c,immediate:false});}else{_3c.callback("{value:{ELEMENT:'"+_15.reference+"'}}");}},_scrollIntoView:function(_41){p=_5.position(_41);_7.scrollTo(p.x,p.y);}};_1.add("doh-custom-robot",function(){return _1("android")&&_robot;});return _robot;});