[PowerToys Run] Add Support for Uris (#5160)

* url handler plugin

* updates

* Add seperate interface classes
rename to uri module

* Update path

* Update implementation to remove slow DNS lookup ( and let browser handle it)

* tabs to spaces

* - Update icon/assets
- Finalize Project

* Update wix project

* Implement UpdateBrowserIconPath

* Implemented Microsoft.CodeAnalysis.FxCopAnalyzers

* Add Language component to installer

* Update logic to determine icon

* Update Translation File to "Open in browser"

* Added test for typing http://test.com and which result to expect on each keystoke

* Implement StyleCop

* Added ipv6 tests

* Fix Solution LineBreaks

* Added Microsoft.Plugin.Uri as build Dependency

* Use ArgumentNullException instead of InvalidOperationException

* Fix wrong Directory in wix installer

Co-authored-by: Roy <royvou@hotmailcom>
This commit is contained in:
Roy
2020-08-11 00:53:43 +02:00
committed by GitHub
parent 3781d1e06b
commit ba2ef23414
24 changed files with 624 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
<RootNamespace>Microsoft.Plugin.Uri.UnitTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Plugin.Uri\Microsoft.Plugin.Uri.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,53 @@
using Microsoft.Plugin.Uri.UriHelper;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using NUnit.Framework;
namespace Microsoft.Plugin.Uri.UnitTests.UriHelper
{
[TestFixture]
public class ExtendedUriParserTests
{
[TestCase("google.com", true, "http://google.com/")]
[TestCase("localhost", true, "http://localhost/")]
[TestCase("127.0.0.1", true, "http://127.0.0.1/")]
[TestCase("127.0.0.1:80", true, "http://127.0.0.1/")]
[TestCase("127", true, "http://0.0.0.127/")]
[TestCase("", false, null)]
[TestCase("https://google.com", true, "https://google.com/")]
[TestCase("ftps://google.com", true, "ftps://google.com/")]
[TestCase(null, false, null)]
[TestCase("bing.com/search?q=gmx", true, "http://bing.com/search?q=gmx")]
[TestCase("h", true, "http://h/")]
[TestCase("ht", true, "http://ht/")]
[TestCase("htt", true, "http://htt/")]
[TestCase("http", true, "http://http/")]
[TestCase("http:", false, null)]
[TestCase("http:/", false, null)]
[TestCase("http://", false, null)]
[TestCase("http://t", true, "http://t/")]
[TestCase("http://te", true, "http://te/")]
[TestCase("http://tes", true, "http://tes/")]
[TestCase("http://test", true, "http://test/")]
[TestCase("http://test.", false, null)]
[TestCase("http://test.c", true, "http://test.c/")]
[TestCase("http://test.co", true, "http://test.co/")]
[TestCase("http://test.com", true, "http://test.com/")]
[TestCase("http:3", true,"http://http:3/")]
[TestCase("[::]", true, "http://[::]")]
[TestCase("[2001:0DB8::1]", true, "http://[2001:0DB8::1]/")]
[TestCase("[2001:0DB8::1]:80",true, "http://[2001:0DB8::1]/")]
public void TryParse_CanParseHostName(string query, bool expectedSuccess, string expectedResult)
{
// Arrange
var parser = new ExtendedUriParser();
// Act
var success = parser.TryParse(query, out var result);
// Assert
Assert.AreEqual(expectedResult, result?.ToString());
Assert.AreEqual(expectedSuccess, success);
}
}
}