示例#1
0
        public async Task SaveScreenshot_WithSuffix_SavesImage()
        {
            var app          = new Simulators.App();
            var testRecorder = new TestRecorder(app);

            await testRecorder.SaveScreenshot("MySuffix");

            var file = GetScreenshots().Single();

            var fileName = Path.GetFileName(file);

            Assert.AreEqual($"{nameof(SaveScreenshot_WithSuffix_SavesImage)}MySuffix{GetLineNumber(-5)}-win1.jpg", fileName);
        }
示例#2
0
        public async Task PrimaryColor_AdjustToTheme(PrimaryColor primary)
        {
            await using var recorder = new TestRecorder(App);

            await App.InitialzeWithMaterialDesign(BaseTheme.Light, primary, colorAdjustment : new ColorAdjustment());

            IWindow window = await App.CreateWindow <ColorAdjustWindow>();

            await recorder.SaveScreenshot();

            Color windowBackground = await window.GetBackgroundColor();

            IVisualElement themeToggle = await window.GetElement("/ToggleButton");

            IVisualElement largeText = await window.GetElement("/TextBlock[0]");

            IVisualElement smallText = await window.GetElement("/TextBlock[1]");

            await AssertContrastRatio();

            await themeToggle.Click();

            await Wait.For(async() => await window.GetBackgroundColor() != windowBackground);

            await AssertContrastRatio();

            recorder.Success();

            async Task AssertContrastRatio()
            {
                Color largeTextForeground = await largeText.GetForegroundColor();

                Color largeTextBackground = await largeText.GetEffectiveBackground();

                Color smallTextForeground = await smallText.GetForegroundColor();

                Color smallTextBackground = await smallText.GetEffectiveBackground();

                var largeContrastRatio = ColorAssist.ContrastRatio(largeTextForeground, largeTextBackground);

                Assert.True(largeContrastRatio >= MaterialDesignSpec.MinimumContrastLargeText, $"Large font contrast ratio '{largeContrastRatio}' does not meet material design spec {MaterialDesignSpec.MinimumContrastLargeText}");
                var smallContrastRatio = ColorAssist.ContrastRatio(smallTextForeground, smallTextBackground);

                Assert.True(smallContrastRatio >= MaterialDesignSpec.MinimumContrastSmallText, $"Small font contrast ratio '{smallContrastRatio}' does not meet material design spec {MaterialDesignSpec.MinimumContrastSmallText}");
            }
        }