예제 #1
0
        internal static void Main(string[] args)
        {
            Stopwatch watch = Stopwatch.StartNew();

            Ecc[] eccLevels = { Ecc.Low, Ecc.Medium, Ecc.Quartile, Ecc.High };

            int textLength      = SampleText.Length;
            int generationCount = 0;

            for (int len = 5; len <= textLength; len++)
            {
                int start = 0;
                int ll    = len;
                if (ll > 400)
                {
                    start = ll - 400;
                    ll   -= start;
                }
                foreach (Ecc ecc in eccLevels)
                {
                    EncodeText(SampleText.Substring(start, ll), ecc);
                    generationCount++;
                }
            }

            watch.Stop();
            long elapsedMs = watch.ElapsedMilliseconds;

            Console.WriteLine("Elapsed time: {0}s", elapsedMs / 1000.0);
            Console.WriteLine("Avg time for generation: {0}ms", elapsedMs / (double)generationCount);
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            if (Active)
            {
                Vector2 textSize = SampleText.Length > 0 ? SampleText.Size(TextFont) : TextSize;
                TextPosition = new Vector2(Left + TextOffset.X, Top + TextOffset.Y);


                if (IsClicked)
                {
                    if (MouseGUI.LeftIsPressed && MouseGUI.Focus != this)
                    {
                        MouseEvent.Out();
                    }
                    OnKeyboardPressed();

                    UpdatePointer(gameTime);
                }
                base.Update(gameTime);
            }

            if (Property != null)
            {
                Property.Update(gameTime);
            }
        }
예제 #3
0
        public void Execute(string updateText)
        {
            // ※下記実装は、本来 static メソッドであるべきですが、このテスト用サンプルは DBConnectionExecutor と比較出来るように、
            // インスタンスとして何らかの処理をすることをイメージしたものとなっています。

            if (string.IsNullOrEmpty(updateText))
            {
                throw new ArgumentException("updateText に Empty 文字、および null 参照 (Visual Basic の場合は Nothing) を指定することは出来ません。", "updateText");
            }

            // DB の接続文字列は、Entity Framework 標準機能により(コンストラクタに何も指定しないことで)App.config から取得して動作します。
            // このクラスの場合、そつ族文字列の名前は UnitTestSampleEntities です。
            using (var db = new UnitTestSampleEntities())
            {
                // ※ Text フィールドにインデックスがないと、大量データだととても遅くなりますね。
                var count =
                    (from row in db.SampleTexts
                     where row.Text == updateText
                     select row).Count();

                if (count > 0)
                {
                    throw new ArgumentException("データベースに既に保存されているテキストを更新することは出来ません。別の値を指定してください。", "updateText");
                }

                var newRow = new SampleText()
                {
                    Text = updateText
                };
                db.SampleTexts.Add(newRow);
                db.SaveChanges();
            } // end using (db)
        }     // end sub
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtInput.Text = SampleText.Giraffe();
         CalculateReability(this, new EventArgs());
     }
 }
예제 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.txtInput.Text = SampleText.Song();
         btnConvert_Click(this, new EventArgs());
     }
 }
예제 #6
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext    = this;
     CurrentTimeStr = "Initializing...";
     SampleText.Focus();
     Loaded += StartTimer;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         txtInput.Text = SampleText.Anything();
         btnCompress_Click(this, new EventArgs());
     }
 }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DocumentPicker.DataSource     = (new CorpusUtils()).Files();
                DocumentPicker.DataTextField  = "value";
                DocumentPicker.DataValueField = "key";
                DocumentPicker.DataBind();

                txtInput.Text = SampleText.Anything();
                btnCompress_Click(this, new EventArgs());
            }
        }
예제 #9
0
 /// <summary>
 /// Check the SampleText contains text or empty.
 /// </summary>
 private void StartTyping()
 {
     if (SampleText.Any())
     {
         textPharase.Text = SampleText;
         SampleText       = string.Empty;
     }
     else
     {
         MessageBox.Show("Hey your Test are completed.", "Done");
         DisplayStatus();
     }
 }
예제 #10
0
        protected void Page_Load(object sender, EventArgs args)
        {
            if (!Page.IsPostBack)
            {
                txtInput.Text = SampleText.Anything();

                //aeiou
                //jklmnpstw
                //Random letters
                SimpleRandomAssignment();

                Degenerate_Click(this, new EventArgs());
            }
        }
예제 #11
0
        public void ShouldReturnTotalAlphaNumbericCharsInSample()
        {
            const string SampleText = "Lorem ipsum.";
            var          samples    = new List <Sample> {
                new Sample("Test Sample", string.Empty, SampleText)
            };
            var formulas = new List <IFormula> {
                new NullFormula()
            };
            var testRunner = new TestRunner(samples, formulas);
            var result     = testRunner.Execute().First();

            Assert.AreEqual(SampleText.Count(chr => char.IsLetterOrDigit(chr)), result.AlphaNumericCharacterCount);
        }
예제 #12
0
        public override string ToString()
        {
            StringBuilder __sb    = new StringBuilder("THNotificationSpec(");
            bool          __first = true;

            if (Name != null && __isset.name)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Name: ");
                __sb.Append(Name);
            }
            if (Description != null && __isset.description)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Description: ");
                __sb.Append(Description);
            }
            if (SampleText != null && __isset.sampleText)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("SampleText: ");
                __sb.Append(SampleText.ToDebugString());
            }
            if (__isset.createdAt)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("CreatedAt: ");
                __sb.Append(CreatedAt);
            }
            __sb.Append(")");
            return(__sb.ToString());
        }
예제 #13
0
 private int GetSearchHash()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 397) ^ SampleText?.GetHashCode() ?? 5;
         hashCode = (hashCode * 397) ^ SearchFor?.GetHashCode() ?? 5;
         hashCode = (hashCode * 397) ^ TypeOfSearch.GetHashCode();
         hashCode = (hashCode * 397) ^ CaseSensitive.GetHashCode();
         hashCode = (hashCode * 397) ^ WholeWord.GetHashCode();
         hashCode = (hashCode * 397) ^ Multiline.GetHashCode();
         hashCode = (hashCode * 397) ^ Singleline.GetHashCode();
         hashCode = (hashCode * 397) ^ BooleanOperators.GetHashCode();
         hashCode = (hashCode * 397) ^ HighlightCaptureGroups.GetHashCode();
         return(hashCode);
     }
 }
