Created test and addressed printer name bug
issue: MatterHackers/MCCentral#6102 Renaming printer when 2 are open, renames both
This commit is contained in:
parent
632953866e
commit
6881e19ee6
7 changed files with 99 additions and 30 deletions
|
|
@ -57,11 +57,11 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
PrinterSettings.AnyPrinterSettingChanged += Printer_SettingChanged;
|
||||
printer.Settings.SettingChanged += Printer_SettingChanged;
|
||||
|
||||
inlineNameEdit.Closed += (s, e) =>
|
||||
{
|
||||
PrinterSettings.AnyPrinterSettingChanged -= Printer_SettingChanged;
|
||||
printer.Settings.SettingChanged -= Printer_SettingChanged;
|
||||
};
|
||||
|
||||
this.AddChild(
|
||||
|
|
|
|||
|
|
@ -672,6 +672,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public ChromeTabs TabControl => tabControl;
|
||||
|
||||
private static int debugPrinterTabIndex = 0;
|
||||
|
||||
private ChromeTab CreatePrinterTab(PartWorkspace workspace, ThemeConfig theme)
|
||||
{
|
||||
var printer = workspace.Printer;
|
||||
|
|
@ -698,7 +700,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
theme,
|
||||
tabImageUrl: ApplicationController.Instance.GetFavIconUrl(oemName: printer.Settings.GetValue(SettingsKey.make)))
|
||||
{
|
||||
Name = "3D View Tab",
|
||||
Name = $"3D View Tab {debugPrinterTabIndex++}",
|
||||
};
|
||||
|
||||
// add a right click menu
|
||||
|
|
|
|||
|
|
@ -126,7 +126,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
var key = printer.Settings.ID;
|
||||
Task.Run(async () =>
|
||||
{
|
||||
ProfileManager.oemSettingsNeedingUpdateCache[key] = await GetChangedOemSettings(printer);
|
||||
if (ProfileManager.oemSettingsNeedingUpdateCache.ContainsKey(key))
|
||||
{
|
||||
ProfileManager.oemSettingsNeedingUpdateCache[key] = await GetChangedOemSettings(printer);
|
||||
}
|
||||
});
|
||||
|
||||
if (oemSettingsNeedingUpdateCache.TryGetValue(key, out List<(string key, string currentValue, string newValue)> cache))
|
||||
|
|
|
|||
|
|
@ -45,10 +45,9 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
private static HashSet<string> savedImages = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Download an image from the web into the specified ImageBuffer
|
||||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
private static object locker = new object();
|
||||
|
||||
// Download an image from the web into the specified ImageBuffer
|
||||
public static void RetrieveImageAsync(ImageBuffer imageToLoadInto, string uriToLoad, bool scaleToImageX, IRecieveBlenderByte scalingBlender = null)
|
||||
{
|
||||
var longHash = uriToLoad.GetLongHashCode();
|
||||
|
|
@ -97,10 +96,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download an image from the web into the specified ImageSequence
|
||||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
// Download an image from the web into the specified ImageSequence
|
||||
public static void RetrieveImageSquenceAsync(ImageSequence imageSequenceToLoadInto,
|
||||
string uriToLoad,
|
||||
Action doneLoading = null)
|
||||
|
|
@ -117,7 +113,11 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
AggContext.StaticData.LoadImageSequenceData(new StreamReader(pngFileName).BaseStream, asyncImageSequence);
|
||||
lock (locker)
|
||||
{
|
||||
AggContext.StaticData.LoadImageSequenceData(new StreamReader(pngFileName).BaseStream, asyncImageSequence);
|
||||
}
|
||||
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
imageSequenceToLoadInto.Copy(asyncImageSequence);
|
||||
|
|
@ -139,7 +139,11 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
try
|
||||
{
|
||||
AggContext.StaticData.LoadImageSequenceData(new StreamReader(gifFileName).BaseStream, asyncImageSequence);
|
||||
lock (locker)
|
||||
{
|
||||
AggContext.StaticData.LoadImageSequenceData(new StreamReader(gifFileName).BaseStream, asyncImageSequence);
|
||||
}
|
||||
|
||||
if (asyncImageSequence.NumFrames > 0)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
|
|
@ -179,12 +183,18 @@ namespace MatterHackers.MatterControl
|
|||
byte[] raw = e.Result;
|
||||
Stream stream = new MemoryStream(raw);
|
||||
|
||||
AggContext.StaticData.LoadImageSequenceData(stream, asyncImageSequence);
|
||||
lock (locker)
|
||||
{
|
||||
AggContext.StaticData.LoadImageSequenceData(stream, asyncImageSequence);
|
||||
}
|
||||
|
||||
if (asyncImageSequence.Frames.Count == 1)
|
||||
{
|
||||
// save the as png
|
||||
AggContext.ImageIO.SaveImageData(pngFileName, asyncImageSequence.Frames[0]);
|
||||
lock (locker)
|
||||
{
|
||||
AggContext.ImageIO.SaveImageData(pngFileName, asyncImageSequence.Frames[0]);
|
||||
}
|
||||
}
|
||||
else // save original stream as gif
|
||||
{
|
||||
|
|
@ -286,7 +296,11 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
try
|
||||
{
|
||||
fileText = File.ReadAllText(appDataFileName);
|
||||
lock (locker)
|
||||
{
|
||||
fileText = File.ReadAllText(appDataFileName);
|
||||
}
|
||||
|
||||
updateResult?.Invoke(fileText);
|
||||
}
|
||||
catch
|
||||
|
|
@ -301,7 +315,11 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
try
|
||||
{
|
||||
fileText = AggContext.StaticData.ReadAllText(staticDataPath);
|
||||
lock (locker)
|
||||
{
|
||||
fileText = AggContext.StaticData.ReadAllText(staticDataPath);
|
||||
}
|
||||
|
||||
updateResult?.Invoke(fileText);
|
||||
}
|
||||
catch
|
||||
|
|
@ -341,8 +359,11 @@ namespace MatterHackers.MatterControl
|
|||
ImageBuffer unScaledImage = new ImageBuffer(10, 10);
|
||||
if (scaleToImageX)
|
||||
{
|
||||
// scale the loaded image to the size of the target image
|
||||
AggContext.StaticData.LoadImageData(stream, unScaledImage);
|
||||
lock (locker)
|
||||
{
|
||||
// scale the loaded image to the size of the target image
|
||||
AggContext.StaticData.LoadImageData(stream, unScaledImage);
|
||||
}
|
||||
|
||||
// If the source image (the one we downloaded) is more than twice as big as our dest image.
|
||||
while (unScaledImage.Width > imageToLoadInto.Width * 2)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 570a8e1ab2e522a1f8177cd58632be8f815a8ad8
|
||||
Subproject commit dd862e4d29fb121cdcee8dffe6305172c2053113
|
||||
|
|
@ -8,10 +8,51 @@ using NUnit.Framework;
|
|||
namespace MatterHackers.MatterControl.Tests.Automation
|
||||
{
|
||||
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain, Apartment(ApartmentState.STA)]
|
||||
public class PrinterNameChangePersists
|
||||
public class PrinterNameChangeTests
|
||||
{
|
||||
[Test]
|
||||
public async Task PrinterNameChangeTest()
|
||||
public async Task NameChangeOnlyEffectsOnePrinter()
|
||||
{
|
||||
await MatterControlUtilities.RunTest((testRunner) =>
|
||||
{
|
||||
testRunner.WaitForFirstDraw();
|
||||
|
||||
// Add Guest printers
|
||||
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
|
||||
|
||||
var printer1 = testRunner.FirstPrinter();
|
||||
|
||||
testRunner.AddAndSelectPrinter("BCN3D", "Sigma");
|
||||
|
||||
var printer2 = ApplicationController.Instance.ActivePrinters.Last();
|
||||
|
||||
string newName0 = "Updated name 0";
|
||||
string newName1 = "Updated name 1";
|
||||
var printerTab0 = testRunner.GetWidgetByName("3D View Tab 0", out _) as ChromeTab;
|
||||
var printerTab1 = testRunner.GetWidgetByName("3D View Tab 1", out _) as ChromeTab;
|
||||
|
||||
// switch back to airwolf tab
|
||||
testRunner.ClickByName("3D View Tab 0")
|
||||
.SwitchToPrinterSettings()
|
||||
.InlineTitleEdit("Printer Name", newName0);
|
||||
|
||||
Assert.AreEqual(newName0, printerTab0.Title);
|
||||
Assert.AreEqual("BCN3D Sigma", printerTab1.Title);
|
||||
|
||||
// switch back to BCN tab
|
||||
testRunner.ClickByName("3D View Tab 1")
|
||||
.SwitchToPrinterSettings()
|
||||
.InlineTitleEdit("Printer Name", newName1);
|
||||
|
||||
Assert.AreEqual(newName1, printerTab1.Title);
|
||||
Assert.AreEqual(newName0, printerTab0.Title, "Name did not change");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}, maxTimeToRun: 120);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task NameChangePersists()
|
||||
{
|
||||
// Ensures that printer model changes are applied correctly and observed by the view
|
||||
await MatterControlUtilities.RunTest((testRunner) =>
|
||||
|
|
@ -42,13 +83,12 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Assert.IsTrue(testRunner.WaitForName(newName + " Node"), "Widget with updated printer name exists");
|
||||
|
||||
// Validate that the tab reflects the new name
|
||||
var printerTab = testRunner.GetWidgetByName("3D View Tab", out _) as ChromeTab;
|
||||
var printerTab = testRunner.GetWidgetByName("3D View Tab 0", out _) as ChromeTab;
|
||||
Assert.AreEqual(newName, printerTab.Title);
|
||||
|
||||
// Validate that the settings layer reflects the new name
|
||||
Assert.AreEqual(newName, printer.Settings.GetValue(SettingsKey.printer_name));
|
||||
|
||||
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1090,17 +1090,17 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// Switch to printer settings
|
||||
/// </summary>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
public static void SwitchToPrinterSettings(this AutomationRunner testRunner)
|
||||
public static AutomationRunner SwitchToPrinterSettings(this AutomationRunner testRunner)
|
||||
{
|
||||
EnsurePrinterSidebarOpen(testRunner);
|
||||
|
||||
if (!testRunner.NameExists("Printer Tab", 0.1))
|
||||
{
|
||||
testRunner.ClickByName("Printer Overflow Menu");
|
||||
testRunner.ClickByName("Configure Printer Menu Item");
|
||||
testRunner.ClickByName("Printer Overflow Menu")
|
||||
.ClickByName("Configure Printer Menu Item");
|
||||
}
|
||||
|
||||
testRunner.ClickByName("Printer Tab");
|
||||
return testRunner.ClickByName("Printer Tab");
|
||||
}
|
||||
|
||||
public static void InlineTitleEdit(this AutomationRunner testRunner, string controlName, string replaceString)
|
||||
|
|
@ -1208,7 +1208,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
if (testRunner.WaitForName("Slice Settings Sidebar", 0.2))
|
||||
{
|
||||
testRunner.ClickByName("Slice Settings Sidebar");
|
||||
testRunner.ClickByName("Pin Settings Button");
|
||||
if (UserSettings.Instance.get(UserSettingsKey.SliceSettingsTabPinned) != "true")
|
||||
{
|
||||
testRunner.ClickByName("Pin Settings Button");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue