internal static string Value(this TextBox textBox) { var itemStatus = textBox.ItemStatus(); var text = itemStatus.Get(NumericBox <double> .ValueProperty); return(text); }
internal static string FormattedText(this TextBox textBox) { var itemStatus = textBox.ItemStatus(); var text = itemStatus.Get(BaseBox.FormattedTextProperty); return(text); }
public static string ValidationError(this TextBox textBox) { var itemStatus = textBox.ItemStatus(); var text = itemStatus.Get("FirstError"); return(text); }
void EnterAndAssertValueOfTextEntered(TextBox textBox, string stringToType) { ClearTextBox(textBox); Keyboard.Send(stringToType, MainWindow); Assert.Equal(stringToType, textBox.Text); ClearTextBox(textBox); }
internal static string EditText(this TextBox textBox) { var itemStatus = textBox.ItemStatus(); var text = itemStatus.Get(System.Windows.Controls.TextBox.TextProperty); return(text); }
public ResultPage(Window window) { this.window = window; var edits = window.GetMultiple(SearchCriteria.ByControlType(ControlType.Edit)).Cast<TextBox>().ToArray(); resultField = edits.First(edit => edit.Text == "0"); resultScreen = edits.First(edit => edit != resultField); resultButton = window.Get<Button>(SearchCriteria.ByText("=")); okButtonCriteria = SearchCriteria.ByText("OK"); }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.currentValueTextBox = this.Window.Get<TextBox>("currentValueTextBox"); this.defaultBox = this.Window.FindRow("default").Value<TextBox>(); this.propertychangedBox = this.Window.FindRow("propertychanged").Value<TextBox>(); this.readonlyBox = this.Window.FindRow("readonly string").Value<TextBox>(); }
internal static Status Status(this TextBox textBox) { var itemStatus = textBox.ItemStatus(); var text = itemStatus.Get(BaseBox.StatusProperty); Status result; if (!Enum.TryParse(text, out result)) { throw new ArgumentException(); } return(result); }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.saveButton = this.Window.GetByText<Button>("save"); this.currentValueTextBox = this.Window.Get<TextBox>("currentValueTextBox"); this.currentMinValueTextBox = this.Window.Get<TextBox>("currentMinValueTextBox"); this.currentMaxValueTextBox = this.Window.Get<TextBox>("currentMaxValueTextBox"); this.currentNullableValueTextBox = this.Window.Get<TextBox>("currentNullableValueTextBox"); this.defaultRow = this.Window.FindRow("default"); this.propertychangedRow = this.Window.FindRow("propertychanged"); this.readonlyRow = this.Window.FindRow("readonly"); this.nullableRow = this.Window.FindRow("nullable"); this.cmRow = this.Window.FindRow("explicit cm"); }
public void SecondWindowTestTextBox() { Window mainWindow = application.GetWindow("MainWindow"); //TestStack.White.UIItems.TabItems.TabPage tabInput = mainWindow.Get<White.UIItems.TabItems.TabPage>(SearchCriteria.ByText("Input Controls")); //tabInput.Click(); TestStack.White.UIItems.TextBox txtBox = mainWindow.Get <White.UIItems.TextBox>(SearchCriteria.ByAutomationId("TextBox")); txtBox.Text = "Hi This is a Text Box"; Thread.Sleep(2000); TestStack.White.UIItems.TextBox txtmultiline = mainWindow.Get <White.UIItems.TextBox>(SearchCriteria.ByAutomationId("MultiLineTextBox")); txtmultiline.Text = "Hi This is a Multi Line Text Box"; Thread.Sleep(2000); //TestStack.White.UIItems.TextBox txtPassword = mainWindow.Get<White.UIItems.TextBox>(SearchCriteria.ByAutomationId("PasswordBox")); //txtBox.Text = "Password123"; Thread.Sleep(2000); }
internal static Button DecreaseButton(this TextBox textBox) { var parent = textBox.GetParent <CustomUIItem>(); return(parent.Get <Button>(SpinnerDecorator.DecreaseButtonName)); }
public override void OneTimeSetUp() { base.OneTimeSetUp(); this.loseFocusButton = this.Window.GetByText<Button>("lose focus"); this.currentValueTextBox = this.Window.Get<TextBox>("currentValueTextBox"); }
//************************************************************************************************************************************************************** public static void UIA_SetFocusOfFirstTextBox(AutomationElement uiaWindow, Window window) { try { PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection textBoxes = uiaWindow.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement textBox in textBoxes) { TestStack.White.UIItems.TextBox t = new TestStack.White.UIItems.TextBox(textBox, window.ActionListener); t.Focus(); t.Click(); Thread.Sleep(int.Parse(Execution_Speed)); break; } } catch (Exception e) { String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
public void ThenIFillToFieldWithEmail(string email) { ToField = MainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("ToAddress")); ControlsHelper.SetTextToTextbox(ToField, email); Thread.Sleep(1000); }
public void ImportMultipleFilesOnOpen() { // get settings in a separate invocation because import starts immediately when a file is passed on the command-line var settings = TestContext.GetAndSetTestSettings(); // this lambda allow reusing of the testing code; we can change only UI parameters to create a specific AppRunner Func<string, AppRunner> createTestCase = (mergedOutputFilepath) => { 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); if (String.IsNullOrEmpty(mergedOutputFilepath)) { // 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(() => saveDialog = window.ModalWindows()[0]); 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(); } 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.RaiseClickEvent(); windowStack.Pop(); while (!progressForm.IsClosed) Thread.Sleep(500); windowStack.Pop(); bool willEmbedGeneMetadata = settings.GUISettings.WarnAboutNoGeneMetadata; // handle prompt for gene metadata embedding if necessary if (willEmbedGeneMetadata) { var prompt = window.ModalWindow(SearchCriteria.ByAutomationId("EmbedGeneMetadataWarningForm"), InitializeOption.NoCache); windowStack.Push(prompt); prompt.Get<CheckBox>("doNotShowCheckBox").Click(); prompt.Get<Button>("embedButton").RaiseClickEvent(); while (!prompt.IsClosed) Thread.Sleep(500); // refresh settings settings = app.GetSettings(windowStack); Assert.AreEqual(false, settings.GUISettings.WarnAboutNoGeneMetadata); // reset to original state settings.GUISettings.WarnAboutNoGeneMetadata = true; app.SetSettings(windowStack, settings); } statusText.WaitForReady(); window = app.GetWindow(SearchCriteria.ByAutomationId("IDPickerForm"), InitializeOption.NoCache); var dockableForms = window.GetDockableForms(); var proteinTableForm = dockableForms.Single(o => o.Id == "ProteinTableForm"); if (willEmbedGeneMetadata) 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: 1 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); }; }; // make sure embed gene metadata warning is turned on for first tests if (!settings.GUISettings.WarnAboutNoGeneMetadata) { settings.GUISettings.WarnAboutNoGeneMetadata = true; TestContext.SetSettings(settings); } var inputFiles = new string[] { "201208-378803-*.mzid", "201208-378803-*xml", "F003098.dat" }; TestOutputSubdirectory = TestContext.TestName + "-EmbedGeneMetadata"; TestContext.CopyTestInputFiles(inputFiles); TestContext.LaunchAppTest("IDPicker.exe", TestContext.TestOutputPath("*.*").QuotePathWithSpaces() + " --test-ui-layout", createTestCase(""), closeAppOnError: true); TestOutputSubdirectory = TestContext.TestName + "-EmbedGeneMetadata-MergedOutputFilepath"; TestContext.CopyTestInputFiles(inputFiles); TestContext.LaunchAppTest("IDPicker.exe", TestContext.TestOutputPath("*.*").QuotePathWithSpaces() + " -MergedOutputFilepath foobar.idpDB --test-ui-layout", createTestCase("foobar.idpDB"), closeAppOnError: true); settings.GUISettings.WarnAboutNoGeneMetadata = false; TestContext.SetSettings(settings); TestOutputSubdirectory = TestContext.TestName + "-MergedOutputFilepath"; TestContext.CopyTestInputFiles(inputFiles); TestContext.LaunchAppTest("IDPicker.exe", TestContext.TestOutputPath("*.*").QuotePathWithSpaces() + " -MergedOutputFilepath foobar.idpDB --test-ui-layout", createTestCase("foobar.idpDB"), closeAppOnError: true); }
//************************************************************************************************************************************************************** public static void UIA_SetFocusOfFirstTextBox(AutomationElement uiaWindow, Window window) { Logger.logMessage("Function call @ :" + DateTime.Now); try { PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection textBoxes = uiaWindow.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement textBox in textBoxes) { TestStack.White.UIItems.TextBox t = new TestStack.White.UIItems.TextBox(textBox, window.ActionListener); t.Focus(); t.Click(); Thread.Sleep(int.Parse(Execution_Speed)); break; } Logger.logMessage("UIA_SetFocusOfFirstTextBox " + uiaWindow + "->" + window + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); } catch (Exception e) { Logger.logMessage("UIA_SetFocusOfFirstTextBox " + uiaWindow + "->" + window + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
public void TestGridView() { var inputFiles = new string[] { "iPRG2012_PP1.2.idpDB" }; TestOutputSubdirectory = TestContext.TestName; TestContext.CopyTestInputFiles(inputFiles); TestContext.LaunchAppTest("IDPicker.exe", TestContext.TestOutputPath("iPRG2012_PP1.2.idpDB").QuotePathWithSpaces() + " --test-ui-layout", (app, windowStack) => { var window = app.GetWindow(SearchCriteria.ByAutomationId("IDPickerForm"), InitializeOption.NoCache); windowStack.Push(window); var statusBar = window.Get<StatusStrip>(); var statusText = statusBar.Get<TextBox>(); statusText.WaitForReady(); //System.Windows.Forms.MessageBox.Show("Ready"); //DataCollection.ResumeProfile(ProfileLevel.Global, DataCollection.CurrentId); window = app.GetWindow(SearchCriteria.ByAutomationId("IDPickerForm"), InitializeOption.NoCache); var dockableForms = window.GetDockableForms(); var modificationTableForm = dockableForms.Single(o => o.Id == "ModificationTableForm"); var toolstrip = modificationTableForm.RawGet<ToolStrip>("toolStrip"); Assert.AreEqual("Modification View: 1375 modified spectra", modificationTableForm.Name); // test that grid view is default var viewModeComboBox = toolstrip.Get<ComboBox>("viewModeComboBox"); Assert.AreEqual("Grid View", viewModeComboBox.SelectedItemText); // test that spectra pivot mode is default var pivotModeComboBox = toolstrip.Get<ComboBox>("pivotModeComboBox"); Assert.AreEqual("Spectra", pivotModeComboBox.SelectedItemText); // test that irrelevant filters/controls are hidden and relevant filters/controls are shown in grid view var minColumnTextBox = toolstrip.Get<TextBox>("minColumnTextBox"); var minRowTextBox = toolstrip.Get<TextBox>("minRowTextBox"); Assert.AreEqual(false, toolstrip.Items.Any(o => o.Id == "minMatchesTextBox")); var roundToNearestUpDown = toolstrip.Get<Spinner>("roundToNearestUpDown"); var unimodButton = toolstrip.Get<Button>(SearchCriteria.ByText("unimodButton")); var exportButton = toolstrip.Get<Button>(SearchCriteria.ByText("exportButton")); Assert.AreEqual("2", minColumnTextBox.Text); Assert.AreEqual("2", minRowTextBox.Text); Assert.AreEqual(0.0001, roundToNearestUpDown.Value); // test that cell values are correct and the default sort order is correct: // (rows sorted descending by mass and columns sorted ascending by site, with totals for the first row and column) // Mass Total N-t C D E K M Q R S T Y // Total 1375 271 198 140 149 191 81 36 55 126 60 68 // 79.9663 230 126 60 44 // 57.0215 198 198 // 44.9851 24 24 // 42.0106 337 271 66 // 37.9559 75 44 31 // 28.0313 87 57 30 // 21.9819 205 96 109 // 15.9949 81 81 // 14.0157 93 68 25 // -17.0265 36 36 // -18.0106 9 9 var gridViewTable = modificationTableForm.GetFastTable("dataGridView"); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); var rows = gridViewTable.Rows; var columns = gridViewTable.Header.Columns; int row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 1375 271 198 140 149 191 81 36 55 126 60 68", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 230 0 0 0 0 0 0 0 0 126 60 44".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("57#0215\nCarbamidomethyl\nAla->Gln\nGly->Asn\nGly 198 0 198 0 0 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("44#9851\nNitro 24 0 0 0 0 0 0 0 0 0 0 24".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 337 271 0 0 0 66 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("37#9559\nCation:K 75 0 0 44 31 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("28#0313\nDimethyl\nDelta:H(4)C(2)\nEthyl\nAla->Val\nCys->Met 87 0 0 0 0 57 0 0 30 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("21#9819\nCation:Na 205 0 0 96 109 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("15#9949\nOxidation\nAla->Ser\nPhe->Tyr 81 0 0 0 0 0 81 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("14#0157\nMethyl\nAsp->Glu\nGly->Ala\nSer->Thr\nVal->Xle\nAsn->Gln 93 0 0 0 0 68 0 0 25 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-17#0265\nGln->pyro-Glu\nAmmonia-loss 36 0 0 0 0 0 0 36 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 9 0 0 0 9 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); // test pivot combo box (distinct matches) // Mass Total N-t C D E K M Q R S T Y // Total 1348 168 186 182 249 273 69 29 60 56 30 46 // 79.9663 104 56 30 18 // 57.0215 186 186 // 44.9851 28 28 // 42.0106 234 168 66 // 37.9559 125 61 64 // 28.0313 94 62 32 // 21.9819 300 121 179 // 15.9949 69 69 // 14.0157 173 145 28 // -17.0265 29 29 // -18.0106 6 6 pivotModeComboBox.Select(1); statusText.WaitForReady(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 1348 168 186 182 249 273 69 29 60 56 30 46", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 104 0 0 0 0 0 0 0 0 56 30 18".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("57#0215\nCarbamidomethyl\nAla->Gln\nGly->Asn\nGly 186 0 186 0 0 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("44#9851\nNitro 28 0 0 0 0 0 0 0 0 0 0 28".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 234 168 0 0 0 66 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("37#9559\nCation:K 125 0 0 61 64 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("28#0313\nDimethyl\nDelta:H(4)C(2)\nEthyl\nAla->Val\nCys->Met 94 0 0 0 0 62 0 0 32 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("21#9819\nCation:Na 300 0 0 121 179 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("15#9949\nOxidation\nAla->Ser\nPhe->Tyr 69 0 0 0 0 0 69 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("14#0157\nMethyl\nAsp->Glu\nGly->Ala\nSer->Thr\nVal->Xle\nAsn->Gln 173 0 0 0 0 145 0 0 28 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-17#0265\nGln->pyro-Glu\nAmmonia-loss 29 0 0 0 0 0 0 29 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 6 0 0 0 6 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); // test pivot combo box (distinct peptides) // Mass Total N-t C D E K M Q R S T Y // Total 768 134 149 95 95 116 55 29 33 23 20 19 // 79.9663 51 23 20 8 // 57.0215 149 149 // 44.9851 11 11 // 42.0106 177 134 43 // 37.9559 53 31 22 // 28.0313 49 34 15 // 21.9819 133 64 69 // 15.9949 55 55 // 14.0157 57 39 18 // -17.0265 29 29 // -18.0106 4 4 pivotModeComboBox.Select(2); statusText.WaitForReady(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("57#0215\nCarbamidomethyl\nAla->Gln\nGly->Asn\nGly 149 0 149 0 0 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("44#9851\nNitro 11 0 0 0 0 0 0 0 0 0 0 11".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 177 134 0 0 0 43 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("37#9559\nCation:K 53 0 0 31 22 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("28#0313\nDimethyl\nDelta:H(4)C(2)\nEthyl\nAla->Val\nCys->Met 49 0 0 0 0 34 0 0 15 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("21#9819\nCation:Na 133 0 0 64 69 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("15#9949\nOxidation\nAla->Ser\nPhe->Tyr 55 0 0 0 0 0 55 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("14#0157\nMethyl\nAsp->Glu\nGly->Ala\nSer->Thr\nVal->Xle\nAsn->Gln 57 0 0 0 0 39 0 0 18 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-17#0265\nGln->pyro-Glu\nAmmonia-loss 29 0 0 0 0 0 0 29 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); // test sorting options { // test row sorting by total column (number of modifications at a mass) columns[0].ClickAndWaitWhileBusy(window); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 177 134 0 0 0 43 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); // test reversal of row sort order by total column (number of modifications at a mass) columns[0].ClickAndWaitWhileBusy(window); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 177 134 0 0 0 43 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); // test sorting by per-site total (delta mass is tie-breaker) columns[1].ClickAndWaitWhileBusy(window); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 177 134 0 0 0 43 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); // test returning to sort by delta-mass by clicking on top-left cell var topLeftCellClickablePoint = new System.Windows.Point(rows[0].GetHeaderCell().ClickablePoint.X, columns[0].Bounds.Y + columns[0].Bounds.Height / 2); window.Mouse.Click(topLeftCellClickablePoint); window.WaitWhileBusy(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); // test column sorting by total row (number of total modified spectra/matches/peptides at each site) rows[0].GetHeaderCell().ClickAndWaitWhileBusy(window); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total C N-term K E D M R Q S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 149 134 116 95 95 55 33 29 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); // test reversal of column sort order by total row (number of total modified spectra/matches/peptides at each site) rows[0].GetHeaderCell().ClickAndWaitWhileBusy(window); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total Y T S Q R M D E K N-term C", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 19 20 23 29 33 55 95 95 116 134 149", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 8 20 23 0 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 0 0 0 0 4 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); // test that right-clicking on top-left cell sorts by site window.Mouse.Location = topLeftCellClickablePoint; window.Mouse.RightClick(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); } // get bounds for a cell outside the grid content and test that clicking there does not change sort order (this point is also used for committing changes from the other toolbar controls and Unimod filter) var rightmostCell = rows[0].Cells.Last(); var pointOutsideGridViewContent = new System.Windows.Point(rightmostCell.Bounds.Right + rightmostCell.Bounds.Width, rightmostCell.Bounds.Bottom); { window.Mouse.Click(pointOutsideGridViewContent); window.WaitWhileBusy(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); } // test round to nearest (and test that rows are merged as expected) { roundToNearestUpDown.Increment(); window.WaitWhileBusy(); Assert.AreEqual(0.0010, roundToNearestUpDown.Value); // only the mass rounding should change, not the counts gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#966\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#011\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); roundToNearestUpDown.Increment(); window.WaitWhileBusy(); Assert.AreEqual(0.0100, roundToNearestUpDown.Value); // only the mass rounding should change, not the counts gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#97\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#01\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); roundToNearestUpDown.Increment(); window.WaitWhileBusy(); Assert.AreEqual(0.1000, roundToNearestUpDown.Value); // only the mass rounding should change, not the counts; but the delta mass annotations become ambiguous gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("80\n(4 Unimod matches) 51 0 0 0 0 0 0 0 0 23 20 8", getRowString(rows[row++], "0")); Assert.AreEqual("-18\n(6 Unimod matches) 4 0 0 0 4 0 0 0 0 0 0 0", getRowString(rows.Last(), "0")); roundToNearestUpDown.Increment(); window.WaitWhileBusy(); Assert.AreEqual(1.0000, roundToNearestUpDown.Value); // the mass rounding and counts stays the same (because in this test data everything rounds to an integer for the nearest 0.1), but the delta mass annotations become even more ambiguous gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("80\n(5 Unimod matches) 51 0 0 0 0 0 0 0 0 23 20 8", getRowString(rows[row++], "0")); Assert.AreEqual("-18\n(8 Unimod matches) 4 0 0 0 4 0 0 0 0 0 0 0", getRowString(rows.Last(), "0")); roundToNearestUpDown.Increment(); window.WaitWhileBusy(); Assert.AreEqual(10.000, roundToNearestUpDown.Value); // now some rows are merged so the row count and cell values will change gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(8, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("80\n(38 Unimod matches) 51 0 0 0 0 0 0 0 0 23 20 8", getRowString(rows[row++], "0")); Assert.AreEqual("-20\n(57 Unimod matches) 33 0 0 0 4 0 0 29 0 0 0 0", getRowString(rows.Last(), "0")); // enter rounding value manually roundToNearestUpDown.DoubleClick(); roundToNearestUpDown.KeyIn(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.DELETE); roundToNearestUpDown.Enter(0.0001m.ToString(CultureInfo.CurrentCulture)); window.Mouse.Click(pointOutsideGridViewContent); // click outside the spinner to commit the changed value window.WaitWhileBusy(); Assert.AreEqual(0.0001, roundToNearestUpDown.Value); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); } // test column and row minimum filters { minColumnTextBox.ClearAndEnter("100"); window.Mouse.Click(pointOutsideGridViewContent); // click outside the text box to commit the changed value gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(4, columns.Count); Assert.AreEqual("Total N-term C K", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 116", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); minColumnTextBox.ClearAndEnter("1"); minRowTextBox.ClearAndEnter("100"); window.Mouse.Click(pointOutsideGridViewContent); // click outside the text box to commit the changed values System.Threading.Thread.Sleep(500); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(4, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("57#0215\nCarbamidomethyl\nAla->Gln\nGly->Asn\nGly 149 0 149 0 0 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 177 134 0 0 0 43 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("21#9819\nCation:Na 133 0 0 64 69 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); // test that invalid values fall back to a safe default minRowTextBox.ClearAndEnter("0"); window.Mouse.Click(pointOutsideGridViewContent); // click outside the text box to commit the changed value Assert.AreEqual("1", minColumnTextBox.Text); Assert.AreEqual("2", minRowTextBox.Text); } // test unimod filter { //var modTableTree = new AutomationElementTreeNode(window.AutomationElement); //var c = modTableTree.Children.Count; //var modTableTree = new AutomationElementTreeNode(selectedMassesTree.AutomationElement); //var c = modTableTree.Children.Count; unimodButton.RaiseClickEvent(); window.WaitWhileBusy(); var unimodFilterControl = window.Get<Panel>("UnimodControl"); // not a child of modificationTableTree var selectedMassesLabel = unimodFilterControl.Get<Label>("MassesLabel"); var selectedSitesLabel = unimodFilterControl.Get<Label>("SitesLabel"); var siteFilterComboBox = unimodFilterControl.Get<ComboBox>("SiteFilterBox"); var showHiddenCheckBox = unimodFilterControl.Get<CheckBox>("HiddenModBox"); var selectedMassesTree = unimodFilterControl.Get<Tree>("UnimodTree"); Assert.AreEqual("0", selectedSitesLabel.Text); Assert.AreEqual("0", selectedMassesLabel.Text); // test all mods (in this test data, all mod should snap to Unimod, so this should not change the number of rows) var allModsNode = selectedMassesTree.Node("Unimod Modifications"); allModsNode.SelectAndToggle(); Assert.IsTrue(allModsNode.IsChecked()); Assert.AreEqual("10", selectedSitesLabel.Text); Assert.AreEqual("8", selectedMassesLabel.Text); showHiddenCheckBox.Toggle(); allModsNode.SelectAndToggle(); // uncheck allModsNode.SelectAndToggle(); // recheck to get hidden nodes Assert.AreEqual("11", selectedSitesLabel.Text); Assert.AreEqual("11", selectedMassesLabel.Text); unimodButton.RaiseClickEvent(); window.WaitWhileBusy(); window.Mouse.Click(pointOutsideGridViewContent); // click outside the popup to commit the new filter window.WaitWhileBusy(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(12, rows.Count); Assert.AreEqual(12, columns.Count); Assert.AreEqual("Total N-term C D E K M Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 55 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows.Last(), "0")); allModsNode.SelectAndToggle(); var ptModsNode = selectedMassesTree.Node("Unimod Modifications", "PostTranslational"); ptModsNode.SelectAndToggle(); Assert.IsFalse(allModsNode.IsChecked()); Assert.IsTrue(ptModsNode.IsChecked()); Assert.AreEqual("10", selectedSitesLabel.Text); Assert.AreEqual("7", selectedMassesLabel.Text); unimodButton.RaiseClickEvent(); window.WaitWhileBusy(); window.Mouse.Click(pointOutsideGridViewContent); // click outside the popup to commit the new filter window.WaitWhileBusy(); gridViewTable = modificationTableForm.GetFastTable("dataGridView"); rows = gridViewTable.Rows; columns = gridViewTable.Header.Columns; row = 0; Assert.AreEqual(8, rows.Count); Assert.AreEqual(11, columns.Count); Assert.AreEqual("Total N-term C D E K Q R S T Y", String.Join(" ", columns.Select(o => o.Name))); Assert.AreEqual("Total 768 134 149 95 95 116 29 33 23 20 19", getRowString(rows[row++], "0")); Assert.AreEqual("79#9663\nPhospho 51 0 0 0 0 0 0 0 23 20 8".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("42#0106\nAcetyl\nSer->Glu 177 134 0 0 0 43 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("28#0313\nDimethyl\nDelta:H(4)C(2)\nEthyl\nAla->Val\nCys->Met 49 0 0 0 0 34 0 15 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("15#9949\nOxidation\nAla->Ser\nPhe->Tyr 55 0 0 0 0 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("14#0157\nMethyl\nAsp->Glu\nGly->Ala\nSer->Thr\nVal->Xle\nAsn->Gln 57 0 0 0 0 39 0 18 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-17#0265\nGln->pyro-Glu\nAmmonia-loss 29 0 0 0 0 0 29 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); Assert.AreEqual("-18#0106\nDehydrated\nGlu->pyro-Glu 4 0 0 0 4 0 0 0 0 0 0".Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), getRowString(rows[row++], "0")); } // test export (to clipboard, to file, and to excel) { exportButton.DoubleClick(); //var modTableTree = new AutomationElementTreeNode(window.AutomationElement, 5); //var c = modTableTree.Children.Count; var exportMenu = new PopUpMenu(window.GetElement(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "DropDown")), new NullActionListener()); var copyToClipboardMenuItem = exportMenu.Items[0]; var exportToFileMenuItem = exportMenu.Items[1]; var openInExcelMenuItem = exportMenu.Items[2]; string expectedTsvText = "Delta Mass\tTotal\tN-term\tC\tD\tE\tK\tQ\tR\tS\tT\tY\n" + "Total\t768\t134\t149\t95\t95\t116\t29\t33\t23\t20\t19\n" + "79#9663 ; Phospho\t51\t\t\t\t\t\t\t\t23\t20\t8\n" + "42#0106 ; Acetyl ; Ser->Glu\t177\t134\t\t\t\t43\t\t\t\t\t\n" + "28#0313 ; Dimethyl ; Delta:H(4)C(2) ; Ethyl ; Ala->Val ; Cys->Met\t49\t\t\t\t\t34\t\t15\t\t\t\n" + "15#9949 ; Oxidation ; Ala->Ser ; Phe->Tyr\t55\t\t\t\t\t\t\t\t\t\t\n" + "14#0157 ; Methyl ; Asp->Glu ; Gly->Ala ; Ser->Thr ; Val->Xle ; Asn->Gln\t57\t\t\t\t\t39\t\t18\t\t\t\n" + "-17#0265 ; Gln->pyro-Glu ; Ammonia-loss\t29\t\t\t\t\t\t29\t\t\t\t\n" + "-18#0106 ; Dehydrated ; Glu->pyro-Glu\t4\t\t\t\t4"; expectedTsvText = expectedTsvText.Replace("#", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); IDPicker.Util.TryRepeatedly<Exception>(() => { exportButton.ClickAndWaitWhileBusy(window); copyToClipboardMenuItem.ClickAndWaitWhileBusy(window); System.Threading.Thread.Sleep(500); var clipboardText = System.Windows.Forms.Clipboard.GetText(); expectedTsvText.AssertMultilineStringEquals(clipboardText, "copyToClipboardTest"); }, 5, 500); exportButton.ClickAndWaitWhileBusy(window); exportToFileMenuItem.ClickAndWaitWhileBusy(window); var saveDialog = new PopUpMenu(window.GetElement(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "Save As")), new NullActionListener()); // 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 string saveFilepath = TestContext.TestOutputPath("GridView.tsv"); var saveTarget = new TextBox(saveDialog.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "1001")), new NullActionListener()); var saveButton = new Button(saveDialog.AutomationElement.FindFirst(TreeScope.Descendants, new AndCondition(new PropertyCondition(AutomationElement.AutomationIdProperty, "1"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))), new NullActionListener()); saveTarget.BulkText = saveFilepath; window.WaitWhileBusy(); saveButton.ClickAndWaitWhileBusy(window); var exportedText = File.ReadAllText(saveFilepath).Replace("\"", ""); expectedTsvText.AssertMultilineStringEquals(exportedText, "exportToTsvTest"); // TODO: how to test Excel if it's not necessarily installed on the test agent? } // test that changing view filter changes mods? maybe not here }, closeAppOnError: true); }
private void ClearTextBox(TextBox textBox) { textBox.Text = String.Empty; }
//************************************************************************************************************************************************************** public static void UIA_SetTextByAutomationID(AutomationElement uiaWindow, Window window, string automationID, string value) { Logger.logMessage("Function call @ :" + DateTime.Now); try { PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit); AutomationElementCollection textBoxes = uiaWindow.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement e in textBoxes) { if (e.Current.AutomationId.Equals(automationID)) { TestStack.White.UIItems.TextBox t = new TestStack.White.UIItems.TextBox(e, window.ActionListener); t.Text = value; } } Thread.Sleep(int.Parse(Execution_Speed)); Logger.logMessage("UIA_SetTextByAutomationID " + uiaWindow + "->" + window + "->" + automationID + "->" + value + "->" + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); } catch (Exception e) { Logger.logMessage("UIA_SetTextByAutomationID " + uiaWindow + "->" + window + "->" + automationID + "->" + value + "->" + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
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 }
//************************************************************************************************************************************************************** public static List<TestStack.White.UIItems.TextBox> GetAllTableEditBoxElements(TestStack.White.UIItems.TableItems.Table table, Window window) { Logger.logMessage("Function call @ :" + DateTime.Now); List<TestStack.White.UIItems.TextBox> elements = null; try { Logger.logMessage("GetAllTableEditBoxElements " + table + "->" + window); PropertyCondition tableElementsCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit); AutomationElementCollection allTableElements = table.AutomationElement.FindAll(TreeScope.Descendants, tableElementsCondition); foreach (AutomationElement item in allTableElements) { TestStack.White.UIItems.TextBox l = new TestStack.White.UIItems.TextBox(item, window.ActionListener); elements.Add(l); } Logger.logMessage("GetAllTableEditBoxElements " + table + "->" + window + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); return elements; } catch (Exception e) { Logger.logMessage("GetAllTableEditBoxElements " + table + "->" + window + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
void ClearTextBox(TextBox textBox) { textBox.Text = string.Empty; }
private void EnterAndAssertValueOfTextEntered(TextBox textBox, string stringToType) { ClearTextBox(textBox); Keyboard.Send(stringToType, MainWindow); Assert.That(textBox.Text, Is.EqualTo(stringToType)); ClearTextBox(textBox); }
public void FillMandatoryDetailsToCreateParcel(string parcelType, double quantity) { AutomationElement childElementParcel = GetChildElement(ParcelCbx, new PropertyCondition(AutomationElement.AutomationIdProperty, ElementProperties.EditableTxtBox)); TextBox parcelTxtbox = new TextBox(childElementParcel, new NullActionListener()); parcelTxtbox.SetValue(parcelType); Quantity.SetValue(quantity); AutomationElement childElementQuantity = GetChildElement(QuantityCbx, new PropertyCondition(AutomationElement.AutomationIdProperty, ElementProperties.EditableTxtBox)); TextBox quantityTxtbox = new TextBox(childElementQuantity, new NullActionListener()); quantityTxtbox.SetValue("BBL"); AutomationElement childElementPlannedDatesFrom = GetChildElement(PlannedDateFrom, new PropertyCondition(AutomationElement.AutomationIdProperty, ElementProperties.TimeInputTxtBox)); TextBox plannedDatesFromTxtbox = new TextBox(childElementPlannedDatesFrom, new NullActionListener()); plannedDatesFromTxtbox.SetValue(DateTime.Now.ToString("dd-MMM-yyyy")); AutomationElement childElementPlannedDatesTo = GetChildElement(PlannedDateTo, new PropertyCondition(AutomationElement.AutomationIdProperty, ElementProperties.TimeInputTxtBox)); TextBox plannedDatesToTxtbox = new TextBox(childElementPlannedDatesTo, new NullActionListener()); plannedDatesToTxtbox.SetValue(DateTime.Now.AddDays(30).ToString("dd-MMM-yyyy")); }