Ejemplo n.º 1
0
        public void MathInputButton_KeyboardProperty()
        {
            var mathKeyboardClassThatProcessesKeyPresses = new MathKeyboard();
            var mathInputButton = new MathInputButton();

            mathInputButton.SetValue(MathInputButton.KeyboardProperty, mathKeyboardClassThatProcessesKeyPresses);
            Assert.Equal(mathKeyboardClassThatProcessesKeyPresses, mathInputButton.Keyboard);
        }
Ejemplo n.º 2
0
        public void MathInputButtonsHaveTransparentBackgroundByDefault(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            Assert.Equal(Color.Transparent, mathInputButton.BackgroundColor);
        }
Ejemplo n.º 3
0
        public void AllMathInputButtonsHaveLatexContent(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            Assert.False(string.IsNullOrEmpty(mathInputButton.Content?.LaTeX));
        }
Ejemplo n.º 4
0
        public void MathInputButtonPlaceholderColorsAreOverridableForDoublePlaceholders(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput, PlaceholderActiveColor = Color.Black, PlaceholderRestingColor = Color.LightGray
            };

            Assert.Equal(Color.Black, mathInputButton.PlaceholderActiveColor);
            Assert.Equal(Color.LightGray, mathInputButton.PlaceholderRestingColor);
            TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{#FF000000}{😀}", @"\color{#FFD3D3D3}{😐}");
        }
Ejemplo n.º 5
0
        public void MathInputButtonPlaceholderColorsAreOverridableForSinglePlaceholder(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput, PlaceholderActiveColor = Color.Red
            };

            Assert.Equal(Color.Red, mathInputButton.PlaceholderActiveColor);
            Assert.Null(mathInputButton.PlaceholderRestingColor);
            Assert.Contains(@"\color{#FFFF0000}{😀}", mathInputButton.Content.NotNull().LaTeX.NotNull());
        }
Ejemplo n.º 6
0
        public void MathInputButtonPlaceholdersAreSameAsEditorOutputByDefaultForDoublePlaceholders(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            Assert.Null(mathInputButton.PlaceholderActiveColor);
            Assert.Null(mathInputButton.PlaceholderRestingColor);
            TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{green}{😀}", @"\color{blue}{😐}");
        }
Ejemplo n.º 7
0
        public void MathInputButtonPlaceholdersAreSameAsEditorOutputByDefaultForSinglePlaceholder(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            Assert.Null(mathInputButton.PlaceholderActiveColor);
            Assert.Null(mathInputButton.PlaceholderRestingColor);
            Assert.Contains(@"\color{green}{😀}", mathInputButton.Content.NotNull().LaTeX.NotNull());
        }
Ejemplo n.º 8
0
        public void MathInputButtonTwoPlaceholdersWithSameNucleusColorsAreOverridable(MathKeyboardInput mathKeyboardInput)
        {
            LaTeXSettings.PlaceholderActiveNucleus = LaTeXSettings.PlaceholderRestingNucleus = "😀";
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput, PlaceholderActiveColor = Color.Black, PlaceholderRestingColor = Color.LightGray
            };

            Assert.Equal(Color.Black, mathInputButton.PlaceholderActiveColor);
            Assert.Equal(Color.LightGray, mathInputButton.PlaceholderRestingColor);
            TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{#FF000000}{😀}", @"\color{#FFD3D3D3}{😀}");
        }
Ejemplo n.º 9
0
        public void MathInputButtonTwoPlaceholdersWithSameNucleusColorsSameAsEditorOutput(MathKeyboardInput mathKeyboardInput)
        {
            LaTeXSettings.PlaceholderActiveNucleus = LaTeXSettings.PlaceholderRestingNucleus = "■";
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            Assert.Null(mathInputButton.PlaceholderActiveColor);
            Assert.Null(mathInputButton.PlaceholderRestingColor);
            TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{green}{■}", @"\color{blue}{■}");
        }