예제 #14
0
        public void PrintToConsole()
        {
            int _lineWidth = LineWidth;
            int _lines     = Lines;
            var _bgColor   = Console.BackgroundColor;
            var _fgColor   = Console.ForegroundColor;

            Console.BackgroundColor = BackgroundColor;
            Console.ForegroundColor = FontColor;
            Console.WriteLine(" ".PadLeft(_lineWidth));
            int spaces = _lineWidth - SampleText.Length;

            Console.WriteLine(SampleText.PadLeft(spaces / 2 + SampleText.Length).PadRight(_lineWidth));
            foreach (int _ in Enumerable.Range(1, _lines - 2))
            {
                Console.WriteLine("".PadLeft(_lineWidth));
            }
            Console.BackgroundColor = _bgColor;
            Console.ForegroundColor = _fgColor;
        }
예제 #15
0
        /// <summary>
        /// 指定されたテキストを、Environment.EntityConnectionString プロパティで指定された接続で SampleText テーブルに保存します。
        /// ただし、指定されたテキストが既に登録されている時は例外を返します。
        /// </summary>
        /// <param name="updateText"></param>
        public void Execute(string updateText)
        {
            if (string.IsNullOrEmpty(updateText))
            {
                throw new ArgumentException("updateText に Empty 文字、および null 参照 (Visual Basic の場合は Nothing) を指定することは出来ません。", "updateText");
            }
            if (this.Environment == null)
            {
                throw new InvalidOperationException("Environment プロパティが指定されていません。Execute メソッドを実行するまえに、Environment プロパティを指定してください。");
            }
            if (string.IsNullOrWhiteSpace(this.Environment.EntityConnectionString))
            {
                throw new InvalidOperationException("Environment プロパティの EntityConnectionString プロパティが指定されていません。Execute メソッドを実行するまえに、Environment.EntityConnectionString プロパティを指定してください。");
            }

            using (var db = new UnitTestSampleModelContainer(this.Environment.EntityConnectionString))
            {
                // ※ Text フィールドにインデックスがないと、大量データだととても遅くなりますね。
                var count =
                    (from row in db.SampleTexts
                     where row.Text == updateText
                     select row).Count();

                if (count > 0)
                {
                    throw new ArgumentException("データベースに既に保存されているテキストを更新することは出来ません。別の値を指定してください。", "updateText");
                }

                var newRow = new SampleText()
                {
                    Text = updateText
                };
                db.AddToSampleTexts(newRow);
                db.SaveChanges();
            } // end using (db)
        }     // end sub
예제 #16
0
        //---------------------------------------------------------------------------
        // Helper for RangeFromPoint() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromPointHelper2(SampleText sampleText, bool isMultiLineExpected, TargetRangeType rangeType, BoundingRectangleLocation pointLocation, RangeCompare rangeCompare)
        {
            Point screenLocation;
            Rect[] boundRects = new Rect[0];
            TextPatternRange callingRange = null;
            TextPatternRange rangeFromPt = null;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLineExpected, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create range equal to <<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Scroll range into view
            // Bug 1134054: TextPatternRange.ScrollIntoView fails to scroll horizontally on edit control
            // We need to make sure we scroll off the view so we can scroll back on it.
            // Otherwise the second scrollIntoView call may be a no-op...
            Range_ScrollIntoView(callingRange, false, null, CheckType.Verification);
            TS_ScrollIntoView(callingRange, true, null, CheckType.Verification);

            // Pre-Condition Call GetBoundingRectangles() on that range
            TS_GetBoundingRectangles(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Pre-Condition Create a point <<pointLocation>> of bounding rect
            TS_CreatePoint(ref callingRange, boundRects, out screenLocation, pointLocation, CheckType.Verification);

            // Call RangeFromPoint on point without errors
            TS_RangeFromPoint(ref rangeFromPt, screenLocation, null, CheckType.Verification);

            // Verify that range returned is <<rangeCompare>>
            TS_CompareRanges(callingRange, rangeFromPt, rangeCompare, null, CheckType.Verification);
        }
예제 #17
0
        //---------------------------------------------------------------------------
        // Overloaded helper for TS_SetText
        //---------------------------------------------------------------------------
        internal void TS_SetText(SampleText sampleText, out string actualText, CheckType checkType)
        {
            // When we change the text of the pattern, any existing ranges are now invalid
            SetText(sampleText, out actualText, checkType);

            m_TestStep++;
        }
예제 #18
0
        //---------------------------------------------------------------------------
        // Helper for Move() test cases
        //---------------------------------------------------------------------------
        internal void MoveHelper2(SampleText sampleText, TargetRangeType callingRangeType, int count, int result)
        {
            int[] numberOfTextUnits = new int[((int)TextUnit.Document) + 1];
            TextUnit[] supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1];
            TextPatternRange callingRange;

            //  Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);

            // Pre-Condition Determine Count for each TextUnit in document
            TS_CountTextUnits(callingRange, supportedTextUnits, ref numberOfTextUnits);

            // Call Move(<<count>>) (N+1) times where N=# characters in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Character, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# formats in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Format, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# words in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Word, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# lines in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Line, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# paragraphs in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Paragraph, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# pages in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Page, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# document in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Document, numberOfTextUnits, callingRange, count, result, CheckType.Verification);
        }
