예제 #1
0
 public void Clear()
 {
     RecordedActions.Clear();
 }
예제 #2
0
 public void Record(UserAction userAction)
 {
     RecordedActions.Add(userAction);
 }
예제 #3
0
        /// <summary>
        /// Remove Automation listener from all objects.
        /// </summary>
        public static void AutomationRelevantActionTaken(AutomationListener listener)
        {
            List <Component> components = listener.gameObject.GetComponents <Component>().ToList();

            //Ignore if no components.
            if (!components.Any())
            {
                return;
            }

            RecordedGameObjectData data = new RecordedGameObjectData();;

            data.Name = listener.gameObject.name.Replace("(Clone)", string.Empty);
            KeyValuePair <string, List <string> > parents = GetTopLevelParentObject(listener.gameObject);

            data.ParentNames        = parents.Value;
            data.TopLevelParentName = parents.Key;
            data.Tag = listener.gameObject.tag;
            data.Components.Add("GameObject");
            data.Components.AddRange(listener.gameObject.GetComponents <Component>().ToList().ToListOfNames());
            data.AsComponent = data.Components.FindIndexOf("GameObject");

            List <KeyValuePair <Type, ActableTypes> > matches = GameSpecificActableTypes.FindAll(x => data.Components.Contains(x.Key.Name));

            Button b = listener.gameObject.GetComponent <Button>();
            Toggle t = listener.gameObject.GetComponent <Toggle>();

            if (b != null || t != null || matches.FindAll(x => x.Value == ActableTypes.Clickable).Any())
            {
                if (b != null)
                {
                    data.AsComponent = data.Components.FindIndexOf("Button");
                }
                else if (t != null)
                {
                    data.AsComponent = data.Components.FindIndexOf("Toggle");
                }
                else
                {
                    data.AsComponent = data.Components.FindIndexOf(matches.Find(x => x.Value == ActableTypes.Clickable).Key.Name);
                }
                data.ID     = CurrentStepID++;
                data.Action = ActableTypes.Clickable;
                RecordedActions.Add(data);
                return;
            }

            if (components.FindAll(z => z.GetType().Name.ToLower().ContainsOrEquals("collider")).Any())
            {
                data.ID     = CurrentStepID++;
                data.Action = ActableTypes.Clickable;
                RecordedActions.Add(data);
                return;
            }

            ScrollRect sr = listener.gameObject.GetComponent <ScrollRect>();

            if (sr != null || matches.FindAll(x => x.Value == ActableTypes.Scroll).Any())
            {
                if (sr != null)
                {
                    data.AsComponent = data.Components.FindAll(x => x == "ScrollRect").Any() ? data.Components.FindIndexOf("ScrollRect") : data.Components.FindIndexOf("ScrollRectEx");
                }
                else
                {
                    data.AsComponent = data.Components.FindIndexOf(matches.Find(x => x.Value == ActableTypes.Scroll).Key.Name);
                }

                data.ID     = CurrentStepID++;
                data.Action = ActableTypes.Scroll;
                data.InitialScrollPosition = sr.verticalScrollbar == null ? (sr.horizontalScrollbar == null ? 0 : sr.horizontalScrollbar.value) : sr.verticalScrollbar.value;
                data.Duration = 1;
                RecordedActions.Add(data);
                return;
            }

            InputField i = listener.gameObject.GetComponent <InputField>();

            if (i != null || matches.FindAll(x => x.Value == ActableTypes.Input).Any())
            {
                data.AsComponent = data.Components.FindIndexOf("InputField");
                data.ID          = CurrentStepID++;
                data.Action      = ActableTypes.Input;
                RecordedActions.Add(data);
                return;
            }

            for (int a = 0; a < GameMaster.AdditionalAssetsAll.Count; a++)
            {
                Component c = listener.gameObject.GetComponent(GameMaster.AdditionalAssetsAll[a].Key.Name);
                if (c != null || matches.FindAll(x => x.Value == GameSpecificActableTypes[a].Value).Any())
                {
                    data.AsComponent = data.Components.FindIndexOf(GameMaster.AdditionalAssetsAll[a].Key.Name);
                    data.ID          = CurrentStepID++;
                    data.Action      = ActableTypes.Input;
                    RecordedActions.Add(data);
                    return;
                }
            }

            for (int ty = 0; ty < GameSpecificActableTypes.Count; ty++)
            {
                Component c = listener.gameObject.GetComponent(GameSpecificActableTypes[ty].Key.Name);
                if (c != null || matches.FindAll(x => x.Value == GameSpecificActableTypes[ty].Value).Any())
                {
                    data.AsComponent = data.Components.FindIndexOf(GameSpecificActableTypes[ty].Key.Name);
                    data.ID          = CurrentStepID++;
                    data.Action      = ActableTypes.Input;
                    RecordedActions.Add(data);
                    return;
                }
            }

            /*TODO: Update around text clickable for floating assertions.
             * Text txt = listener.gameObject.GetComponent<Text>();
             * TMPro.TextMeshProUGUI tmp = listener.gameObject.GetComponent<TMPro.TextMeshProUGUI>();
             * if(txt != null || tmp != null) {
             *
             * data.AsComponent = txt != null ? data.Components.FindIndexOf("Text") : data.Components.FindIndexOf("TextMeshProUGUI");
             * data.ID = CurrentStepID++;
             * data.Action = ActableTypes.TextForAssert;
             * RecordingAssertionData assert = new RecordingAssertionData(CurrentAssertionID++);
             * assert.Type = AssertionType.IsTrue;
             * assert.AssertionIsTrue = AssertionIsTrue.TextContainsOrEquals;
             * RecordedActions.Add(data);
             * return;
             *
             * }
             */
        }
예제 #4
0
 public static void RemoveActionAt(int index)
 {
     RecordedActions.RemoveAt(index);
 }
예제 #5
0
 public static void AddActionAtIndex(RecordedGameObjectData data, int index)
 {
     data.ID         = CurrentStepID++;
     RecordedActions = RecordedActions.AddAt(index, data);
 }
예제 #6
0
 //Add existing assertion to step.
 public static void AddAssertionToActionId(int id, RecordingAssertionData assertion)
 {
     assertion.ID = CurrentAssertionID++;
     RecordedActions.Find(x => x.ID == id).Assertions.Add(assertion);
 }
예제 #7
0
 public static void AddAction(RecordedGameObjectData data)
 {
     data.ID = CurrentStepID++;
     RecordedActions.Add(data);
 }