Exemplo n.º 1
0
        public void TestUnsetBehConf()
        {
            var ubc = new UnsetBehConf();

            for (Ucbx u = Ucbx.bold; u < Ucbx.last; u++)
            {
                ubc.SetCbuFlag(u, true);
                ubc.SetCbuFlag(u, false);
                Assert.IsFalse(ubc.GetCbuFlag(u));
                UndoFactory.UndoLastAction();
                Assert.IsTrue(ubc.GetCbuFlag(u));
                UndoFactory.RedoLastCanceledAction();
                Assert.IsFalse(ubc.GetCbuFlag(u));
                UndoFactory.UndoLastAction();
                Assert.IsTrue(ubc.GetCbuFlag(u));
            }
            ubc.Reset();
            for (Ucbx u = Ucbx.bold; u < Ucbx.last; u++)
            {
                Assert.IsFalse(ubc.GetCbuFlag(u));
            }
            UndoFactory.UndoLastAction();
            for (Ucbx u = Ucbx.bold; u < Ucbx.last; u++)
            {
                Assert.IsTrue(ubc.GetCbuFlag(u));
            }
            UndoFactory.RedoLastCanceledAction();
            for (Ucbx u = Ucbx.bold; u < Ucbx.last; u++)
            {
                Assert.IsFalse(ubc.GetCbuFlag(u));
            }
        }
Exemplo n.º 2
0
 private void CheckConsistency(UnsetBehConf uB)
 {
     if (uB.GetCbuFlag(Ucbx.all))
     {
         for (int i = 0; i < (int)Ucbx.all; i++)
         {
             Assert.IsTrue(uB.GetCbuFlag((Ucbx)i));
         }
     }
 }
Exemplo n.º 3
0
        public void TestFormatage1()
        {
            UnsetBehConf uB  = conf.unsetBeh;
            ColConfWin   ccw = conf.colors[PhonConfType.phonemes];
            SylConfig    sC  = conf.sylConf;

            RGB            color   = new RGB(25, 100, 200);
            RGB            hiColor = new RGB(200, 100, 25);
            CharFormatting cfAll   = new CharFormatting(true, true, true, true, true, color, true, hiColor);

            ccw.SetCbxAndCF("m", cfAll);

            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, true);
            ttt.AssertItalic(0, true);
            ttt.AssertUnderline(0, true);
            ttt.AssertColor(0, color);
            ttt.AssertChangeHilight(0, true);
            ttt.AssertHilightColor(0, hiColor);
            ttt.AssertBold(10, true); // La config par défaut fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ccw.SetCerasRose();
            uB.SetCbuFlag("Bold", true);
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, true);
            ttt.AssertUnderline(0, true);
            ttt.AssertColor(0, color);
            ttt.AssertChangeHilight(0, true);
            ttt.AssertHilightColor(0, hiColor);
            ttt.AssertBold(10, true); // Ceras rosé fait ça.
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("All", true);
            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, false);
            ttt.AssertUnderline(0, false);
            ttt.AssertColor(0, TestTheText.black);
            ttt.AssertChangeHilight(0, false);
            ttt.AssertBold(10, true); // Ceras rosé fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ttt.ColorizePhons(conf, PhonConfType.muettes);
            ttt.AssertBold(0, false);
            ttt.AssertItalic(0, false);
            ttt.AssertUnderline(0, false);
            ttt.AssertColor(0, TestTheText.black);
            ttt.AssertChangeHilight(0, false);
            ttt.AssertBold(10, false);
            ttt.AssertColor(10, TestTheText.black);
        }
Exemplo n.º 4
0
        public void TestFlags()
        {
            UnsetBehConf uB = conf.unsetBeh;

            ResetEventCounters();
            uB.SetCbuFlag("Bold", true);
            Assert.AreEqual(1, checkboxUnsetModifiedEvents.Count);
            Assert.AreEqual("Bold", checkboxUnsetModifiedEvents[0].unsetCBName);
            Assert.IsTrue(uB.GetCbuFlag("Bold"));
            Assert.IsFalse(uB.GetCbuFlag("Italic"));
            Assert.IsFalse(uB.GetCbuFlag("Underline"));
            Assert.IsFalse(uB.GetCbuFlag("Color"));
            Assert.IsFalse(uB.GetCbuFlag("Hilight"));
            Assert.IsFalse(uB.GetCbuFlag("All"));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.color));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.all));

            ResetEventCounters();
            uB.SetCbuFlag("Underline", true);
            Assert.AreEqual(1, checkboxUnsetModifiedEvents.Count);
            Assert.AreEqual("Underline", checkboxUnsetModifiedEvents[0].unsetCBName);
            Assert.IsTrue(uB.GetCbuFlag("Bold"));
            Assert.IsFalse(uB.GetCbuFlag("Italic"));
            Assert.IsTrue(uB.GetCbuFlag("Underline"));
            Assert.IsFalse(uB.GetCbuFlag("Color"));
            Assert.IsFalse(uB.GetCbuFlag("Hilight"));
            Assert.IsFalse(uB.GetCbuFlag("All"));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.color));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.all));

            ResetEventCounters();
            uB.SetCbuFlag("Bold", false);
            Assert.AreEqual(1, checkboxUnsetModifiedEvents.Count);
            Assert.AreEqual("Bold", checkboxUnsetModifiedEvents[0].unsetCBName);
            Assert.IsFalse(uB.GetCbuFlag("Bold"));
            Assert.IsFalse(uB.GetCbuFlag("Italic"));
            Assert.IsTrue(uB.GetCbuFlag("Underline"));
            Assert.IsFalse(uB.GetCbuFlag("Color"));
            Assert.IsFalse(uB.GetCbuFlag("Hilight"));
            Assert.IsFalse(uB.GetCbuFlag("All"));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.color));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.all));
        }
Exemplo n.º 5
0
        public void TestDefault()
        {
            UnsetBehConf uB = conf.unsetBeh;

            CheckConsistency(uB);
            // Default config - everything should be false
            for (int i = 0; i < (int)Ucbx.last; i++)
            {
                Assert.IsFalse(uB.GetCbuFlag((Ucbx)i));
            }
        }
Exemplo n.º 6
0
        public void TestExceptions()
        {
            UnsetBehConf uB = conf.unsetBeh;

            Assert.ThrowsException <ArgumentNullException>(() => uB.SetCbuFlag(null, true));
            Assert.ThrowsException <KeyNotFoundException>(() => uB.SetCbuFlag("alea", true));

            Assert.ThrowsException <ArgumentNullException>(() => _ = uB.GetCbuFlag(null));
            Assert.ThrowsException <KeyNotFoundException>(() => _  = uB.GetCbuFlag("alea"));

            Assert.ThrowsException <IndexOutOfRangeException>(() => _ = uB.GetCbuFlag(Ucbx.last));
        }
Exemplo n.º 7
0
        public void TestReset()
        {
            UnsetBehConf uB = conf.unsetBeh;

            uB.SetCbuFlag("All", true);
            CheckConsistency(uB);
            uB.Reset();
            CheckConsistency(uB);
            Assert.IsFalse(uB.GetCbuFlag("Bold"));
            Assert.IsFalse(uB.GetCbuFlag("Italic"));
            Assert.IsFalse(uB.GetCbuFlag("Underline"));
            Assert.IsFalse(uB.GetCbuFlag("Color"));
            Assert.IsFalse(uB.GetCbuFlag("Hilight"));
            Assert.IsFalse(uB.GetCbuFlag("All"));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.color));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.all));
        }