Ejemplo n.º 10
0
        public void MathInputButtonsHaveBlackTextColorByDefault(MathKeyboardInput mathKeyboardInput)
        {
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            // At the time of writing this test, phatom = @"{\color{#00FFFFFF}{|}}" (Xamarin.Forms.Color.Transparent = "#00FFFFFF") is used as there is no \phantom command yet.
            // As soon as \phantom has been implemented, the call .Replace(LatexHelper.phantom, "") can be removed.
            Assert.DoesNotContain(@"\color", mathInputButton.Content.NotNull().LaTeX.NotNull().Replace(LatexHelper.phantom, ""));
            Assert.Equal(Color.Black, mathInputButton.TextColor);
        }
Ejemplo n.º 11
0
        public void MathInputButtonTextColorCanChangeMultipleTimes()
        {
            var mathInputButton = new MathInputButton {
                Input = MathKeyboardInput.Fraction
            };

            Assert.True(mathInputButton.ImageSourceEquals("files/buttons/MathInputButton_Fraction_Black.png"));
            mathInputButton.TextColor = Color.Blue;
            Assert.True(mathInputButton.ImageSourceEquals("files/buttons/MathInputButton_Fraction_Blue.png"));
            mathInputButton.TextColor = Color.Black;
            Assert.True(mathInputButton.ImageSourceEquals("files/buttons/MathInputButton_Fraction_Black.png"));
        }
Ejemplo n.º 12
0
        public void SameNucleusPlaceholders_MathInputButtonPlaceholderWithSinglePlaceholderIsActive(MathKeyboardInput mathKeyboardInput)
        {
            LaTeXSettings.PlaceholderActiveNucleus = LaTeXSettings.PlaceholderRestingNucleus = "■";
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput
            };

            Assert.Null(mathInputButton.PlaceholderActiveColor);
            Assert.Null(mathInputButton.PlaceholderRestingColor);
            var latex = mathInputButton.Content.NotNull().LaTeX.NotNull();

            Assert.Contains(@"\color{green}{■}", latex);
            Assert.DoesNotContain(@"\color{blue}", latex);
        }
Ejemplo n.º 13
0
        public void MathInputButton_Command(MathKeyboardInput mathKeyboardInput)
        {
            var mathKeyboardClassThatProcessesKeyPresses = new MathKeyboard();
            var mathInputButton = new MathInputButton {
                Input = mathKeyboardInput, Keyboard = mathKeyboardClassThatProcessesKeyPresses
            };

            mathInputButton.Command.Execute(null); // Simulate a MathInputButton key press
            Assert.Equal(expectedResult(), mathKeyboardClassThatProcessesKeyPresses.LaTeX);
            string expectedResult()
            {
                var kb = new MathKeyboard();

                kb.KeyPress(mathKeyboardInput);
                return(kb.LaTeX);
            }
        }
Ejemplo n.º 14
0
        void TestTwoButtonDisplayPlaceholders(MathInputButton mathInputButton, string expectedColoredActivePlaceholder, string expectedColoredRestingPlaceholder)
        {
            var mathInputButtonLatex = mathInputButton.Content.NotNull().LaTeX.NotNull();

            Assert.Contains(expectedColoredActivePlaceholder, mathInputButtonLatex);
            Assert.Contains(expectedColoredRestingPlaceholder, mathInputButtonLatex);
            var activeNucleusIndex  = mathInputButtonLatex.IndexOf(expectedColoredActivePlaceholder);
            var restingNucleusIndex = mathInputButtonLatex.IndexOf(expectedColoredRestingPlaceholder);

            if (mathInputButton.Input == MathKeyboardInput.Power || mathInputButton.Input == MathKeyboardInput.Subscript)
            {
                Assert.True(restingNucleusIndex < activeNucleusIndex);
            }
            else
            {
                Assert.True(activeNucleusIndex < restingNucleusIndex);
            }
        }