Skip to content

Commit

Permalink
chore: Adjust for UWP build and StyleHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Sep 3, 2024
1 parent e945b32 commit c387f1a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,114 +56,102 @@ public void VerifyDefaultSelectorBarPropertyValues()
[TestMethod]
public async Task VerifySelectorBarItems()
{
IDisposable styleDisposable = null;
try
//using (PrivateLoggingHelper privateIVLoggingHelper = new PrivateLoggingHelper("ItemsView", "ScrollView"))
{
await TestServices.RunOnUIThread(() =>
{
styleDisposable = StyleHelper.UseFluentStyles();
});
//using (PrivateLoggingHelper privateIVLoggingHelper = new PrivateLoggingHelper("ItemsView", "ScrollView"))
SelectorBar selectorBar = null;
AutoResetEvent selectorBarLoadedEvent = new AutoResetEvent(false);
AutoResetEvent selectorBarUnloadedEvent = new AutoResetEvent(false);

RunOnUIThread.Execute(() =>
{
SelectorBar selectorBar = null;
AutoResetEvent selectorBarLoadedEvent = new AutoResetEvent(false);
AutoResetEvent selectorBarUnloadedEvent = new AutoResetEvent(false);
selectorBar = new SelectorBar();
Verify.IsNotNull(selectorBar);
Verify.IsNotNull(selectorBar.Items);

RunOnUIThread.Execute(() =>
SelectorBarItem selectorBarItemDeleted = new SelectorBarItem()
{
selectorBar = new SelectorBar();
Verify.IsNotNull(selectorBar);
Verify.IsNotNull(selectorBar.Items);
Text = "Deleted",
Icon = new SymbolIcon(Symbol.Delete),
IsEnabled = false
};

SelectorBarItem selectorBarItemDeleted = new SelectorBarItem()
{
Text = "Deleted",
Icon = new SymbolIcon(Symbol.Delete),
IsEnabled = false
};
selectorBar.Items.Add(selectorBarItemDeleted);

selectorBar.Items.Add(selectorBarItemDeleted);
SelectorBarItem selectorBarItemRemote = new SelectorBarItem()
{
Text = "Remote",
Icon = new SymbolIcon(Symbol.Remote),
IsSelected = true
};

SelectorBarItem selectorBarItemRemote = new SelectorBarItem()
{
Text = "Remote",
Icon = new SymbolIcon(Symbol.Remote),
IsSelected = true
};
selectorBar.Items.Add(selectorBarItemRemote);

selectorBar.Items.Add(selectorBarItemRemote);
SelectorBarItem selectorBarItemShared = new SelectorBarItem()
{
Text = "Shared",
Icon = new SymbolIcon(Symbol.Share)
};

SelectorBarItem selectorBarItemShared = new SelectorBarItem()
{
Text = "Shared",
Icon = new SymbolIcon(Symbol.Share)
};
selectorBar.Items.Add(selectorBarItemShared);

selectorBar.Items.Add(selectorBarItemShared);
SelectorBarItem selectorBarItemFavorites = new SelectorBarItem()
{
Text = "Favorites",
Icon = new SymbolIcon(Symbol.Favorite)
};

SelectorBarItem selectorBarItemFavorites = new SelectorBarItem()
{
Text = "Favorites",
Icon = new SymbolIcon(Symbol.Favorite)
};
selectorBar.Items.Add(selectorBarItemFavorites);

selectorBar.Items.Add(selectorBarItemFavorites);
Verify.AreEqual(4, selectorBar.Items.Count);

Verify.AreEqual(4, selectorBar.Items.Count);
SetupDefaultUI(selectorBar, selectorBarLoadedEvent, selectorBarUnloadedEvent);
});

SetupDefaultUI(selectorBar, selectorBarLoadedEvent, selectorBarUnloadedEvent);
});
WaitForEvent("Waiting for Loaded event", selectorBarLoadedEvent);

WaitForEvent("Waiting for Loaded event", selectorBarLoadedEvent);
RunOnUIThread.Execute(() =>
{
Log.Comment("Logging SelectorBar property values after Loaded event");
LogSelectorBarProperties(selectorBar);

Log.Comment("Verifying SelectorBar property values after Loaded event");
Verify.AreEqual(selectorBar.Items[1], selectorBar.SelectedItem);
Verify.IsTrue(selectorBar.IsEnabled);
Verify.IsFalse(selectorBar.IsTabStop);
Verify.AreEqual(XYFocusKeyboardNavigationMode.Auto, selectorBar.XYFocusKeyboardNavigation);
Verify.AreEqual(KeyboardNavigationMode.Once, selectorBar.TabNavigation);

ItemsView itemsView = SelectorBarTestHooks.GetItemsViewPart(selectorBar);

Log.Comment("Logging ItemsView property values after Loaded event");
LogItemsViewProperties(itemsView);

Log.Comment("Verifying ItemsView property values after Loaded event");
Verify.IsNotNull(itemsView);
Verify.AreEqual(XYFocusKeyboardNavigationMode.Disabled, itemsView.XYFocusKeyboardNavigation);
Verify.AreEqual(KeyboardNavigationMode.Once, itemsView.TabNavigation);
Verify.AreEqual(ItemsViewSelectionMode.Single, itemsView.SelectionMode);
Verify.AreEqual(1, itemsView.SelectedItems.Count);
Verify.AreEqual(-1, itemsView.CurrentItemIndex);
Verify.AreEqual(selectorBar.Items[1], itemsView.SelectedItem);

Log.Comment("Removing 2nd SelectorBarItem.");
selectorBar.Items.RemoveAt(1);
Verify.AreEqual(3, selectorBar.Items.Count);
Verify.IsNull(selectorBar.SelectedItem);

Log.Comment("Clearing all SelectorBarItems.");
selectorBar.Items.Clear();
Verify.AreEqual(0, selectorBar.Items.Count);

Log.Comment("Resetting window content and SelectorBar");
Content = null;
selectorBar = null;
});

RunOnUIThread.Execute(() =>
{
Log.Comment("Logging SelectorBar property values after Loaded event");
LogSelectorBarProperties(selectorBar);

Log.Comment("Verifying SelectorBar property values after Loaded event");
Verify.AreEqual(selectorBar.Items[1], selectorBar.SelectedItem);
Verify.IsTrue(selectorBar.IsEnabled);
Verify.IsFalse(selectorBar.IsTabStop);
Verify.AreEqual(XYFocusKeyboardNavigationMode.Auto, selectorBar.XYFocusKeyboardNavigation);
Verify.AreEqual(KeyboardNavigationMode.Once, selectorBar.TabNavigation);

ItemsView itemsView = SelectorBarTestHooks.GetItemsViewPart(selectorBar);

Log.Comment("Logging ItemsView property values after Loaded event");
LogItemsViewProperties(itemsView);

Log.Comment("Verifying ItemsView property values after Loaded event");
Verify.IsNotNull(itemsView);
Verify.AreEqual(XYFocusKeyboardNavigationMode.Disabled, itemsView.XYFocusKeyboardNavigation);
Verify.AreEqual(KeyboardNavigationMode.Once, itemsView.TabNavigation);
Verify.AreEqual(ItemsViewSelectionMode.Single, itemsView.SelectionMode);
Verify.AreEqual(1, itemsView.SelectedItems.Count);
Verify.AreEqual(-1, itemsView.CurrentItemIndex);
Verify.AreEqual(selectorBar.Items[1], itemsView.SelectedItem);

Log.Comment("Removing 2nd SelectorBarItem.");
selectorBar.Items.RemoveAt(1);
Verify.AreEqual(3, selectorBar.Items.Count);
Verify.IsNull(selectorBar.SelectedItem);

Log.Comment("Clearing all SelectorBarItems.");
selectorBar.Items.Clear();
Verify.AreEqual(0, selectorBar.Items.Count);

Log.Comment("Resetting window content and SelectorBar");
Content = null;
selectorBar = null;
});

WaitForEvent("Waiting for Unloaded event", selectorBarUnloadedEvent);
await TestServices.WindowHelper.WaitForIdle();
Log.Comment("Done");
}
}
finally
{
await TestServices.RunOnUIThread(() => styleDisposable?.Dispose());
WaitForEvent("Waiting for Unloaded event", selectorBarUnloadedEvent);
await TestServices.WindowHelper.WaitForIdle();
Log.Comment("Done");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task When_Theme_Changes()
{
continue;
}
var background = (backgroundBrush as SolidColorBrush)?.Color ?? ((RevealBackgroundBrush)backgroundBrush).Color;
var background = (backgroundBrush as SolidColorBrush)?.Color ?? ((Microsoft/* UWP don't rename */.UI.Xaml.Media.RevealBackgroundBrush)backgroundBrush).Color;

// Skip colored dates (selected), or those with opacity of zero.
if (background.R == background.G && background.G == background.B && background.A != 0)
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task When_Theme_Changes()
{
continue;
}
var background = (backgroundBrush as SolidColorBrush)?.Color ?? ((RevealBackgroundBrush)backgroundBrush).Color;
var background = (backgroundBrush as SolidColorBrush)?.Color ?? ((Microsoft/* UWP don't rename */.UI.Xaml.Media.RevealBackgroundBrush)backgroundBrush).Color;

// Skip colored dates (selected), or those with opacity of zero.
if (background.R == background.G && background.G == background.B && background.A != 0)
Expand Down

0 comments on commit c387f1a

Please sign in to comment.