public void ModifyOtherMappingsTest() { CheckDisposed(); m_DummyImportWizard.Activate(); // Test 1: test the cancel button // Move to Project type step. m_DummyImportWizard.NextButtonPerformClick(); // Choose other project type. m_DummyImportWizard.OtherButton.Checked = true; // Move to project location step. m_DummyImportWizard.NextButtonPerformClick(); // Add our test file to the file list builder. m_DummyImportWizard.AddFiles(new string[] {Unpacker.PtProjectTestFolder + "SOTest.sfm"}); // Move to the mappings step. Application.DoEvents(); m_DummyImportWizard.NextButtonPerformClick(); // modify dialog m_DummyImportWizard.ShouldAccept = false; Application.DoEvents(); // Choose only item 11 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[10].Selected = true; Assert.IsTrue(m_DummyImportWizard.Mappings.Items.Count > 0, "No mappings found"); string original = m_DummyImportWizard.Mappings.Items[10].SubItems[1].Text; Assert.IsTrue(m_DummyImportWizard.ModifyButton.Enabled, "Modify button not enabled."); m_DummyImportWizard.ModifyButton.PerformClick(); Application.DoEvents(); Assert.IsFalse(m_DummyImportWizard.MappingDialog.Visible, "Dialog didn't close properly."); Assert.AreEqual(original, m_DummyImportWizard.Mappings.Items[10].SubItems[1].Text, "Cancel button doesn't work!"); // Test 2: test that the right dialog box gets created and that stuff is changed // modify dialog m_DummyImportWizard.ShouldAccept = true; // Choose only item 3 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[3].Selected = true; // Choose the "List Item1" style, French writing system, and vernacular domain m_DummyImportWizard.StyleSelection = "List Item1"; m_DummyImportWizard.WsSelection = "French"; m_DummyImportWizard.RadioboxSelection = 0; // Open modify dialog m_DummyImportWizard.ModifyButton.PerformClick(); Application.DoEvents(); Assert.AreEqual(typeof(ModifyMapping), m_DummyImportWizard.MappingDialog.GetType(), "MappingDialog is of the wrong type"); m_DummyImportWizard.MappingDialog.CancelButton.PerformClick(); Assert.IsFalse(m_DummyImportWizard.MappingDialog.Visible, "Dialog didn't close properly."); // Make sure "List Item1" was chosen in the dialog. Assert.AreEqual("List Item1", ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.m_styleListHelper.SelectedStyleName); // Check the ListView Item's contents. Assert.AreEqual("List Item1", m_DummyImportWizard.Mappings.Items[3].SubItems[1].Text, "Value not correctly changed: test 2"); Assert.AreEqual("scripture, french", m_DummyImportWizard.Mappings.Items[3].SubItems[2].Text.ToLower(), "Value not correctly changed: test 2"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("List Item1", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).StyleName, "Value not correctly changed: test 2"); Assert.AreEqual(MarkerDomain.Default, ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).Domain, "Value not correctly changed: test 2"); // // Check to make sure the data encoding was changed // Assert.AreEqual(kDummyVernLegacyMapping, // ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).DataEncoding, // "Value not correctly changed: test 2"); // Choose only item 10 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[10].Selected = true; // Choose the "Speech Line2" style, German writing system, and back translation domain m_DummyImportWizard.StyleSelection = "Speech Line2"; m_DummyImportWizard.WsSelection = "German"; m_DummyImportWizard.BackTranslation = true; m_DummyImportWizard.ModifyButton.PerformClick(); Application.DoEvents(); Assert.IsTrue(m_DummyImportWizard.MappingDialog is ModifyMapping, "MappingDialog is of the wrong type"); Assert.IsFalse(m_DummyImportWizard.MappingDialog.Visible, "Dialog didn't close properly."); // Make sure "Speech Line2" was chosen in the dialog. Assert.AreEqual("Speech Line2", ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.m_styleListHelper.SelectedStyleName); // Check the ListView Item's contents. Assert.AreEqual("Speech Line2", m_DummyImportWizard.Mappings.Items[10].SubItems[1].Text, "Value not correctly changed: test 2"); Assert.AreEqual("back translation, german", m_DummyImportWizard.Mappings.Items[10].SubItems[2].Text.ToLower(), "Value not correctly changed: test 2"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("Speech Line2", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[10].Tag).StyleName, "Value not correctly changed: test 2"); Assert.AreEqual(MarkerDomain.BackTrans, ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[10].Tag).Domain, "Value not correctly changed: test 2"); // Check to make sure the data encoding was changed Assert.AreEqual("de", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[10].Tag).IcuLocale, "Value not correctly changed: test 2"); // Save changes to database m_DummyImportWizard.SimulateFinish(); // Close and re-open dialog to force all it's internal data to be reinitialized. m_DummyImportWizard.Close(); m_DummyImportWizard = new DummyImportWizard(m_cache, (Scripture)m_Scripture, m_styleSheet); m_DummyImportWizard.Show(); Application.DoEvents(); // Move to Mappings step for the TEV scripture project. m_DummyImportWizard.NextButtonPerformClick(); m_DummyImportWizard.OtherButton.Checked = true; m_DummyImportWizard.NextButtonPerformClick(); // We should be on the wizard step where files can be added to the // list of files to import. Check that the list has one file name. Assert.AreEqual((Unpacker.PtProjectTestFolder + "SOTest.sfm").ToLower(), ((string)m_DummyImportWizard.FileListBuilder.ScriptureFiles[0]).ToLower(), "Value wasn't saved in DB"); // Before getting to the mappings step of the wizard, get the main title mapping // directly from the dialog's import settings. Then verify that its domain and // ICU locale properties are set properly. This mapping shouldn't // get changed by going to the modify mappings dialog. ImportMappingInfo mapping; mapping = m_DummyImportWizard.ScrImportSet.MappingForMarker(@"\mt", MappingSet.Main); Assert.AreEqual(MarkerDomain.Default, mapping.Domain, @"Domain for \mt is incorrect"); Assert.IsNull(mapping.IcuLocale); // Move to the mappings step of the wizard. m_DummyImportWizard.NextButtonPerformClick(); // Check the mapping ListView Item's contents. Assert.AreEqual("List Item1", m_DummyImportWizard.Mappings.Items[3].SubItems[1].Text, "Value not correctly changed: test 2"); Assert.AreEqual("scripture, french", m_DummyImportWizard.Mappings.Items[3].SubItems[2].Text.ToLower(), "Value not correctly changed: test 2"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("List Item1", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).StyleName, "Value not correctly changed: test 2"); Assert.AreEqual(MarkerDomain.Default, ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).Domain, "Value not correctly changed: test 2"); // // Check to make sure the data encoding was changed // Assert.AreEqual(kDummyVernLegacyMapping, // ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).DataEncoding, // "Value not correctly changed: test 2"); // Check the ListView Item's contents. Assert.AreEqual("Speech Line2", m_DummyImportWizard.Mappings.Items[10].SubItems[1].Text, "Value not correctly changed: test 2"); Assert.AreEqual("back translation, german", m_DummyImportWizard.Mappings.Items[10].SubItems[2].Text.ToLower(), "Value not correctly changed: test 2"); // Check the content of the ImportMappingInfo object pointed to by the ListView Item. ImportMappingInfo info = (ImportMappingInfo)m_DummyImportWizard.Mappings.Items[10].Tag; Assert.AreEqual("Speech Line2", info.StyleName, "StyleName value not correctly changed: test 2"); Assert.AreEqual(MarkerDomain.BackTrans, info.Domain, "Domain value not correctly changed: test 2"); Assert.AreEqual("de", info.IcuLocale, "ICU locale value not correctly changed: test 2"); m_DummyImportWizard.StyleSelection = string.Empty; m_DummyImportWizard.WsSelection = string.Empty; m_DummyImportWizard.RadioboxSelection = -1; m_DummyImportWizard.ShouldAccept = true; // Choose only item 10 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[10].Selected = true; m_DummyImportWizard.ModifyButton.PerformClick(); // Make sure "Speech Line2" was chosen in the dialog. Assert.AreEqual("Speech Line2", ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.m_styleListHelper.SelectedStyleName); Assert.AreEqual("de", ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.WritingSystem); Assert.IsTrue( ((ModifyMapping)m_DummyImportWizard.MappingDialog).Scripture.Checked); Assert.IsFalse( ((ModifyMapping)m_DummyImportWizard.MappingDialog).Footnotes.Checked); Assert.IsFalse( ((ModifyMapping)m_DummyImportWizard.MappingDialog).Notes.Checked); }
public void ModifyParatextMappingsTest() { CheckDisposed(); // Test 1: test the cancel button // Move to Mappings step for the TEV scripture project. m_DummyImportWizard.NextButtonPerformClick(); m_DummyImportWizard.Paratext6.Checked = true; m_DummyImportWizard.NextButtonPerformClick(); // Choose TEV for the scripture project and Kamwe as the back translation project. m_DummyImportWizard.CboPTLangProj.SelectedItem = "PREDISTRIBUTION Today's English Version (USFM)"; m_DummyImportWizard.CboPTBackTrans.SelectedItem = "Kamwe"; // Move to Mappings step. m_DummyImportWizard.NextButtonPerformClick(); // modify dialog m_DummyImportWizard.ShouldAccept = false; Assert.IsTrue(m_DummyImportWizard.Mappings.Items.Count > 0, "No mappings found"); string original = m_DummyImportWizard.Mappings.Items[0].SubItems[1].Text; m_DummyImportWizard.ModifyButton.PerformClick(); Application.DoEvents(); Assert.IsFalse(m_DummyImportWizard.MappingDialog.Visible, "Dialog didn't close properly."); Assert.AreEqual(original, m_DummyImportWizard.Mappings.Items[0].SubItems[1].Text, "Cancel button doesn't work! "); // Test 2: test that the right dialog box gets created and that stuff is changed // modify dialog m_DummyImportWizard.ShouldAccept = true; // Choose only item 3 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[3].Selected = true; // Choose the "Intro Table Row" style m_DummyImportWizard.StyleSelection = "Intro Table Row"; // Open modify dialog m_DummyImportWizard.ModifyButton.PerformClick(); Application.DoEvents(); Assert.IsTrue(m_DummyImportWizard.MappingDialog is ModifyMapping, "MappingDialog is of the wrong type"); Assert.IsFalse(m_DummyImportWizard.MappingDialog.Visible, "Dialog didn't close properly."); // Make sure "Intro Table Row" was chosen in the dialog. Assert.AreEqual( ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.m_styleListHelper.SelectedStyleName, "Intro Table Row"); // Check the ListView Item's contents. Assert.AreEqual("Intro Table Row", m_DummyImportWizard.Mappings.Items[3].SubItems[1].Text, "Value not correctly changed: test 2"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("Intro Table Row", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).StyleName, "Value not correctly changed: test 2"); // Choose only item 10 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[10].Selected = true; // Choose the "Speech Line2" style m_DummyImportWizard.StyleSelection = "Speech Line2"; // Open modify mappings dialog. m_DummyImportWizard.ModifyButton.PerformClick(); Application.DoEvents(); Assert.IsTrue( m_DummyImportWizard.MappingDialog is ModifyMapping, "MappingDialog is of the wrong type"); Assert.IsFalse(m_DummyImportWizard.MappingDialog.Visible, "Dialog didn't close properly."); // Make sure "Speech Line2" was chosen in the dialog. Assert.AreEqual( ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.m_styleListHelper.SelectedStyleName, "Speech Line2"); // Check the ListView Item's contents. Assert.AreEqual("Speech Line2", m_DummyImportWizard.Mappings.Items[10].SubItems[1].Text, "Value not correctly changed: test 2"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("Speech Line2", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[10].Tag).StyleName, "Value not correctly changed: test 2"); // Save changes to database m_DummyImportWizard.SimulateFinish(); m_DummyImportWizard.Close(); m_DummyImportWizard = new DummyImportWizard(m_cache, (Scripture)m_Scripture, m_styleSheet); m_DummyImportWizard.Show(); Application.DoEvents(); // Move to Mappings step for the TEV scripture project. m_DummyImportWizard.NextButtonPerformClick(); Assert.IsTrue(m_DummyImportWizard.Paratext6.Checked, "Paratext 6 should be selected"); m_DummyImportWizard.NextButtonPerformClick(); Application.DoEvents(); Assert.AreEqual( "PREDISTRIBUTION Today's English Version (USFM)", m_DummyImportWizard.CboPTLangProj.Text, "Settings not loaded from database."); Assert.AreEqual("Kamwe", m_DummyImportWizard.CboPTBackTrans.Text, "Settings not loaded from database."); Assert.AreEqual("(none)", m_DummyImportWizard.CboPTTransNotes.Text, "Settings not loaded from database."); m_DummyImportWizard.NextButtonPerformClick(); // Check the ListView Item's contents after having read settings from DB. Assert.AreEqual("Speech Line2", m_DummyImportWizard.Mappings.Items[10].SubItems[1].Text, "Value wasn't saved in DB"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("Speech Line2", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[10].Tag).StyleName, "Value wasn't saved in DB"); // Check the ListView Item's contents after having read settings from DB. Assert.AreEqual("Intro Table Row", m_DummyImportWizard.Mappings.Items[3].SubItems[1].Text, "Value wasn't saved in DB"); // Check the content of the ECMappings object pointed to by the ListView Item. Assert.AreEqual("Intro Table Row", ((ImportMappingInfo)m_DummyImportWizard.Mappings.Items[3].Tag).StyleName, "Value wasn't saved in DB"); m_DummyImportWizard.StyleSelection = string.Empty; m_DummyImportWizard.WsSelection = string.Empty; m_DummyImportWizard.RadioboxSelection = -1; m_DummyImportWizard.ShouldAccept = true; // Choose only item 10 in mappings ListView. m_DummyImportWizard.Mappings.SelectedItems.Clear(); m_DummyImportWizard.Mappings.Items[10].Selected = true; m_DummyImportWizard.ModifyButton.PerformClick(); // Make sure "Speech Line2" was chosen in the dialog. Assert.AreEqual("Speech Line2", ((ModifyMapping)m_DummyImportWizard.MappingDialog).mappingDetailsCtrl.m_styleListHelper.SelectedStyleName); }
public void Init() { CheckDisposed(); m_cache = FdoCache.Create("TestLangProj"); if (!m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.BeginTrans(); m_cache.BeginUndoTask("Undo ScrImportSetTest", "Redo ScrImportSetTest"); m_Scripture = m_cache.LangProject.TranslatedScriptureOA; m_settings = new ScrImportSet(); m_Scripture.DefaultImportSettings = m_settings; m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(m_cache, m_Scripture.Hvo, (int)Scripture.ScriptureTags.kflidStyles); foreach (ILgWritingSystem ws in m_cache.LanguageEncodings) { if (ws.ICULocale != null && ws.ICULocale.ToLower() == "de") ws.LegacyMapping = kGermanLegacyMapping; if (ws.ICULocale == m_cache.LangProject.DefaultAnalysisWritingSystemICULocale) ws.LegacyMapping = kDummyAnalLegacyMapping; if (ws.ICULocale == m_cache.LangProject.DefaultVernacularWritingSystemICULocale) ws.LegacyMapping = kDummyVernLegacyMapping; } m_DummyImportWizard = new DummyImportWizard(m_cache, (Scripture)m_Scripture, m_styleSheet); m_DummyImportWizard.Show(); Application.DoEvents(); }