public void MultiActionTestCase()
        {
            IOSDriver <IWebElement> driver  = new IOSDriver <IWebElement>(defaultUri, capabilities);
            RequestProcessor        re      = setupMultiAction();
            IWebElement             element = driver.FindElementByIosUIAutomation(".elements()");

            MultiAction m = new MultiAction(driver);

            m.Perform();
            Assert.AreEqual(re.inputData, "");

            TouchAction a1 = new TouchAction(driver);

            a1
            .Press(element, 100, 100)
            .Wait(1000)
            .Release();
            m.Add(a1);
            m.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}]]}");

            TouchAction a2 = new TouchAction(driver);

            a2
            .Tap(100, 100)
            .MoveTo(element);
            m.Add(a2);
            m.Perform();
            Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}],[{\"action\":\"tap\",\"options\":{\"x\":100,\"y\":100}},{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]]}");
        }
Example #2
0
        private void onMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (this.action == null)
                {
                    this.action = new MultiAction("Eraser");
                }

                int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16);
                int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16);

                if (xt != lxt || yt != lyt)
                {
                    int tilesetIndex = TileEditorState.Instance.SelectedTileset;

                    MockupTile t = EditorEngine.Instance.CurrentMap.GetTile(xt, yt, EditorEngine.Instance.SelectedLayer);

                    if (t != null)
                    {
                        SetTileAction tileAction = new SetTileAction(xt, yt, EditorEngine.Instance.SelectedLayer, tilesetIndex, -1);
                        tileAction.Execute();

                        action.Actions.Add(tileAction);
                    }
                }

                lxt = xt;
                lyt = yt;
            }
        }
Example #3
0
        /// <summary>
        /// 事务操作
        /// </summary>
        public void TranstionDemo()
        {
            MultiAction actions = new MultiAction();

            for (int i = 0; i < 10; i++)
            {
                if (i % 4 == 0)
                {
                    DeleteAction delete = new DeleteAction(Entity);
                    delete.Cast <cms_user>().Where(u => u.username == "wangjun");
                    actions.AddAction(delete);
                }
                if (i % 4 == 1)
                {
                    UpdateAction update = new UpdateAction(Entity);
                    update.Cast <cms_user>()
                    .Where(u => u.username == "wangjun")
                    .UnCast()
                    .SqlKeyValue(cms_user.Columns.password, "1234567");
                    actions.AddAction(update);
                }
            }
            try
            {
                actions.Commit();
            }
            catch (Exception)
            {
                actions.Rollback();
            }
        }
Example #4
0
 /**
  * @inheritDoc
  */
 public override void clear()
 {
     this._isFinish     = true;
     this._rootAction   = null;
     this._parentAction = null;
     base.clear();
 }
Example #5
0
 public virtual TriggerGroupAction init(Dictionary <string, object> data, PersonEntity player)
 {
     this._data     = data;
     this._player   = player;
     this._triggers = new MultiAction(this._map);
     return(this);
 }
        public void SequentalMultiActionTestCase()
        {
            string originalActivity      = driver.CurrentActivity;
            IList <AppiumWebElement> els = driver.FindElementsByClassName("android.widget.TextView");
            MultiAction multiTouch       = new MultiAction(driver);

            TouchAction tap1 = new TouchAction(driver);

            tap1.Press(els[5]).Wait(1500).Release();

            multiTouch.Add(tap1).Add(tap1).Perform();

            Thread.Sleep(2500);
            els = driver.FindElementsByClassName("android.widget.TextView");

            TouchAction tap2 = new TouchAction(driver);

            tap2.Press(els[1]).Wait(1500).Release();

            MultiAction multiTouch2 = new MultiAction(driver);

            multiTouch2.Add(tap2).Add(tap2).Perform();

            Thread.Sleep(2500);
            Assert.AreNotEqual(originalActivity, driver.CurrentActivity);
        }
Example #7
0
 private void onMouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         EditorEngine.Instance.GetActionManager().Execute(this.action);
         this.action = null;
     }
 }
