Esempio n. 1
0
        public static Task <bool> Swipe(int mobileIndex, int x1, int y1, int x2, int y2, int steps)
        {
            string mobileId = DeviceConnectionManager.Instance.GetDeviceNameByMobileIndex(mobileIndex);

            return(Task.Run(() =>
            {
                if (string.IsNullOrEmpty(mobileId))
                {
                    return false;
                }
                else
                {
                    ProcessUtils.AdbSwipe(mobileId, x1, y1, x2, y2);

                    return true;
                }
            }));

            #region uitest implementation
            //int taskNum = Guid.NewGuid().GetHashCode();

            //var task = new SimulationTask<bool>(taskNum, TimeoutMilliseconds);

            //if (SimulationTaskManager.RegisterSingle(task))
            //{
            //    var obj = new JObject()
            //    {
            //        {"tasktype",(int)TaskType.Swipe },
            //        {"txtmsg","" },
            //    };

            //    var list = new JArray();
            //    list.Add($"{x1}");
            //    list.Add($"{y1}");
            //    list.Add($"{x2}");
            //    list.Add($"{y2}");
            //    list.Add($"{steps}");

            //    obj.Add("list", list);

            //    SocketServer.SendTaskInstruct(mobileIndex, (int)TaskType.Swipe, taskNum, obj.ToString(Newtonsoft.Json.Formatting.None));

            //    return task.Task as Task<bool>;
            //}

            //return Task.FromResult(false);
            #endregion
        }