public void MakeAndBreakPhraseAndKeepFocusBoxInPlace() { JumpToWord("wonderfulXXXzzzcounselor"); int indexWordBeforeEdit = m_wordList.CurrentIndex; int hvoWordBeforeEdit = m_wordList.CurrentObject.Hvo; using (InterlinMasterHelper imh = new InterlinMasterHelper(this)) { imh.SwitchTab(InterlinMaster.TabPageSelection.Interlinearizer); InterlinDocChild idc = imh.CurrentInterlinDoc; // paragraph1: XXXlocoZZZ, XXXsegmentZZZ?? ZZZamazingXXX wonderfulXXXzzzcounselor!! StTxtPara para1 = m_text1.ContentsOA.ParagraphsOS[1] as StTxtPara; int hvoAnnBeforeEdit = para1.SegmentForm(1, 0); StTxtPara.TwficInfo twficBeforeEdit1_0 = new StTxtPara.TwficInfo(Cache, hvoAnnBeforeEdit); twficBeforeEdit1_0.CaptureObjectInfo(); // select a "ZZZamazingXXX" so we can make a phrase with "wonderfulXXXzzzcounselor" IStText stTextBeforeEdit = idc.RawStText; idc.SelectAnnotation(hvoAnnBeforeEdit); // XXXlocoZZZ, XXXsegmentZZZ?? [ZZZamazingXXX wonderfulXXXzzzcounselor] m_window.InvokeCommand("CmdMakePhrase"); ValidateFocusBoxState(indexWordBeforeEdit, idc, twficBeforeEdit1_0, stTextBeforeEdit); StTxtPara.TwficInfo twficAfterMakePhrase1_0 = new StTxtPara.TwficInfo(Cache, idc.HvoAnnotation); twficAfterMakePhrase1_0.CaptureObjectInfo(); m_window.InvokeCommand("CmdBreakPhrase"); // worderfulXXXzzzcounselor will have been inserted back before the current index, so advance one ValidateFocusBoxState(indexWordBeforeEdit + 1, idc, twficAfterMakePhrase1_0, stTextBeforeEdit); StTxtPara.TwficInfo twficAfterBreakPhrase1_0 = new StTxtPara.TwficInfo(Cache, idc.HvoAnnotation); twficAfterBreakPhrase1_0.CaptureObjectInfo(); idc.OnUndo(null); ValidateFocusBoxState(indexWordBeforeEdit, idc, twficAfterBreakPhrase1_0, stTextBeforeEdit); } }
private void ValidateExpectedPlaceInText(int indexWordBeforeEdit, int ichExpected, int hvoWordBeforeEdit, InterlinMasterHelper imh, RawTextPane rtp, IStText stTextBeforeEdit, TextSelInfo tsiBeforeEdit) { IStText stTextAfterEdit = rtp.RootObject; TextSelInfo tsiAfterEdit = imh.CurrentSelectionInfo; Assert.AreEqual(stTextBeforeEdit, stTextAfterEdit, "We expect to be in the same text."); // make sure we're in the same text Assert.AreEqual(tsiBeforeEdit.HvoAnchor, tsiAfterEdit.HvoAnchor, "We expect to be in the same paragraph"); // make sure the cursor is in the expected location Assert.AreEqual(ichExpected, tsiAfterEdit.IchAnchor, "Expected cursor somewhere else."); // Make sure we haven't changed word in the wordform record list. int indexWordAfterEdit = m_wordList.CurrentIndex; int hvoWordAfterEdit = m_wordList.CurrentObject.Hvo; Assert.AreEqual(indexWordBeforeEdit, indexWordAfterEdit, "word index shouldn't have changed"); Assert.AreEqual(hvoWordBeforeEdit, hvoWordAfterEdit, "word hvo shouldn't have changed"); }
public void LT7777_EnsureAllSegmentsHaveFreeformAnnotation() { Set<int> allAnalWsIds = new Set<int>(Cache.LangProject.AnalysisWssRC.HvoArray); int tagSegFF = StTxtPara.SegmentFreeformAnnotationsFlid(Cache); int segDefn_literalTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnLiteralTranslation); int segDefn_freeTranslation = Cache.GetIdFromGuid(LangProject.kguidAnnFreeTranslation); int segDefn_note = Cache.GetIdFromGuid(LangProject.kguidAnnNote); // Switch to first text m_window.ActivateTool("interlinearEdit"); RecordClerk clerk = m_window.ActiveClerk; clerk.JumpToRecord(m_text1.ContentsOA.Hvo); m_window.ProcessPendingItems(); // switch to baseline tab. int hvoSelectedText = clerk.CurrentObject.Hvo; Assert.AreEqual(m_text1.ContentsOA.Hvo, hvoSelectedText, "clerk current object should have changed to m_text1"); // should be the text in the active clerk. StText stText = clerk.CurrentObject as StText; InterlinMaster interlinMaster = m_window.FindControl("InterlinMaster") as InterlinMaster; using (InterlinMasterHelper imh = new InterlinMasterHelper(this)) { // switch to RawText (Edit Pane) imh.SwitchTab(InterlinMaster.TabPageSelection.RawText); //// Insert new segments in a new paragraph. //IStTxtPara newPara; //using (new UndoRedoTaskHelper(Cache, "EnsureAllSegmentsHaveFreeformAnnotation", "EnsureAllSegmentsHaveFreeformAnnotation")) //{ // // insert a new paragraph with two new sentences. // // paste in a new paragraph // ITsStrFactory tsf = TsStrFactoryClass.Create(); // newPara = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as IStTxtPara; // newPara.Contents.UnderlyingTsString = tsf.MakeString("XXXXsentenceOneZZZ; XXXsentenceTwoZZZ!!", Cache.DefaultVernWs); //} // first verify that paragraph 1 has only one real segment. List<int> segs1 = (m_text1.ContentsOA.ParagraphsOS[1] as StTxtPara).Segments; Assert.AreEqual(2, segs1.Count, "expect paragraph 1 to have two segments"); Assert.IsFalse(Cache.IsDummyObject(segs1[0]), "expect paragraph 1 seg 0 to be real"); Assert.IsFalse(Cache.IsDummyObject(segs1[1]), "expect paragraph 1 seg 1 to be real"); // Verify paragraph 1 segment 1 has only one freeform translation. StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segs1), allAnalWsIds); int[] segFF1_0 = Cache.GetVectorProperty(segs1[0], tagSegFF, true); Assert.AreEqual(3, segFF1_0.Length, "expected paragraph 1 seg 0 to have freeform annotations"); Assert.AreEqual(1, FreeformTypeCount(segFF1_0, segDefn_freeTranslation)); int[] segFF1_1 = Cache.GetVectorProperty(segs1[1], tagSegFF, true); Assert.AreEqual(0, segFF1_1.Length, "expected paragraph 1 seg 1 to have no freeform annotations"); // now switch to interlinear tab and make sure we added new freeform translations imh.SwitchTab(InterlinMaster.TabPageSelection.Interlinearizer); // Verify paragraph 1 segment 1 still has only one freeform translation. segs1 = (m_text1.ContentsOA.ParagraphsOS[1] as StTxtPara).Segments; Assert.AreEqual(2, segs1.Count, "expect paragraph 1 to have two segments"); // Verify paragraph 1 segment 1 has only one freeform translation. StTxtPara.LoadSegmentFreeformAnnotationData(Cache, new Set<int>(segs1), allAnalWsIds); segFF1_0 = Cache.GetVectorProperty(segs1[0], tagSegFF, true); Assert.AreEqual(3, segFF1_0.Length, "expected paragraph 1 seg 0 to have freeform annotations"); Assert.AreEqual(1, FreeformTypeCount(segFF1_0, segDefn_freeTranslation)); // make sure our last segment has a free translation now. segFF1_1 = Cache.GetVectorProperty(segs1[1], tagSegFF, true); Assert.AreEqual(1, segFF1_1.Length, "expected paragraph 1 seg 1 to have a freeform annotation"); Assert.AreEqual(1, FreeformTypeCount(segFF1_1, segDefn_freeTranslation)); } }
public void SelectWordWithOneOccurrenceAndEditOccurrenceInText() { JumpToWord("XXXlocoZZZ"); int indexWordBeforeEdit = m_wordList.CurrentIndex; int hvoWordBeforeEdit = m_wordList.CurrentObject.Hvo; using (InterlinMasterHelper imh = new InterlinMasterHelper(this)) { imh.SwitchTab(InterlinMaster.TabPageSelection.RawText); RawTextPane rtp = imh.RawTextPane; IStText stTextBeforeEdit = rtp.RootObject; // paragraph1: XXXlocoZZZ, XXXsegmentZZZ?? ZZZamazingXXX wonderfulXXXzzzcounselor!! StTxtPara para1 = m_text1.ContentsOA.ParagraphsOS[1] as StTxtPara; imh.SetCursor(para1, "XXXlocoZZZ".Length); // save the cursor location TextSelInfo tsiBeforeEdit = imh.CurrentSelectionInfo; imh.OnKeyDownAndKeyPress(Keys.Back); ValidateExpectedPlaceInText(indexWordBeforeEdit, tsiBeforeEdit.IchAnchor - 1, hvoWordBeforeEdit, imh, rtp, stTextBeforeEdit, tsiBeforeEdit); imh.SetCursor(para1, "XXXlocoZZ, XXXsegmentZZ".Length); tsiBeforeEdit = imh.CurrentSelectionInfo; imh.OnKeyDownAndKeyPress(Keys.Delete); // delete last letter in "XXXsegmentZZZ" ValidateExpectedPlaceInText(indexWordBeforeEdit, tsiBeforeEdit.IchAnchor, hvoWordBeforeEdit, imh, rtp, stTextBeforeEdit, tsiBeforeEdit); } }
//[Ignore("FWC-16 - this test causes NUnit to hang. Need to investigate further.")] public void MakeAndBreakPhrases() { using (InterlinMasterHelper imh = new InterlinMasterHelper(this)) { // 1. Start with a search in the basic text. m_concordanceControl.SelectLineOption(ConcordanceControl.ConcordanceLines.kWord); m_concordanceControl.MatchCase = true; m_concordanceControl.SearchOption = MockConcordanceControl.ConcordanceSearchOption.Anywhere; m_concordanceControl.SearchText = "XXX"; // should get all our twfics. List<int> results = m_concordanceControl.Search(); // this should parse the paragraphs creating dummy twfics. m_window.ProcessPendingItems(); Assert.AreEqual(6, results.Count); Assert.AreEqual(results.Count, m_concordanceControl.Clerk.ListSize); // jump to ZZZamazingXXX m_concordanceControl.Clerk.JumpToIndex(4); m_window.ProcessPendingItems(); StTxtPara.TwficInfo currentTwficInfo = new StTxtPara.TwficInfo(Cache, m_concordanceControl.Clerk.CurrentObject.Hvo); WfiWordform wf = WfiWordform.CreateFromDBObject(Cache, currentTwficInfo.HvoWfiWordform) as WfiWordform; Assert.AreEqual("ZZZamazingXXX", wf.Form.VernacularDefaultWritingSystem); // switch to interlinear tab, and make sure we're selecting "ZZZamazingXXX" imh.SwitchTab(InterlinMaster.TabPageSelection.Interlinearizer); m_window.ProcessPendingItems(); // nothing should have changed results = m_concordanceControl.Results(); // the merge should not have refreshed our list (yet) Assert.AreEqual(6, results.Count); Assert.AreEqual(results.Count, m_concordanceControl.Clerk.ListSize); currentTwficInfo = new StTxtPara.TwficInfo(Cache, imh.CurrentInterlinDoc.HvoAnnotation); wf = WfiWordform.CreateFromDBObject(Cache, currentTwficInfo.HvoWfiWordform) as WfiWordform; Assert.AreEqual("ZZZamazingXXX", wf.Form.VernacularDefaultWritingSystem); // 2. Make a basic phrase // XXXlocoZZZ, XXXsegmentZZZ?? [ZZZamazingXXX wonderfulXXXzzzcounselor] m_window.InvokeCommand("CmdMakePhrase"); currentTwficInfo = new StTxtPara.TwficInfo(Cache, imh.CurrentInterlinDoc.HvoAnnotation); wf = WfiWordform.CreateFromDBObject(Cache, currentTwficInfo.HvoWfiWordform) as WfiWordform; Assert.AreEqual("ZZZamazingXXX wonderfulXXXzzzcounselor", wf.Form.VernacularDefaultWritingSystem); results = m_concordanceControl.Results(); // CmBaseAnnotation.DeleteUnderlyingObject() removed itself from our cache. Assert.AreEqual(6, m_concordanceControl.Clerk.ListSize); // but we haven't refreshed our list yet. results = m_concordanceControl.Search(); // manually get the new results m_window.ProcessPendingItems(); Assert.AreEqual(5, results.Count); // now compare this result set against the number of items in our browse view. Assert.AreEqual(results.Count, m_concordanceControl.Clerk.ListSize, "Our browse view results should match our propery list size"); // 3. Break the phrase // XXXlocoZZZ, XXXsegmentZZZ?? \ZZZamazingXXX\ \wonderfulXXXzzzcounselor\ m_window.InvokeCommand("CmdBreakPhrase"); currentTwficInfo = new StTxtPara.TwficInfo(Cache, imh.CurrentInterlinDoc.HvoAnnotation); wf = WfiWordform.CreateFromDBObject(Cache, currentTwficInfo.HvoWfiWordform) as WfiWordform; Assert.AreEqual("ZZZamazingXXX", wf.Form.VernacularDefaultWritingSystem); results = m_concordanceControl.Results(); // CmBaseAnnotation.DeleteUnderlyingObject() removed phrase from our cache. Assert.AreEqual(4, results.Count); results = m_concordanceControl.Search(); // the break should result in new search results. m_window.ProcessPendingItems(); Assert.AreEqual(6, results.Count); // now compare this result set against the number of items in our browse view. Assert.AreEqual(results.Count, m_concordanceControl.Clerk.ListSize, "Our browse view results should match our propery list size"); } }