예제 #19
0
        //---------------------------------------------------------------------------
        // Helper for GetText() test cases
        //---------------------------------------------------------------------------
        internal void GetTextHelper(SampleText sampleText, TargetRangeType callingRangeType, MaxLength maxLengthType, GetResult getResult, Type expectedException)
        {
            int maxLength = 0;
            string actualText = "";
            string expectedText = "";
            TextPatternRange callingRange;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine length of text to get = <<maxLength>>
            TS_CalcMaxLength(maxLengthType, out maxLength, expectedText);

            // Call GetText(<<maxLength>>) <<expectedException>>
            TS_GetText(callingRange, ref actualText, maxLength, expectedException, CheckType.Verification);

            // Validate text is <<getResult>>
            TS_VerifyTextLength(getResult, actualText, expectedText, maxLength, expectedException, CheckType.Verification);
        }
예제 #20
0
        //---------------------------------------------------------------------------
        // Helper for GetAttributeValue() test cases
        //---------------------------------------------------------------------------
        internal void GetAttributeValueHelper(SampleText sampleText, TargetRangeType callingRangeType, AttributeType attribType, GetResult getResult, Type expectedException)
        {
            IDictionary attributes = null;
            TextPatternRange callingRange;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Identify & use <<attribType>>
            TS_GetAttributeValues(callingRange, out attributes, attribType, CheckType.Verification);

            // For each attribute identified, GetAttributeValue() returns <<getResult>>
            TS_GetAttributeValue(callingRange, attributes, attribType, getResult, expectedException, CheckType.Verification);
        }
예제 #21
0
        //---------------------------------------------------------------------------
        // SetText will set the text of a control to a specific value
        // Caller may, optionally, set the text the want to set into the control
        // Going to violate convention and hardcode the CheckType arguments in this method
        // originalText is either...
        // A) Text of the control before this call was made
        // B) Textstring sent to the control (without any pesky \r, \n or \r\n that
        //    Win32 RichEdit automatically adds to any string it contains)
        //---------------------------------------------------------------------------
        internal void SetText(SampleText sampleText, string textToSet, out string actualText, CheckType checkType)
        {
            TextPatternRange    documentRange = Pattern_DocumentRange(checkType);;
            bool                isEmptyRange  = IsEmptyRange(documentRange, checkType);
            bool                setText       = true;
            
            actualText = "";

            Comment("ENTERING SetText(" + Parse(sampleText) + ",...)");

            // Sanity check: verify usage due to overloads...
            if( String.IsNullOrEmpty(textToSet) && (sampleText == SampleText.Custom) )
            {
                throw new ArgumentException("Incorrect usage. SampleText.Custom requires non-null textToSet argument");
            }

            // Sanity check: No IP Control support
            if (IsIPControl())
            {
                ThrowMe(checkType, "TextPattern tests that set text are not supported on SysIPAddress32 control");
            }

            // Sanity check: caller cannot pass in SampleText.Unused
            if( sampleText == SampleText.Unused )
            {
                ThrowMe(checkType, "Incorrect usage. You cannot call SetText(SampleText.Unused...)");
            }
            
            // State check: Is this first time through *THIS* method for the current automation element?
            // Only applies to cmd line usage with /ID <id1> /ID <id2> otherwise this method should 
            // esentaially equate a no-op
            ResetSampleText();

            // Okay... process the request...
            if( (isEmptyRange == true) && (sampleText == SampleText.Empty) )
            {
                // Special Case: sampleText = SampleText.Empty
                // We want empty, we got empty(!)
                textToSet  = "";
                actualText = "";
                
                Comment("   Control is already empty");
                setText = false;
            }
            else if( (isEmptyRange == false) && (sampleText == SampleText.NotEmpty))
            {
                // Special Case: sampleText = SampleText.NotEmpty
                // We want non-empty, we got non-empty(!)
                Range_GetText(documentRange, ref actualText, -1, null, checkType);
                if( (actualText.Length + _trailingCRLFCount) != 0) 
                {
                    Comment("   Control is already non-empty");
                    textToSet = actualText;
                    setText   = false;
                }
                else
                    textToSet = easyText;
            }
            else if( sampleText == _sampleText )
            {
                // Special case: We already have the desired text, so continue
                actualText = _actualText;
                setText    = false;
                Comment("   Control already has correct text");       
            }
            else if( _noClobber == true )
            {
                // Special case. If test doesn't care what text is there, continue else bail
                if( sampleText == SampleText.NotApplicable )
                {
                    actualText = _actualText;
                    Comment("   Unable to alter text of control due to /NOCLOBBER switch, continuing with the test though"); 
                    setText = false;
                }
                else
                   ThrowMe(checkType, "Unable to alter text of control due to /NOCLOBBER switch"); 
            }

            if( setText == true )
            {            
                // Get new text to shove into the control
                if( sampleText != SampleText.Custom )
                {
                    GetSampleText(sampleText, ref textToSet);  // Text to assign to control
                }
                
                SetValue(textToSet, checkType);            // assign it!

                documentRange = Pattern_DocumentRange(checkType);   // Any trialing \r \n added?
                Range_GetText(documentRange, ref actualText, -1, null, checkType);

                // Look for any discrpenecies based on trailing /r /n added to the text
                // i.e. this is the diff between textToSet.length and actualText.Length
                _trailingCRLFCount = TextLibrary.CountTrailingCRLF(m_le, documentRange);

                if (_trailingCRLFCount != 0)
                {
                    Comment("   Count of trailing \\r and/or \\n = " + (-1 * _trailingCRLFCount));
                    Comment("   Requested Text Length          = " + textToSet.Length);
                    Comment("   Requested Text                 = " + textToSet);
                }
            }

            Comment("   Actual Text Length             = " + actualText.Length);
            Comment("   Actual Text                    = " + actualText);

            _originalText = textToSet;
            _actualText   = actualText;
            _sampleText   = sampleText;            

            Comment("    EXITING SetText(" + ParseType(sampleText) + ",...)");
        }
예제 #22
0
 //---------------------------------------------------------------------------
 // Overload of SetText. Most commonly used flavor, relies upon pre-defined
 // string values (associated with sampleText) to set text int he control
 //---------------------------------------------------------------------------
 internal void SetText(SampleText sampleText, out string actualText, CheckType checkType)
 {
     string originalText = "";
     
     GetSampleText(sampleText, ref originalText);  // Text to assign to control
     
     SetText(sampleText, originalText, out actualText, checkType);
 }
