public void DataFormatPage() { Assert.IsNotNull(m_dialog, "Didn't get an Import dialog"); m_app.SendKeys("%N"); Application.DoEvents(); AccessibilityHelper step2 = m_dialog.FindChild("Step 2", AccessibleRole.None); Assert.IsNotNull(step2, "Can't find Step 2"); // first test with Paratext "installed" int nRequiredRbs = 0; CheckRadioButtons(step2, ref nRequiredRbs); Assert.AreEqual(2, nRequiredRbs, "Unexpected number of radio buttons"); // then without //TODO DavidO: Unsure of these changes; need to fix and reenable this test //PrepareParatextProjectTestData.RestoreRegistry(); //PrepareParatextProjectTestData.TestFolder = null; //PrepareParatextProjectTestData.PrepareRegistryForTestData(); m_saveRegistryData.RestoreRegistryData(); //Unpacker.TEStyleFileTestFolder = null; m_saveRegistryData = Unpacker.PrepareRegistryForPTData(); // go back to overview page and then go again to second step m_app.SendKeys("%B"); m_app.SendKeys("%N"); Application.DoEvents(); nRequiredRbs = 0; CheckRadioButtons(step2, ref nRequiredRbs); Assert.AreEqual(2, nRequiredRbs, "Unexpected number of radio buttons"); }
public override void Init() { base.Init(); Thread.Sleep(500); // Select "File/Import/Standard Format" to bring up the import dialog m_app.SendKeys("%F"); m_app.SendKeys("{DOWN 8}"); m_app.SendKeys("{ENTER}"); m_app.SendKeys("{ENTER}"); Application.DoEvents(); AccessibilityHelper importDlg = m_app.MainAccessibilityHelper.Parent.FindDirectChild("Import Standard Format", AccessibleRole.None); // select the "Import" button which is the default button if (importDlg != null) { m_app.SendKeys("{ENTER}"); } Application.DoEvents(); m_dialog = m_app.MainAccessibilityHelper.Parent.FindDirectChild( "Import Standard Format", AccessibleRole.None); m_saveRegistryData = Unpacker.PrepareRegistryForPTData(); }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); }
public override void FixtureSetup() { base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; ScrReferenceTests.InitializeScrReferenceForTests(); }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); // TeApp derives from FwApp m_testTeApp = new TestTeApp(new string[] { "-c", m_sSvrName, // ComputerName (aka the SQL server) "-proj", m_ProjName, // ProjectName "-db", m_sDbName}); // DatabaseName m_fMainWindowOpened = m_testTeApp.OpenMainWindow(); }
public void Init() { CheckDisposed(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); // TeApp derives from FwApp m_testTeApp = new TestTeApp(new string[] { "-c", m_sSvrName, // ComputerName (aka the SQL server) "-proj", m_ProjName, // ProjectName "-db", m_sDbName}); // DatabaseName m_fMainWindowOpened = m_testTeApp.OpenMainWindow(); if (m_fMainWindowOpened) { m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0]; // reload the styles from the database (test may have inserted new styles!) m_firstMainWnd.Synchronize(new SyncInfo(SyncMsg.ksyncStyle, 0, 0)); // Set the view to the DraftView m_firstMainWnd.SelectScriptureDraftView(); Application.DoEvents(); // insert book tests create filters - turn them off to prevent interaction // between tests m_firstMainWnd.TurnOffAllFilters(); m_firstDraftView = (TestTeDraftView)m_firstMainWnd.TheDraftView; m_firstDraftView.ActivateView(); SelectionHelper helper = m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true); // helper.IhvoEndPara = -1; helper.SetSelection(m_firstDraftView, true, true); // we don't want to open a transaction! } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. if (m_testTeApp != null) { m_testTeApp.ExitAppplication(); m_testTeApp.Dispose(); } if (m_regData != null) m_regData.RestoreRegistryData(); // restore the value we saved in Init if (m_draftAreaStyleWidth != -1) m_teSubKey.SetValue("DraftStyleAreaWidth", m_draftAreaStyleWidth); } // Dispose unmanaged resources here, whether disposing is true or false. m_firstMainWnd = null; // The app should have disposed this. m_firstDraftView = null; // The app should have disposed this. m_testTeApp = null; // This used to be done by the dispose of the FwFindReplaceDlg control, but doing it // that often is wrong, because other instances of the control (or other controls) // may have the default WSF open. However, later tests depend on ShutDown writing // stuff out. #if !__MonoCS__ ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); #else // TODO-Linux: above code hangs - FIXME // Currently doing without the Invoke - see FwKernel.cs LgWritingSystemFactoryClass.Create. ILgWritingSystemFactory wsf = new LgWritingSystemFactory(); #endif wsf.Shutdown(); Marshal.ReleaseComObject(wsf); wsf = null; // // Cleanup (and Release?) the ICU memory mapping. // SIL.FieldWorks.Common.Utils.Icu.Cleanup(); m_DefParaCharsStyle = null; m_teSubKey = null; m_regData = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Instantiate a TeApp object. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); Debug.Assert(m_testTeApp == null, "Why does it have something in m_testTeApp here?"); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_teSubKey = Registry.CurrentUser.CreateSubKey(@"Software\SIL\FieldWorks\Translation Editor"); // save the width of the style pane, only if it already has a value // Tests will fail if the style pane is showing, so we turn it off. object keyValue = m_teSubKey.GetValue("DraftStyleAreaWidth"); if (keyValue != null) { m_draftAreaStyleWidth = (int)keyValue; m_teSubKey.SetValue("DraftStyleAreaWidth", 0); } // TeApp derives from FwApp StartTestApp(); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { if (!MiscUtils.IsUserAdmin) RegistryRedirect.ResetRegistry(); // Dispose managed resources here. if (m_dataFiles != null) { m_dataFiles.CleanUp(); m_dataFiles = null; } if (m_regDataSettingsDir != null) { m_regDataSettingsDir.RestoreRegistryData(); m_regDataSettingsDir = null; } } m_regDataSettingsDir = null; m_dataFiles = null; m_settings = null; // Dispose unmanaged resources here, whether disposing is true or false. base.Dispose(disposing); }
public override void FixtureSetup() { base.FixtureSetup(); // Check our permissions. If we don't have admin privileges (e.g. on Vista with UAC // enabled), we redirect HKCR if (!MiscUtils.IsUserAdmin) RegistryRedirect.InitializeRegistry(); m_dataFiles = new Unpacker.ResourceUnpacker("ECImportData", @"c:\~~asdfsdf_asdfas~"); m_regDataSettingsDir = new RegistryData(Registry.LocalMachine, @"SOFTWARE\ScrChecks\1.0\Settings_Directory", string.Empty, m_dataFiles.UnpackedDestinationPath); }
public override void Init() { base.Init(); Thread.Sleep(500); // Select "File/Import/Standard Format" to bring up the import dialog m_app.SendKeys("%F"); m_app.SendKeys("{DOWN 8}"); m_app.SendKeys("{ENTER}"); m_app.SendKeys("{ENTER}"); Application.DoEvents(); AccessibilityHelper importDlg = m_app.MainAccessibilityHelper.Parent.FindDirectChild("Import Standard Format", AccessibleRole.None); // select the "Import" button which is the default button if (importDlg != null) m_app.SendKeys("{ENTER}"); Application.DoEvents(); m_dialog = m_app.MainAccessibilityHelper.Parent.FindDirectChild( "Import Standard Format", AccessibleRole.None); m_saveRegistryData = Unpacker.PrepareRegistryForPTData(); }
public void DataFormatPage() { Assert.IsNotNull(m_dialog, "Didn't get an Import dialog"); m_app.SendKeys("%N"); Application.DoEvents(); AccessibilityHelper step2 = m_dialog.FindChild("Step 2", AccessibleRole.None); Assert.IsNotNull(step2, "Can't find Step 2"); // first test with Paratext "installed" int nRequiredRbs = 0; CheckRadioButtons(step2, ref nRequiredRbs); Assert.AreEqual(2, nRequiredRbs, "Unexpected number of radio buttons"); // then without //TODO DavidO: Unsure of these changes; need to fix and reenable this test //PrepareParatextProjectTestData.RestoreRegistry(); //PrepareParatextProjectTestData.TestFolder = null; //PrepareParatextProjectTestData.PrepareRegistryForTestData(); m_saveRegistryData.RestoreRegistryData(); //Unpacker.TEStyleFileTestFolder = null; m_saveRegistryData = Unpacker.PrepareRegistryForPTData(); // go back to overview page and then go again to second step m_app.SendKeys("%B"); m_app.SendKeys("%N"); Application.DoEvents(); nRequiredRbs = 0; CheckRadioButtons(step2, ref nRequiredRbs); Assert.AreEqual(2, nRequiredRbs, "Unexpected number of radio buttons"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize things used by all import tests /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { // our base class FixtureSetup loads the project we specify here m_xmlProjectFilename = "TestLangProj.xml"; base.FixtureSetup(); // Create temp registry and unzip the physical SF files System.Diagnostics.Debug.WriteLine("unzipping SF files"); //Logger.WriteEvent("unzipping SF files"); Unpacker.UnPackParatextTestProjects(); Unpacker.UnPackSfTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); // Initialize our versification info from the vrs files System.Diagnostics.Debug.WriteLine("initializing versification info from files"); //Logger.WriteEvent("initializing versification info from files"); ScrReference.InitializeVersification(DirectoryFinder.GetFWCodeSubDirectory( "Translation Editor"), false); // init some member variables for the tests InitWsInfo(); m_scr = Cache.LangProject.TranslatedScriptureOA; m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); m_fileMaker = new TempSFFileMaker(); m_bcvRefTitus = new BCVRef(56, 1, 1); m_bcvRefJonah = new BCVRef(32, 1, 1); NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () => { // By default, use auto-generated footnote markers for import tests. m_scr.FootnoteMarkerType = FootnoteMarkerTypes.AutoFootnoteMarker; //get a reference to the import settings in the project cache m_settings = Cache.LangProject.TranslatedScriptureOA.DefaultImportSettings; // patch in a few values so that the settings appear valid //m_settings.ImportTypeEnum = TypeOfImport.Paratext6; //m_settings.ImportTypeEnum = TypeOfImport.Other; //m_settings.ParatextScrProj = "TEV"; }); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. if (m_dlg != null) m_dlg.Dispose(); if (m_regData != null) { m_regData.RestoreRegistryData(); } Unpacker.RemoveParatextTestProjects(); } // Dispose unmanaged resources here, whether disposing is true or false. m_dlg = null; m_regData = null; m_settings = null; base.Dispose(disposing); }
public void CheckProjCombo_NoProjSelected() { Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); ReflectionHelper.CallMethod(m_importWizard, "PrepareToGetParatextProjectSettings", null); try { // Set the combobox index to indicate that nothing is selected. ComboBox cbo = ReflectionHelper.GetField(m_importWizard, "cboPTBackTrans") as ComboBox; if (cbo != null) cbo.SelectedIndex = 0; // Set the current projName to null (indicating that nothing was loaded). string projName = null; ReflectionHelper.CallMethod(m_importWizard, "CheckProjectCombo", new object[] { projName, cbo as FwOverrideComboBox, ImportDomain.BackTrans }); // We expect that nothing would be selected (and that the ParatextLoadException // would not be thrown). Assert.AreEqual(0, cbo.SelectedIndex, "The first item in the combobox (none) should have been selected."); } finally { if (m_regData != null) m_regData.RestoreRegistryData(); Unpacker.RemoveParatextTestProjects(); } }
public void CheckProjCombo_ValidProjSelected() { Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); ReflectionHelper.CallMethod(m_importWizard, "PrepareToGetParatextProjectSettings", null); try { // Set the combobox index to the second Paratext project in the list (TEV). ComboBox cbo = ReflectionHelper.GetField(m_importWizard, "cboPTLangProj") as ComboBox; if (cbo != null) cbo.SelectedIndex = 1; FwOverrideComboBox projCombo = ReflectionHelper.GetField( m_importWizard, "cboPTLangProj") as FwOverrideComboBox; string projName = "TEV"; ReflectionHelper.CallMethod(m_importWizard, "CheckProjectCombo", new object[] { projName, projCombo, ImportDomain.Main }); // We expect that the selected index in the combobox would still be set to 1. Assert.AreEqual(1, projCombo.SelectedIndex); } finally { if (m_regData != null) m_regData.RestoreRegistryData(); Unpacker.RemoveParatextTestProjects(); } }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); Unpacker.UnPackSfTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_fileMaker = new TempSFFileMaker(); m_cache = FdoCache.Create("TestLangProj"); m_scr = m_cache.LangProject.TranslatedScriptureOA; m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(m_cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); InitWsInfo(); if (!m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.BeginTrans(); // By default, use auto-generated footnote markers for import tests. m_scr.FootnoteMarkerType = FootnoteMarkerTypes.AutoFootnoteMarker; m_titus = new BCVRef(56, 1, 1); m_settings = new ScrImportSet(); m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings = m_settings; }
public void InitFixture() { Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); ScrReferenceTests.InitializeScrReferenceForTests(); }
public void TestSetup() { Debug.Assert(m_testTeApp == null, "Why does it have something in m_testTeApp here?"); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_teSubKey = Registry.CurrentUser.CreateSubKey(@"Software\SIL\FieldWorks\Translation Editor"); // save the width of the style pane, only if it already has a value // Tests will fail if the style pane is showing, so we turn it off. object keyValue = m_teSubKey.GetValue("DraftStyleAreaWidth"); if (keyValue != null) { m_draftAreaStyleWidth = (int)keyValue; m_teSubKey.SetValue("DraftStyleAreaWidth", 0); } // TeApp derives from FwApp // Make sure the registry thinks the last time an attempt was made to open TE // was successful. Otherwise, the welcome dialog shows up in the middle of tests. RegistryBoolSetting successfulStartup = new RegistryBoolSetting(FwSubKey.TE, "OpenSuccessful", true); successfulStartup.Value = true; // TODO: Figure out what we need to pass into the app m_testTeApp = new TestTeApp(new string[0]); m_fMainWindowOpened = m_testTeApp.OpenMainWindow(); Assert.AreEqual(1, m_testTeApp.MainWindows.Count); // Sidebar buttons get pressed as part of main window initialization; // wait for that initialization to finish before we proceed. while (DataUpdateMonitor.IsUpdateInProgress( ((TestTeMainWnd)m_testTeApp.MainWindows[0]).Cache.MainCacheAccessor)) { Application.DoEvents(); } if (m_fMainWindowOpened) { m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0]; m_firstMainWnd.CreateDraftView(); // Set the view to the DraftView m_firstMainWnd.SwitchActiveView(m_firstMainWnd.TheDraftViewWrapper); Application.DoEvents(); m_firstDraftView = (TestTeDraftView)m_firstMainWnd.TheDraftView; m_firstDraftView.ActivateView(); SelectionHelper helper = m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true); // helper.IhvoEndPara = -1; helper.SetSelection(m_firstDraftView, true, true); Application.DoEvents(); } }
public void TestTearDown() { // Close the footnote view if it was showing if (m_firstMainWnd.TheDraftViewWrapper.FootnoteViewShowing) m_firstMainWnd.TheDraftViewWrapper.HideFootnoteView(); m_testTeApp.ExitAppplication(); //m_firstMainWnd.Cache = null; // Bad idea, since it has been disposed. m_testTeApp.Dispose(); m_testTeApp = null; m_regData.RestoreRegistryData(); // restore the value we saved in Init if (m_draftAreaStyleWidth != -1) m_teSubKey.SetValue("DraftStyleAreaWidth", m_draftAreaStyleWidth); m_firstMainWnd = null; // The app should have disposed this. m_firstDraftView = null; // The app should have disposed this. // // Cleanup (and Release?) the ICU memory mapping. // SIL.FieldWorks.Common.Utils.Icu.Cleanup(); m_teSubKey = null; m_regData = null; }
public void CheckProjCombo_InvalidProjSelected() { Unpacker.UnPackMissingFileParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(Unpacker.MissingFilePtProjectTestFolder); try { // Set the combobox index to the second Paratext project in the list (NSF). ComboBox cbo = ReflectionHelper.GetField(m_importWizard, "cboPTLangProj") as ComboBox; // We have to manually add the projects because they could not be loaded. cbo.Items.AddRange(new object[] { new ImportWizard.PTProject("NEC", "No encoding converter"), new ImportWizard.PTProject("NSF", "No style file")}); if (cbo != null) cbo.SelectedIndex = 1; // Set the current projName to null (indicating that nothing was loaded because // there was a problem with the selected Paratext project). string projName = null; try { // We expect that a ParatextLoadException would be thrown. ReflectionHelper.CallMethod(m_importWizard, "CheckProjectCombo", new object[] { projName, cbo as FwOverrideComboBox, ImportDomain.Main }); } catch (Exception e) { // Since we call the method by reflection, the outer exception will be // a System.Reflection.TargetInvocationException. We need to check the // inner exception to see if it is the correct type. Assert.AreEqual(typeof(ParatextLoadException), e.InnerException.GetType()); Assert.AreEqual(1, cbo.SelectedIndex, "The index should still be on the second item in the combo."); } } finally { if (m_regData != null) m_regData.RestoreRegistryData(); Unpacker.RemoveParatextMissingFileTestProject(); } }