2020-11-26 03:35:48 -06:00
|
|
|
|
// 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.Linq;
|
2021-08-16 15:25:06 +02:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2020-11-26 03:35:48 -06:00
|
|
|
|
using Moq;
|
|
|
|
|
|
using Wox.Infrastructure;
|
|
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
|
|
2021-01-08 16:11:30 +01:00
|
|
|
|
namespace Microsoft.PowerToys.Run.Plugin.System.UnitTests
|
2020-11-26 03:35:48 -06:00
|
|
|
|
{
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[TestClass]
|
2020-11-26 03:35:48 -06:00
|
|
|
|
public class ImageTests
|
|
|
|
|
|
{
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[TestInitialize]
|
2020-11-26 03:35:48 -06:00
|
|
|
|
public void Setup()
|
|
|
|
|
|
{
|
|
|
|
|
|
StringMatcher.Instance = new StringMatcher();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[DataTestMethod]
|
|
|
|
|
|
[DataRow("shutdown", "Images\\shutdown.dark.png")]
|
|
|
|
|
|
[DataRow("restart", "Images\\restart.dark.png")]
|
|
|
|
|
|
[DataRow("sign out", "Images\\logoff.dark.png")]
|
|
|
|
|
|
[DataRow("lock", "Images\\lock.dark.png")]
|
|
|
|
|
|
[DataRow("sleep", "Images\\sleep.dark.png")]
|
|
|
|
|
|
[DataRow("hibernate", "Images\\sleep.dark.png")]
|
|
|
|
|
|
[DataRow("empty recycle", "Images\\recyclebin.dark.png")]
|
2022-02-04 17:56:31 +01:00
|
|
|
|
[DataRow("uefi firmware settings", "Images\\firmwareSettings.dark.png")]
|
2022-04-04 13:47:58 +02:00
|
|
|
|
[DataRow("ip v4 addr", "Images\\networkAdapter.dark.png", true)]
|
|
|
|
|
|
[DataRow("ip v6 addr", "Images\\networkAdapter.dark.png", true)]
|
|
|
|
|
|
[DataRow("mac addr", "Images\\networkAdapter.dark.png", true)]
|
|
|
|
|
|
public void IconThemeDarkTest(string typedString, string expectedResult, bool isDelayed = default)
|
2020-11-26 03:35:48 -06:00
|
|
|
|
{
|
|
|
|
|
|
// Setup
|
|
|
|
|
|
Mock<Main> main = new Mock<Main>();
|
|
|
|
|
|
main.Object.IconTheme = "dark";
|
2022-02-04 17:56:31 +01:00
|
|
|
|
main.Object.IsBootedInUefiMode = true; // Set to true that we can test, regardless of the environment we run on.
|
2021-02-26 13:21:58 +02:00
|
|
|
|
Query expectedQuery = new Query(typedString);
|
2020-11-26 03:35:48 -06:00
|
|
|
|
|
|
|
|
|
|
// Act
|
2022-04-04 13:47:58 +02:00
|
|
|
|
var result = !isDelayed ? main.Object.Query(expectedQuery).FirstOrDefault().IcoPath : main.Object.Query(expectedQuery, true).FirstOrDefault().IcoPath;
|
2020-11-26 03:35:48 -06:00
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
Assert.AreEqual(expectedResult, result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[DataTestMethod]
|
|
|
|
|
|
[DataRow("shutdown", "Images\\shutdown.light.png")]
|
|
|
|
|
|
[DataRow("restart", "Images\\restart.light.png")]
|
|
|
|
|
|
[DataRow("sign out", "Images\\logoff.light.png")]
|
|
|
|
|
|
[DataRow("lock", "Images\\lock.light.png")]
|
|
|
|
|
|
[DataRow("sleep", "Images\\sleep.light.png")]
|
|
|
|
|
|
[DataRow("hibernate", "Images\\sleep.light.png")]
|
|
|
|
|
|
[DataRow("empty recycle", "Images\\recyclebin.light.png")]
|
2022-02-04 17:56:31 +01:00
|
|
|
|
[DataRow("uefi firmware settings", "Images\\firmwareSettings.light.png")]
|
2022-04-04 13:47:58 +02:00
|
|
|
|
[DataRow("ipv4 addr", "Images\\networkAdapter.light.png", true)]
|
|
|
|
|
|
[DataRow("ipv6 addr", "Images\\networkAdapter.light.png", true)]
|
|
|
|
|
|
[DataRow("mac addr", "Images\\networkAdapter.light.png", true)]
|
|
|
|
|
|
public void IconThemeLightTest(string typedString, string expectedResult, bool isDelayed = default)
|
2020-11-26 03:35:48 -06:00
|
|
|
|
{
|
|
|
|
|
|
// Setup
|
|
|
|
|
|
Mock<Main> main = new Mock<Main>();
|
|
|
|
|
|
main.Object.IconTheme = "light";
|
2022-02-04 17:56:31 +01:00
|
|
|
|
main.Object.IsBootedInUefiMode = true; // Set to true that we can test, regardless of the environment we run on.
|
2021-02-26 13:21:58 +02:00
|
|
|
|
Query expectedQuery = new Query(typedString);
|
2020-11-26 03:35:48 -06:00
|
|
|
|
|
|
|
|
|
|
// Act
|
2022-04-04 13:47:58 +02:00
|
|
|
|
var result = !isDelayed ? main.Object.Query(expectedQuery).FirstOrDefault().IcoPath : main.Object.Query(expectedQuery, true).FirstOrDefault().IcoPath;
|
2020-11-26 03:35:48 -06:00
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
Assert.AreEqual(expectedResult, result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|