Exemplo n.º 1
0
        public static ITogglePattern GetTogglePattern(PatternsData data)
        {
            ITogglePattern togglePattern = Substitute.For <ITogglePattern>();

            // togglePattern.Toggle().Received();
            // togglePattern.Toggle.SetDockPosition(Arg.Do<DockPosition>(pos => data.DockPattern_DockPosition = pos));
            togglePattern.Current.ToggleState.Returns(data.TogglePattern_ToggleState);
            return(togglePattern);
        }
Exemplo n.º 2
0
 public static IUiElement PerformToggle(this IUiElement element, bool on)
 {
     try {
         ITogglePattern togglePattern =
             element.GetCurrentPattern <ITogglePattern>(classic.TogglePattern.Pattern);
         if ((on && classic.ToggleState.Off == togglePattern.Current.ToggleState) ||
             !on && classic.ToggleState.On == togglePattern.Current.ToggleState)
         {
             element.GetCurrentPattern <ITogglePattern>(classic.TogglePattern.Pattern).Toggle();
         }
     }
     catch {
         // maybe, a click
     }
     return(element);
 }
Exemplo n.º 3
0
        public override void Body()
        {
            ActualResult = TestCaseResult.Failed;

            UIControlBase c = UIControlBase.FindControlByPath(_control);

            if (!c.Exists)
            {
                Log.Error("Control not found");
                return;
            }

            if (!c.Enabled)
            {
                Log.Error("Control not enabled");
                return;
            }

            ITogglePattern toggle = c.GetControlInterface <ITogglePattern>();

            if (toggle != null)
            {
                ToggleState currentState = toggle.ToggleState;

                if (currentState != _state)
                {
                    LogFailedByExpectedResult("Did not match",
                                              string.Format("The control's state was \"{0}\" instead of \"{1}\".",
                                                            currentState, _state));
                    return;
                }

                ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
            }
            else
            {
                Log.Error("The target control doesn't support toggle operations.");
                return;
            }
        }
Exemplo n.º 4
0
 public TogglePatternInformation(ITogglePattern tooglePattern, bool useCache)
 {
     _togglePattern = tooglePattern;
     _useCache = useCache;
 }
Exemplo n.º 5
0
        public override void Body()
        {
            ActualResult = TestCaseResult.Failed;

            UIControlBase c = UIControlBase.FindControlByPath(_control);

            if (!c.Exists)
            {
                Log.Error("Control not found");
                return;
            }

            if (!c.Enabled)
            {
                Log.Error("Control not enabled");
                return;
            }

            ITogglePattern toggle = c.GetControlInterface <ITogglePattern>();
            IInvokePattern invoke = c.GetControlInterface <IInvokePattern>();

            HTMLInput input = c as HTMLInput;

            if (toggle != null)
            {
                switch (_action)
                {
                case ToggleAction.On:
                    for (int i = 0; i < 3; i++)
                    {
                        if (toggle.ToggleState != ToggleState.On)
                        {
                            toggle.Toggle();
                        }
                    }

                    if (toggle.ToggleState != ToggleState.On)
                    {
                        Log.Error("Tried three times, but couldn't set the checkbox to On.");
                        return;
                    }

                    break;

                case ToggleAction.Off:
                    for (int i = 0; i < 3; i++)
                    {
                        if (toggle.ToggleState != ToggleState.Off)
                        {
                            toggle.Toggle();
                        }
                    }

                    if (toggle.ToggleState != ToggleState.Off)
                    {
                        Log.Error("Tried three times, but couldn't set the checkbox to Off.");
                        return;
                    }

                    break;

                case ToggleAction.Toggle:
                    toggle.Toggle();
                    break;
                }

                ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
            }
            else if (invoke != null)
            {
                if (_action != ToggleAction.Toggle)
                {
                    Log.Error("The target control only supports invoke operations. Try toggle action instead.");
                    return;
                }

                switch (_action)
                {
                case ToggleAction.On:
                case ToggleAction.Off:
                    Log.Error("The target control only supports invoke operations. Try toggle action instead.");
                    return;

                case ToggleAction.Toggle:
                    invoke.Invoke();
                    break;
                }

                ActualResult = TestCaseResult.Passed;
            }
            else if (input != null)
            {
                switch (_action)
                {
                case ToggleAction.Toggle:
                    input.Click();
                    break;

                case ToggleAction.On:
                    if (!input.Checked)
                    {
                        input.Click();
                    }

                    break;

                case ToggleAction.Off:
                    if (input.Checked)
                    {
                        input.Click();
                    }

                    break;
                }

                ActualResult = TestCaseResult.Passed;
            }
            else
            {
                Log.Error("Couldn't find an appropriate way to toggle the control.");
                ActualResult = TestCaseResult.Failed;
            }
        }
Exemplo n.º 6
0
 public TogglePatternInformation(ITogglePattern tooglePattern, bool useCache)
 {
     _togglePattern = tooglePattern;
     _useCache      = useCache;
 }