Exemple #1
0
        public void FragmentRoot_DocumentRange_OneString_ReadOnly()
        {
            using (var site = new RootSiteDataProviderView(m_cache))
            {
                site.StyleSheet           = FixtureStyleSheet;
                site.WritingSystemFactory = m_wsManager;

                using (new SimpleRootSiteDataProviderTestsHelper(site))
                {
                    const string expected = "This string should be in a read-only view";
                    site.ShowForm(m_wsEng, expected,
                                  new SimpleRootSiteDataProviderVc.DisplayOptions {
                        ReadOnlyView = true
                    });
                    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.");
                }
            }
        }
Exemple #2
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");
                }
            }
        }
Exemple #3
0
 public void FragmentRoot_DocumentRange_OneString()
 {
     using (var site = new RootSiteDataProviderView(m_cache))
     {
         site.StyleSheet           = FixtureStyleSheet;
         site.WritingSystemFactory = m_wsManager;
         using (new SimpleRootSiteDataProviderTestsHelper(site))
         {
             const string expected = "Should only show this string";
             site.ShowForm(m_wsEng, expected, new SimpleRootSiteDataProviderVc.DisplayOptions());
             var dataProvider = new SimpleRootSiteDataProvider(site);
             var doc          = dataProvider.DocumentRange;
             Assert.NotNull(doc, "DocumentRange shouldn't be null");
             Assert.AreEqual(expected, doc.GetText(-1));
         }
     }
 }
Exemple #4
0
        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);
                }
            }
        }