Skip to content

Commit

Permalink
Skyline: Final improvements for phase 1 of screenshot updates (#3310)
Browse files Browse the repository at this point in the history
- Fixed ability to use a screenshot of an error message in AllChromatogramsGraph (TargetedMsmsTutorialTest)
- Added short-circuit for auto-screenshot mode in non-en languages to untranslated tutorials
- Final tweaks to LibraryExplorerTutorialTest for auto-screenshot update
  • Loading branch information
brendanx67 authored Jan 2, 2025
1 parent b4b8d58 commit a5b5c72
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 7 deletions.
26 changes: 23 additions & 3 deletions pwiz_tools/Skyline/Controls/Graphs/AllChromatogramsGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace pwiz.Skyline.Controls.Graphs
/// <summary>
/// A window that progressively displays chromatogram data during file import.
/// </summary>
public partial class AllChromatogramsGraph : FormEx
public partial class AllChromatogramsGraph : FormEx, FileProgressControl.IStateProvider
{
private readonly Stopwatch _stopwatch;
private int _selected = -1;
Expand Down Expand Up @@ -528,7 +528,7 @@ private void AddProgressControls(MultiProgressStatus status)
bool first = true;
var width = flowFileStatus.Width - 2 - // Avoid clipping the cancel/retry button when we need a vertical scrollbar
(flowFileStatus.VerticalScroll.Visible ||
status.ProgressList.Count > (panelFileList.Height / (new FileProgressControl()).Height) // If scrollbar isn't visible already, it's about to be
status.ProgressList.Count > (panelFileList.Height / new FileProgressControl(this).Height) // If scrollbar isn't visible already, it's about to be
? SystemInformation.VerticalScrollBarWidth
: 0);
List<FileProgressControl> controlsToAdd = new List<FileProgressControl>();
Expand All @@ -540,7 +540,7 @@ private void AddProgressControls(MultiProgressStatus status)
continue;

// Create a progress control for new file.
progressControl = new FileProgressControl
progressControl = new FileProgressControl(this)
{
Number = flowFileStatus.Controls.Count + controlsToAdd.Count + 1,
Width = width,
Expand Down Expand Up @@ -783,6 +783,8 @@ private void btnCopyText_Click(object sender, EventArgs e)

private int? _freezeProgressPercent;
private string _elapsedTimeAtFreeze;
private DateTime? _timeAtFreeze;
private Tuple<string, string> _replacementText;
private List<MultiProgressStatus> _missedProgressStatusList = new List<MultiProgressStatus>();

/// <summary>
Expand All @@ -799,6 +801,24 @@ public void SetFreezeProgressPercent(int? percent, string elapsedTime)
}
}

public void SetFreezeTimeForError(DateTime time)
{
_timeAtFreeze = time;
}

DateTime FileProgressControl.IStateProvider.Time => _timeAtFreeze ?? DateTime.Now;

public void SetReplacementForError(string oldValue, string newValue)
{
_replacementText = new Tuple<string, string>(oldValue, newValue);
}

string FileProgressControl.IStateProvider.PrepareErrorText(string errorText)
{
return _replacementText == null ? errorText
: errorText.Replace(_replacementText.Item1, _replacementText.Item2);
}

public bool IsProgressFrozen(MultiProgressStatus status = null)
{
lock (_missedProgressStatusList)
Expand Down
14 changes: 11 additions & 3 deletions pwiz_tools/Skyline/Controls/Graphs/FileProgressControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ namespace pwiz.Skyline.Controls.Graphs
{
public partial class FileProgressControl : UserControl
{
public interface IStateProvider
{
DateTime Time { get; }
string PrepareErrorText(string errorText);
}

private readonly IStateProvider _stateProvider;
private int _number;
private MsDataFileUri _filePath;
private bool _selected;
Expand All @@ -47,8 +54,9 @@ public partial class FileProgressControl : UserControl
public event EventHandler ShowGraph;
public event EventHandler ShowLog;

public FileProgressControl()
public FileProgressControl(IStateProvider stateProvider)
{
_stateProvider = stateProvider;
InitializeComponent();
labelPercent.Text = string.Empty;
TabStop = false;
Expand Down Expand Up @@ -132,8 +140,8 @@ public void SetStatus(ChromatogramLoadingStatus status)
{
if (Error == null)
{
Error = string.Format(GraphsResources.FileProgressControl_SetStatus_, DateTime.Now.ToShortTimeString(),
ExceptionUtil.GetMessage(status.ErrorException));
Error = string.Format(GraphsResources.FileProgressControl_SetStatus_, _stateProvider.Time.ToShortTimeString(),
_stateProvider.PrepareErrorText(ExceptionUtil.GetMessage(status.ErrorException)));
_errorCount++;
if (_errorLog.Count == 3)
{
Expand Down
4 changes: 4 additions & 0 deletions pwiz_tools/Skyline/TestTutorial/AuditLogTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public class AuditLogTutorialTest : AbstractFunctionalTestEx
[TestMethod]
public void TestAuditLogTutorial()
{
// Not yet translated
if (IsTranslationRequired)
return;

// Set true to look at tutorial screenshots.
// IsPauseForScreenShots = true;
// PauseStartingPage = 16;
Expand Down
4 changes: 4 additions & 0 deletions pwiz_tools/Skyline/TestTutorial/CEOptimizationTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public class CEOptimizationTutorialTest : AbstractFunctionalTestEx
[TestMethod]
public void TestCEOptimizationTutorial()
{
// Not yet translated
if (IsTranslationRequired)
return;

AsSmallMolecules = false;
RunCEOptimizationTutorialTest();
}
Expand Down
14 changes: 14 additions & 0 deletions pwiz_tools/Skyline/TestTutorial/LibraryExplorerTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class LibraryExplorerTutorialTest : AbstractFunctionalTest
[TestMethod]
public void TestLibraryExplorerTutorial()
{
// Not yet translated
if (IsTranslationRequired)
return;
// Set true to look at tutorial screenshots.
// IsPauseForScreenShots = true;
// IsCoverShotMode = true;
Expand Down Expand Up @@ -337,12 +340,15 @@ protected override void DoTest()
Assert.AreEqual(2, viewLibraryDlg1.PeptideDisplayCount);
Assert.AreEqual(countLabels1, viewLibraryDlg1.GraphItem.IonLabels.Count());
});
RunUIForScreenShot(() => viewLibraryDlg1.Width -= 185);
LimitXAxis(viewLibraryDlg1);
PauseForGraphScreenShot("Spectrum graph metafile", viewLibraryDlg1.GraphExtensionControl, 16); // p. 16, figure 1a
RunUI(() =>
{
viewLibraryDlg1.SelectedIndex = 1;
Assert.AreEqual(countLabels2, viewLibraryDlg1.GraphItem.IonLabels.Count());
});
LimitXAxis(viewLibraryDlg1);
PauseForGraphScreenShot("Spectrum graph metafile", viewLibraryDlg1.GraphExtensionControl, 16); // p. 16, figure 1b

docInitial = SkylineWindow.Document;
Expand Down Expand Up @@ -380,6 +386,7 @@ protected override void DoTest()
Assert.IsTrue(labelsPhospho.Contains(label => label.Contains(string.Format("{0} {1}", IonType.precursor.GetLocalizedString(), lossText))));
Assert.AreEqual(countLabels1 + countLossLabels1 + countPrecursors1, labelsPhospho.Count);
});
LimitXAxis(viewLibraryDlg1);
PauseForGraphScreenShot("Spectrum graph metafile", viewLibraryDlg1.GraphExtensionControl, 18); // p. 18, figure 1a.

RunUI(() =>
Expand All @@ -390,6 +397,7 @@ protected override void DoTest()
Assert.IsTrue(labelsPhospho.Contains(label => label.Contains(string.Format("{0} {1}", IonType.precursor.GetLocalizedString(), lossText))));
Assert.AreEqual(countLabels2 + countLossLabels2 + countPrecursors2, labelsPhospho.Count);
});
LimitXAxis(viewLibraryDlg1);
PauseForGraphScreenShot("Spectrum graph metafile", viewLibraryDlg1.GraphExtensionControl, 18); // p. 18, figure 1b.

// Matching Library Peptides to Proteins p. 18
Expand All @@ -400,6 +408,7 @@ protected override void DoTest()
{
buildBackgroundProteomeDlg.BackgroundProteomePath = GetTestPath(@"human.protdb");
buildBackgroundProteomeDlg.BackgroundProteomeName = "Human (mini)";
buildBackgroundProteomeDlg.SelToEndBackgroundProteomePath();
});
PauseForScreenShot<BuildBackgroundProteomeDlg>("Edit Background Proteome", 19); // p. 19

Expand Down Expand Up @@ -464,5 +473,10 @@ protected override void DoTest()

OkDialog(viewLibraryDlg, viewLibraryDlg.Close);
}

private void LimitXAxis(ViewLibraryDlg viewLibraryDlg)
{
viewLibraryDlg.GraphExtensionControl.Graph.GraphPane.XAxis.Scale.Max = 1225;
}
}
}
4 changes: 4 additions & 0 deletions pwiz_tools/Skyline/TestTutorial/PeakPickingTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ protected override bool UseRawFiles
[TestMethod]
public void TestPeakPickingTutorial()
{
// Not yet translated
if (IsTranslationRequired)
return;

// Set true to look at tutorial screenshots.
// IsPauseForScreenShots = true;
// IsCoverShotMode = true;
Expand Down
9 changes: 8 additions & 1 deletion pwiz_tools/Skyline/TestTutorial/TargetedMSMSTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,16 @@ private void TofTest()

// Try to import a file to show it fails.
ImportResultsDlg importResultsDlg3 = ShowDialog<ImportResultsDlg>(SkylineWindow.ImportResults);
var uri500fmol = MsDataFileUri.Parse(GetTestPath(@"TOF\6-BSA-500fmol" + ExtAgilentRaw));
RunUI(() => importResultsDlg3.NamedPathSets = importResultsDlg3.GetDataSourcePathsFileReplicates(
new[] { MsDataFileUri.Parse(GetTestPath(@"TOF\6-BSA-500fmol" + ExtAgilentRaw)) }));
new[] { uri500fmol }));
var importProgress = ShowDialog<AllChromatogramsGraph>(importResultsDlg3.OkDialog);
// Set a consistent time for a screenshot
var dateTimeCurrent = DateTime.Now;
var dateTimeError = new DateTime(dateTimeCurrent.Year, dateTimeCurrent.Month, dateTimeCurrent.Day, 12, 35, 0);
importProgress.SetFreezeTimeForError(dateTimeError);
// Remove the full path for the error in a screenshot
importProgress.SetReplacementForError(Path.GetDirectoryName(uri500fmol.GetFilePath()) + Path.DirectorySeparatorChar, string.Empty);
var docFullScanError = WaitForDocumentChangeLoaded(docCalibrate1);
// WaitForConditionUI(() => importProgress.Files.Any());
WaitForConditionUI(() => importProgress.Finished);
Expand Down
2 changes: 2 additions & 0 deletions pwiz_tools/Skyline/TestUtil/TestFunctional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,8 @@ public static bool IsAutoScreenShotMode
}
}

public static bool IsTranslationRequired => IsAutoScreenShotMode && !Equals("en", GetFolderNameForLanguage(CultureInfo.CurrentCulture));

private static bool _isCoverShotMode;

public static bool IsCoverShotMode
Expand Down

0 comments on commit a5b5c72

Please sign in to comment.