Exemplo n.º 8
0
        public void TestAll()
        {
            UnsetBehConf uB = conf.unsetBeh;

            ResetEventCounters();
            uB.SetCbuFlag("All", true);
            Assert.AreEqual((int)Ucbx.last, checkboxUnsetModifiedEvents.Count);
            for (int i = 0; i < (int)Ucbx.last; i++)
            {
                Assert.IsTrue(IsInEventList((Ucbx)i));
            }
            CheckConsistency(uB);
            Assert.IsTrue(uB.GetCbuFlag("Bold"));
            Assert.IsTrue(uB.GetCbuFlag("Italic"));
            Assert.IsTrue(uB.GetCbuFlag("Underline"));
            Assert.IsTrue(uB.GetCbuFlag("Color"));
            Assert.IsTrue(uB.GetCbuFlag("Hilight"));
            Assert.IsTrue(uB.GetCbuFlag("All"));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.color));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsTrue(uB.GetCbuFlag(Ucbx.all));

            ResetEventCounters();
            uB.SetCbuFlag("All", false);
            Assert.AreEqual((int)Ucbx.last, checkboxUnsetModifiedEvents.Count);
            for (int i = 0; i < (int)Ucbx.last; i++)
            {
                Assert.IsTrue(IsInEventList((Ucbx)i));
            }
            CheckConsistency(uB);
            Assert.IsFalse(uB.GetCbuFlag("Bold"));
            Assert.IsFalse(uB.GetCbuFlag("Italic"));
            Assert.IsFalse(uB.GetCbuFlag("Underline"));
            Assert.IsFalse(uB.GetCbuFlag("Color"));
            Assert.IsFalse(uB.GetCbuFlag("Hilight"));
            Assert.IsFalse(uB.GetCbuFlag("All"));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.color));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.all));

            ResetEventCounters();
            uB.SetCbuFlag("All", false);
            Assert.AreEqual(0, checkboxUnsetModifiedEvents.Count);
            CheckConsistency(uB);
            Assert.IsFalse(uB.GetCbuFlag("Bold"));
            Assert.IsFalse(uB.GetCbuFlag("Italic"));
            Assert.IsFalse(uB.GetCbuFlag("Underline"));
            Assert.IsFalse(uB.GetCbuFlag("Color"));
            Assert.IsFalse(uB.GetCbuFlag("Hilight"));
            Assert.IsFalse(uB.GetCbuFlag("All"));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.bold));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.italic));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.underline));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.color));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.hilight));
            Assert.IsFalse(uB.GetCbuFlag(Ucbx.all));
        }
Exemplo n.º 9
0
        public void TestFormatage2()
        {
            UnsetBehConf uB  = conf.unsetBeh;
            ColConfWin   ccw = conf.colors[PhonConfType.phonemes];
            SylConfig    sC  = conf.sylConf;

            RGB            color   = new RGB(25, 100, 200);
            RGB            hiColor = new RGB(200, 100, 25);
            CharFormatting cfAll   = new CharFormatting(true, true, true, true, true, color, true, hiColor);

            ccw.SetCbxAndCF("p", cfAll);
            TestTheText ttt = new TestTheText(text1);

            ttt.ColorizePhons(conf, PhonConfType.phonemes);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, true);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true); // La config par défaut fait ça.
            ttt.AssertColor(10, TestTheText.black);

            ttt.MarkLetters(conf); // ça ne devrait pas toucher au P majuscule...
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, true);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("Italic", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, true);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("Underline", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, true);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, false);
            ttt.AssertColor(9, color);
            ttt.AssertChangeHilight(9, true);
            ttt.AssertHilightColor(9, hiColor);
            ttt.AssertBold(10, true);
            ttt.AssertColor(10, TestTheText.black);

            uB.SetCbuFlag("All", true);
            ttt.MarkLetters(conf);
            ttt.AssertBold(9, false);
            ttt.AssertItalic(9, false);
            ttt.AssertUnderline(9, false);
            ttt.AssertColor(9, TestTheText.black);
            ttt.AssertChangeHilight(9, false);
            ttt.AssertBold(10, false);
            ttt.AssertColor(10, TestTheText.black);
        }