Merge branch 'master' of https://github.com/MatterHackers/MatterControl
This commit is contained in:
commit
ce835942d3
5 changed files with 75 additions and 3 deletions
|
|
@ -75,6 +75,7 @@
|
|||
<Compile Include="MatterControl\LibraryProviderTests.cs" />
|
||||
<Compile Include="MatterControl\AutomationTests\OptionsTabTests.cs" />
|
||||
<Compile Include="MatterControl\PrinterCallbackTests.cs" />
|
||||
<Compile Include="MatterControl\PrinterChooserUnitTests.cs" />
|
||||
<Compile Include="MatterControl\PrinterConfigurationTests.cs" />
|
||||
<Compile Include="MatterControl\AutomationTests\PrintQueueTests.cs" />
|
||||
<Compile Include="MatterControl\ReleaseBuildTests.cs" />
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace MatterControl.Tests
|
|||
[Test, RunInApplicationDomain]
|
||||
public void LibraryProviderSqlite_NavigationWorking()
|
||||
{
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting2();
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewMatterControlAppDataFolderForTesting();
|
||||
|
||||
LibraryProviderSQLite testProvider = new LibraryProviderSQLite(null, null, null, "Local Library");
|
||||
testProvider.DataReloaded += (sender, e) => { dataReloaded = true; };
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
internal string renamedUserDataPath;
|
||||
}
|
||||
|
||||
public static DataFolderState MakeNewStaticDataForTesting2(string testDBFolderName = null)
|
||||
public static DataFolderState MakeNewMatterControlAppDataFolderForTesting(string testDBFolderName = null)
|
||||
{
|
||||
DataFolderState state = new DataFolderState();
|
||||
state.userDataPath = MatterHackers.MatterControl.DataStorage.ApplicationDataStorage.ApplicationUserDataPath;
|
||||
|
|
@ -299,7 +299,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(staticDataPathOverride);
|
||||
#endif
|
||||
bool showWindow;
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting2(testDbFolder);
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewMatterControlAppDataFolderForTesting(testDbFolder);
|
||||
|
||||
if (queueItemFolderToAdd != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
using MatterHackers.MatterControl;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
|
||||
namespace MatterControl.Tests.MatterControl
|
||||
{
|
||||
class PrinterChooserUnitTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void PrinterChooserHonorsWhitelist()
|
||||
{
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
|
||||
// Whitelist on non-OEM builds should contain all printers
|
||||
var printChooser = new PrinterChooser();
|
||||
|
||||
Assert.IsTrue(printChooser.CountOfMakes > 15);
|
||||
|
||||
// Set private member to override settings.json values for this test
|
||||
SetPrivatePrinterWhiteListMember(new List<string>() { "3D Stuffmaker" });
|
||||
printChooser = new PrinterChooser();
|
||||
Assert.IsTrue(printChooser.CountOfMakes == 1);
|
||||
|
||||
SetPrivatePrinterWhiteListMember(new List<string>() { "Airwolf 3D", "3D Stuffmaker" });
|
||||
printChooser = new PrinterChooser();
|
||||
Assert.IsTrue(printChooser.CountOfMakes == 2);
|
||||
|
||||
SetPrivatePrinterWhiteListMember(new List<string>() { "Esagono" });
|
||||
var manufacturerNameMapping = new ManufacturerNameMapping();
|
||||
manufacturerNameMapping.NameOnDisk = "Esagono";
|
||||
manufacturerNameMapping.NameToDisplay = "Esagonò";
|
||||
printChooser = new PrinterChooser();
|
||||
|
||||
string expectedItem = null;
|
||||
foreach (var menuItem in printChooser.ManufacturerDropList.MenuItems)
|
||||
{
|
||||
if(menuItem.Text.StartsWith("Esa"))
|
||||
{
|
||||
expectedItem = menuItem.Text;
|
||||
}
|
||||
}
|
||||
Assert.IsTrue(!string.IsNullOrEmpty(expectedItem) && expectedItem == "Esagonò");
|
||||
}
|
||||
|
||||
private static void SetPrivatePrinterWhiteListMember(List<string> newValue)
|
||||
{
|
||||
var fieldInfo = typeof(OemSettings).GetField("printerWhiteList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
fieldInfo.SetValue(OemSettings.Instance, newValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue