Beispiel #1
0
        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");
                }
            }
        }
Beispiel #2
0
        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));
                }
            }
        }