예제 #23
0
        //---------------------------------------------------------------------------
        // Helper for TextPattern() test cases
        //---------------------------------------------------------------------------
        internal void TextPatternHelper(SampleText sampleText)
        {
            string actualText = "";
            TextPattern newPattern = null;
            TextPatternRange range = null;

            // Pre-Condition Verify/Set text in control is as expected
            TS_SetText(sampleText, out actualText, CheckType.IncorrectElementConfiguration);

            // Get TextPattern Property Helpers
            range = Pattern_DocumentRange(CheckType.Verification);
            TS_TextPattern(range, ref newPattern, CheckType.Verification);

            // ReferenceEquals comparison of pattern and TextPattern Property Helpers
            TS_IsMatchingTextPattern(_pattern, newPattern, CheckType.Verification);
        }
예제 #24
0
 //---------------------------------------------------------------------------
 // Do we reset the _sampleText var. based on automation elements runtime ID?
 // This is for the scenario where more than one /ID #### is used on the 
 // command line UIA Verify. Edit and RichEdit controls will have different
 // text size, even for the same value of sampleText. Our SetText() method 
 // will try to save time by not resetting the text of a control unless
 // absolutely necessary: Conditions which make it necessary:
 //  - A different value of SampleText is sent to SetText() than the last
 //    call to SetText()
 //  - The previous call to SetText() was for a DIFFERENT automation element
 // The logic for SetText handles the first case. This method identifies
 // the second case and resets the global _sampleText variable accordingly
 //---------------------------------------------------------------------------
 internal void ResetSampleText()
 {
     int[] runtimeID = m_le.GetRuntimeId();
     
     if (_runtimeID.Length == 0)
         _sampleText = SampleText.Unused; // reset
     else
     {
         if ( runtimeID.Length != _runtimeID.Length )    // should never happen (we hope)
             _sampleText = SampleText.Unused;            // reset anyway
         else
         {
             for( int i = 0; i < runtimeID.Length; i++ )
             {
                 if( runtimeID[i] != _runtimeID[i] )
                 {
                     _sampleText = SampleText.Unused;    // reset
                 }
             }                
         }
     }
     _runtimeID = runtimeID;
 }
