예제 #1
0
        protected override void DoTest()
        {
            var startPage = _showStartPage ? WaitForOpenForm <StartPage>() : null;
            var modeDlg   = WaitForOpenForm <NoModeUIDlg>(); // Expect a dialog asking user to select a default UI mode

            RunUI(() =>
            {
                modeDlg.SelectModeUI(SrmDocument.DOCUMENT_TYPE.small_molecules);
                modeDlg.ClickOk();
            });
            WaitForClosedForm(modeDlg);

            if (_showStartPage)
            {
                // ReSharper disable PossibleNullReferenceException
                Assert.AreEqual(SrmDocument.DOCUMENT_TYPE.small_molecules, startPage.GetModeUIHelper().GetUIToolBarButtonState());
                // Verify that start page UI is updated
                Assert.IsFalse(startPage.GetVisibleBoxPanels().Where(c => c is ActionBoxControl).Any(c => ((ActionBoxControl)c).IsProteomicOnly));
                RunUI(() => startPage.DoAction(skylineWindow => true)); // Start a new file
                // ReSharper restore PossibleNullReferenceException
                WaitForOpenForm <SkylineWindow>();
            }

            // Verify that Skyline UI isn't showing anything proteomic
            Assert.AreEqual(SrmDocument.DOCUMENT_TYPE.small_molecules, SkylineWindow.GetModeUIHelper().GetUIToolBarButtonState());
            Assert.IsFalse(SkylineWindow.HasProteomicMenuItems);

            RunUI(() =>
            {
                SkylineWindow.SaveDocument(TestFilesDir.GetTestPath("blank.sky"));
            });

            // Verify handling of start page invoked from Skyline menu with a populated document
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("Proteomic.sky")));
            Assert.IsTrue(SkylineWindow.HasProteomicMenuItems);
            startPage = ShowDialog <StartPage>(SkylineWindow.OpenStartPage);
            RunDlg <AlertDlg>(() => startPage.SetUIMode(SrmDocument.DOCUMENT_TYPE.small_molecules), alertDlg => alertDlg.ClickYes());
            Assert.IsTrue(SkylineWindow.Document.MoleculeCount == 0); // Document should be empty
            RunUI(() => startPage.DoAction(skylineWindow => true));   // Close the start window
            Assert.IsFalse(SkylineWindow.HasProteomicMenuItems);

            if (!_showStartPage)
            {
                return; // No need to do the rest of this this twice
            }

            foreach (SrmDocument.DOCUMENT_TYPE uimode in Enum.GetValues(typeof(SrmDocument.DOCUMENT_TYPE)))
            {
                if (uimode == SrmDocument.DOCUMENT_TYPE.none)
                {
                    continue;
                }

                // Loading a purely proteomic doc should change UI mode to straight up proteomic
                TestUIModesFileLoadAction(uimode,                               // Initial UI mode
                                          "Proteomic.sky",                      // Doc to be loaded
                                          SrmDocument.DOCUMENT_TYPE.proteomic); // Resulting UI mode

                // Loading a purely small mol doc should change UI mode to straight up small mol
                TestUIModesFileLoadAction(uimode,                                     // Initial UI mode
                                          "SmallMol.sky",                             // Doc to be loaded
                                          SrmDocument.DOCUMENT_TYPE.small_molecules); // Resulting UI mode

                // Loading a mixed doc should change UI mode to mixed
                TestUIModesFileLoadAction(uimode,                           // Initial UI mode
                                          "Mixed.sky",                      // Doc to be loaded
                                          SrmDocument.DOCUMENT_TYPE.mixed); // Resulting UI mode

                // Loading an empty doc shouldn't have any effect on UI mode
                TestUIModesFileLoadAction(uimode,      // Initial UI mode
                                          "blank.sky", // Doc to be loaded
                                          uimode);     // Resulting UI mode

                // Test behavior in an empty document
                RunUI(() =>
                {
                    SkylineWindow.NewDocument();
                    SkylineWindow.SetUIMode(uimode);
                    Assert.AreEqual(uimode, SkylineWindow.ModeUI);
                });

                // Test per-ui-mode persistence of "peptide" settings tab choice
                var peptideSettingsDlg = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() => Assume.AreEqual(peptideSettingsDlg.SelectedTab, (PeptideSettingsUI.TABS)uimode));
                OkDialog(peptideSettingsDlg, peptideSettingsDlg.CancelDialog);
            }

            TestPeptideToMoleculeText(); // Exercise the UI peptide->molecule translation code

            // Test interaction of buttons in non-empty documents
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.small_molecules, SrmDocument.DOCUMENT_TYPE.small_molecules, false);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.small_molecules, SrmDocument.DOCUMENT_TYPE.proteomic, true);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.small_molecules, SrmDocument.DOCUMENT_TYPE.mixed, false);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.proteomic, SrmDocument.DOCUMENT_TYPE.proteomic, false);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.proteomic, SrmDocument.DOCUMENT_TYPE.small_molecules, true);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.proteomic, SrmDocument.DOCUMENT_TYPE.mixed, false);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.mixed, SrmDocument.DOCUMENT_TYPE.mixed, false);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.mixed, SrmDocument.DOCUMENT_TYPE.small_molecules, true);
            TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE.mixed, SrmDocument.DOCUMENT_TYPE.proteomic, true);

            // Verify operation of small-mol-only UI elements
            foreach (SrmDocument.DOCUMENT_TYPE uimode2 in Enum.GetValues(typeof(SrmDocument.DOCUMENT_TYPE)))
            {
                if (uimode2 == SrmDocument.DOCUMENT_TYPE.none)
                {
                    continue;
                }

                RunUI(() =>
                {
                    SkylineWindow.NewDocument();
                    SkylineWindow.SetUIMode(uimode2);
                });
                var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                Assert.AreEqual(uimode2 == SrmDocument.DOCUMENT_TYPE.small_molecules, peptideSettingsUI.SmallMoleculeLabelsTabEnabled);
                if (uimode2 == SrmDocument.DOCUMENT_TYPE.small_molecules)
                {
                    // Verify operation of internal standard list edit
                    RunUI(() =>
                    {
                        peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Labels;
                    });
                }
                OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
            }
        }