Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User/ejohn/settings #121

Merged
merged 13 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.SetupFlow.DevDrive"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Logging", "logging\DevHome.Logging.csproj", "{DB84FAA0-ACBF-48DA-AF1B-BCCA5053AF8B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Settings", "settings\DevHome.Settings\DevHome.Settings.csproj", "{72CE876A-7272-4460-92EB-845A45B743FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -493,6 +495,22 @@ Global
{DB84FAA0-ACBF-48DA-AF1B-BCCA5053AF8B}.Release|x64.Build.0 = Release|x64
{DB84FAA0-ACBF-48DA-AF1B-BCCA5053AF8B}.Release|x86.ActiveCfg = Release|x86
{DB84FAA0-ACBF-48DA-AF1B-BCCA5053AF8B}.Release|x86.Build.0 = Release|x86
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|Any CPU.ActiveCfg = Debug|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|Any CPU.Build.0 = Debug|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|arm64.ActiveCfg = Debug|arm64
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|arm64.Build.0 = Debug|arm64
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|x64.ActiveCfg = Debug|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|x64.Build.0 = Debug|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|x86.ActiveCfg = Debug|x86
{72CE876A-7272-4460-92EB-845A45B743FB}.Debug|x86.Build.0 = Debug|x86
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|Any CPU.ActiveCfg = Release|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|Any CPU.Build.0 = Release|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|arm64.ActiveCfg = Release|arm64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|arm64.Build.0 = Release|arm64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x64.ActiveCfg = Release|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x64.Build.0 = Release|x64
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x86.ActiveCfg = Release|x86
{72CE876A-7272-4460-92EB-845A45B743FB}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Windows.DevHome.SDK;

namespace DevHome.Contracts.Services;
namespace DevHome.Common.Contracts.Services;

public interface IAccountsService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

namespace DevHome.Core.Contracts.Services;
namespace DevHome.Common.Contracts;
Copy link
Member

@dkbennett dkbennett Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we come up with something other than "Common"? That could be a grab bag of a whole bunch of stuff and is ambiguous. Is this common to all plugins? Common to DevHome? Common to Windows? Also why is common not under src? Is it not src? There's common\helpers and src\helpers, common\services and src services - what's the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev Home is split between core app and tools. "Common" is shared between the two. "src" is just the core application source code. Ideally, the "common" code would live in "src", but then we have a circular dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with actually getting rid of the "common" namespace and just making all namespaces in DevHome.Common.* be DevHome.*, but that would definitely be a separate change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev Home is split between core app and tools. "Common" is shared between the two. "src" is just the core application source code. Ideally, the "common" code would live in "src", but then we have a circular dependency.

I would expect all source for shipping code to be under source, and if it's just the core application then that should be refactored into a sub folder of src for the app. Or change 'src' to be indicative that it is the app and not have a src folder.


public interface IFileService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

namespace DevHome.Contracts.Services;
using System.Threading.Tasks;

namespace DevHome.Common.Contracts;

public interface ILocalSettingsService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace DevHome.Helpers;
namespace DevHome.Common.Helpers;