예제 #25
0
        //---------------------------------------------------------------------------
        // Helper for TextSelectionChangedEvent() test cases
        //---------------------------------------------------------------------------
        internal void TextSelectionChangedEventHelper2(SampleText sampleText, bool backward)
        {
            SupportedTextSelection supportedTextSelection = SupportedTextSelection.None;

            // Pre-Condition Verify SupportedTextSelection!=SupportedTextSelection.None
            Pattern_SupportedTextSelection(ref supportedTextSelection);
            TS_VerifySupportedTextSelection(supportedTextSelection, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition set focus to control containing TextPattern
            TS_SetFocus(CheckType.IncorrectElementConfiguration);

            // Pre-Condition Set listener for TextPattern.SelectionChangedEvent
            TSC_AddEventListener(m_le, TextPattern.TextSelectionChangedEvent, TreeScope.Element, CheckType.Verification);

            // Select one character using keyboard input
            TS_KeyboardMove(backward);

            // Wait for event
            TSC_WaitForEvents(1);

            // Verify ElementAddedToSelection event fires
            TSC_VerifyEventListener(m_le, TextPattern.TextSelectionChangedEvent, EventFired.True, CheckType.Verification);
        }
예제 #26
0
        static internal void GetSampleText(SampleText sampleText, ref string text, out string dupBlock)
        {
            int i = 0;
            string tempText;
            StringBuilder tempBuilder = new StringBuilder();

            dupBlock = "";

            // If noclobber flag is set, we cannot update the existing text
            if (_noClobber == true)
            {
                // For some tests, noClobber equates IncorrectElementConfiguration. Filter out for 
                // acceptable values only.
                if(sampleText != SampleText.NotApplicable)
                    ThrowMe(CheckType.IncorrectElementConfiguration, "/NOCLOBBER switch means this test cannot be run. It requires changing the text in the control being tested");
            }
            
            // Determine type of text we're going to set            
            switch (sampleText)
            {
                case SampleText.NotApplicable:              // Value of text does not matter for test
                    // We don't care, just return with text as-is
                    return;
                case SampleText.NotEmpty:                   // Verify text is NOT empty (or SET text if it is empty)
                    if ((text.Length == 0)      // If nothing is there...
                        || (text.Equals("\r"))     // Default from old RichEdit
                        || (text.Equals("\r\n"))) // Default from newer RichEdit
                    {
                        text = easyText;    // ...just assign something, don't care what
                    }
                    return;
                case SampleText.Empty:                      // Set text to EMPTY string
                    text = noText;
                    break;
                case SampleText.String1:                // Set text to be 'String 1' text
                    text = string1;
                    break;
                case SampleText.EasyText:                   // Set text to be ONE character
                    text = easyText;
                    break;
                case SampleText.TextIsOneChar:
                    text = textIsOneChar;
                    break;
                case SampleText.Random256:
                    text = Helpers.RandomString(256, true);
                    break;
                case SampleText.MultipleLines:            // Set text to be multi-line
                    text = Helpers.RandomString(336, true);
                    text = text.Replace(text.Substring(47, 2), "\r\n");  // Each line is 46 chars wide, six lines
                    text = text.Replace(text.Substring(95, 2), "\r\n");
                    text = text.Replace(text.Substring(143, 2), "\r\n");
                    text = text.Replace(text.Substring(191, 2), "\r\n");
                    text = text.Replace(text.Substring(239, 2), "\r\n");
                    text = text.Replace(text.Substring(287, 2), "\r\n");
                    break;

                case SampleText.Random64:
                    text = Helpers.RandomString(64, true);
                    break;
                case SampleText.Random64CR:
                    text = Helpers.RandomString(64, true);
                    text = text.Replace(text.Substring(4, 1), " ");      // each line has two(+) words
                    text = text.Replace(text.Substring(12, 1), " ");
                    text = text.Replace(text.Substring(20, 1), " ");
                    text = text.Replace(text.Substring(28, 1), " ");
                    text = text.Replace(text.Substring(36, 1), " ");
                    text = text.Replace(text.Substring(44, 1), " ");
                    text = text.Replace(text.Substring(15, 2), "\r\n");
                    text = text.Replace(text.Substring(23, 2), "\r\n");
                    text = text.Replace(text.Substring(31, 2), "\r\n");
                    text = text.Replace(text.Substring(47, 2), "\r\n");
                    text = text.Replace(text.Substring(52, 2), "\r\n");  // Each line is 8 chars wide
                    break;
                case SampleText.RandomTextAnySize:          // Set text to be RANDOM sample text
                    text = Helpers.RandomString((int)Helpers.RandomValue(32, 1024), true);
                    break;
                case SampleText.Complex1:                   // Set text to complex multi-line text with long line of text at end
                    text = "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" + Helpers.RandomString(256, true);
                    break;
                case SampleText.Complex2:                   // Set text to complex multi-line text with long line of text at start
                    text = Helpers.RandomString(256, true) + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
                    break;
                case SampleText.Num123:                     // Set text to 123456789
                    text = "123456789";
                    break;
                case SampleText.Num123CR:
                    text = "1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n6 6\r\n7 7\r\n8 8\r\n9 9";
                    break;
                case SampleText.OneTwoThree:             // Set text to OneTwoThree...Nine
                    text = "OneTwoThreeFourFiveSixSevenEightNine";
                    break;
                case SampleText.OneCRTwoCRThreeCR:       // Set text to One\\nTwo\\nThree\\n...\\nNine
                    text = "One\r\nTwo\r\nThree\r\nFour\r\nFive\r\nSix\r\nSeven\r\nEight\r\nNine";
                    break;
                case SampleText.Null:                       // set text to be NULL
                    text = null;
                    break;
                case SampleText.WordsAndSpaces:             // Range of 3x words each followed 2 spaces
                    tempText = Helpers.RandomString(8, true);
                    text = tempText + "  " + tempText + "  " + tempText + "  ";
                    break;
                case SampleText.WordsAndPunctuation:        // Range of 3x words each followed by 2 punctuation marks
                    tempText = Helpers.RandomString(8, true);
                    text = tempText + ".." + tempText + ".." + tempText + "..";   // TODO: Make these random punctuation marks
                    break;
                case SampleText.ExtraLarge:                 // Text that has lots of lines and is wider than our controls
                    text = "";
                    for (i = 0; i < 10; i++)
                    {
                        tempBuilder.Append(Helpers.RandomString(256, true));
                        tempBuilder.Append("\r\n");
                    }
                    text = tempBuilder.ToString();
                    break;
                case SampleText.DuplicateBlocksOfText:      // Set text to have duplicate blocks of text
                    dupBlock = "<<<" + Helpers.RandomString(randomBlockSize, true) + ">>>";
                    text = Helpers.RandomString(256, true);
                    text = text.Replace(text.Substring(0, randomBlockSize), dupBlock);
                    text = text.Replace(text.Substring(text.Length - randomBlockSize, randomBlockSize), dupBlock);
                    break;
                case SampleText.Unused: // Its SUPPOSED to be a flag used for initial state of the class!!!
                    ThrowMe( CheckType.Verification, ParseType(sampleText) + " should not be explicitly used in a test");
                    break;
                case SampleText.ComplexHidden:              // Set text to complex multi-line text with big block of hidden text
                default:
                    throw new ArgumentException("GetSampleText() has no support for " + ParseType(sampleText));
            }
        }
예제 #27
0
 //---------------------------------------------------------------------------
 // Overload for GetSampleText, for versions that don't need a duplicate block of text
 //---------------------------------------------------------------------------
 static internal void GetSampleText(SampleText sampleText, ref string text)
 {
     string dupBlock = "";
     GetSampleText(sampleText, ref text, out dupBlock);
 }
예제 #28
0
        //---------------------------------------------------------------------------
        // Helper for TextSelectionChangedEvent() test cases
        //---------------------------------------------------------------------------
        internal void TextSelectionChangedEventHelper(SampleText sampleText, TargetRangeType rangeType)
        {
            TextPatternRange       callingRange          = null;
            SupportedTextSelection supportedTextSelection = SupportedTextSelection.None; 

            // Pre-Condition Verify SupportedTextSelection != SupportedTextSelection.None
            Pattern_SupportedTextSelection(ref supportedTextSelection);
            TS_VerifySupportedTextSelection(supportedTextSelection, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create range equal to <<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.Verification);

            // Pre-Condition Set listener for TextPattern.SelectionChangedEvent
            TSC_AddEventListener(m_le, TextPattern.TextSelectionChangedEvent, TreeScope.Element, CheckType.Verification);

            // Select the element 
            TS_Select(callingRange, null, CheckType.Verification);

            // Wait for event
            TSC_WaitForEvents(1);

            // Verify ElementAddedToSelection event did/didnot happen
            TSC_VerifyEventListener(m_le, TextPattern.TextSelectionChangedEvent, EventFired.True, CheckType.Verification);
        }
예제 #29
0
        //---------------------------------------------------------------------------
        // Helper for GetChildren() test cases
        //---------------------------------------------------------------------------
        internal void ChildrenHelper(SampleText sampleText, bool requiresChildren)
        {
            AutomationElement[] children = null;
            TextPatternRange documentRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify (Children Property Helpers is non-null) == <<hasChildren>>
            documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration);
            TS_Children(documentRange, ref children, requiresChildren, CheckType.IncorrectElementConfiguration);

            // Enumerate children (if they exist)
            TS_EnumerateChildren(children, false, null, CheckType.Verification);
        }
