예제 #1
0
        public static IDPickerAllSettings GetAndSetTestSettings(this TestContext testContext)
        {
            IDPickerAllSettings settings = null;

            testContext.LaunchAppTest("IDPicker.exe", "", (app, windowStack) => { settings = app.GetAndSetTestSettings(windowStack); });
            return(settings);
        }
예제 #2
0
        public static IDPickerAllSettings GetAndSetTestSettings(this Application app, Stack <Window> windowStack)
        {
            var settings = new IDPickerAllSettings();

            SetSettings(app, windowStack, settings);
            return(settings);
        }
예제 #3
0
        /// <summary>
        /// Get the values from the options menu of an existing IDPicker Application instance (the Settings are not directly accessible from a separate process)
        /// </summary>
        public static IDPickerAllSettings GetSettings(this Application app, Stack <Window> windowStack)
        {
            var settings = new IDPickerAllSettings();

            var window = app.GetWindow(SearchCriteria.ByAutomationId("IDPickerForm"), InitializeOption.NoCache);

            windowStack.Push(window);

            var menu = window.RawGet <MenuBar>(SearchCriteria.ByAutomationId("menuStrip1"), 2);

            //menu.MenuItemBy(SearchCriteria.ByAutomationId("toolsToolStripMenuItem"), SearchCriteria.ByAutomationId("optionsToolStripMenuItem")).Click();
            menu.MenuItem("Tools", "Options...").RaiseClickEvent(); // FIXME: not localized, but the AutomationIds aren't being set properly so the above line won't work

            var options = window.ModalWindow(SearchCriteria.ByAutomationId("DefaultSettingsManagerForm"), InitializeOption.WithCache);

            windowStack.Push(options);

            settings.GeneralSettings.DefaultMinSpectraPerDistinctMatch   = Convert.ToInt32(options.Get <TextBox>("minSpectraPerMatchTextBox").Text);
            settings.GeneralSettings.DefaultMinSpectraPerDistinctPeptide = Convert.ToInt32(options.Get <TextBox>("minSpectraPerPeptideTextBox").Text);
            settings.GeneralSettings.DefaultMaxPrecursorMzError          = options.Get <TextBox>("maxPrecursorMzToleranceTextBox").Text;
            settings.GeneralSettings.DefaultMaxProteinGroupsPerPeptide   = Convert.ToInt32(options.Get <TextBox>("maxProteinGroupsTextBox").Text);
            settings.GeneralSettings.DefaultMinSpectra            = Convert.ToInt32(options.Get <TextBox>("minSpectraTextBox").Text);
            settings.GeneralSettings.DefaultMinDistinctPeptides   = Convert.ToInt32(options.Get <TextBox>("minDistinctPeptidesTextBox").Text);
            settings.GeneralSettings.DefaultMinAdditionalPeptides = Convert.ToInt32(options.Get <TextBox>("minAdditionalPeptidesTextBox").Text);
            settings.GeneralSettings.DefaultMaxRank = Convert.ToInt32(options.Get <TextBox>("maxImportRankTextBox").Text);

            settings.GeneralSettings.DefaultMaxFDR       = Convert.ToDouble(options.Get <ComboBox>("maxQValueComboBox").EditableText) / 100;
            settings.GeneralSettings.DefaultMaxImportFDR = Convert.ToDouble(options.Get <ComboBox>("maxImportFdrComboBox").EditableText) / 100;

            settings.GeneralSettings.DefaultDecoyPrefix            = options.Get <TextBox>("defaultDecoyPrefixTextBox").Text;
            settings.GeneralSettings.DefaultIgnoreUnmappedPeptides = options.Get <CheckBox>("ignoreUnmappedPeptidesCheckBox").Checked;

            settings.GeneralSettings.DefaultGeneLevelFiltering         = options.Get <CheckBox>("filterByGeneCheckBox").Checked;
            settings.GeneralSettings.DefaultChargeIsDistinct           = options.Get <CheckBox>("chargeIsDistinctCheckBox").Checked;
            settings.GeneralSettings.DefaultAnalysisIsDistinct         = options.Get <CheckBox>("analysisIsDistinctCheckBox").Checked;
            settings.GeneralSettings.DefaultModificationsAreDistinct   = options.Get <CheckBox>("modificationsAreDistinctCheckbox").Checked;
            settings.GeneralSettings.DefaultModificationRoundToNearest = Convert.ToDecimal(options.Get <TextBox>("modificationRoundToMassTextBox").Text);

            //settings.GeneralSettings.FastaPaths.Clear(); settings.GeneralSettings.FastaPaths.AddRange(lbFastaPaths.Items.OfType<string>().ToArray());
            //settings.GeneralSettings.SourcePaths.Clear(); settings.GeneralSettings.SourcePaths.AddRange(lbSourcePaths.Items.OfType<string>().ToArray());

            settings.GeneralSettings.SourceExtensions     = options.Get <TextBox>("sourceExtensionsTextBox").Text;
            settings.GeneralSettings.GroupConcatSeparator = options.Get <TextBox>("groupSeparatorTextBox").Text;

            settings.GUISettings.WarnAboutNonFixedDrive  = options.Get <CheckBox>("nonFixedDriveWarningCheckBox").Checked;
            settings.GUISettings.WarnAboutNoGeneMetadata = options.Get <CheckBox>("embedGeneMetadataWarningCheckBox").Checked;

            options.Get <Button>("btnOk").RaiseClickEvent();
            windowStack.Pop();

            return(settings);
        }