Example #8
0
        private void onMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (action == null)
            {
                action = new MultiAction("Tile Update");
            }

            int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16);
            int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16);

            if (xt != lxt || yt != lyt)
            {
                if (TileEditorState.Instance.SelectedRegion != Rectangle.Empty)
                {
                    MultiAction multiAction = new MultiAction("Tile Update");
                    Rectangle   selection   = TileEditorState.Instance.SelectedRegion;

                    for (int x = 0; x < selection.Width; x++)
                    {
                        for (int y = 0; y < selection.Height; y++)
                        {
                            int currentX = selection.X + x;
                            int currentY = selection.Y + y;

                            int tilesetIndex = TileEditorState.Instance.SelectedTileset;

                            Tileset tilesheet = EditorEngine.Instance.CurrentMap.Tilesets[tilesetIndex].Tileset;
                            int     tileIndex = tilesheet.Texture.GetIndex(currentX, currentY);

                            int        zt = EditorEngine.Instance.SelectedLayer;
                            MockupTile t  = EditorEngine.Instance.CurrentMap.GetTile(xt + x, yt + y, zt);

                            if (t == null)
                            {
                                continue;
                            }

                            SetTileAction tileAction = new SetTileAction(
                                xt + x, yt + y,
                                zt,
                                tilesetIndex,
                                tileIndex);
                            multiAction.Actions.Add(tileAction);
                        }
                    }

                    multiAction.Execute();
                    action.Actions.Add(multiAction);
                }
            }

            lxt = xt;
            lyt = yt;
        }
Example #9
0
 public virtual TriggerAction initTrigger(int interval, int totalTime, Dictionary <string, object> triggerData, PersonEntity person, PersonEntity lockTarget = null)
 {
     this.lockTarget   = lockTarget;
     this._mutilAction = new MultiAction(this._map);
     this._triggerData = triggerData;
     this._person      = person;
     this._cdTime      = new TimeAction(this._map).init(interval);
     return((TriggerAction)this.init(totalTime));
 }
Example #10
0
 public void onMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         action = new MultiAction("Logic Pencil");
         temp   = new MultiAction("customary rape action");
         processDraw(e);
     }
 }
Example #11
0
        /// <summary>
        /// Perform the multi action
        /// </summary>
        /// <param name="multiAction">multi action to perform</param>
        public void PerformMultiAction(MultiAction multiAction)
        {
            if (null == multiAction)
            {
                return; // do nothing
            }

            var parameters = multiAction.GetParameters();
            this.Execute(AppiumDriverCommand.MultiActionV2Perform, parameters);
        }
        /// <summary>
        /// Convenience method for tapping the center of an element on the screen
        /// </summary>
        /// <param name="fingers">number of fingers/appendages to tap with</param>
        /// <param name="element">element to tap</param>
        /// <param name="duration">how long between pressing down, and lifting fingers/appendages</param>
        public void Tap(int fingers, IWebElement element, int duration)
        {
            MultiAction multiTouch = new MultiAction(this);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(CreateTap(element, duration));
            }

            multiTouch.Perform();
        }
        public void Tapxy(IPerformsTouchActions multitouchPerformer, int fingers, int x, int y)
        {
            MultiAction multiTouch = new MultiAction(multitouchPerformer);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(new TouchAction(multitouchPerformer).Tap(x, y));
            }

            multiTouch.Perform();
        }
        public void Tap(IPerformsTouchActions multitouchPerformer, int fingers, IWebElement webElement)
        {
            MultiAction multiTouch = new MultiAction(multitouchPerformer);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(new TouchAction(multitouchPerformer).Tap(webElement));
            }

            multiTouch.Perform();
        }
        public void Tap(int fingers, int x, int y, int duration)
        {
            MultiAction multiTouch = new MultiAction(this);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(new TouchAction(this).Press(x, y).Wait(duration).Release());
            }

            multiTouch.Perform();
        }
        /// <summary>
        /// Convenience method for tapping a position on the screen
        /// </summary>
        /// <param name="fingers">number of fingers/appendages to tap with</param>
        /// <param name="x">x coordinate</param>
        /// <param name="y">y coordinate</param>
        /// <param name="duration">how long between pressing down, and lifting fingers/appendages</param>
        public void Tap(int fingers, int x, int y, int duration)
        {
            MultiAction multiTouch = new MultiAction(this);

            for (int i = 0; i < fingers; i++)
            {
                multiTouch.Add(CreateTap(x, y, duration));
            }

            multiTouch.Perform();
        }
Example #17
0
        private void PerformMoves()
        {
            MultiAction ma = new MultiAction();

            foreach (PlayerDeclareMoveAttackEvent evt in this.moveAttackDeclaration.Values)
            {
                MovePathAction mpa = evt.MoveAction;
                ma.AddAction(mpa);
            }
            ma.Resolved += (sender, maEvt) => SkipToPhase(Phases.React, this.playersTurn);
            this.ActionManager.Queue(ma);
        }