예제 #30
0
        //---------------------------------------------------------------------------
        // Helper for GetBoundingRectangles() test cases
        //---------------------------------------------------------------------------
        internal void GetBoundingRectanglesHelper(SampleText sampleText, TargetRangeType callingRangeType, bool isMultiLine, ScrollLocation scrollLocation, GetBoundRectResult boundRectResults)
        {
            Rect autoElement;
            Rect[] boundRects = new Rect[0];
            TextPatternRange callingRange;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLine, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Scroll viewport to <<ScrollLocation>>
            TS_ScrollViewPort(scrollLocation, false, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Get Automation Element Bounding Rectangle
            TS_GetAutomationElementBoundingRectangle(out autoElement);

            // Call GetBoundingRectangles()
            TS_GetBoundingRectanglesLite(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Valdiate Bounding Rectangles <<getResult>>
            TS_VerifyWithinRects(autoElement, boundRects, boundRectResults, CheckType.Verification);

        }
예제 #31
0
        //---------------------------------------------------------------------------
        // Helper for Clone() test cases
        //---------------------------------------------------------------------------
        internal void CloneHelper(SampleText sampleText, TargetRangeType callingRangeType, bool requiresChildren)
        {
            TextPatternRange callingRange;
            TextPatternRange cloneRange = null;
            AutomationElement[] children = null;
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create range = <<callingRange>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Children Property Helpers is <<requiresChildren>> array
            TS_Children(documentRange, ref children, requiresChildren, CheckType.IncorrectElementConfiguration);

            // Clone the range
            TS_Clone(callingRange, ref cloneRange, CheckType.Verification);

            // Verify identical ranges by calling Compare()
            TS_IsMatchingRange(callingRange, cloneRange, CheckType.Verification);

            // If children, Verify each child element is identical
            TS_IsMatchingRangeChildren(callingRange, cloneRange, CheckType.Verification);
        }
예제 #32
0
        //---------------------------------------------------------------------------
        // Helper for Move() test cases
        //---------------------------------------------------------------------------
        internal void MoveHelper(SampleText sampleText, TargetRangeType callingRangeType, Count count, Count expectedCount)
        {
            TextUnit[]       supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1];
            int[]            numberOfTextUnits  = new int[((int)TextUnit.Document) + 1];
            TextPatternRange callingRange       = null;
            TextPatternRange documentRange      = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition: Acquire range for entire document
            TS_DocumentRange( ref documentRange, CheckType.IncorrectElementConfiguration );

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);

            // Pre-Condition: Determine Count for each TextUnit in document
            TS_CountTextUnits( documentRange, supportedTextUnits, ref numberOfTextUnits );
            
            // Call Move(<<count>>) for each TextUnit, validiting result is <<result>>
            TS_Move(callingRange, supportedTextUnits, numberOfTextUnits, count, expectedCount, CheckType.Verification);
        }
예제 #33
0
        //---------------------------------------------------------------------------
        // Helper for RangeFromChild() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromChildHelper(SampleText sampleText, bool requiresChildren, AutoElementType autoElementArgument, Type expectedException)
        {
            string actualText = "";
            AutomationElement[] autoElements = null;

            //Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, out actualText, CheckType.IncorrectElementConfiguration);

            //Pre-Condition Verify range children c<<requiresChildren>>
            TS_VerifyChildren(requiresChildren, CheckType.IncorrectElementConfiguration);

            //Pre-Condition Acquire automation element(s)
            TS_GetAutomationElement(ref autoElements, autoElementArgument, CheckType.Verification);

            // Iterate through each AutomationElement, calling RangeFromChild (<<expectedException>> for any expected errors)
            TS_EnumerateChildren(autoElements, true, expectedException, CheckType.Verification);
        }
예제 #34
0
        //---------------------------------------------------------------------------
        // Helper for MoveEndpointByUnit() test cases
        //---------------------------------------------------------------------------
        internal void MoveEndpointByUnitHelper2(SampleText sampleText, TargetRangeType callingRangeType, Count requestedCount, Count startExpectedCount, Count endExpectedCount )
        {
            TextPatternRange documentRange      = Pattern_DocumentRange(CheckType.Verification);
            int              richEditOffset     = TextLibrary.CountTrailingCRLF(m_le, documentRange);
            int[]            numberOfTextUnits  = new int[((int)TextUnit.Document) + 1];
            TextUnit[]       supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1]; 
            TextPatternRange callingRange       = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);
            
            // Pre-Condition Calculate # of text units to move by
            TS_CountTextUnits(callingRange, supportedTextUnits, ref numberOfTextUnits);

            // Verify MoveEndpointEndPoints(start,TextUnit.*, 1) returns <<startOne>> for all TextUnits
            TS_MoveEndpointByUnitAndValidate2(callingRange, TextPatternRangeEndpoint.Start, requestedCount, startExpectedCount, numberOfTextUnits, richEditOffset, CheckType.Verification);

            // Verify MoveEndpointEndPoints(end,  TextUnit.*, 1) returns <<endOne>> for all TextUnits
            TS_MoveEndpointByUnitAndValidate2(callingRange, TextPatternRangeEndpoint.End, requestedCount, endExpectedCount, numberOfTextUnits, richEditOffset, CheckType.Verification);

        }
예제 #35
0
        //---------------------------------------------------------------------------
        // Helper for CompareEndpoints() test cases
        //---------------------------------------------------------------------------
        internal void CompareEndpointsHelper(SampleText sampleText, TargetRangeType callingRangeType, TargetRangeType argumentRangeType, ValueComparison startStart, ValueComparison startEnd, ValueComparison endStart, ValueComparison endEnd, Type expectedException)
        {
            TextPatternRange callingRange = null;
            TextPatternRange argumentRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, true, CheckType.Verification);

            // Pre-Condition Create argument range = <<argumentRangeType>>
            TS_CreateRange(out argumentRange, argumentRangeType, callingRange, true, CheckType.Verification);

            // Verify CompareEndPoints(start,start) <<startStart>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.Start, argumentRange, 
                                              TextPatternRangeEndpoint.Start, startStart, expectedException, CheckType.Verification);

            // Verify CompareEndPoints(start,  end) <<startEnd>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.Start, argumentRange,
                                              TextPatternRangeEndpoint.End,   startEnd, expectedException, CheckType.Verification);

            // Verify CompareEndPoints(  end,start) <<endStart>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.End,   argumentRange,
                                              TextPatternRangeEndpoint.Start, endStart, expectedException, CheckType.Verification);

            // Verify CompareEndPoints(  end,  end) <<endEnd>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.End,   argumentRange, 
                                              TextPatternRangeEndpoint.End,   endEnd, expectedException, CheckType.Verification);
        }