예제 #4
0
 /// <summary>
 /// Launch IDPicker without any arguments and set up the options menu according to the given settings parameter (the Settings are not directly accessible from a separate process)
 /// </summary>
 public static void SetSettings(this TestContext testContext, IDPickerAllSettings settings)
 {
     testContext.LaunchAppTest("IDPicker.exe", "", (app, windowStack) => { app.SetSettings(windowStack, settings); });
 }
예제 #5
0
        public void ImportMultipleFilesFromMenu()
        {
            IDPickerAllSettings settings = null;

            Func <AppRunner> createTestCase = () =>
            {
                return((app, windowStack) =>
                {
                    var window = app.GetWindow(SearchCriteria.ByAutomationId("IDPickerForm"), InitializeOption.NoCache);
                    var statusBar = window.Get <StatusStrip>();
                    var statusText = statusBar.Get <TextBox>();
                    windowStack.Push(window);

                    settings = app.GetAndSetTestSettings(windowStack);

                    var menu = window.RawGet <MenuBar>(SearchCriteria.ByAutomationId("menuStrip1"), 2);
                    //menu.MenuItemBy(SearchCriteria.ByAutomationId("toolsToolStripMenuItem"), SearchCriteria.ByAutomationId("optionsToolStripMenuItem")).Click();
                    menu.MenuItem("File", "Import files").Click(); // FIXME: not localized, but the AutomationIds aren't being set properly so the above line won't work

                    var importFilesForm = window.ModalWindow(SearchCriteria.ByAutomationId("IDPOpenDialog"), InitializeOption.WithCache);
                    windowStack.Push(importFilesForm);

                    // make sure "all importable IDPicker formats" is selected, should be the first option
                    var sourceType = importFilesForm.Get <ComboBox>("sourceTypeComboBox");
                    sourceType.Select(0);

                    var fileTree = importFilesForm.Get <Tree>(SearchCriteria.ByAutomationId("FileTree"));
                    List <string> pathSegments = TestContext.TestOutputPath().Split('\\').ToList();
                    pathSegments[0] += '\\';
                    var node = fileTree.Node(pathSegments.ToArray());
                    node.Select();
                    importFilesForm.Get <Button>("AddNode").Click(); // TODO: fix variable names in Jay's code to be consistent with my code
                    Thread.Sleep(500);
                    importFilesForm.Get <Button>("openButton").RaiseClickEvent();
                    window.WaitWhileBusy();

                    // check:
                    // - trying to save to a read only location prompts for a new location
                    // - choosing an existing filepath asks user to confirm overwriting
                    // - that the automatically generated merged filepath is correct
                    Window saveDialog = null;
                    IDPicker.Util.TryRepeatedly <ArgumentOutOfRangeException>(() => saveDialog = window.ModalWindows()[0], 10, 500);
                    windowStack.Push(saveDialog);

                    // HACK: saveDialog.Get<TextBox>() won't work because of some unsupported control types in the Save Dialog (at least on Windows 7); I'm not sure if the 1001 id is stable
                    var saveTarget = new TextBox(saveDialog.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "1001")), new NullActionListener());
                    Assert.AreEqual(TestContext.TestOutputPath("201208-378803.idpDB"), saveTarget.Text);

                    var saveButton = new Button(saveDialog.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "1")), new NullActionListener());
                    saveButton.Click();
                    windowStack.Pop();

                    var progressForm = window.ModalWindow(SearchCriteria.ByAutomationId("ProgressForm"), InitializeOption.NoCache);
                    windowStack.Push(progressForm);

                    var importSettings = window.ModalWindow(SearchCriteria.ByAutomationId("UserDialog"));
                    windowStack.Push(importSettings);

                    var settingsTable = importSettings.GetFastTable("dataGridView");
                    Assert.IsNotNull(settingsTable);
                    Assert.AreEqual(4, settingsTable.Rows.Count);

                    Assert.AreEqual(7, settingsTable.Rows[0].Cells.Count);
                    UnitTestExtensions.AssertSequenceEquals(new Object[] { "Comet 2014.02", FilepathOrFilename(settingsTable.Rows[0].Cells[1].Value.ToString()), "XXX_", "2", 0.1m.ToString(CultureInfo.CurrentCulture), "False", "Comet optimized" }, settingsTable.Rows[0].Cells.Select(o => o.Value).ToArray());
                    UnitTestExtensions.AssertSequenceEquals(new Object[] { "MyriMatch 2.2.140", FilepathOrFilename(settingsTable.Rows[1].Cells[1].Value.ToString()), "XXX_", "2", 0.1m.ToString(CultureInfo.CurrentCulture), "False", "MyriMatch optimized" }, settingsTable.Rows[1].Cells.Select(o => o.Value).ToArray());
                    UnitTestExtensions.AssertSequenceEquals(new Object[] { "MS-GF+ Beta (v10072)", FilepathOrFilename(settingsTable.Rows[2].Cells[1].Value.ToString()), "XXX", "2", 0.1m.ToString(CultureInfo.CurrentCulture), "False", "MS-GF+" }, settingsTable.Rows[2].Cells.Select(o => o.Value).ToArray());
                    UnitTestExtensions.AssertSequenceEquals(new Object[] { "Mascot 2.2.06", "cow.protein.PRG2012-subset.fasta", "DECOY_", "2", 0.1m.ToString(CultureInfo.CurrentCulture), "False", "Mascot ionscore" }, settingsTable.Rows[3].Cells.Select(o => o.Value).ToArray());

                    // HACK: for some reason White's TableCell.Value property isn't sending keyboard input correctly;
                    // with this workaround, be careful while debugging around this code because the keyboard input might be sent to the debugger!
                    settingsTable.Rows[0].Cells[1].Click();
                    importSettings.Keyboard.Enter(TestContext.TestDataFilePath("cow.protein.PRG2012-subset.fasta"));

                    // TODO: add interface testing
                    // test qonverter settings
                    // test error conditions (bad values for max rank and max FDR score)
                    // test invalid decoy prefix
                    // test analysis parameters tree

                    var ok = importSettings.Get <Button>("okButton");
                    ok.Click();
                    windowStack.Pop();

                    while (!progressForm.IsClosed)
                    {
                        Thread.Sleep(1000);
                    }

                    windowStack.Pop();

                    if (settings.GUISettings.WarnAboutNoGeneMetadata)
                    {
                        // handle prompt for gene metadata embedding
                        var prompt = window.ModalWindow(SearchCriteria.ByAutomationId("EmbedGeneMetadataWarningForm"), InitializeOption.NoCache);
                        prompt.Get <Button>("embedButton").RaiseClickEvent();
                    }

                    statusText.WaitForReady();

                    window = app.GetWindow(SearchCriteria.ByAutomationId("IDPickerForm"), InitializeOption.NoCache);
                    var dockableForms = window.GetDockableForms();

                    var proteinTableForm = dockableForms.Single(o => o.Id == "ProteinTableForm");
                    if (settings.GUISettings.WarnAboutNoGeneMetadata)
                    {
                        Assert.AreEqual("Protein View: 6 clusters, 8 protein groups, 13 proteins, 0% protein FDR, 8 gene groups, 13 genes", proteinTableForm.Name);
                    }
                    else
                    {
                        Assert.AreEqual("Protein View: 6 clusters, 8 protein groups, 13 proteins, 0% protein FDR", proteinTableForm.Name);
                    }

                    var peptideTableForm = dockableForms.Single(o => o.Id == "PeptideTableForm");
                    Assert.AreEqual("Peptide View: 43 distinct peptides, 47 distinct matches", peptideTableForm.Name);

                    var spectrumTableForm = dockableForms.Single(o => o.Id == "SpectrumTableForm");
                    Assert.AreEqual("Spectrum View: 2 groups, 1 sources, 42 spectra", spectrumTableForm.Name);

                    var modificationTableForm = dockableForms.Single(o => o.Id == "ModificationTableForm");
                    Assert.AreEqual("Modification View: 24 modified spectra", modificationTableForm.Name);

                    var analysisTableForm = dockableForms.Single(o => o.Id == "AnalysisTableForm");
                    Assert.AreEqual("Analysis View", analysisTableForm.Name);

                    var filterHistoryForm = dockableForms.Single(o => o.Id == "FilterHistoryForm");
                    Assert.AreEqual("Filter History", filterHistoryForm.Name);
                });
            };



            TestContext.CopyTestInputFiles("201208-378803*.pepXML", "201208-378803*.pep.xml", "201208-378803*.mzid", "F003098.dat");

            TestContext.LaunchAppTest("IDPicker.exe", "--test-ui-layout", createTestCase(), closeAppOnError: true);

            // toggle embed gene metadata warning
            settings.GUISettings.WarnAboutNoGeneMetadata = !settings.GUISettings.WarnAboutNoGeneMetadata;
            TestContext.SetSettings(settings);

            // delete the idpDB files between tests
            Directory.GetFiles(TestContext.TestOutputPath(), "*.idpDB").ToList().ForEach(o => File.Delete(o));

            TestContext.LaunchAppTest("IDPicker.exe", "--test-ui-layout", createTestCase(), closeAppOnError: true);

            // test with default hierarchy when input is a flat hierarchy, e.g. /source1, /source2; should be no groups in output
            // test with default hierarchy when input is a multi-level hierarchy, e.g. /A/1/source1, /B/2/source2; the hierarchy should be preserved in the output
            // test that sources are combined together when they are in separate places in the filesystem, even Mascot DAT files
            // test that files are combined properly when
        }