public class EnumToBooleanConverter : IValueConverter
{
Expand Down
3 changes: 2 additions & 1 deletion src/Helpers/Json.cs → common/Helpers/Json.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using System.Threading.Tasks;
using Newtonsoft.Json;

namespace DevHome.Core.Helpers;
namespace DevHome.Common.Helpers;

public static class Json
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Runtime.InteropServices;
using System.Text;

namespace DevHome.Helpers;
namespace DevHome.Common.Helpers;

public class RuntimeHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

namespace DevHome.Models;
namespace DevHome.Common.Models;

public class LocalSettingsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using System.IO;
using System.Text;
using DevHome.Core.Contracts.Services;
using DevHome.Common.Contracts;
using Newtonsoft.Json;

namespace DevHome.Core.Services;
namespace DevHome.Common.Services;

public class FileService : IFileService
{
Expand Down
4 changes: 2 additions & 2 deletions common/Services/IPluginService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace DevHome.Common.Services;
public interface IPluginService
{
Task<IEnumerable<IPluginWrapper>> GetInstalledPluginsAsync();
Task<IEnumerable<IPluginWrapper>> GetInstalledPluginsAsync(bool includeDisabledPlugins = false);

Task<IEnumerable<IPluginWrapper>> GetInstalledPluginsAsync(Microsoft.Windows.DevHome.SDK.ProviderType providerType);
Task<IEnumerable<IPluginWrapper>> GetInstalledPluginsAsync(Microsoft.Windows.DevHome.SDK.ProviderType providerType, bool includeDisabledPlugins = false);

Task<IEnumerable<IPluginWrapper>> StartAllPluginsAsync();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using DevHome.Contracts.Services;
using DevHome.Core.Contracts.Services;
using DevHome.Core.Helpers;
using DevHome.Helpers;
using DevHome.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using DevHome.Common.Contracts;
using DevHome.Common.Helpers;
using DevHome.Common.Models;
using Microsoft.Extensions.Options;
using Windows.ApplicationModel;
using Windows.Storage;

namespace DevHome.Services;
namespace DevHome.Common.Services;

public class LocalSettingsService : ILocalSettingsService
{
Expand Down
31 changes: 31 additions & 0 deletions settings/DevHome.Settings.UITest/DashboardScenarioStandard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;

namespace DevHome.Dashboard.UITest;

[TestClass]
public class DashboardScenarioStandard : DashboardSession
{
[TestMethod]
public void DashboardTest1()
{
session.FindElementByName("Dashboard").Click();
WindowsElement title = session.FindElementByName("Dashboard");
Assert.AreEqual("Dashboard", title.Text);
}

[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
Setup(context);
}

[ClassCleanup]
public static void ClassCleanup()
{
TearDown();
}
}
49 changes: 49 additions & 0 deletions settings/DevHome.Settings.UITest/DashboardSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;

namespace DevHome.Dashboard.UITest;

public class DashboardSession
{
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
private const string DevHomeAppId = "Microsoft.DevHome_8wekyb3d8bbwe!App";

#pragma warning disable SA1401 // Fields should be private
#pragma warning disable CA2211 // Non-constant fields should not be visible
protected static WindowsDriver<WindowsElement> session;
#pragma warning restore CA2211 // Non-constant fields should not be visible
#pragma warning restore SA1401 // Fields should be private

public static void Setup(TestContext context)
{
if (session == null)
{
// Create a new session to bring up an instance of the Dev Home application
// Note: Multiple calculator windows (instances) share the same process Id
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("deviceName", "WindowsPC");
options.AddAdditionalCapability("platformName", "Windows");
options.AddAdditionalCapability("app", DevHomeAppId);

session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), options);
Assert.IsNotNull(session);

// Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
}
}

public static void TearDown()
{
// Close the application and delete the session
if (session != null)
{
session.Quit();
session = null;
}
}
}
19 changes: 19 additions & 0 deletions settings/DevHome.Settings.UITest/DevHome.Dashboard.UITest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RootNamespace>Dashboard.UITest</RootNamespace>
<Platforms>x86;x64;arm64</Platforms>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWinUI>true</UseWinUI>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<ProjectPriFileName>resources.pri</ProjectPriFileName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Appium.WebDriver" Version="4.4.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RootNamespace>Dashboard.Test</RootNamespace>
<Platforms>x86;x64;arm64</Platforms>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWinUI>true</UseWinUI>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<ProjectPriFileName>resources.pri</ProjectPriFileName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\DevHome.csproj" />
<ProjectReference Include="..\DevHome.Dashboard\DevHome.Dashboard.csproj" />
</ItemGroup>
</Project>
26 changes: 26 additions & 0 deletions settings/DevHome.Settings.UnitTest/Initialize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using Microsoft.Windows.ApplicationModel.DynamicDependency;

[assembly: WinUITestTarget(typeof(DevHome.App))]

namespace DevHome.Dashboard.Test;

[TestClass]
public class Initialize
{
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
// TODO: Initialize the appropriate version of the Windows App SDK.
// This is required when testing MSIX apps that are framework-dependent on the Windows App SDK.
Bootstrap.TryInitialize(0x00010001, out var _);
}

[AssemblyCleanup]
public static void AssemblyCleanup()
{
Bootstrap.Shutdown();
}
}
5 changes: 5 additions & 0 deletions settings/DevHome.Settings.UnitTest/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
52 changes: 52 additions & 0 deletions settings/DevHome.Settings/DevHome.Settings.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>DevHome.Settings</RootNamespace>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<UseWinUI>true</UseWinUI>
</PropertyGroup>
<ItemGroup>
<None Remove="Views\AboutPage.xaml" />
<None Remove="Views\AccountsPage.xaml" />
<None Remove="Views\ExtensionsPage.xaml" />
<None Remove="Views\NotificationsPage.xaml" />
<None Remove="Views\PreferencesPage.xaml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Labs.WinUI.SettingsControls" Version="0.0.14" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.WinUI.UI" Version="7.1.2" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\common\DevHome.Common.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="Views\AccountsPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Views\AboutPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Views\NotificationsPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Views\PreferencesPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Views\ExtensionsPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Windows.DevHome.SDK;

namespace DevHome.ViewModels;
namespace DevHome.Settings.Models;

public partial class AccountViewModel : ObservableObject
public partial class Account : ObservableObject
{
private readonly IDeveloperId _devId;

internal IDeveloperId GetDevId() => _devId;

public AccountViewModel(IDeveloperId devId)
public Account(IDeveloperId devId)
{
_devId = devId;
}
Expand Down
Loading