예제 #36
0
        //---------------------------------------------------------------------------
        // Helper for Select() test cases
        //---------------------------------------------------------------------------
        internal void SelectHelper(SampleText sampleText, TargetRangeType callingRangeType, Type expectedException)
        {
            string actualText             = "";   
            string expectedText           = "";   // comparison of these strings.
            TextPatternRange callingRange = null;

            // Pre-Condition SetFocus to control containing TextPattern
            TS_SetFocus(CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Select the range
            TS_Select(callingRange, expectedException, CheckType.Verification);

            // Get the text from the selection
            TS_GetTextSelection(ref actualText, CheckType.Verification);

            // Verify the selection is as expected
            TS_IsMatchingText("Select()", actualText, expectedText, true, CheckType.Verification);
        }
예제 #37
0
        //---------------------------------------------------------------------------
        // Helper for FindAttribute() test cases
        //---------------------------------------------------------------------------
        internal void FindAttributeHelper(SampleText sampleText, TypeValue typeValue, AttributeType attribType, bool backward, FindResults FindResults, Type expectedException)
        {
            bool isConsistentAttributes;
            IDictionary attributes = null;
            TextPatternRange documentRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Identify & use <<attribType>> attributes
            documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration);
            TS_GetAttributeValues(documentRange, out attributes, attribType, CheckType.Verification);

            // Pre-Condition Identify if document has consistent attribute values
            TS_VerifyAttributeRanges(attributes, out isConsistentAttributes);

            // Pre-Condition For each attribute, Val argument has <<typeValue>> type and <<typeValue>> value
            TS_SetAttributeValues(ref attributes, typeValue);

            // Call FindAttribute(<<backward>>) without errors (<<FindResults>>)/with <<expectedException, if not null>>
            TS_FindAttributes(attributes, typeValue, backward, FindResults, expectedException, CheckType.Verification);
        }
예제 #38
0
        //---------------------------------------------------------------------------
        // Overloaded helper for TS_SetText
        //---------------------------------------------------------------------------
        internal void TS_SetText(SampleText sampleText, CheckType checkType)
        {
            string actualText = "";

            TS_SetText(sampleText, out actualText, checkType);
        }
예제 #39
0
        //---------------------------------------------------------------------------
        // Helper for FindAttribute() test cases
        //---------------------------------------------------------------------------
        internal void FindAttributeHelper2(SampleText sampleText, Type expectedException)
        {
            object value = null;
            TextPatternRange returnedRange = null;
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration); 
            
            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Call FindAttribute(null,<correct type & value>,false) <<expectedException>>
            Range_FindAttribute(documentRange, ref returnedRange, TextPattern.IsReadOnlyAttribute, value, false, expectedException, CheckType.Verification);
        }
예제 #40
0
        //---------------------------------------------------------------------------
        // Helper for GetSelection() test cases
        //---------------------------------------------------------------------------
        internal void GetSelectionHelper(SampleText sampleText, SupportedTextSelection supportedTextSelection, TargetRangeType rangeType, bool expectMatch, uint arrayCount, Type expectedException)
        {
            bool               isEqual       = false;
            string             actualText    = "";
            TextPatternRange   callingRange  = null;
            TextPatternRange[] selectedRange = null;

            // Pre-Condition Verify SupportedTextSelection=<<supportedTextSelection>>
            TS_VerifySupportedTextSelection(supportedTextSelection, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, out actualText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range=<<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.Verification);

            // Call Select()
            TS_Select(callingRange, null, CheckType.Verification);

            // Call GetSelection() on calling range
            TS_GetSelection(ref selectedRange, arrayCount, expectedException, CheckType.Verification);

            // Compare selected range and calling range, comparison should = <<expectMatch>>
            TS_Compare(callingRange, selectedRange[0], ref isEqual, expectMatch, null, CheckType.Verification);
        }
예제 #41
0
        //---------------------------------------------------------------------------
        // Helper for FindAttribute() test cases
        //---------------------------------------------------------------------------
        internal void FindAttributeHelper3(SampleText sampleText, Type expectedException)
        {
            int bogusValue = 0;
            TextPatternRange returnedRange = null;
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration); 

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Call FindAttribute(<faux random Attribute>,null,false) <<expectedException>>
            Range_FindAttribute(documentRange, ref returnedRange, null, bogusValue, false, expectedException, CheckType.Verification);
        }
