mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-15 08:46:37 +01:00
Compare commits
4 Commits
leilzh/tes
...
leilzh/pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfa490cfde | ||
|
|
b99e62af48 | ||
|
|
46d380c2b6 | ||
|
|
decb947283 |
@@ -13,7 +13,7 @@ parameters:
|
||||
default: false
|
||||
- name: buildSource
|
||||
type: string
|
||||
default: "latestOfficialBuild"
|
||||
default: "latestMainOfficialBuild"
|
||||
displayName: "Build Source"
|
||||
- name: specificBuildId
|
||||
type: string
|
||||
@@ -45,6 +45,7 @@ jobs:
|
||||
BuildConfiguration: ${{ parameters.configuration }}
|
||||
SrcPath: $(Build.Repository.LocalPath)
|
||||
TestArtifactsName: build-${{ variables.BuildPlatform }}-${{ parameters.configuration }}${{ parameters.inputArtifactStem }}
|
||||
isBuildNow: ${{ eq(parameters.buildSource, 'buildNow') }}
|
||||
pool:
|
||||
${{ if eq(variables['System.CollectionId'], 'cb55739e-4afe-46a3-970f-1b49d8ee7564') }}:
|
||||
${{ if ne(parameters.platform, 'ARM64') }}:
|
||||
@@ -115,7 +116,7 @@ jobs:
|
||||
& '$(build.sourcesdirectory)\.pipelines\InstallWinAppDriver.ps1'
|
||||
displayName: Download and install WinAppDriver
|
||||
|
||||
- ${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if not(variables.isBuildNow) }}:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
buildType: 'specific'
|
||||
@@ -136,7 +137,7 @@ jobs:
|
||||
patterns: |
|
||||
**/PowerToysSetup*.exe
|
||||
|
||||
- ${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if not(variables.isBuildNow) }}:
|
||||
- ${{ if eq(parameters.installMode, 'peruser') }}:
|
||||
- pwsh: |-
|
||||
& "$(build.sourcesdirectory)\.pipelines\installPowerToys.ps1" -InstallMode "PerUser"
|
||||
@@ -172,7 +173,7 @@ jobs:
|
||||
!**\UITests-FancyZones\**\UITests-FancyZonesEditor.dll
|
||||
env:
|
||||
platform: '$(TestPlatform)'
|
||||
useInstallerForTest: ${{ ne(parameters.buildSource, 'buildNow') }}
|
||||
useInstallerForTest: ${{ not(variables.isBuildNow) }}
|
||||
|
||||
- ${{ if ne(length(parameters.uiTestModules), 0) }}:
|
||||
- ${{ each module in parameters.uiTestModules }}:
|
||||
@@ -194,4 +195,4 @@ jobs:
|
||||
!**\UITests-FancyZones\**\UITests-FancyZonesEditor.dll
|
||||
env:
|
||||
platform: '$(TestPlatform)'
|
||||
useInstallerForTest: ${{ ne(parameters.buildSource, 'buildNow') }}
|
||||
useInstallerForTest: ${{ not(variables.isBuildNow) }}
|
||||
|
||||
@@ -3,6 +3,8 @@ variables:
|
||||
value: false
|
||||
- name: EnablePipelineCache
|
||||
value: true
|
||||
- name: isBuildNow
|
||||
value: ${{ eq(parameters.buildSource, 'buildNow') }}
|
||||
|
||||
parameters:
|
||||
- name: buildPlatforms
|
||||
@@ -21,10 +23,10 @@ parameters:
|
||||
default: false
|
||||
- name: buildSource
|
||||
type: string
|
||||
default: "latestOfficialBuild"
|
||||
default: "latestMainOfficialBuild"
|
||||
displayName: "Build Source"
|
||||
values:
|
||||
- latestOfficialBuild
|
||||
- latestMainOfficialBuild
|
||||
- buildNow
|
||||
- specificBuildId
|
||||
- name: specificBuildId
|
||||
@@ -37,7 +39,7 @@ parameters:
|
||||
|
||||
stages:
|
||||
- ${{ each platform in parameters.buildPlatforms }}:
|
||||
- ${{ if eq(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if variables.isBuildNow }}:
|
||||
- stage: Build_${{ platform }}
|
||||
displayName: Build ${{ platform }}
|
||||
dependsOn: []
|
||||
@@ -61,7 +63,7 @@ stages:
|
||||
useVSPreview: ${{ parameters.useVSPreview }}
|
||||
timeoutInMinutes: 90
|
||||
|
||||
- ${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if not(variables.isBuildNow) }}:
|
||||
- stage: BuildUITests_${{ platform }}
|
||||
displayName: Build UI Tests Only
|
||||
dependsOn: []
|
||||
@@ -82,7 +84,7 @@ stages:
|
||||
- ${{ if eq(platform, 'x64') }}:
|
||||
- stage: Test_x64Win10
|
||||
displayName: Test x64Win10
|
||||
${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
${{ if not(variables.isBuildNow) }}:
|
||||
dependsOn:
|
||||
- BuildUITests_${{ platform }}
|
||||
${{ else }}:
|
||||
@@ -99,7 +101,7 @@ stages:
|
||||
uiTestModules: ${{ parameters.uiTestModules }}
|
||||
|
||||
# Additional per-user installation test
|
||||
- ${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if not(variables.isBuildNow) }}:
|
||||
- template: job-test-project.yml
|
||||
parameters:
|
||||
platform: x64Win10
|
||||
@@ -114,7 +116,7 @@ stages:
|
||||
- ${{ if eq(platform, 'x64') }}:
|
||||
- stage: Test_x64Win11
|
||||
displayName: Test x64Win11
|
||||
${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
${{ if not(variables.isBuildNow) }}:
|
||||
dependsOn:
|
||||
- BuildUITests_${{ platform }}
|
||||
${{ else }}:
|
||||
@@ -131,7 +133,7 @@ stages:
|
||||
uiTestModules: ${{ parameters.uiTestModules }}
|
||||
|
||||
# Additional per-user installation test
|
||||
- ${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if not(variables.isBuildNow) }}:
|
||||
- template: job-test-project.yml
|
||||
parameters:
|
||||
platform: x64Win11
|
||||
@@ -146,7 +148,7 @@ stages:
|
||||
- ${{ if ne(platform, 'x64') }}:
|
||||
- stage: Test_${{ platform }}
|
||||
displayName: Test ${{ platform }}
|
||||
${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
${{ if not(variables.isBuildNow) }}:
|
||||
dependsOn:
|
||||
- BuildUITests_${{ platform }}
|
||||
${{ else }}:
|
||||
@@ -163,7 +165,7 @@ stages:
|
||||
uiTestModules: ${{ parameters.uiTestModules }}
|
||||
|
||||
# Additional per-user installation test
|
||||
- ${{ if ne(parameters.buildSource, 'buildNow') }}:
|
||||
- ${{ if not(variables.isBuildNow) }}:
|
||||
- template: job-test-project.yml
|
||||
parameters:
|
||||
platform: ${{ platform }}
|
||||
|
||||
@@ -786,6 +786,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.TimeDa
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.WindowWalker.UnitTests", "src\modules\cmdpal\Tests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests\Microsoft.CmdPal.Ext.WindowWalker.UnitTests.csproj", "{E816D7B0-4688-4ECB-97CC-3D8E798F3829}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CmdPal.Ext.UnitTestBase", "src\modules\cmdpal\Tests\Microsoft.CmdPal.Ext.UnitTestsBase\Microsoft.CmdPal.Ext.UnitTestBase.csproj", "{00D8659C-2068-40B6-8B86-759CD6284BBB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
@@ -2840,6 +2842,14 @@ Global
|
||||
{E816D7B0-4688-4ECB-97CC-3D8E798F3829}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{E816D7B0-4688-4ECB-97CC-3D8E798F3829}.Release|x64.ActiveCfg = Release|x64
|
||||
{E816D7B0-4688-4ECB-97CC-3D8E798F3829}.Release|x64.Build.0 = Release|x64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Debug|x64.Build.0 = Debug|x64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Release|x64.ActiveCfg = Release|x64
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -3150,6 +3160,7 @@ Global
|
||||
{E816D7AE-4688-4ECB-97CC-3D8E798F3827} = {8EF25507-2575-4ADE-BF7E-D23376903AB8}
|
||||
{E816D7AF-4688-4ECB-97CC-3D8E798F3828} = {8EF25507-2575-4ADE-BF7E-D23376903AB8}
|
||||
{E816D7B0-4688-4ECB-97CC-3D8E798F3829} = {8EF25507-2575-4ADE-BF7E-D23376903AB8}
|
||||
{00D8659C-2068-40B6-8B86-759CD6284BBB} = {8EF25507-2575-4ADE-BF7E-D23376903AB8}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||
|
||||
@@ -23,11 +23,11 @@ The PowerToys UI test pipeline provides flexible options for building and testin
|
||||
### Pipeline Options
|
||||
|
||||
- **buildSource**: Select the build type for testing:
|
||||
- `latestOfficialBuild`: Downloads and uses the latest official PowerToys build from main branch
|
||||
- `latestMainOfficialBuild`: Downloads and uses the latest official PowerToys build from main branch
|
||||
- `buildNow`: Builds PowerToys from current source code and uses it for testing
|
||||
- `specificBuildId`: Downloads a specific PowerToys build using the build ID specified in `specificBuildId` parameter
|
||||
|
||||
**Default value**: `latestOfficialBuild`
|
||||
**Default value**: `latestMainOfficialBuild`
|
||||
|
||||
- **specificBuildId**: When `buildSource` is set to `specificBuildId`, specify the exact PowerToys build ID to download and test against.
|
||||
|
||||
@@ -50,7 +50,7 @@ The PowerToys UI test pipeline provides flexible options for building and testin
|
||||
|
||||
### Build Modes
|
||||
|
||||
1. **Official Build Testing** (`buildSource = latestOfficialBuild` or `specificBuildId`)
|
||||
1. **Official Build Testing** (`buildSource = latestMainOfficialBuild` or `specificBuildId`)
|
||||
- Downloads and installs official PowerToys build (latest from main or specific build ID)
|
||||
- Builds only UI test projects (all or specific based on `uiTestModules`)
|
||||
- Runs UI tests against installed PowerToys
|
||||
|
||||
@@ -76,44 +76,44 @@
|
||||
|
||||
<Grid
|
||||
x:Name="IconRoot"
|
||||
Margin="8,0,0,0"
|
||||
Tapped="PageIcon_Tapped"
|
||||
Margin="3,0,-5,0"
|
||||
Visibility="{x:Bind CurrentPageViewModel.IsNested, Mode=OneWay}">
|
||||
<InfoBadge Visibility="{x:Bind CurrentPageViewModel.HasStatusMessage, Mode=OneWay}" Value="{x:Bind CurrentPageViewModel.StatusMessages.Count, Mode=OneWay}" />
|
||||
<Grid.ContextFlyout>
|
||||
<Flyout x:Name="StatusMessagesFlyout" Placement="TopEdgeAlignedLeft">
|
||||
<ItemsRepeater
|
||||
x:Name="MessagesDropdown"
|
||||
Margin="-8"
|
||||
ItemsSource="{x:Bind CurrentPageViewModel.StatusMessages, Mode=OneWay}"
|
||||
Layout="{StaticResource VerticalStackLayout}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate x:DataType="coreViewModels:StatusMessageViewModel">
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Bottom"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
CornerRadius="0">
|
||||
<InfoBar
|
||||
CornerRadius="{ThemeResource ControlCornerRadius}"
|
||||
IsClosable="False"
|
||||
IsOpen="True"
|
||||
Message="{x:Bind Message, Mode=OneWay}"
|
||||
Severity="{x:Bind State, Mode=OneWay, Converter={StaticResource MessageStateToSeverityConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</Flyout>
|
||||
</Grid.ContextFlyout>
|
||||
<Button
|
||||
x:Name="StatusMessagesButton"
|
||||
x:Uid="StatusMessagesButton"
|
||||
Padding="4"
|
||||
Style="{StaticResource SubtleButtonStyle}"
|
||||
Visibility="{x:Bind CurrentPageViewModel.HasStatusMessage, Mode=OneWay}">
|
||||
<InfoBadge Value="{x:Bind CurrentPageViewModel.StatusMessages.Count, Mode=OneWay}" />
|
||||
<Button.Flyout>
|
||||
<Flyout x:Name="StatusMessagesFlyout" Placement="TopEdgeAlignedLeft">
|
||||
<ItemsRepeater
|
||||
x:Name="MessagesDropdown"
|
||||
Margin="-8"
|
||||
ItemsSource="{x:Bind CurrentPageViewModel.StatusMessages, Mode=OneWay}"
|
||||
Layout="{StaticResource VerticalStackLayout}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate x:DataType="coreViewModels:StatusMessageViewModel">
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
|
||||
<InfoBar
|
||||
CornerRadius="{ThemeResource ControlCornerRadius}"
|
||||
IsClosable="False"
|
||||
IsOpen="True"
|
||||
Message="{x:Bind Message, Mode=OneWay}"
|
||||
Severity="{x:Bind State, Mode=OneWay, Converter={StaticResource MessageStateToSeverityConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Button
|
||||
x:Name="SettingsIconButton"
|
||||
x:Uid="SettingsButton"
|
||||
Click="SettingsIcon_Clicked"
|
||||
Style="{StaticResource SubtleButtonStyle}"
|
||||
Tapped="SettingsIcon_Tapped"
|
||||
Visibility="{x:Bind CurrentPageViewModel.IsNested, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<FontIcon
|
||||
@@ -146,8 +146,8 @@
|
||||
x:Load="{x:Bind IsLoaded, Mode=OneWay}"
|
||||
AutomationProperties.Name="{x:Bind ViewModel.PrimaryCommand.Name, Mode=OneWay}"
|
||||
Background="Transparent"
|
||||
Click="PrimaryButton_Clicked"
|
||||
Style="{StaticResource SubtleButtonStyle}"
|
||||
Tapped="PrimaryButton_Tapped"
|
||||
Visibility="{x:Bind ViewModel.HasPrimaryCommand, Mode=OneWay}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock
|
||||
@@ -169,8 +169,8 @@
|
||||
Padding="6,4,4,4"
|
||||
x:Load="{x:Bind IsLoaded, Mode=OneWay}"
|
||||
AutomationProperties.Name="{x:Bind ViewModel.SecondaryCommand.Name, Mode=OneWay}"
|
||||
Click="SecondaryButton_Clicked"
|
||||
Style="{StaticResource SubtleButtonStyle}"
|
||||
Tapped="SecondaryButton_Tapped"
|
||||
Visibility="{x:Bind ViewModel.HasSecondaryCommand, Mode=OneWay}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock
|
||||
@@ -200,8 +200,8 @@
|
||||
x:Name="MoreCommandsButton"
|
||||
x:Uid="MoreCommandsButton"
|
||||
Padding="4"
|
||||
Click="MoreCommandsButton_Clicked"
|
||||
Style="{StaticResource SubtleButtonStyle}"
|
||||
Tapped="MoreCommandsButton_Tapped"
|
||||
ToolTipService.ToolTip="Ctrl+K"
|
||||
Visibility="{x:Bind ViewModel.ShouldShowContextMenu, Mode=OneWay}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
|
||||
@@ -114,34 +114,23 @@ public sealed partial class CommandBar : UserControl,
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "VS has a tendency to delete XAML bound methods over-aggressively")]
|
||||
private void PrimaryButton_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
private void PrimaryButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.InvokePrimaryCommand();
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "VS has a tendency to delete XAML bound methods over-aggressively")]
|
||||
private void SecondaryButton_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
private void SecondaryButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.InvokeSecondaryCommand();
|
||||
}
|
||||
|
||||
private void PageIcon_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
if (CurrentPageViewModel?.StatusMessages.Count > 0)
|
||||
{
|
||||
StatusMessagesFlyout.ShowAt(
|
||||
placementTarget: IconRoot,
|
||||
showOptions: new FlyoutShowOptions() { ShowMode = FlyoutShowMode.Standard });
|
||||
}
|
||||
}
|
||||
|
||||
private void SettingsIcon_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
private void SettingsIcon_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<OpenSettingsMessage>();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void MoreCommandsButton_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
private void MoreCommandsButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<OpenContextMenuMessage>(new OpenContextMenuMessage(null, null, null, ContextMenuFilterLocation.Bottom));
|
||||
}
|
||||
|
||||
@@ -113,13 +113,14 @@
|
||||
<ListView
|
||||
x:Name="ItemsList"
|
||||
Padding="0,2,0,0"
|
||||
ContextCanceled="ItemsList_OnContextCanceled"
|
||||
ContextRequested="ItemsList_OnContextRequested"
|
||||
DoubleTapped="ItemsList_DoubleTapped"
|
||||
IsDoubleTapEnabled="True"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="ItemsList_ItemClick"
|
||||
ItemTemplate="{StaticResource ListItemViewModelTemplate}"
|
||||
ItemsSource="{x:Bind ViewModel.FilteredItems, Mode=OneWay}"
|
||||
RightTapped="ItemsList_RightTapped"
|
||||
SelectionChanged="ItemsList_SelectionChanged">
|
||||
<ListView.ItemContainerTransitions>
|
||||
<TransitionCollection />
|
||||
|
||||
@@ -316,30 +316,51 @@ public sealed partial class ListPage : Page,
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ItemsList_RightTapped(object sender, RightTappedRoutedEventArgs e)
|
||||
private void ItemsList_OnContextRequested(UIElement sender, ContextRequestedEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is FrameworkElement element &&
|
||||
element.DataContext is ListItemViewModel item)
|
||||
var (item, element) = e.OriginalSource switch
|
||||
{
|
||||
if (ItemsList.SelectedItem != item)
|
||||
{
|
||||
ItemsList.SelectedItem = item;
|
||||
}
|
||||
// caused by keyboard shortcut (e.g. Context menu key or Shift+F10)
|
||||
ListViewItem listViewItem => (ItemsList.ItemFromContainer(listViewItem) as ListItemViewModel, listViewItem),
|
||||
|
||||
ViewModel?.UpdateSelectedItemCommand.Execute(item);
|
||||
// caused by right-click on the ListViewItem
|
||||
FrameworkElement { DataContext: ListItemViewModel itemViewModel } frameworkElement => (itemViewModel, frameworkElement),
|
||||
|
||||
var pos = e.GetPosition(element);
|
||||
_ => (null, null),
|
||||
};
|
||||
|
||||
_ = DispatcherQueue.TryEnqueue(
|
||||
() =>
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<OpenContextMenuMessage>(
|
||||
new OpenContextMenuMessage(
|
||||
element,
|
||||
Microsoft.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.BottomEdgeAlignedLeft,
|
||||
pos,
|
||||
ContextMenuFilterLocation.Top));
|
||||
});
|
||||
if (item == null || element == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemsList.SelectedItem != item)
|
||||
{
|
||||
ItemsList.SelectedItem = item;
|
||||
}
|
||||
|
||||
ViewModel?.UpdateSelectedItemCommand.Execute(item);
|
||||
|
||||
if (!e.TryGetPosition(element, out var pos))
|
||||
{
|
||||
pos = new(0, element.ActualHeight);
|
||||
}
|
||||
|
||||
_ = DispatcherQueue.TryEnqueue(
|
||||
() =>
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<OpenContextMenuMessage>(
|
||||
new OpenContextMenuMessage(
|
||||
element,
|
||||
Microsoft.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.BottomEdgeAlignedLeft,
|
||||
pos,
|
||||
ContextMenuFilterLocation.Top));
|
||||
});
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void ItemsList_OnContextCanceled(UIElement sender, RoutedEventArgs e)
|
||||
{
|
||||
_ = DispatcherQueue.TryEnqueue(() => WeakReferenceMessenger.Default.Send<CloseContextMenuMessage>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,11 +225,11 @@
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
ui:VisualExtensions.NormalizedCenterPoint="0.5,0.5"
|
||||
Click="BackButton_Clicked"
|
||||
Content="{ui:FontIcon Glyph=,
|
||||
FontSize=14}"
|
||||
FontSize="16"
|
||||
Style="{StaticResource SubtleButtonStyle}"
|
||||
Tapped="BackButton_Tapped"
|
||||
Visibility="{x:Bind ViewModel.CurrentPage.IsNested, Mode=OneWay}">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:OpacityAnimation
|
||||
|
||||
@@ -413,7 +413,7 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
||||
}
|
||||
}
|
||||
|
||||
private void BackButton_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e) => WeakReferenceMessenger.Default.Send<NavigateBackMessage>(new());
|
||||
private void BackButton_Clicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) => WeakReferenceMessenger.Default.Send<NavigateBackMessage>(new());
|
||||
|
||||
private void RootFrame_Navigated(object sender, Microsoft.UI.Xaml.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
|
||||
@@ -428,4 +428,10 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
|
||||
<data name="Settings_ExtensionPage_Alias_ToggleSwitch.OffContent" xml:space="preserve">
|
||||
<value>Indirect</value>
|
||||
</data>
|
||||
<data name="StatusMessagesButton.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Show status messages</value>
|
||||
</data>
|
||||
<data name="StatusMessagesButton.[using:Microsoft.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Show status messages</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -11,17 +11,6 @@ namespace Microsoft.CmdPal.Ext.System.UnitTests;
|
||||
[TestClass]
|
||||
public class BasicTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void CommandsHelperTest()
|
||||
{
|
||||
// Setup & Act
|
||||
var commands = Commands.GetSystemCommands(false, false, false, false);
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(commands);
|
||||
Assert.IsTrue(commands.Count > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IconsHelperTest()
|
||||
{
|
||||
|
||||
@@ -16,56 +16,25 @@ namespace Microsoft.CmdPal.Ext.System.UnitTests;
|
||||
[TestClass]
|
||||
public class ImageTests
|
||||
{
|
||||
[DataTestMethod]
|
||||
[DataRow("shutdown", "ShutdownIcon")]
|
||||
[DataRow("restart", "RestartIcon")]
|
||||
[DataRow("sign out", "LogoffIcon")]
|
||||
[DataRow("lock", "LockIcon")]
|
||||
[DataRow("sleep", "SleepIcon")]
|
||||
[DataRow("hibernate", "SleepIcon")]
|
||||
[DataRow("recycle bin", "RecycleBinIcon")]
|
||||
[DataRow("uefi firmware settings", "FirmwareSettingsIcon")]
|
||||
[DataRow("IPv4 addr", "NetworkAdapterIcon")]
|
||||
[DataRow("IPV6 addr", "NetworkAdapterIcon")]
|
||||
[DataRow("MAC addr", "NetworkAdapterIcon")]
|
||||
public void IconThemeDarkTest(string typedString, string expectedIconPropertyName)
|
||||
[DataRow(true)]
|
||||
[DataRow(false)]
|
||||
[TestMethod]
|
||||
public void IconThemeTest(bool isDarkIcon)
|
||||
{
|
||||
var systemPage = new SystemCommandPage(new SettingsManager());
|
||||
var systemPage = new SystemCommandPage(new Settings());
|
||||
var commands = systemPage.GetItems();
|
||||
|
||||
foreach (var item in systemPage.GetItems())
|
||||
foreach (var item in commands)
|
||||
{
|
||||
if (item.Title.Contains(typedString, StringComparison.OrdinalIgnoreCase) || item.Subtitle.Contains(typedString, StringComparison.OrdinalIgnoreCase))
|
||||
var icon = item.Icon;
|
||||
Assert.IsNotNull(icon, $"Icon for '{item.Title}' should not be null.");
|
||||
if (isDarkIcon)
|
||||
{
|
||||
var icon = item.Icon;
|
||||
Assert.IsNotNull(icon, $"Icon for '{typedString}' should not be null.");
|
||||
Assert.IsNotEmpty(icon.Dark.Icon, $"Icon for '{typedString}' should not be empty.");
|
||||
Assert.IsNotEmpty(icon.Dark.Icon, $"Icon for '{item.Title}' should not be empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow("shutdown", "ShutdownIcon")]
|
||||
[DataRow("restart", "RestartIcon")]
|
||||
[DataRow("sign out", "LogoffIcon")]
|
||||
[DataRow("lock", "LockIcon")]
|
||||
[DataRow("sleep", "SleepIcon")]
|
||||
[DataRow("hibernate", "SleepIcon")]
|
||||
[DataRow("recycle bin", "RecycleBinIcon")]
|
||||
[DataRow("uefi firmware settings", "FirmwareSettingsIcon")]
|
||||
[DataRow("IPv4 addr", "NetworkAdapterIcon")]
|
||||
[DataRow("IPV6 addr", "NetworkAdapterIcon")]
|
||||
[DataRow("MAC addr", "NetworkAdapterIcon")]
|
||||
public void IconThemeLightTest(string typedString, string expectedIconPropertyName)
|
||||
{
|
||||
var systemPage = new SystemCommandPage(new SettingsManager());
|
||||
|
||||
foreach (var item in systemPage.GetItems())
|
||||
{
|
||||
if (item.Title.Contains(typedString, StringComparison.OrdinalIgnoreCase) || item.Subtitle.Contains(typedString, StringComparison.OrdinalIgnoreCase))
|
||||
else
|
||||
{
|
||||
var icon = item.Icon;
|
||||
Assert.IsNotNull(icon, $"Icon for '{typedString}' should not be null.");
|
||||
Assert.IsNotEmpty(icon.Light.Icon, $"Icon for '{typedString}' should not be empty.");
|
||||
Assert.IsNotEmpty(icon.Light.Icon, $"Icon for '{item.Title}' should not be empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,6 @@
|
||||
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\..\ext\Microsoft.CmdPal.Ext.System\Microsoft.CmdPal.Ext.System.csproj" />
|
||||
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.CmdPal.Ext.UnitTestsBase\Microsoft.CmdPal.Ext.UnitTestBase.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.CmdPal.Ext.System.Helpers;
|
||||
using Microsoft.CmdPal.Ext.System.Pages;
|
||||
using Microsoft.CmdPal.Ext.UnitTestBase;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.System.UnitTests;
|
||||
|
||||
[TestClass]
|
||||
public class QueryTests
|
||||
public class QueryTests : CommandPaletteUnitTestBase
|
||||
{
|
||||
[DataTestMethod]
|
||||
[DataRow("shutdown", "Shutdown")]
|
||||
@@ -19,87 +23,130 @@ public class QueryTests
|
||||
[DataRow("lock", "Lock")]
|
||||
[DataRow("sleep", "Sleep")]
|
||||
[DataRow("hibernate", "Hibernate")]
|
||||
public void SystemCommandsTest(string typedString, string expectedCommand)
|
||||
[DataRow("open recycle", "Open Recycle Bin")]
|
||||
[DataRow("empty recycle", "Empty Recycle Bin")]
|
||||
[DataRow("uefi", "UEFI Firmware Settings")]
|
||||
public void TopLevelPageQueryTest(string input, string matchedTitle)
|
||||
{
|
||||
// Setup
|
||||
var commands = Commands.GetSystemCommands(false, false, false, false);
|
||||
var settings = new Settings();
|
||||
var pages = new SystemCommandPage(settings);
|
||||
var allCommands = pages.GetItems();
|
||||
|
||||
// Act
|
||||
var result = commands.Where(c => c.Title.Contains(expectedCommand, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
var result = Query(input, allCommands);
|
||||
|
||||
// Assert
|
||||
// Empty recycle bin command should exist
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue(result.Title.Contains(expectedCommand, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var firstItem = result.FirstOrDefault();
|
||||
|
||||
Assert.IsNotNull(firstItem, "No items matched the query.");
|
||||
Assert.AreEqual(matchedTitle, firstItem.Title, $"Expected to match '{input}' but got '{firstItem.Title}'");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RecycleBinCommandTest()
|
||||
{
|
||||
// Setup
|
||||
var commands = Commands.GetSystemCommands(false, false, false, false);
|
||||
var settings = new Settings(hideEmptyRecycleBin: true);
|
||||
var pages = new SystemCommandPage(settings);
|
||||
var allCommands = pages.GetItems();
|
||||
|
||||
// Act
|
||||
var result = commands.Where(c => c.Title.Contains("Recycle", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
var result = Query("recycle", allCommands);
|
||||
|
||||
// Assert
|
||||
// Empty recycle bin command should exist
|
||||
Assert.IsNotNull(result);
|
||||
|
||||
foreach (var item in result)
|
||||
{
|
||||
if (item.Title.Contains("Open Recycle Bin") || item.Title.Contains("Empty Recycle Bin"))
|
||||
{
|
||||
Assert.Fail("Recycle Bin commands should not be available when hideEmptyRecycleBin is true.");
|
||||
}
|
||||
}
|
||||
|
||||
var firstItem = result.FirstOrDefault();
|
||||
Assert.IsNotNull(firstItem, "No items matched the query.");
|
||||
Assert.IsTrue(
|
||||
firstItem.Title.Contains("Recycle Bin", StringComparison.OrdinalIgnoreCase),
|
||||
$"Expected to match 'Recycle Bin' but got '{firstItem.Title}'");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NetworkCommandsTest()
|
||||
{
|
||||
// Test that network commands can be retrieved
|
||||
try
|
||||
var settings = new Settings();
|
||||
var pages = new SystemCommandPage(settings);
|
||||
var allCommands = pages.GetItems();
|
||||
|
||||
var ipv4Result = Query("IPv4", allCommands);
|
||||
|
||||
Assert.IsNotNull(ipv4Result);
|
||||
Assert.IsTrue(ipv4Result.Length > 0, "No IPv4 commands matched the query.");
|
||||
|
||||
var ipv6Result = Query("IPv6", allCommands);
|
||||
Assert.IsNotNull(ipv6Result);
|
||||
Assert.IsTrue(ipv6Result.Length > 0, "No IPv6 commands matched the query.");
|
||||
|
||||
var macResult = Query("MAC", allCommands);
|
||||
Assert.IsNotNull(macResult);
|
||||
Assert.IsTrue(macResult.Length > 0, "No MAC commands matched the query.");
|
||||
|
||||
var findDisconnectedMACResult = false;
|
||||
foreach (var item in macResult)
|
||||
{
|
||||
var networkPropertiesList = NetworkConnectionProperties.GetList();
|
||||
Assert.IsTrue(networkPropertiesList.Count >= 0); // Should not throw exceptions
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.Fail($"Network commands should not throw exceptions: {ex.Message}");
|
||||
if (item.Details.Body.Contains("Disconnected"))
|
||||
{
|
||||
findDisconnectedMACResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue(findDisconnectedMACResult, "No disconnected MAC address found in the results.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UefiCommandIsAvailableTest()
|
||||
public void HideDisconnectedNetworkInfoTest()
|
||||
{
|
||||
// Setup
|
||||
var firmwareType = Win32Helpers.GetSystemFirmwareType();
|
||||
var isUefiMode = firmwareType == FirmwareType.Uefi;
|
||||
var settings = new Settings(hideDisconnectedNetworkInfo: true);
|
||||
var pages = new SystemCommandPage(settings);
|
||||
var allCommands = pages.GetItems();
|
||||
|
||||
// Act
|
||||
var commands = Commands.GetSystemCommands(isUefiMode, false, false, false);
|
||||
var uefiCommand = commands.Where(c => c.Title.Contains("UEFI", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
var macResult = Query("MAC", allCommands);
|
||||
Assert.IsNotNull(macResult);
|
||||
Assert.IsTrue(macResult.Length > 0, "No MAC commands matched the query.");
|
||||
|
||||
// Assert
|
||||
if (isUefiMode)
|
||||
var findDisconnectedMACResult = false;
|
||||
foreach (var item in macResult)
|
||||
{
|
||||
Assert.IsNotNull(uefiCommand);
|
||||
}
|
||||
else
|
||||
{
|
||||
// UEFI command may still exist but be disabled on non-UEFI systems
|
||||
Assert.IsTrue(true); // Test environment independent
|
||||
if (item.Details.Body.Contains("Disconnected"))
|
||||
{
|
||||
findDisconnectedMACResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue(!findDisconnectedMACResult, "Disconnected MAC address found in the results.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FirmwareTypeTest()
|
||||
[DataRow(FirmwareType.Uefi, true)]
|
||||
[DataRow(FirmwareType.Bios, false)]
|
||||
[DataRow(FirmwareType.Max, false)]
|
||||
[DataRow(FirmwareType.Unknown, false)]
|
||||
public void FirmwareSettingsTest(FirmwareType firmwareType, bool hasCommand)
|
||||
{
|
||||
// Test that GetSystemFirmwareType returns a valid enum value
|
||||
var firmwareType = Win32Helpers.GetSystemFirmwareType();
|
||||
Assert.IsTrue(Enum.IsDefined(typeof(FirmwareType), firmwareType));
|
||||
}
|
||||
var settings = new Settings(firmwareType: firmwareType);
|
||||
var pages = new SystemCommandPage(settings);
|
||||
var allCommands = pages.GetItems();
|
||||
var result = Query("UEFI", allCommands);
|
||||
|
||||
[TestMethod]
|
||||
public void EmptyRecycleBinCommandTest()
|
||||
{
|
||||
// Test that empty recycle bin command exists
|
||||
var commands = Commands.GetSystemCommands(false, false, false, false);
|
||||
var result = commands.Where(c => c.Title.Contains("Empty", StringComparison.OrdinalIgnoreCase) &&
|
||||
c.Title.Contains("Recycle", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
|
||||
// Empty recycle bin command should exist
|
||||
// UEFI Firmware Settings command should exist
|
||||
Assert.IsNotNull(result);
|
||||
var firstItem = result.FirstOrDefault();
|
||||
Assert.IsNotNull(firstItem, "No items matched the query.");
|
||||
var containsFirmwareSettings = firstItem.Title.Contains("UEFI Firmware Settings", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
Assert.IsTrue(
|
||||
containsFirmwareSettings == hasCommand,
|
||||
$"Expected to match 'UEFI Firmware Settings' but got '{firstItem.Title}'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.System.Helpers;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.System.UnitTests;
|
||||
|
||||
public class Settings : ISettingsInterface
|
||||
{
|
||||
private bool hideDisconnectedNetworkInfo;
|
||||
private bool hideEmptyRecycleBin;
|
||||
private bool showDialogToConfirmCommand;
|
||||
private bool showSuccessMessageAfterEmptyingRecycleBin;
|
||||
private FirmwareType firmwareType;
|
||||
|
||||
public Settings(bool hideDisconnectedNetworkInfo = false, bool hideEmptyRecycleBin = false, bool showDialogToConfirmCommand = false, bool showSuccessMessageAfterEmptyingRecycleBin = false, FirmwareType firmwareType = FirmwareType.Uefi)
|
||||
{
|
||||
this.hideDisconnectedNetworkInfo = hideDisconnectedNetworkInfo;
|
||||
this.hideEmptyRecycleBin = hideEmptyRecycleBin;
|
||||
this.showDialogToConfirmCommand = showDialogToConfirmCommand;
|
||||
this.showSuccessMessageAfterEmptyingRecycleBin = showSuccessMessageAfterEmptyingRecycleBin;
|
||||
this.firmwareType = firmwareType;
|
||||
}
|
||||
|
||||
public bool HideDisconnectedNetworkInfo() => hideDisconnectedNetworkInfo;
|
||||
|
||||
public bool HideEmptyRecycleBin() => hideEmptyRecycleBin;
|
||||
|
||||
public bool ShowDialogToConfirmCommand() => showDialogToConfirmCommand;
|
||||
|
||||
public bool ShowSuccessMessageAfterEmptyingRecycleBin() => showSuccessMessageAfterEmptyingRecycleBin;
|
||||
|
||||
public FirmwareType GetSystemFirmwareType() => firmwareType;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.UnitTestBase;
|
||||
|
||||
public class CommandPaletteUnitTestBase
|
||||
{
|
||||
private bool MatchesFilter(string filter, IListItem item) => StringMatcher.FuzzySearch(filter, item.Title).Success || StringMatcher.FuzzySearch(filter, item.Subtitle).Success;
|
||||
|
||||
public IListItem[] Query(string query, IListItem[] candidates)
|
||||
{
|
||||
IListItem[] listItems = candidates
|
||||
.Where(item => MatchesFilter(query, item))
|
||||
.ToArray();
|
||||
|
||||
return listItems;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<!-- Look at Directory.Build.props in root for common stuff as well -->
|
||||
<Import Project="..\..\..\..\Common.Dotnet.CsWinRT.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Microsoft.CmdPal.Ext.UnitTestsBase</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="MSTest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -12,16 +12,16 @@ namespace Microsoft.CmdPal.Ext.System;
|
||||
|
||||
internal sealed partial class FallbackSystemCommandItem : FallbackCommandItem
|
||||
{
|
||||
public FallbackSystemCommandItem(SettingsManager settings)
|
||||
public FallbackSystemCommandItem(ISettingsInterface settings)
|
||||
: base(new NoOpCommand(), Resources.Microsoft_plugin_ext_fallback_display_title)
|
||||
{
|
||||
Title = string.Empty;
|
||||
Subtitle = string.Empty;
|
||||
|
||||
var isBootedInUefiMode = Win32Helpers.GetSystemFirmwareType() == FirmwareType.Uefi;
|
||||
var hideEmptyRB = settings.HideEmptyRecycleBin;
|
||||
var confirmSystemCommands = settings.ShowDialogToConfirmCommand;
|
||||
var showSuccessOnEmptyRB = settings.ShowSuccessMessageAfterEmptyingRecycleBin;
|
||||
var isBootedInUefiMode = settings.GetSystemFirmwareType() == FirmwareType.Uefi;
|
||||
var hideEmptyRB = settings.HideEmptyRecycleBin();
|
||||
var confirmSystemCommands = settings.ShowDialogToConfirmCommand();
|
||||
var showSuccessOnEmptyRB = settings.ShowSuccessMessageAfterEmptyingRecycleBin();
|
||||
|
||||
systemCommands = Commands.GetSystemCommands(isBootedInUefiMode, hideEmptyRB, confirmSystemCommands, showSuccessOnEmptyRB);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ internal static class Commands
|
||||
/// </summary>
|
||||
/// <param name="manager">The tSettingsManager instance</param>
|
||||
/// <returns>The list of available results</returns>
|
||||
public static List<IListItem> GetNetworkConnectionResults(SettingsManager manager)
|
||||
public static List<IListItem> GetNetworkConnectionResults(ISettingsInterface manager)
|
||||
{
|
||||
var results = new List<IListItem>();
|
||||
|
||||
@@ -151,7 +151,7 @@ internal static class Commands
|
||||
CompositeFormat sysIpv4DescriptionCompositeFormate = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_ip4_description);
|
||||
CompositeFormat sysIpv6DescriptionCompositeFormate = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_ip6_description);
|
||||
CompositeFormat sysMacDescriptionCompositeFormate = CompositeFormat.Parse(Resources.Microsoft_plugin_sys_mac_description);
|
||||
var hideDisconnectedNetworkInfo = manager.HideDisconnectedNetworkInfo;
|
||||
var hideDisconnectedNetworkInfo = manager.HideDisconnectedNetworkInfo();
|
||||
|
||||
foreach (NetworkConnectionProperties intInfo in networkPropertiesCache)
|
||||
{
|
||||
@@ -200,7 +200,7 @@ internal static class Commands
|
||||
return results;
|
||||
}
|
||||
|
||||
public static List<IListItem> GetAllCommands(SettingsManager manager)
|
||||
public static List<IListItem> GetAllCommands(ISettingsInterface manager)
|
||||
{
|
||||
var list = new List<IListItem>();
|
||||
var listLock = new object();
|
||||
@@ -209,11 +209,11 @@ internal static class Commands
|
||||
// On global queries the first word/part has to be 'ip', 'mac' or 'address' for network results
|
||||
var networkConnectionResults = Commands.GetNetworkConnectionResults(manager);
|
||||
|
||||
var isBootedInUefiMode = Win32Helpers.GetSystemFirmwareType() == FirmwareType.Uefi;
|
||||
var isBootedInUefiMode = manager.GetSystemFirmwareType() == FirmwareType.Uefi;
|
||||
|
||||
var hideEmptyRB = manager.HideEmptyRecycleBin;
|
||||
var confirmSystemCommands = manager.ShowDialogToConfirmCommand;
|
||||
var showSuccessOnEmptyRB = manager.ShowSuccessMessageAfterEmptyingRecycleBin;
|
||||
var hideEmptyRB = manager.HideEmptyRecycleBin();
|
||||
var confirmSystemCommands = manager.ShowDialogToConfirmCommand();
|
||||
var showSuccessOnEmptyRB = manager.ShowSuccessMessageAfterEmptyingRecycleBin();
|
||||
|
||||
// normal system commands are fast and can be returned immediately
|
||||
var systemCommands = Commands.GetSystemCommands(isBootedInUefiMode, hideEmptyRB, confirmSystemCommands, showSuccessOnEmptyRB);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.System.Helpers;
|
||||
|
||||
public interface ISettingsInterface
|
||||
{
|
||||
public bool ShowDialogToConfirmCommand();
|
||||
|
||||
public bool ShowSuccessMessageAfterEmptyingRecycleBin();
|
||||
|
||||
public bool HideEmptyRecycleBin();
|
||||
|
||||
public bool HideDisconnectedNetworkInfo();
|
||||
|
||||
public FirmwareType GetSystemFirmwareType();
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.System.Helpers;
|
||||
|
||||
public class SettingsManager : JsonSettingsManager
|
||||
public class SettingsManager : JsonSettingsManager, ISettingsInterface
|
||||
{
|
||||
private static readonly string _namespace = "system";
|
||||
|
||||
@@ -37,14 +37,6 @@ public class SettingsManager : JsonSettingsManager
|
||||
Resources.Microsoft_plugin_ext_settings_hideDisconnectedNetworkInfo,
|
||||
false);
|
||||
|
||||
public bool ShowDialogToConfirmCommand => _showDialogToConfirmCommand.Value;
|
||||
|
||||
public bool ShowSuccessMessageAfterEmptyingRecycleBin => _showSuccessMessageAfterEmptyingRecycleBin.Value;
|
||||
|
||||
public bool HideEmptyRecycleBin => _hideEmptyRecycleBin.Value;
|
||||
|
||||
public bool HideDisconnectedNetworkInfo => _hideDisconnectedNetworkInfo.Value;
|
||||
|
||||
internal static string SettingsJsonPath()
|
||||
{
|
||||
var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
|
||||
@@ -54,6 +46,16 @@ public class SettingsManager : JsonSettingsManager
|
||||
return Path.Combine(directory, "settings.json");
|
||||
}
|
||||
|
||||
public bool ShowDialogToConfirmCommand() => _showDialogToConfirmCommand.Value;
|
||||
|
||||
public bool ShowSuccessMessageAfterEmptyingRecycleBin() => _showSuccessMessageAfterEmptyingRecycleBin.Value;
|
||||
|
||||
public bool HideEmptyRecycleBin() => _hideEmptyRecycleBin.Value;
|
||||
|
||||
public bool HideDisconnectedNetworkInfo() => _hideDisconnectedNetworkInfo.Value;
|
||||
|
||||
public FirmwareType GetSystemFirmwareType() => Win32Helpers.GetSystemFirmwareType();
|
||||
|
||||
public SettingsManager()
|
||||
{
|
||||
FilePath = SettingsJsonPath();
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Microsoft.CmdPal.Ext.System.Pages;
|
||||
|
||||
public sealed partial class SystemCommandPage : ListPage
|
||||
{
|
||||
private readonly SettingsManager _settingsManager;
|
||||
private readonly ISettingsInterface _settingsManager;
|
||||
|
||||
public SystemCommandPage(SettingsManager settingsManager)
|
||||
public SystemCommandPage(ISettingsInterface settingsManager)
|
||||
{
|
||||
Title = Resources.Microsoft_plugin_ext_system_page_title;
|
||||
Name = Resources.Microsoft_plugin_command_name_open;
|
||||
|
||||
Reference in New Issue
Block a user