public void RibbonLayout() { m_ribbon.MakeRoot(); m_ribbon.CallLayout(); Assert.IsNotNull(m_ribbon.RootBox, "layout should produce some root box"); int widthEmpty = m_ribbon.RootBox.Width; int heightEmpty = m_ribbon.RootBox.Height; int[] glosses = MakeAnnotations(m_firstPara); int[] firstGloss = new int[] { glosses[0] }; Cache.VwCacheDaAccessor.CacheVecProp(m_stText.Hvo, m_ribbon.AnnotationListId, firstGloss, 1); Cache.PropChanged(m_stText.Hvo, m_ribbon.AnnotationListId, 0, 1, 0); m_ribbon.CallLayout(); int widthOne = m_ribbon.RootBox.Width; int heightOne = m_ribbon.RootBox.Height; Assert.IsTrue(widthOne > widthEmpty, "adding a wordform should make the root box wider"); Cache.VwCacheDaAccessor.CacheVecProp(m_stText.Hvo, m_ribbon.AnnotationListId, glosses, glosses.Length); Cache.PropChanged(m_stText.Hvo, m_ribbon.AnnotationListId, 0, glosses.Length - 1, 0); m_ribbon.CallLayout(); int widthMany = m_ribbon.RootBox.Width; int heightMany = m_ribbon.RootBox.Height; Assert.IsTrue(widthMany > widthOne, "adding more wordforms should make the root box wider"); // In a real view they might not be exactly equal due to subscripts and the like, but our // text and anaysis are very simple. Assert.AreEqual(heightOne, heightMany, "ribbon should not wrap!"); }
public void RibbonLayout() { EndSetupTask(); // SUT#1 (but not one that changes data) m_ribbon.MakeRoot(); m_ribbon.CallLayout(); Assert.IsNotNull(m_ribbon.RootBox, "layout should produce some root box"); var widthEmpty = m_ribbon.RootBox.Width; var glosses = new AnalysisOccurrence[0]; // SUT#2 This changes data! Use a UOW. UndoableUnitOfWorkHelper.Do("RibbonLayoutUndo", "RibbonLayoutRedo", Cache.ActionHandlerAccessor, () => glosses = GetParaAnalyses(m_firstPara)); Assert.Greater(glosses.Length, 0); var firstGloss = new List <AnalysisOccurrence> { glosses[0] }; // SUT#3 This changes some internal data! Use a UOW. UndoableUnitOfWorkHelper.Do("CacheAnnsUndo", "CacheAnnsRedo", Cache.ActionHandlerAccessor, () => m_ribbon.CacheRibbonItems(firstGloss)); m_ribbon.CallLayout(); int widthOne = m_ribbon.RootBox.Width; int heightOne = m_ribbon.RootBox.Height; Assert.IsTrue(widthOne > widthEmpty, "adding a wordform should make the root box wider"); var glossList = new List <AnalysisOccurrence>(); glossList.AddRange(glosses); // SUT#4 This changes some internal data! Use a UOW. UndoableUnitOfWorkHelper.Do("CacheAnnsUndo", "CacheAnnsRedo", Cache.ActionHandlerAccessor, () => m_ribbon.CacheRibbonItems(glossList)); m_ribbon.CallLayout(); int widthMany = m_ribbon.RootBox.Width; int heightMany = m_ribbon.RootBox.Height; Assert.IsTrue(widthMany > widthOne, "adding more wordforms should make the root box wider"); // In a real view they might not be exactly equal due to subscripts and the like, but our // text and anaysis are very simple. Assert.AreEqual(heightOne, heightMany, "ribbon should not wrap!"); }