public void Init() { CheckDisposed(); if (m_fMainWindowOpened) { m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0]; // Set the view to the DraftView m_firstMainWnd.SelectScriptureDraftView(); 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); if (!m_firstMainWnd.Cache.DatabaseAccessor.IsTransactionOpen()) { m_firstMainWnd.Cache.DatabaseAccessor.BeginTrans(); } m_firstMainWnd.Cache.BeginUndoTask("Undo TeAppTest", "Redo TeAppTest"); } }
public void Init() { CheckDisposed(); 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! } }
public void FindNext_WhenChangingIPManually() { CheckDisposed(); m_testTeApp.ShowFindReplaceDialog(false, m_firstDraftView); FwFindReplaceDlg dlg = m_testTeApp.FindReplaceDialog; dlg.FindText = MakeTSS("the"); // make sure the initial find works dlg.FindNext(); Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex); Assert.AreEqual(2, m_firstDraftView.TeEditingHelper.SectionIndex); Assert.AreEqual(1, m_firstDraftView.ParagraphIndex); Assert.AreEqual(138, m_firstDraftView.SelectionAnchorIndex); Assert.AreEqual(142, m_firstDraftView.SelectionEndIndex); // make sure find next works dlg.FindNext(); Assert.AreEqual(0, m_firstDraftView.TeEditingHelper.BookIndex); Assert.AreEqual(3, m_firstDraftView.TeEditingHelper.SectionIndex); Assert.AreEqual(0, m_firstDraftView.ParagraphIndex); Assert.AreEqual(42, m_firstDraftView.SelectionAnchorIndex); Assert.AreEqual(46, m_firstDraftView.SelectionEndIndex); // make sure find next works finding in a book title dlg.FindNext(); Assert.AreEqual(1, m_firstDraftView.TeEditingHelper.BookIndex); Assert.AreEqual(-1, m_firstDraftView.TeEditingHelper.SectionIndex); Assert.AreEqual(0, m_firstDraftView.ParagraphIndex); Assert.AreEqual(0, m_firstDraftView.SelectionAnchorIndex); Assert.AreEqual(3, m_firstDraftView.SelectionEndIndex); // make sure find next works after setting the IP manually m_firstDraftView.SetInsertionPoint(2, 4, 1, 163, true); dlg.FindNext(); Assert.AreEqual(2, m_firstDraftView.TeEditingHelper.BookIndex); Assert.AreEqual(4, m_firstDraftView.TeEditingHelper.SectionIndex); Assert.AreEqual(1, m_firstDraftView.ParagraphIndex); Assert.AreEqual(174, m_firstDraftView.SelectionAnchorIndex); Assert.AreEqual(177, m_firstDraftView.SelectionEndIndex); }
public void InsertFootnote() { CheckDisposed(); FdoCache cache = m_firstMainWnd.Cache; // Set the IP to the second section in the first book at the 10th character in // the first paragraph m_firstDraftView.SetInsertionPoint(0, 1, 0, 10, false); ScrBook book = (ScrBook)cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS[0]; int nFootnotes = book.FootnotesOS.Count; m_firstMainWnd.CallInsertFootnote(); Assert.AreEqual(nFootnotes + 1, book.FootnotesOS.Count); // Test footnote string expectedMarker = new String((char)((int)'a' + nFootnotes), 1); StFootnote footnote = (StFootnote)book.FootnotesOS[nFootnotes]; Assert.AreEqual(expectedMarker, footnote.FootnoteMarker.Text, "Wrong footnote marker in footnote"); ITsString tsString = footnote.FootnoteMarker.UnderlyingTsString; ITsTextProps ttp = tsString.get_PropertiesAt(0); string styleName = ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(ScrStyleNames.FootnoteMarker, styleName, "Wrong style for footnote marker in footnote"); // Test footnote marker in text IVwSelection sel = m_firstDraftView.RootBox.Selection; ITsString tss; int ich, hvoObj, tag, enc; bool fAssocPrev; sel.TextSelInfo(true, out tss, out ich, out fAssocPrev, out hvoObj, out tag, out enc); string strPara = tss.Text; Assert.AreEqual(StringUtils.kchObject, strPara[ich]); ttp = tss.get_PropertiesAt(ich); int nDummy; int wsActual = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out nDummy); Assert.AreEqual(cache.LangProject.DefaultVernacularWritingSystem, wsActual, "Wrong writing system for footnote marker in text"); string objData = ttp.GetStrPropValue((int)FwTextPropType.ktptObjData); Assert.AreEqual((char)(int)FwObjDataTypes.kodtOwnNameGuidHot, objData[0]); }
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! } }