Example #18
0
        private void processDraw(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                int  _size = FrmLogicTileSelector.Instance.size;
                bool odd   = _size % 2 == 0;

                int xt = (int)((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16);
                int yt = (int)((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16);

                if (xt != lxt || yt != lyt)
                {
                    changed = true;
                }

                lxt = xt;
                lyt = yt;

                if (changed)
                {
                    int l_index = FrmLogicTileSelector.Instance.CurrentLogicIndex;

                    int x0 = xt - (int)Math.Floor((double)_size / 2);
                    int y0 = yt - (int)Math.Floor((double)_size / 2);
                    int x1 = xt + (int)Math.Floor((double)_size / 2);
                    int y1 = yt + (int)Math.Floor((double)_size / 2);

                    MultiAction act = new MultiAction();

                    for (int y = y0; !odd ? (y <= y1) : (y < y1); y++)
                    {
                        for (int x = x0; !odd ? (x <= x1) : (x < x1); x++)
                        {
                            act.Actions.Add(new LogicSetAction(x, y, l_index));
                        }
                    }

                    act.Execute();
                    temp.Actions.Add(act);

                    foreach (IAction ia in act.Actions)
                    {
                        LogicSetAction i = ia as LogicSetAction;
                        i.FillList();
                        foreach (IAction ia2 in i.Actions)
                        {
                            action.Actions.Add(ia2);
                        }
                    }
                }
            }
            changed = false;
        }
        public void CheckTap(IPerformsTouchActions performer)
        {
            TouchAction t = new TouchAction(performer);

            t.Tap(accessibility);
            t.Perform();

            MultiAction m = new MultiAction(performer);

            m.Add(new TouchAction().Tap(customView));
            m.Add(new TouchAction(performer).Tap(clickable));
            m.Perform();
        }
Example #20
0
        public void CheckTap(IPerformsTouchActions performer)
        {
            var t = new TouchAction(performer);

            t.Tap(_accessibility);
            t.Perform();

            var m = new MultiAction(performer);

            m.Add(new TouchAction(performer).Tap(_customView));
            m.Add(new TouchAction(performer).Tap(_clickable));
            m.Perform();
        }
Example #21
0
 public void checkDead()
 {
     if (this._data.ContainsKey("dead"))
     {
         MultiAction deadAction = new MultiAction(this._map);
         object[]    deadData   = (object[])this._data["dead"];
         for (int i = 0, len = deadData.Length; i < len; i++)
         {
             deadAction.addAction(new SkillAction(this._map).init((Dictionary <string, object>)deadData[i], this._player));
         }
         this._player.addAction(deadAction);
     }
 }
Example #22
0
        public void MultiActionTestCase()
        {
            IWebElement  el = driver.FindElementByAccessibilityId("ComputeSumButton");
            ITouchAction a1 = new TouchAction(driver);

            a1.Tap(el, 10, 10);
            ITouchAction a2 = new TouchAction(driver);

            a2.Tap(el);
            IMultiAction m = new MultiAction(driver);

            m.Add(a1).Add(a2);
            m.Perform();
        }
Example #23
0
 public override void setData(Dictionary <string, object> data)
 {
     base.setData(data);
     this._isFinish   = Convert.ToBoolean(data["isFinish"]);
     this._cannelFlag = Convert.ToBoolean(data["cannelFlag"]);
     this._isStart    = Convert.ToBoolean(data["isStart"]);
     if (data.ContainsKey("rootAction"))
     {
         this._rootAction = (ActionManager)this._map.getNetObject((int)(data["rootAction"]));
     }
     if (data.ContainsKey("parentAction"))
     {
         this._parentAction = (MultiAction)this._map.getNetObject((int)(data["parentAction"]));
     }
 }
Example #24
0
        private void PerformAttacks()
        {
            MultiAction ma = new MultiAction();

            foreach (PlayerDeclareMoveAttackEvent evt in this.moveAttackDeclaration.Values)
            {
                AttackUnitAction aua = evt.AttackAction;
                if (evt.AttackUnit != null)
                {
                    ma.AddAction(evt.Entity, aua);
                }
            }
            ma.Resolved += (sender, maEvt) => SkipToPhase(Phases.EndCombat, this.playersTurn);
            this.ActionManager.Queue(ma);
        }
 public override void start()
 {
     //对于魔法 有些是立刻执行的 填写skill 有些是通过触发器执行的。 在live.triggers里面。
     if (this._data.ContainsKey("skill"))
     {
         object[]    skillData   = (object[])this._data["skill"];
         MultiAction multiAction = new MultiAction(this._map);
         for (int i = 0, len = skillData.Length; i < len; i++)
         {
             multiAction.addAction(new SkillAction(this._map).init((Dictionary <string, object>)skillData[i], this._player));
         }
         this.addAction(multiAction);
     }
     base.start();
 }
        /// <summary>
        /// Convenience method for "zooming in" on an element on the screen.
        /// "zooming in" refers to the action of two appendages Pressing the screen and sliding away from each other.
        /// NOTE:
        /// driver convenience method slides touches away from the element, if driver would happen to place one of them
        /// off the screen, appium will return an outOfBounds error. In driver case, revert to using the MultiAction api
        /// instead of driver method.
        /// <param name="el">The element to pinch</param>
        /// </summary>
        public void Zoom(IWebElement el)
        {
            MultiAction multiTouch = new MultiAction(this);

            Size  dimensions = el.Size;
            Point upperLeft  = el.Location;
            Point center     = new Point(upperLeft.X + dimensions.Width / 2, upperLeft.Y + dimensions.Height / 2);
            int   yOffset    = center.Y - upperLeft.Y;

            ITouchAction action0 = new TouchAction(this).Press(el).MoveTo(el, 0, -yOffset).Release();
            ITouchAction action1 = new TouchAction(this).Press(el).MoveTo(el, 0, yOffset).Release();

            multiTouch.Add(action0).Add(action1);

            multiTouch.Perform();
        }
        public void SingleMultiActionTestCase()
        {
            IList <AppiumWebElement> els = driver.FindElementsByClassName("android.widget.TextView");
            var loc1 = els[7].Location;
            AppiumWebElement target = els[1];
            var loc2 = target.Location;

            TouchAction swipe = new TouchAction(driver);

            swipe.Press(loc1.X, loc1.Y).Wait(1000)
            .MoveTo(loc2.X, loc2.Y).Release();

            MultiAction multiAction = new MultiAction(driver);

            multiAction.Add(swipe).Perform();
            Assert.AreNotEqual(loc2.Y, target.Location.Y);
        }
Example #28
0
        public virtual void SwipeToDelete(string automationId, int index)
        {
            var item  = Driver.FindElement(ByAutomationId(automationId));
            var width = Driver.Manage().Window.Size.Width;

            var act   = new TouchAction(Driver);
            var press = act.Press(item, width, item.Location.Y);
            var move  = act.MoveTo(item, 0, item.Location.Y);
            var lift  = act.Release();

            var action = new MultiAction(Driver);

            action.Add(press);
            action.Add(move);
            action.Add(lift);
            action.Perform();
        }
Example #29
0
        public void onMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //action.UnExecute();
                temp.UnExecute();
                EditorEngine.Instance.GetActionManager().Execute(action);
                foreach (SetTileAction a in action.Actions)
                {
                    Map map = EditorEngine.Instance.CurrentMap;

                    MockupTileBehavior b = map.GetBehavior(a.X, a.Y);
                    b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId;
                }
                action = null;
                temp   = null;
            }
        }
 public static void Unshare(string shareWith)
 {
     try
     {
         AndroidElement dragItem = (AndroidElement)ShareWithList.GetInternalElement().FindElementByName(shareWith);
         AndroidElement dropItem = TeamList.GetInternalElement();
         TouchAction    action   = new TouchAction(Appium.Instance.Driver);
         action.Press(dragItem).Wait(1500).MoveTo(dragItem).Wait(1500).MoveTo(dropItem).Wait(1500).Release();
         MultiAction multi = new MultiAction(Appium.Instance.Driver);
         multi.Add(action).Perform();
         ConsoleMessage.Pass(String.Format("{0}. Unshare. Drag user with name: {1} and drop to team", ActivityName, shareWith));
     }
     catch (Exception ex)
     {
         ConsoleMessage.Fail(String.Format("{0}. Can't unshare. Can't drag user with name: {1} and drop to team", ActivityName, shareWith), ex);
         throw;
     }
 }
 protected Transaction(ActionManager actionManager, bool delayed) : base(actionManager, delayed)
 {
     _accumulatingAction = new MultiAction();
 }