public void FragmentRoot_MultiString_ReadOnly() { using (var site = new RootSiteDataProvider_MultiStringView(m_cache)) { site.StyleSheet = FixtureStyleSheet; site.WritingSystemFactory = m_wsManager; using (var helper = new SimpleRootSiteDataProviderTestsHelper(site)) { const string engExpected = "This is the English sentence."; const string frExpected = "This is the French sentence."; string expected = engExpected + Environment.NewLine + frExpected; IList <KeyValuePair <int, string> > vkvp = new List <KeyValuePair <int, string> >(); vkvp.Add(m_wsEng, engExpected); vkvp.Add(m_wsFr, frExpected); site.ShowForm(vkvp, new SimpleRootSiteDataProvider_MultiStringViewVc.DisplayOptions { ReadOnlyView = true, LiteralStringLabels = false }); Assert.IsTrue(site.ReadOnlyView, "site should now be read-only"); var dataProvider = new SimpleRootSiteDataProvider(site); var doc = dataProvider.DocumentRange; Assert.NotNull(doc, "DocumentRange shouldn't be null"); Assert.IsInstanceOf <bool>(doc.GetAttributeValue(TextPatternIdentifiers.IsReadOnlyAttribute.Id)); Assert.IsTrue((bool)doc.GetAttributeValue(TextPatternIdentifiers.IsReadOnlyAttribute.Id)); Assert.AreEqual(expected, doc.GetText(-1)); var firstChild = dataProvider.Navigate(NavigateDirection.FirstChild); Assert.IsNull(firstChild, "FragmentRoot (ReadOnly view) should not have a custom edit control."); } } }
public void FragmentRoot_HasCustomEditControl() { using (var site = new RootSiteDataProviderView(m_cache)) { site.StyleSheet = FixtureStyleSheet; site.WritingSystemFactory = m_wsManager; using (var helper = new SimpleRootSiteDataProviderTestsHelper(site)) { const string expected = "Should have a custom edit control"; site.ShowForm(m_wsEng, expected, new SimpleRootSiteDataProviderVc.DisplayOptions()); var dataProvider = new SimpleRootSiteDataProvider(site); Assert.AreEqual(expected, dataProvider.DocumentRange.GetText(-1)); var firstChild = dataProvider.Navigate(NavigateDirection.FirstChild); Assert.NotNull(firstChild, "FragmentRoot should have a custom edit control."); Assert.IsInstanceOf <SimpleRootSiteEditControl>(firstChild); Assert.IsInstanceOf <ITextProvider>(firstChild); var lastChild = dataProvider.Navigate(NavigateDirection.LastChild); Assert.AreSame(firstChild, lastChild); var childTextProvider = (ITextProvider)firstChild; Assert.AreEqual(expected, childTextProvider.DocumentRange.GetText(-1)); // make sure the bounding rectangle of the child is contained in the parent's bounding rectangle. var rsBoundintRect = helper.GetRootSiteScreenRect(); Assert.IsTrue( rsBoundintRect.Contains(firstChild.BoundingRectangle), "Edit control BoundingRectangle should be contained within the root fragment bounding rectangle"); } } }
public void StringPropertyCollectorEnv_MultiStringView_TwoEditableFields() { using (var site = new RootSiteDataProvider_MultiStringView(m_cache)) { site.StyleSheet = FixtureStyleSheet; site.WritingSystemFactory = m_wsManager; using (var helper = new SimpleRootSiteDataProviderTestsHelper(site)) { const string engExpected = "This is the English sentence."; const string frExpected = "This is the French sentence."; string expected = engExpected + Environment.NewLine + frExpected; IList <KeyValuePair <int, string> > vkvp = new List <KeyValuePair <int, string> >(); vkvp.Add(m_wsEng, engExpected); vkvp.Add(m_wsFr, frExpected); site.ShowForm(vkvp, new SimpleRootSiteDataProvider_MultiStringViewVc.DisplayOptions { ReadOnlyView = false, LiteralStringLabels = false }); var editableSelections = site.CollectEditableStringPropSelections(); Assert.IsNotNull(editableSelections); Assert.AreEqual(2, editableSelections.Count); var sli1 = CollectorEnvServices.MakeLocationInfo(site.RootBox, editableSelections[0]); Assert.AreEqual(0, sli1.m_location.Length); Assert.AreEqual(SimpleRootSiteDataProvider_MultiStringViewVc.kflidMultiString, sli1.m_tag); Assert.AreEqual(m_wsEng, sli1.m_ws); Assert.AreEqual(0, sli1.m_ichMin, "m_ichMin"); Assert.AreEqual(0, sli1.m_ichLim, "m_ichLim"); Assert.AreEqual(0, sli1.m_cpropPrev); var sli2 = CollectorEnvServices.MakeLocationInfo(site.RootBox, editableSelections[1]); Assert.AreEqual(SimpleRootSiteDataProvider_MultiStringViewVc.kflidMultiString, sli2.m_tag); Assert.AreEqual(m_wsFr, sli2.m_ws); Assert.AreEqual(0, sli2.m_ichMin, "m_ichMin"); Assert.AreEqual(0, sli2.m_ichLim, "m_ichLim"); Assert.AreEqual(1, sli2.m_cpropPrev); // Verify we can actually use these to make valid selections. var sel1 = editableSelections[0]; Assert.IsNotNull(sel1); Assert.IsTrue(sel1.IsEditable, "sel1.IsEditable"); var sel2 = editableSelections[1]; Assert.IsNotNull(sel2); Assert.IsTrue(sel2.IsEditable, "sel2.IsEditable"); } } }
public void FragmentRoot_HasCustomEditControl_ChangeValue() { using (var site = new RootSiteDataProviderView(m_cache)) { site.StyleSheet = FixtureStyleSheet; site.WritingSystemFactory = m_wsManager; using (var helper = new SimpleRootSiteDataProviderTestsHelper(site)) { const string expected = "This has been replaced"; site.ShowForm(m_wsEng, "This should get changed.", new SimpleRootSiteDataProviderVc.DisplayOptions()); var dataProvider = new SimpleRootSiteDataProvider(site); IRawElementProviderFragment firstChild = dataProvider.Navigate(NavigateDirection.FirstChild); Assert.NotNull(firstChild, "FragmentRoot should have a custom edit control."); Assert.IsInstanceOf <SimpleRootSiteEditControl>(firstChild); Assert.IsInstanceOf <IValueProvider>(firstChild); var originalBoundingRect = firstChild.BoundingRectangle; var childValueProvider = (IValueProvider)firstChild; childValueProvider.SetValue(expected); Assert.AreSame(firstChild, dataProvider.Navigate(NavigateDirection.FirstChild)); Assert.AreEqual(expected, childValueProvider.Value); Assert.IsFalse(firstChild.BoundingRectangle.Equals(originalBoundingRect), "The bounding rectangle of the control should have changed from " + originalBoundingRect); Assert.Less(firstChild.BoundingRectangle.Width, originalBoundingRect.Width); Assert.AreEqual(originalBoundingRect.Height, firstChild.BoundingRectangle.Height); Assert.AreEqual(originalBoundingRect.X, firstChild.BoundingRectangle.X); Assert.AreEqual(originalBoundingRect.Y, firstChild.BoundingRectangle.Y); var childTextProvider = (ITextProvider)firstChild; Assert.AreEqual(expected, childTextProvider.DocumentRange.GetText(-1)); Assert.AreEqual(expected, dataProvider.DocumentRange.GetText(-1)); var lastChild = dataProvider.Navigate(NavigateDirection.LastChild); Assert.AreSame(firstChild, lastChild); } } }
public void StringPropertyCollectorEnv_MultiStringView_ReadOnlyView() { using (var site = new RootSiteDataProvider_MultiStringView(m_cache)) { site.StyleSheet = FixtureStyleSheet; site.WritingSystemFactory = m_wsManager; using (var helper = new SimpleRootSiteDataProviderTestsHelper(site)) { const string engExpected = "This is the English sentence."; const string frExpected = "This is the French sentence."; string expected = engExpected + Environment.NewLine + frExpected; IList <KeyValuePair <int, string> > vkvp = new List <KeyValuePair <int, string> >(); vkvp.Add(m_wsEng, engExpected); vkvp.Add(m_wsFr, frExpected); site.ShowForm(vkvp, new SimpleRootSiteDataProvider_MultiStringViewVc.DisplayOptions { ReadOnlyView = true, LiteralStringLabels = false }); var editableSelections = site.CollectEditableStringPropSelections(); Assert.AreEqual(0, editableSelections.Count); } } }
public void FragmentRoot_MultiString_TwoEditControls() { using (var site = new RootSiteDataProvider_MultiStringView(m_cache)) { site.StyleSheet = FixtureStyleSheet; site.WritingSystemFactory = m_wsManager; using (var helper = new SimpleRootSiteDataProviderTestsHelper(site)) { const string engExpected = "This is the English sentence."; const string frExpected = "This is the French sentence."; string expected = engExpected + Environment.NewLine + frExpected; IList <KeyValuePair <int, string> > vkvp = new List <KeyValuePair <int, string> >(); vkvp.Add(m_wsEng, engExpected); vkvp.Add(m_wsFr, frExpected); site.ShowForm(vkvp, new SimpleRootSiteDataProvider_MultiStringViewVc.DisplayOptions { ReadOnlyView = false, LiteralStringLabels = false }); Assert.IsFalse(site.ReadOnlyView, "site should not be read-only"); var dataProvider = new SimpleRootSiteDataProvider(site, site.CreateUIAutomationEditControls); var doc = dataProvider.DocumentRange; Assert.NotNull(doc, "DocumentRange shouldn't be null"); Assert.IsInstanceOf <bool>(doc.GetAttributeValue(TextPatternIdentifiers.IsReadOnlyAttribute.Id)); Assert.IsFalse((bool)doc.GetAttributeValue(TextPatternIdentifiers.IsReadOnlyAttribute.Id)); Assert.AreEqual(expected, doc.GetText(-1)); var firstChild = dataProvider.Navigate(NavigateDirection.FirstChild); Assert.NotNull(firstChild, "FragmentRoot should have a custom edit control."); Assert.IsInstanceOf <SimpleRootSiteEditControl>(firstChild); Assert.IsInstanceOf <ITextProvider>(firstChild); var lastChild = dataProvider.Navigate(NavigateDirection.LastChild); Assert.AreNotSame(firstChild, lastChild); var engTextProvider = (ITextProvider)firstChild; Assert.AreEqual(engExpected, engTextProvider.DocumentRange.GetText(-1)); var frTextProvider = (ITextProvider)lastChild; Assert.AreEqual(frExpected, frTextProvider.DocumentRange.GetText(-1)); // make sure the bounding rectangle of the child is contained in the parent's bounding rectangle. var rsBoundintRect = helper.GetRootSiteScreenRect(); Assert.IsTrue( rsBoundintRect.Contains(firstChild.BoundingRectangle), "Edit control BoundingRectangle should be contained within the root fragment bounding rectangle"); Assert.IsTrue( rsBoundintRect.Contains(lastChild.BoundingRectangle), "Edit control BoundingRectangle should be contained within the root fragment bounding rectangle"); Assert.AreEqual(firstChild.BoundingRectangle.Left, lastChild.BoundingRectangle.Left, 0); Rect intersection = Rect.Intersect(firstChild.BoundingRectangle, lastChild.BoundingRectangle); Assert.AreEqual(0, intersection.Height * intersection.Width, 0, "Sibling edit control BoundingRectangles should not intersect with each other"); // make sure we've only created two EditControl children. var nextSibling = firstChild.Navigate(NavigateDirection.NextSibling); Assert.AreSame(lastChild, nextSibling, "Navigate.NextSibling"); Assert.IsNull(firstChild.Navigate(NavigateDirection.PreviousSibling)); var previousSibling = lastChild.Navigate(NavigateDirection.PreviousSibling); Assert.AreSame(firstChild, previousSibling); Assert.IsNull(lastChild.Navigate(NavigateDirection.NextSibling)); } } }