public async Task GetAppThemeIsCaseInsensitive() { await TestHost.SwitchToAppThread(); AppTheme theme = ThemeManager.GetAppTheme("basedark"); Assert.NotNull(theme); Assert.Equal(new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml"), theme.Resources.Source); }
public async Task FlyoutIsHiddenByDefault() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); // root grid should be hidden Assert.Equal(Visibility.Hidden, window.DefaultFlyout.Visibility); }
public async Task GetAccentIsCaseInsensitive() { await TestHost.SwitchToAppThread(); Accent accent = ThemeManager.GetAccent("blue"); Assert.NotNull(accent); Assert.Equal(new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml"), accent.Resources.Source); }
public async Task MinMaxButtonsShouldBeToggled() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); var minButton = GetButton(window, "PART_Min"); var maxButton = GetButton(window, "PART_Max"); // min/max should be visible Assert.True(minButton.IsVisible); Assert.True(maxButton.IsVisible); Assert.Equal(ResizeMode.CanResize, window.ResizeMode); window.ResizeMode = ResizeMode.CanMinimize; // min should be visible, max hidden Assert.True(minButton.IsVisible); Assert.False(maxButton.IsVisible); Assert.Equal(ResizeMode.CanMinimize, window.ResizeMode); window.ShowMinButton = false; // min should be hidden Assert.False(minButton.IsVisible); window.ResizeMode = ResizeMode.NoResize; // min/max should be hidden Assert.False(minButton.IsVisible); Assert.False(maxButton.IsVisible); Assert.Equal(ResizeMode.NoResize, window.ResizeMode); window.ShowMaxRestoreButton = false; // max should be hidden Assert.False(maxButton.IsVisible); window.ResizeMode = ResizeMode.CanResizeWithGrip; // min/max should be hidden Assert.False(minButton.IsVisible); Assert.False(maxButton.IsVisible); Assert.Equal(ResizeMode.CanResizeWithGrip, window.ResizeMode); window.ShowMinButton = true; window.ShowMaxRestoreButton = true; // min/max should be visible Assert.True(minButton.IsVisible); Assert.True(maxButton.IsVisible); window.ResizeMode = ResizeMode.NoResize; // min/max should be hidden Assert.False(minButton.IsVisible); Assert.False(maxButton.IsVisible); Assert.Equal(ResizeMode.NoResize, window.ResizeMode); }
public async Task IconShouldBeVisibleByDefault() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); var icon = window.GetPart <ContentControl>("PART_Icon"); Assert.Equal(Visibility.Visible, icon.Visibility); }
public async Task FlyoutRespondsToFlyoutThemeChange() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); window.DefaultFlyout.Theme = FlyoutTheme.Light; Assert.Equal(Theme.Light, window.DefaultFlyout.ActualTheme); }
public async Task InverseFlyoutHasInverseWindowTheme() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); window.DefaultFlyout.Theme = FlyoutTheme.Inverse; Assert.Equal(Theme.Dark, window.DefaultFlyout.ActualTheme); }
public async Task DefaultWindowCommandColorIsBlack() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <CleanWindow>(); var blackBrushColor = ((SolidColorBrush)ThemeManager.GetAppTheme("BaseLight").Resources["BlackBrush"]).Color; window.AssertWindowCommandsColor(blackBrushColor); }
public async Task GetInverseAppThemeReturnsNullForMissingTheme() { await TestHost.SwitchToAppThread(); var appTheme = new AppTheme("TestTheme", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml")); AppTheme theme = ThemeManager.GetInverseAppTheme(appTheme); Assert.Null(theme); }
public async Task WindowButtonCommandsAreOverFlyout() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); int windowCommandsZIndex = Panel.GetZIndex(window.WindowButtonCommands); int flyoutindex = Panel.GetZIndex(window.RightFlyout); Assert.True(windowCommandsZIndex > flyoutindex); }
public async Task IconCanOverlayHiddenTitlebar() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); window.IconOverlayBehavior = WindowCommandsOverlayBehavior.HiddenTitleBar; window.ShowTitleBar = false; var icon = window.GetPart <ContentControl>("PART_Icon"); Assert.Equal(Visibility.Visible, icon.Visibility); }
public async Task FlyoutIsHiddenByDefault() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); // find the root grid in the visual tree var rootGrid = window.DefaultFlyout.FindChildren <Grid>(true).FirstOrDefault(); Assert.NotNull(rootGrid); // root grid should be hidden Assert.Equal(Visibility.Hidden, rootGrid.Visibility); }
public async Task HiddenWindowCommandsAreBelowFlyout() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); window.ShowWindowCommandsOnTop = false; int windowCommandsZIndex = Panel.GetZIndex(window.WindowButtonCommands); int flyoutindex = Panel.GetZIndex(window.RightFlyout); Assert.True(flyoutindex < windowCommandsZIndex); }
public async Task RightWindowCommandsAreOverFlyout() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); window.RightFlyout.IsOpen = true; var exposedWindow = Exposed.From(window); int windowCommandsZIndex = Panel.GetZIndex(exposedWindow.RightWindowCommandsPresenter); int flyoutindex = Panel.GetZIndex(window.RightFlyout); Assert.True(windowCommandsZIndex > flyoutindex); }
public async Task GetAppThemeWithUriIsCaseInsensitive() { await TestHost.SwitchToAppThread(); var dic = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/basedark.xaml") }; AppTheme detected = ThemeManager.GetAppTheme(dic); Assert.NotNull(detected); Assert.Equal("BaseDark", detected.Name); }
public async Task HiddenLeftWindowCommandsAreBelowFlyout() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); window.LeftWindowCommandsOverlayBehavior = WindowCommandsOverlayBehavior.Never; window.LeftFlyout.IsOpen = true; var exposedWindow = Exposed.From(window); int windowCommandsZIndex = Panel.GetZIndex(exposedWindow.LeftWindowCommandsPresenter); int flyoutindex = Panel.GetZIndex(window.LeftFlyout); Assert.True(flyoutindex < windowCommandsZIndex); }
public async Task ChangesWindowTheme() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <MetroWindow>(); Accent expectedAccent = ThemeManager.DefaultAccents.First(x => x.Name == "Teal"); ThemeManager.ChangeTheme(Application.Current, expectedAccent, Theme.Dark); var theme = ThemeManager.DetectTheme(window); Assert.Equal(Theme.Dark, theme.Item1); Assert.Equal(expectedAccent, theme.Item2); }
public async Task ChangesWindowTheme() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); Accent expectedAccent = ThemeManager.Accents.First(x => x.Name == "Teal"); AppTheme expectedTheme = ThemeManager.GetAppTheme("BaseDark"); ThemeManager.ChangeAppStyle(Application.Current, expectedAccent, expectedTheme); var theme = ThemeManager.DetectAppStyle(window); Assert.Equal(expectedTheme, theme.Item1); Assert.Equal(expectedAccent, theme.Item2); }
public async Task MinMaxCloseButtonsShouldBeHidden() { await TestHost.SwitchToAppThread(); var window = await TestHelpers.CreateInvisibleWindowAsync <HiddenMinMaxCloseButtonsWindow>(); var minButton = GetButton(window, "PART_Min"); var maxButton = GetButton(window, "PART_Max"); var closeButton = GetButton(window, "PART_Close"); // min/max/close should be hidden Assert.False(minButton.IsVisible); Assert.False(maxButton.IsVisible); Assert.False(closeButton.IsVisible); Assert.Equal(ResizeMode.CanResize, window.ResizeMode); }
public async Task MinMaxCloseButtonsShouldBeVisibleByDefault() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); var minButton = GetButton(window, "PART_Min"); var maxButton = GetButton(window, "PART_Max"); var closeButton = GetButton(window, "PART_Close"); // min/max/close should be visible Assert.True(minButton.IsVisible); Assert.True(maxButton.IsVisible); Assert.True(closeButton.IsVisible); Assert.Equal(ResizeMode.CanResize, window.ResizeMode); }
public async Task TestAutoWatermark() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <AutoWatermarkTestWindow>().ConfigureAwait(false); window.Invoke(() => { var autoWatermark = "AutoWatermark"; Assert.Equal(autoWatermark, window.TestTextBox.GetValue(TextBoxHelper.WatermarkProperty)); Assert.Equal(autoWatermark, window.TestTextBoxSubModel.GetValue(TextBoxHelper.WatermarkProperty)); Assert.Equal(autoWatermark, window.TestComboBox.GetValue(TextBoxHelper.WatermarkProperty)); Assert.Equal(autoWatermark, window.TestNumericUpDown.GetValue(TextBoxHelper.WatermarkProperty)); Assert.Equal(autoWatermark, window.TestDatePicker.GetValue(TextBoxHelper.WatermarkProperty)); }); }
public async Task RaisesIsOpenChangedEvent() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); bool eventRaised = false; window.RightFlyout.IsOpenChanged += (sender, args) => { eventRaised = true; }; window.RightFlyout.IsOpen = true; Assert.True(eventRaised); }
public async Task AdaptsWindowCommandsToDarkFlyout() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <FlyoutWindow>(); var flyout = new Flyout { Theme = FlyoutTheme.Dark }; window.Flyouts.Items.Add(flyout); flyout.IsOpen = true; Color expectedColor = ((SolidColorBrush)ThemeManager.GetAppTheme("BaseDark").Resources["BlackBrush"]).Color; window.AssertWindowCommandsColor(expectedColor); }
public async Task MaxButtonShouldBeHiddenWithCanMinimizeResizeMode() { await TestHost.SwitchToAppThread(); var window = await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); var minButton = GetButton(window, "PART_Min"); var maxButton = GetButton(window, "PART_Max"); // min/max should be visible Assert.True(minButton.IsVisible); Assert.True(maxButton.IsVisible); Assert.Equal(ResizeMode.CanResize, window.ResizeMode); window.ResizeMode = ResizeMode.CanMinimize; // min should be visible, max hidden Assert.True(minButton.IsVisible); Assert.False(maxButton.IsVisible); Assert.Equal(ResizeMode.CanMinimize, window.ResizeMode); }
public async Task CanAddAppThemeBeforeGetterIsCalled() { await TestHost.SwitchToAppThread(); ThemeManager.AddAppTheme("TestTheme", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml")); }
public async Task MetroWindowSmokeTest() { await TestHost.SwitchToAppThread(); await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>(); }