Exemplo n.º 1
0
        /// -------------------------------------------------------------------
        /// <summary>Changes the position to a new random position if the two are the same</summary>
        /// -------------------------------------------------------------------
        private void VerifyNotSame(ref double positionToChange, string positionToChangeStr, double otherPosition, string otherPositionStr, ArrayList validPositions, ScrollDirection scrollDirection, double min, double max, RandomBoundaries boundaries, CheckType checkType)
        {
            if (positionToChange.Equals(otherPosition))  
            {
                if (validPositions.Count < 4)
                    ThrowMe(CheckType.IncorrectElementConfiguration, validPositions.Count.ToString() + " valid scroll positions, not enough for test (4 minimum). Is your display resolution set too low?");

                for (int i = 0; i < 10 && (positionToChange.Equals(otherPosition)); i++)
                {
                    Comment("\"{0}\"({1}) and \"{2}\"({3}) were found to be the same. Find a new \"{0}\"", positionToChange, positionToChangeStr, otherPosition, otherPositionStr);

                    // false says don't incremenet m_TestStep TSC_RandomPosition
                    positionToChange = TSC_RandomPosition(scrollDirection, min, max, boundaries, false, checkType);
                }
                if (positionToChange.Equals(otherPosition))
                    ThrowMe(CheckType.Verification, "Cannot find a random \"{0}\" position", positionToChangeStr);

                Comment("Found new \"{0}\" position : {1}", positionToChangeStr, positionToChange);
            }
        }
Exemplo n.º 2
0
        double TSC_RandomPosition(ScrollDirection direction, double min, double max, RandomBoundaries rb, bool increment, CheckType ct)
        {
            string str = "Looking for a position ";
            switch (rb)
            {
                case RandomBoundaries.between:
                    str += "between " + min + " and " + max;
                    break;
                case RandomBoundaries.CanIncludeBoth:
                    str += "between and including " + min + " and " + max;
                    break;
                case RandomBoundaries.CanIncludeLower:
                    str += "greater than or equal to " + min + " and less than " + max;
                    break;
                case RandomBoundaries.CanIncludeUpper:
                    str += "greater than " + min + " and less than or equal to " + max;
                    break;
                default:
                    throw new Exception("Unhandled argument");
            }

            //Comment (str);

            if (min < 0 || max < 0 || min > _HUNDRED || max > _HUNDRED)
                return _NOSCROLL;

            switch (direction)
            {
                case ScrollDirection.Horizontal:
                    if (_validHPositions.Count.Equals(0))
                    {
                        if (increment)
                            m_TestStep++;
                        return _ZERO; // ZZZ NoScroll;
                    }
                    else
                        MinMaxPosition(ref this._validHPositions, ref min, ref max);
                    break;
                case ScrollDirection.Vertical:
                    if (_validVPositions.Count.Equals(0))
                    {
                        if (increment)
                            m_TestStep++;
                        return _ZERO; // ZZZ NoScroll;
                    }
                    else
                        MinMaxPosition(ref this._validVPositions, ref min, ref max);
                    break;
            }

            switch (rb)
            {
                case RandomBoundaries.between:
                    if (min == double.MaxValue)
                        throw new Exception("Cannot increase min past" + double.MaxValue);
                    else
                        min++;

                    if (max == double.MinValue)
                        throw new Exception("Cannot decrease max past " + double.MinValue);
                    else
                        max--;

                    break;
                case RandomBoundaries.CanIncludeBoth:
                    break;
                case RandomBoundaries.CanIncludeLower:
                    max--;
                    break;
                case RandomBoundaries.CanIncludeUpper:
                    min++;
                    break;
            }

            if (min > max)
                ThrowMe(ct, str + " : There are no scrollable positions that meet the criteria");

            // Is a scrollbar going to be larger thant 32K positions?  Nah????
            int val = (int)Helpers.RandomValue((int)min, (int)max + 1);

            switch (direction)
            {
                case ScrollDirection.Horizontal:
                    Comment("Found " + _validHPositions[val]);

                    if (increment)
                        m_TestStep++;

                    return (double)_validHPositions[val];

                case ScrollDirection.Vertical:
                    Comment("Found " + _validVPositions[val]);

                    if (increment)
                        m_TestStep++;

                    return (double)_validVPositions[val];

                default:
                    throw new Exception("Argument not handled");
            }
        }