Exemplo n.º 1
0
        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!");
        }
Exemplo n.º 2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Create minimal test data required for every test.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected override void CreateTestData()
 {
     base.CreateTestData();
     m_ribbon        = new TestInterlinRibbon(Cache, m_stText.Hvo);
     m_ribbon.Width  = 100;
     m_ribbon.Height = 40;
     Assert.IsNotNull(m_ribbon.Decorator, "Don't have correct access here.");
     m_ribbon.CacheRibbonItems(new List <AnalysisOccurrence>());
 }
Exemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create minimal test data required for every test.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_ribbon = new TestInterlinRibbon(Cache, m_stText.Hvo);
			m_ribbon.Width = 100;
			m_ribbon.Height = 40;
			Assert.IsNotNull(m_ribbon.Decorator, "Don't have correct access here.");
			m_ribbon.CacheRibbonItems(new List<AnalysisOccurrence>());
		}