mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
PWAs should not show up when searching for the main app (#4221)
* Search shows up steam games * Formatting * Filtering only those steam shortcuts which run an application * Using equals instead of == * PWAs should not show up when searching for the main app * Modified the subtitle to say progressive web application * renamed to web application * To search for web applications for all chromium based browsers * Renamed it to WebApplication * Added unit tests and refactored code * made string global const * Added localization tags * Added a separate function for localization as the IPublic API was not available to all * Removed unnecessary references and variables * Update src/modules/launcher/Plugins/Microsoft.Plugin.Program/Languages/de.xaml Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Added enum for application types Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
@@ -78,6 +78,53 @@ namespace Wox.Test.Plugins
|
||||
LnkResolvedPath = null
|
||||
};
|
||||
|
||||
Win32 twitter_pwa = new Win32
|
||||
{
|
||||
Name = "Twitter",
|
||||
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome_proxy.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\chrome apps\\twitter.lnk",
|
||||
Arguments = " --profile-directory=Default --app-id=jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi"
|
||||
};
|
||||
|
||||
Win32 pinned_webpage = new Win32
|
||||
{
|
||||
Name = "Web page",
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\web page.lnk",
|
||||
Arguments = "--profile-directory=Default --app-id=homljgmgpmcbpjbnjpfijnhipfkiclkd"
|
||||
};
|
||||
|
||||
Win32 edge_named_pinned_webpage = new Win32
|
||||
{
|
||||
Name = "edge - Bing",
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\edge - bing.lnk",
|
||||
Arguments = " --profile-directory=Default --app-id=aocfnapldcnfbofgmbbllojgocaelgdd"
|
||||
};
|
||||
|
||||
Win32 msedge = new Win32
|
||||
{
|
||||
Name = "Microsoft Edge",
|
||||
ExecutableName = "msedge.exe",
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft edge.lnk"
|
||||
};
|
||||
|
||||
Win32 chrome = new Win32
|
||||
{
|
||||
Name = "Google Chrome",
|
||||
ExecutableName = "chrome.exe",
|
||||
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\google chrome.lnk"
|
||||
};
|
||||
|
||||
Win32 dummy_proxy_app = new Win32
|
||||
{
|
||||
Name = "Proxy App",
|
||||
ExecutableName = "test_proxy.exe",
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\test_proxy.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\test proxy.lnk"
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void DedupFunction_whenCalled_mustRemoveDuplicateNotepads()
|
||||
@@ -139,5 +186,79 @@ namespace Wox.Test.Plugins
|
||||
// Assert
|
||||
Assert.AreEqual(apps.Length, 3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FunctionIsWebApplication_ShouldReturnTrue_ForWebApplications()
|
||||
{
|
||||
// The IsWebApplication(() function must return true for all PWAs and pinned web pages
|
||||
Assert.IsTrue(twitter_pwa.IsWebApplication());
|
||||
Assert.IsTrue(pinned_webpage.IsWebApplication());
|
||||
Assert.IsTrue(edge_named_pinned_webpage.IsWebApplication());
|
||||
|
||||
// Should not filter apps whose executable name ends with proxy.exe
|
||||
Assert.IsFalse(dummy_proxy_app.IsWebApplication());
|
||||
}
|
||||
|
||||
[TestCase("ignore")]
|
||||
public void FunctionFilterWebApplication_ShouldReturnFalse_WhenSearchingForTheMainApp(string query)
|
||||
{
|
||||
// Irrespective of the query, the FilterWebApplication() Function must not filter main apps such as edge and chrome
|
||||
Assert.IsFalse(msedge.FilterWebApplication(query));
|
||||
Assert.IsFalse(chrome.FilterWebApplication(query));
|
||||
}
|
||||
|
||||
[TestCase("edge", ExpectedResult = true)]
|
||||
[TestCase("EDGE", ExpectedResult = true)]
|
||||
[TestCase("msedge", ExpectedResult = true)]
|
||||
[TestCase("Microsoft", ExpectedResult = true)]
|
||||
[TestCase("edg", ExpectedResult = true)]
|
||||
[TestCase("Edge page", ExpectedResult = false)]
|
||||
[TestCase("Edge Web page", ExpectedResult = false)]
|
||||
public bool EdgeWebSites_ShouldBeFiltered_WhenSearchingForEdge(string query)
|
||||
{
|
||||
return pinned_webpage.FilterWebApplication(query);
|
||||
}
|
||||
|
||||
[TestCase("chrome", ExpectedResult = true)]
|
||||
[TestCase("CHROME", ExpectedResult = true)]
|
||||
[TestCase("Google", ExpectedResult = true)]
|
||||
[TestCase("Google Chrome", ExpectedResult = true)]
|
||||
[TestCase("Google Chrome twitter", ExpectedResult = false)]
|
||||
public bool ChromeWebSites_ShouldBeFiltered_WhenSearchingForChrome(string query)
|
||||
{
|
||||
return twitter_pwa.FilterWebApplication(query);
|
||||
}
|
||||
|
||||
[TestCase("twitter", 0, ExpectedResult = false)]
|
||||
[TestCase("Twit", 0, ExpectedResult = false)]
|
||||
[TestCase("TWITTER", 0, ExpectedResult = false)]
|
||||
[TestCase("web", 1, ExpectedResult = false)]
|
||||
[TestCase("Page", 1, ExpectedResult = false)]
|
||||
[TestCase("WEB PAGE", 1, ExpectedResult = false)]
|
||||
[TestCase("edge", 2, ExpectedResult = false)]
|
||||
[TestCase("EDGE", 2, ExpectedResult = false)]
|
||||
public bool PinnedWebPages_ShouldNotBeFiltered_WhenSearchingForThem(string query, int Case)
|
||||
{
|
||||
const uint CASE_TWITTER = 0;
|
||||
const uint CASE_WEB_PAGE = 1;
|
||||
const uint CASE_EDGE_NAMED_WEBPAGE = 2;
|
||||
|
||||
// If the query is a part of the name of the web application, it should not be filtered,
|
||||
// even if the name is the same as that of the main application, eg: case 2 - edge
|
||||
if (Case == CASE_TWITTER)
|
||||
{
|
||||
return twitter_pwa.FilterWebApplication(query);
|
||||
}
|
||||
else if(Case == CASE_WEB_PAGE)
|
||||
{
|
||||
return pinned_webpage.FilterWebApplication(query);
|
||||
}
|
||||
else if(Case == CASE_EDGE_NAMED_WEBPAGE)
|
||||
{
|
||||
return edge_named_pinned_webpage.FilterWebApplication(query);
|
||||
}
|
||||
// unreachable code
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user