예제 #42
0
        //---------------------------------------------------------------------------
        // Helper for RangeFromPoint() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromPointHelper(SampleText sampleText, int expandBy, TextPatternRangeEndpoint endPoint, RangeLocation rangeLocation, BoundingRectangleLocation pointLocation, RangeCompare rangeCompare, Type expectedException)
        {
            Point screenLocation;
            Rect[] boundRects = new Rect[0];
            string actualText = "";
            TextPatternRange callingRange = null;
            TextPatternRange rangeFromPt = null;

            // Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, out actualText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create empty calling range @ <<RangeLocation>> of TextPattern.DocumentRange
            TS_CreateEmptyRange(out callingRange, rangeLocation, CheckType.Verification);

            // Pre-Condition Expand <<endPoint>> endPoint by <<expandby>> character(s)
            TS_ExpandRange(ref callingRange, endPoint, TextUnit.Character, expandBy, true, CheckType.Verification);

            // Pre-Condition Scroll range into view
            // Bug 1134054: TextPatternRange.ScrollIntoView fails to scroll horizontally on edit control
            // We need to make sure we scroll off the view so we can scroll back on it.
            // Otherwise the second scrollIntoView call may be a no-op...
            Range_ScrollIntoView(callingRange, false, null, CheckType.Verification);
            TS_ScrollIntoView(callingRange, true, null, CheckType.Verification);

            // Pre-Condition Call GetBoundingRectangles() on that range
            TS_GetBoundingRectangles(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Pre-Condition Create a point <<pointLocation>> of bounding rect
            TS_CreatePoint(ref callingRange, boundRects, out screenLocation, pointLocation, CheckType.Verification);

            // Call RangeFromPoint on point 
            TS_RangeFromPoint(ref rangeFromPt, screenLocation, expectedException, CheckType.Verification);

            // Verify that range returned is  <<rangeCompare>>
            TS_CompareRanges(callingRange, rangeFromPt, rangeCompare, expectedException, CheckType.Verification);
        }
예제 #43
0
        //---------------------------------------------------------------------------
        // Helper for FindText() test cases
        //---------------------------------------------------------------------------
        internal void FindTextHelper(SampleText sampleText, SearchText searchTextType, FindResults result1, FindResults result2, FindResults result3, FindResults result4, Type expectedException)
        {
            string searchText;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Text to search for is <<searchText>>
            TS_SetSearchText(out searchText, searchTextType, CheckType.Verification);

            // CallFindText(forwards, case-insensitive) <<result1>>
            if((searchTextType != SearchText.MatchesLastBlock) && (searchTextType != SearchText.MismatchedCaseLastBlock))
                TS_FindText(searchText, false, false, result1, expectedException, CheckType.Verification);
            else
                m_TestStep++;

            // CallFindText(forwards, case-sensitive)   <<result2>>
            if ((searchTextType != SearchText.MatchesLastBlock) && (searchTextType != SearchText.MismatchedCaseLastBlock))
                TS_FindText(searchText, false, true, result2, expectedException, CheckType.Verification);
            else
                m_TestStep++;

            // CallFindText(backwards,case-insensitive) <<result3>>
            if ((searchTextType != SearchText.MatchesFirstBlock) && (searchTextType != SearchText.MismatchedCaseFirstBlock))
                TS_FindText(searchText, true, false, result3, expectedException, CheckType.Verification);
            else
                m_TestStep++;


            // CallFindText(backwards,case-sensitive)  <<result4>>
            if ((searchTextType != SearchText.MatchesFirstBlock) && (searchTextType != SearchText.MismatchedCaseFirstBlock))
                TS_FindText(searchText, true, true, result4, expectedException, CheckType.Verification);
            else
                m_TestStep++;

        }
예제 #44
0
        //---------------------------------------------------------------------------
        // Helper for Compare() test cases
        //---------------------------------------------------------------------------
        internal void CompareHelper(SampleText sampleText, TargetRangeType callingRangeType, TargetRangeType argumentRangeType, bool expectMatch, Type expectedException)
        {
            bool isEqual = false;
            TextPatternRange callingRange;
            TextPatternRange argumentRange;
            string expectedText = "";
            IDictionary attribsExpected = null;
            AutomationElement enclosingExpected = null;
            AutomationElement[] childrenExpected = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRange>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Argument range is <<argumentRange>>
            TS_CreateRange(out argumentRange, argumentRangeType, callingRange, false, CheckType.Verification);

            // Compare the ranges (<<expectedException>> for any expected errors)
            TS_Compare(callingRange, argumentRange, ref isEqual, expectMatch, expectedException, CheckType.Verification);

            // Calling Range: Get Attribute dictionary (assuming we're not done first!)
            if (expectedException != null)
            {
                Comment("Cannot continue with comparison tests when exception was raised as expected");
                return;
            }

            TS_GetAttributeValues(callingRange, out attribsExpected, AttributeType.SupportedAttributes, CheckType.Verification);

            // Calling Range: Get Get Enclosing element
            TS_GetEnclosingElement(callingRange, ref enclosingExpected, null, CheckType.Verification);

            // Calling Range: Get children
            TS_Children(callingRange, ref childrenExpected, false, CheckType.Verification);

            // Verify <<expectMatch>> Start/End Points
            TS_IsMatchingEndPoints(callingRange, argumentRange, expectMatch, CheckType.Verification);

            // Verify <<expectMatch>>  text
            TS_IsMatchingText("Compare", argumentRange, expectedText, expectMatch, true, CheckType.Verification);

            // Verify <<expectMatch>>  Attribute dictionary
            TS_IsMatchingDictionary(argumentRange, attribsExpected, AttributeType.SupportedAttributes, expectMatch, CheckType.Verification);

            // Verify <<expectMatch>>  Get Enclosing element
            TS_IsMatchingEnclosingElement(argumentRange, enclosingExpected, expectMatch, CheckType.Verification);

            // Verify <<expectMatch>>  children
            TS_IsMatchingChildren(argumentRange, childrenExpected, expectMatch, CheckType.Verification);
        }
예제 #45
0
        //---------------------------------------------------------------------------
        // Helper for GetVisibleRange() test cases
        // NOTE: This method assumes only a single range is selected, and will
        //       not work correctly if multiple selections have taken place
        //       Win32/DUI/Avalon do not support multiple selection.
        //---------------------------------------------------------------------------
        internal void GetVisibleRangesHelper(SampleText sampleText, bool isMultiLineExpected, SupportedTextSelection supportedTextSelection, uint arrayCount)
        {
            string             expectedText  = "";
            string             actualText    = "";
            TextPatternRange[] visibleRanges = null;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLineExpected, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Call GetVisibleRange on the control with no errors
            TS_GetVisibleRanges(ref visibleRanges, null, CheckType.Verification);

            // Call GetText() on FIRST visible range (post V1, this should validate against each/all ranges)
            TS_GetText(visibleRanges[0], ref actualText, -1, null, CheckType.Verification);

            // Verify that text range matches what was set in the control
            TS_TextWithin("GetVisibleRange()", actualText, expectedText, CheckType.Verification);

        }