From ef122971fa9c96fcc2173fc9c4a4424add28747a Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Wed, 21 Jun 2023 19:09:09 +0500 Subject: [PATCH 01/23] [de] Start to refactor shortcut tests --- tests/word/shortcuts/shortcuts.html | 73 +- tests/word/shortcuts/shortcuts.js | 3302 ++++++++++++++------------- 2 files changed, 1712 insertions(+), 1663 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.html b/tests/word/shortcuts/shortcuts.html index d757e1a14a..2bce53d2ad 100644 --- a/tests/word/shortcuts/shortcuts.html +++ b/tests/word/shortcuts/shortcuts.html @@ -1,16 +1,43 @@ - - - Shortcuts tests - - - - - + + + Shortcuts tests + + + + + + + + + + + + + + @@ -20,32 +47,6 @@

    test markup, will be hidden
    - - - - - - - - \ No newline at end of file diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 42b4a79b4b..c640a1bade 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -35,59 +35,112 @@ (function (window) { - const { - addPropertyToDocument, - getLogicDocumentWithParagraphs, - checkTextAfterKeyDownHelperEmpty, - checkDirectTextPrAfterKeyDown, - checkDirectParaPrAfterKeyDown, - oGlobalLogicDocument, - addParagraphToDocumentWithText, - remove, - clean, - recalculate, - onKeyDown, - moveToParagraph, - createNativeEvent, - moveCursorDown, - moveCursorLeft, - moveCursorRight, - selectAll, - getSelectedText, - executeTestWithCatchEvent, - startTest, - createChart, - createEvent, - checkInsertElementByType, - createParagraphWithText, - checkApplyParagraphStyle, - createHyperlink, - createTable, - moveToTable, - createShape, - createGroup, - selectOnlyObjects, - selectParaDrawing, - drawingObjects, - logicContent, - directParaPr, - directTextPr, - addBreakPage, - createMath, - resetLogicDocument, - addText, - moveShapeHelper, - setFillingFormsMode, - createCheckBox, - createComboBox, - createComplexForm, - contentPosition, - oTestTypes, - mouseMove, - mouseDown, - mouseUp, - insertManualBreak - } = AscTestShortcut; + // const { + // addPropertyToDocument, + // getLogicDocumentWithParagraphs, + // checkTextAfterKeyDownHelperEmpty, + // checkDirectTextPrAfterKeyDown, + // checkDirectParaPrAfterKeyDown, + // oGlobalLogicDocument, + // addParagraphToDocumentWithText, + // remove, + // clean, + // recalculate, + // onKeyDown, + // moveToParagraph, + // createNativeEvent, + // moveCursorDown, + // moveCursorLeft, + // moveCursorRight, + // selectAll, + // getSelectedText, + // executeTestWithCatchEvent, + // startTest, + // createChart, + // createEvent, + // checkInsertElementByType, + // createParagraphWithText, + // checkApplyParagraphStyle, + // createHyperlink, + // createTable, + // moveToTable, + // createShape, + // createGroup, + // selectOnlyObjects, + // selectParaDrawing, + // drawingObjects, + // logicContent, + // directParaPr, + // directTextPr, + // addBreakPage, + // createMath, + // resetLogicDocument, + // addText, + // moveShapeHelper, + // setFillingFormsMode, + // createCheckBox, + // createComboBox, + // createComplexForm, + // contentPosition, + // oTestTypes, + // mouseMove, + // mouseDown, + // mouseUp, + // insertManualBreak + // } = AscTestShortcut; + + let logicDocument = AscTest.CreateLogicDocument(); + editor.getShortcut = function(e) + { + return e; + }; + editor.FontSizeIn = function() + { + logicDocument.IncreaseDecreaseFontSize(true); + }; + editor.FontSizeOut = function() + { + logicDocument.IncreaseDecreaseFontSize(false); + }; + + function ExecuteShortcut(type) + { + logicDocument.OnKeyDown(type); + } + function ClearDocumentAndAddParagraph(text) + { + let p = AscTest.CreateParagraph(); + AscTest.ClearDocument(); + logicDocument.AddToContent(0, p); + + if (text) + { + let run = AscTest.CreateRun(); + run.AddText(text); + p.AddToContentToEnd(run); + } + + return p; + } + + logicDocument.Start_SilentMode(); + function TurnOnRecalculate() + { + logicDocument.TurnOn_Recalculate(); + } + function TurnOffRecalculate() + { + logicDocument.TurnOff_Recalculate(); + } + + function ApplyTextPrToDocument(textPr) + { + logicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(textPr)); + } + function GetDirectTextPr() + { + return logicDocument.GetDirectTextPr(); + } $(function () { @@ -111,1580 +164,1575 @@ } }); - QUnit.test('Check page break shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertPageBreak}; - let oEvent = createNativeEvent(); - const {oLogicDocument} = getLogicDocumentWithParagraphs([''], true); - onKeyDown(oEvent); - oAssert.strictEqual(oLogicDocument.GetPagesCount(), 2, 'Check page break shortcut'); - onKeyDown(oEvent); - oAssert.strictEqual(oLogicDocument.GetPagesCount(), 3, 'Check page break shortcut'); - onKeyDown(oEvent); - oAssert.strictEqual(oLogicDocument.GetPagesCount(), 4, 'Check page break shortcut'); - }); - - QUnit.test('Check line break shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertLineBreak}; - const {oLogicDocument, oParagraph} = getLogicDocumentWithParagraphs([''], true); - onKeyDown(createNativeEvent()); - oAssert.strictEqual(oParagraph.GetLinesCount(), 2, 'Check line break shortcut'); - onKeyDown(createNativeEvent()); - oAssert.strictEqual(oParagraph.GetLinesCount(), 3, 'Check line break shortcut'); - onKeyDown(createNativeEvent()); - oAssert.strictEqual(oParagraph.GetLinesCount(), 4, 'Check line break shortcut'); - }); - - QUnit.test('Check column break shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertColumnBreak}; - let oColumnProps = new Asc.CDocumentColumnsProps(); - oColumnProps.put_Num(2); - editor.asc_SetColumnsProps(oColumnProps); - const {oLogicDocument} = getLogicDocumentWithParagraphs([''], true); - - onKeyDown(createNativeEvent()); - const oParagraph = oLogicDocument.GetCurrentParagraph(); - - oAssert.strictEqual(oParagraph.Get_CurrentColumn(), 1, 'Check column break shortcut'); - oColumnProps = new Asc.CDocumentColumnsProps(); - oColumnProps.put_Num(1); - editor.asc_SetColumnsProps(oColumnProps); - }); - - QUnit.test('Check reset char shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.ResetChar}; - - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello world']); - oLogicDocument.SelectAll(); - addPropertyToDocument({Bold: true, Italic: true, Underline: true}); - onKeyDown(createNativeEvent()); - const oDirectTextPr = directTextPr(); - oAssert.true(!(oDirectTextPr.Get_Bold() || oDirectTextPr.Get_Italic() || oDirectTextPr.Get_Underline()), 'Check reset char shortcut'); - }); - - QUnit.test('Check add non breaking space shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.NonBreakingSpace}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x00A0), createNativeEvent(), oAssert, 'Check add non breaking space shortcut'); - }); - - QUnit.test('Check add strikeout shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Strikeout}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Strikeout(), true, 'Check add strikeout shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_Strikeout(), false, 'Check add strikeout shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check show non printing characters shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.ShowAll}; - editor.put_ShowParaMarks(false); - onKeyDown(createNativeEvent()); - oAssert.true(editor.get_ShowParaMarks(), 'Check show non printing characters shortcut'); - }); - - QUnit.test('Check select all shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditSelectAll}; - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello World']); - onKeyDown(createNativeEvent()); - oAssert.strictEqual(oLogicDocument.GetSelectedText(), 'Hello World', 'Check select all shortcut'); - }); - - QUnit.test('Check bold shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Bold}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Bold(), true, 'Check bold shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_Bold(), false, 'Check bold shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check copy format shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.CopyFormat}; - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - addPropertyToDocument({Bold: true, Italic: true, Underline: true}); - - onKeyDown(createNativeEvent()); - const oCopyParagraphTextPr = new AscCommonWord.CTextPr(); - oCopyParagraphTextPr.SetUnderline(true); - oCopyParagraphTextPr.SetBold(true); - oCopyParagraphTextPr.BoldCS = true; - oCopyParagraphTextPr.SetItalic(true); - oCopyParagraphTextPr.ItalicCS = true; - oAssert.deepEqual(editor.getFormatPainterData().TextPr, oCopyParagraphTextPr, 'Check copy format shortcut'); - }); - - QUnit.test('Check insert copyright shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.CopyrightSign}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x00A9), createNativeEvent(), oAssert, 'Check add non breaking space shortcut'); - }); - - QUnit.test('Check insert endnote shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertEndnoteNow}; - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello']); - oLogicDocument.SelectAll(); - onKeyDown(createNativeEvent()); - const arrEndnotes = oLogicDocument.GetEndnotesList(); - oAssert.deepEqual(arrEndnotes.length, 1, 'Check insert endnote shortcut'); - }); - - QUnit.test('Check center para shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.CenterPara}; - const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Center, 'Check center para shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check insert euro sign shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.EuroSign}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x20AC), createNativeEvent(), oAssert, 'Check add non breaking space shortcut'); - }); - - QUnit.test('Check italic shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Italic}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Italic(), true, 'Check add italic shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_Italic(), false, 'Check add italic shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check justify para shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.JustifyPara}; - const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Justify, 'Check justify para shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check justify para shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check bullet list shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyListBullet}; - const {oLogicDocument, oParagraph} = getLogicDocumentWithParagraphs(['Hello']); - oLogicDocument.SelectAll(); - onKeyDown(createNativeEvent()); - - oAssert.true(oParagraph.IsBulletedNumbering(), 'check apply bullet list'); - }); - - QUnit.test('Check left para shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.LeftPara}; - const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Justify, 'Check center para shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check indent shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Indent}; - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello']); - oParagraph.Pr.SetInd(0, 0, 0); - moveToParagraph(oParagraph, true); - - onKeyDown(createNativeEvent()); - oAssert.strictEqual(directParaPr().GetIndLeft(), 12.5, 'Check increase indent'); - }); - - QUnit.test('Check unindent shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.UnIndent}; - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello']); - oParagraph.Pr.SetInd(0, 12.5, 0); - moveToParagraph(oParagraph, true); - - onKeyDown(createNativeEvent()); - oAssert.true(AscFormat.fApproxEqual(directParaPr().GetIndLeft(), 0), 'Check decrease indent'); - }); - - QUnit.test('Check insert page number shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertPageNumber}; - checkInsertElementByType(para_PageNum, 'Check insert page number shortcut', oAssert, createNativeEvent()); - }); - - QUnit.test('Check right para shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.RightPara}; - const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Right, 'Check center para shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check registered sign shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.RegisteredSign}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x00AE), createNativeEvent(), oAssert, 'Check registered sign shortcut'); - }); - - QUnit.test('Check trademark sign shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.TrademarkSign}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x2122), createNativeEvent(), oAssert, 'Check registered sign shortcut'); - }); - - QUnit.test('Check underline shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Underline}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Underline(), true, 'Check underline shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_Underline(), false, 'Check underline shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check paste format shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.PasteFormat}; - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - addPropertyToDocument({Bold: true, Italic: true}); - oGlobalLogicDocument.Document_Format_Copy(); - remove(); - addParagraphToDocumentWithText('Hello'); - oGlobalLogicDocument.SelectAll(); - onKeyDown(createNativeEvent()); - const oDirectTextPr = directTextPr(); - oAssert.true(oDirectTextPr.Get_Bold() && oDirectTextPr.Get_Italic(), 'Check paste format shortcut'); - }); - - QUnit.test('Check redo shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditRedo}; - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello World']); - oLogicDocument.SelectAll(); - oLogicDocument.Remove(undefined, undefined, true); - oLogicDocument.Document_Undo(); - onKeyDown(createNativeEvent()); - oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), '', 'Check redo shortcut'); - }); - - QUnit.test('Check undo shortcut', (oAssert) => - { - getLogicDocumentWithParagraphs(['Hello World']); - selectAll(); - editor.asc_Remove(); - - editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditUndo}; - onKeyDown(createNativeEvent()); - selectAll(); - oAssert.strictEqual(getSelectedText(), 'Hello World', 'Check redo shortcut'); - }); - - QUnit.test('Check en dash shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.EnDash}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x2013), createNativeEvent(), oAssert, 'Check en dash shortcut'); - }); - - QUnit.test('Check em dash shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.EmDash}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x2014), createNativeEvent(), oAssert, 'Check em dash shortcut'); - }); - - QUnit.test('Check update fields shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.UpdateFields}; - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello', 'Hello', 'Hello'], true); - for (let i = 0; i < logicContent().length; i += 1) - { - oLogicDocument.Set_CurrentElement(i, true); - oLogicDocument.SetParagraphStyle("Heading 1"); - } - oLogicDocument.MoveCursorToStartPos(); - const props = new Asc.CTableOfContentsPr(); - props.put_OutlineRange(1, 9); - props.put_Hyperlink(true); - props.put_ShowPageNumbers(true); - props.put_RightAlignTab(true); - props.put_TabLeader(Asc.c_oAscTabLeader.Dot); - editor.asc_AddTableOfContents(null, props); - - oLogicDocument.MoveCursorToEndPos(); - const oParagraph = createParagraphWithText('Hello'); - oLogicDocument.AddToContent(logicContent().length, oParagraph); - moveToParagraph(oParagraph); - oLogicDocument.SetParagraphStyle("Heading 1"); - - logicContent()[0].SetThisElementCurrent(); - onKeyDown(createNativeEvent()); - oAssert.strictEqual(logicContent()[0].Content.Content.length, 5, 'Check update fields shortcut'); - }); - - QUnit.test('Check superscript shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Superscript}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_VertAlign(), AscCommon.vertalign_SuperScript, 'Check center para shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_VertAlign(), AscCommon.vertalign_Baseline, 'Check center para shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check non breaking hyphen shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.NonBreakingHyphen}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x002D), createNativeEvent(), oAssert, 'Check non breaking hyphen shortcut'); - }); - - QUnit.test('Check horizontal ellipsis shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.HorizontalEllipsis}; - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x2026), createNativeEvent(), oAssert, 'Check add horizontal ellipsis shortcut'); - }); - - QUnit.test('Check subscript shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Subscript}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_VertAlign(), AscCommon.vertalign_SubScript, 'Check center para shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_VertAlign(), AscCommon.vertalign_Baseline, 'Check center para shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check show hyperlink menu shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertHyperlink}; - executeTestWithCatchEvent('asc_onDialogAddHyperlink', () => true, true, createNativeEvent(), oAssert, () => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - moveToParagraph(oParagraph); - oGlobalLogicDocument.SelectAll(); - }); - }); - - QUnit.test('Check print shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.PrintPreviewAndPrint}; - executeTestWithCatchEvent('asc_onPrint', () => true, true, createNativeEvent(), oAssert); - }); - - QUnit.test('Check save shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.Save}; - const fOldSave = editor._onSaveCallbackInner; - let bCheck = false; - editor._onSaveCallbackInner = function () - { - bCheck = true; - editor.canSave = true; - }; - onKeyDown(createNativeEvent()); - oAssert.strictEqual(bCheck, true, 'Check save shortcut'); - editor._onSaveCallbackInner = fOldSave; - }); - - QUnit.test('Check increase font size shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.IncreaseFontSize}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_FontSize(), 11, 'Check increase font size shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_FontSize(), 12, 'Check increase font size shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check decrease font size shortcut', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.DecreaseFontSize}; - const fAnotherCheck = checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_FontSize(), 9, 'Check decrease font size shortcut', createNativeEvent(), oAssert); - fAnotherCheck((oTextPr) => oTextPr.Get_FontSize(), 8, 'Check decrease font size shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check apply heading 1', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading1}; - checkApplyParagraphStyle('Heading 1', 'Check apply heading 1 shortcut', createNativeEvent(), oAssert); - }); - QUnit.test('Check apply heading 2', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading2}; - checkApplyParagraphStyle('Heading 2', 'Check apply heading 2 shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check apply heading 3', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading3}; - checkApplyParagraphStyle('Heading 3', 'Check apply heading 3 shortcut', createNativeEvent(), oAssert); - }); - - QUnit.test('Check insert footnotes now', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertFootnoteNow}; - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello']); - oLogicDocument.SelectAll(); - onKeyDown(createNativeEvent()); - const arrFootnotes = oLogicDocument.GetFootnotesList(); - oAssert.deepEqual(arrFootnotes.length, 1, 'Check insert footnote shortcut'); - }); - - QUnit.test('Check insert equation', (oAssert) => - { - editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertEquation}; - const {oLogicDocument} = getLogicDocumentWithParagraphs(['']); - onKeyDown(createNativeEvent()); - const oMath = oLogicDocument.GetCurrentMath(); - oAssert.true(!!oMath, 'Check insert equation shortcut'); - }); - - QUnit.module("Test getting desired action by event") - QUnit.test("Test getting common desired action by event", (oAssert) => - { - editor.initDefaultShortcuts(); - oAssert.strictEqual(editor.getShortcut(createEvent(13, true, false, false, false, false, false)), c_oAscDocumentShortcutType.InsertPageBreak, 'Check getting c_oAscDocumentShortcutType.InsertPageBreak action'); - oAssert.strictEqual(editor.getShortcut(createEvent(13, false, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertLineBreak, 'Check getting c_oAscDocumentShortcutType.InsertLineBreak action'); - oAssert.strictEqual(editor.getShortcut(createEvent(13, true, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertColumnBreak, 'Check getting c_oAscDocumentShortcutType.InsertColumnBreak action'); - oAssert.strictEqual(editor.getShortcut(createEvent(32, true, false, false, false, false, false)), c_oAscDocumentShortcutType.ResetChar, 'Check getting c_oAscDocumentShortcutType.ResetChar action'); - oAssert.strictEqual(editor.getShortcut(createEvent(32, true, true, false, false, false, false)), c_oAscDocumentShortcutType.NonBreakingSpace, 'Check getting c_oAscDocumentShortcutType.NonBreakingSpace action'); - oAssert.strictEqual(editor.getShortcut(createEvent(53, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Strikeout, 'Check getting c_oAscDocumentShortcutType.Strikeout action'); - oAssert.strictEqual(editor.getShortcut(createEvent(56, true, true, false, false, false, false)), c_oAscDocumentShortcutType.ShowAll, 'Check getting c_oAscDocumentShortcutType.ShowAll action'); - oAssert.strictEqual(editor.getShortcut(createEvent(65, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditSelectAll, 'Check getting c_oAscDocumentShortcutType.EditSelectAll action'); - oAssert.strictEqual(editor.getShortcut(createEvent(66, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Bold, 'Check getting c_oAscDocumentShortcutType.Bold action'); - oAssert.strictEqual(editor.getShortcut(createEvent(67, true, false, true, false, false, false)), c_oAscDocumentShortcutType.CopyFormat, 'Check getting c_oAscDocumentShortcutType.CopyFormat action'); - oAssert.strictEqual(editor.getShortcut(createEvent(71, true, false, true, false, false, false)), c_oAscDocumentShortcutType.CopyrightSign, 'Check getting c_oAscDocumentShortcutType.CopyrightSign action'); - oAssert.strictEqual(editor.getShortcut(createEvent(68, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEndnoteNow, 'Check getting c_oAscDocumentShortcutType.InsertEndnoteNow action'); - oAssert.strictEqual(editor.getShortcut(createEvent(69, true, false, false, false, false, false)), c_oAscDocumentShortcutType.CenterPara, 'Check getting c_oAscDocumentShortcutType.CenterPara action'); - oAssert.strictEqual(editor.getShortcut(createEvent(69, true, false, true, false, false, false)), c_oAscDocumentShortcutType.EuroSign, 'Check getting c_oAscDocumentShortcutType.EuroSign action'); - oAssert.strictEqual(editor.getShortcut(createEvent(73, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Italic, 'Check getting c_oAscDocumentShortcutType.Italic action'); - oAssert.strictEqual(editor.getShortcut(createEvent(74, true, false, false, false, false, false)), c_oAscDocumentShortcutType.JustifyPara, 'Check getting c_oAscDocumentShortcutType.JustifyPara action'); - oAssert.strictEqual(editor.getShortcut(createEvent(75, true, false, false, false, false, false)), c_oAscDocumentShortcutType.InsertHyperlink, 'Check getting c_oAscDocumentShortcutType.InsertHyperlink action'); - oAssert.strictEqual(editor.getShortcut(createEvent(76, true, true, false, false, false, false)), c_oAscDocumentShortcutType.ApplyListBullet, 'Check getting c_oAscDocumentShortcutType.ApplyListBullet action'); - oAssert.strictEqual(editor.getShortcut(createEvent(76, true, false, false, false, false, false)), c_oAscDocumentShortcutType.LeftPara, 'Check getting c_oAscDocumentShortcutType.LeftPara action'); - oAssert.strictEqual(editor.getShortcut(createEvent(77, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Indent, 'Check getting c_oAscDocumentShortcutType.Indent action'); - oAssert.strictEqual(editor.getShortcut(createEvent(77, true, true, false, false, false, false)), c_oAscDocumentShortcutType.UnIndent, 'Check getting c_oAscDocumentShortcutType.UnIndent action'); - oAssert.strictEqual(editor.getShortcut(createEvent(80, true, false, false, false, false, false)), c_oAscDocumentShortcutType.PrintPreviewAndPrint, 'Check getting c_oAscDocumentShortcutType.PrintPreviewAndPrint action'); - oAssert.strictEqual(editor.getShortcut(createEvent(80, true, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertPageNumber, 'Check getting c_oAscDocumentShortcutType.InsertPageNumber action'); - oAssert.strictEqual(editor.getShortcut(createEvent(82, true, false, false, false, false, false)), c_oAscDocumentShortcutType.RightPara, 'Check getting c_oAscDocumentShortcutType.RightPara action'); - oAssert.strictEqual(editor.getShortcut(createEvent(82, true, false, true, false, false, false)), c_oAscDocumentShortcutType.RegisteredSign, 'Check getting c_oAscDocumentShortcutType.RegisteredSign action'); - oAssert.strictEqual(editor.getShortcut(createEvent(83, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Save, 'Check getting c_oAscDocumentShortcutType.Save action'); - oAssert.strictEqual(editor.getShortcut(createEvent(84, true, false, true, false, false, false)), c_oAscDocumentShortcutType.TrademarkSign, 'Check getting c_oAscDocumentShortcutType.TrademarkSign action'); - oAssert.strictEqual(editor.getShortcut(createEvent(85, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Underline, 'Check getting c_oAscDocumentShortcutType.Underline action'); - oAssert.strictEqual(editor.getShortcut(createEvent(86, true, false, true, false, false, false)), c_oAscDocumentShortcutType.PasteFormat, 'Check getting c_oAscDocumentShortcutType.PasteFormat action'); - oAssert.strictEqual(editor.getShortcut(createEvent(89, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditRedo, 'Check getting c_oAscDocumentShortcutType.EditRedo action'); - oAssert.strictEqual(editor.getShortcut(createEvent(90, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditUndo, 'Check getting c_oAscDocumentShortcutType.EditUndo action'); - oAssert.strictEqual(editor.getShortcut(createEvent(109, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EnDash, 'Check getting c_oAscDocumentShortcutType.EnDash action'); - oAssert.strictEqual(editor.getShortcut(createEvent(109, true, false, true, false, false, false)), c_oAscDocumentShortcutType.EmDash, 'Check getting c_oAscDocumentShortcutType.EmDash action'); - oAssert.strictEqual(editor.getShortcut(createEvent(120, false, false, false, false, false, false)), c_oAscDocumentShortcutType.UpdateFields, 'Check getting c_oAscDocumentShortcutType.UpdateFields action'); - oAssert.strictEqual(editor.getShortcut(createEvent(188, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Superscript, 'Check getting c_oAscDocumentShortcutType.Superscript action'); - oAssert.strictEqual(editor.getShortcut(createEvent(189, true, true, false, false, false, false)), c_oAscDocumentShortcutType.NonBreakingHyphen, 'Check getting c_oAscDocumentShortcutType.NonBreakingHyphen action'); - oAssert.strictEqual(editor.getShortcut(createEvent(190, true, false, true, false, false, false)), c_oAscDocumentShortcutType.HorizontalEllipsis, 'Check getting c_oAscDocumentShortcutType.HorizontalEllipsis action'); - oAssert.strictEqual(editor.getShortcut(createEvent(190, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Subscript, 'Check getting c_oAscDocumentShortcutType.Subscript action'); - oAssert.strictEqual(editor.getShortcut(createEvent(219, true, false, false, false, false, false)), c_oAscDocumentShortcutType.DecreaseFontSize, 'Check getting c_oAscDocumentShortcutType.DecreaseFontSize action'); - oAssert.strictEqual(editor.getShortcut(createEvent(221, true, false, false, false, false, false)), c_oAscDocumentShortcutType.IncreaseFontSize, 'Check getting c_oAscDocumentShortcutType.IncreaseFontSize action'); - editor.Shortcuts = new AscCommon.CShortcuts(); - }); - - QUnit.test("Test getting windows desired action by event", (oAssert) => - { - editor.initDefaultShortcuts(); - oAssert.strictEqual(editor.getShortcut(createEvent(49, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading1, 'Check getting c_oAscDocumentShortcutType.ApplyHeading1 shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(50, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading2, 'Check getting c_oAscDocumentShortcutType.ApplyHeading2 shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(51, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading3, 'Check getting c_oAscDocumentShortcutType.ApplyHeading3 shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(70, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertFootnoteNow, 'Check getting c_oAscDocumentShortcutType.InsertFootnoteNow shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(187, false, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEquation, 'Check getting c_oAscDocumentShortcutType.InsertEquation shortcut type'); - editor.Shortcuts = new AscCommon.CShortcuts(); - }); - - QUnit.test("Test getting macOs desired action by event", (oAssert) => - { - const bOldMacOs = AscCommon.AscBrowser.isMacOs; - AscCommon.AscBrowser.isMacOs = true; - editor.initDefaultShortcuts(); - oAssert.strictEqual(editor.getShortcut(createEvent(49, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading1, 'Check getting c_oAscDocumentShortcutType.ApplyHeading1 shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(50, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading2, 'Check getting c_oAscDocumentShortcutType.ApplyHeading2 shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(51, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading3, 'Check getting c_oAscDocumentShortcutType.ApplyHeading3 shortcut type'); - oAssert.strictEqual(editor.getShortcut(createEvent(187, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEquation, 'Check getting c_oAscDocumentShortcutType.InsertEquation shortcut type'); - editor.Shortcuts = new AscCommon.CShortcuts(); - AscCommon.AscBrowser.isMacOs = bOldMacOs; - }); - - QUnit.module('Test hotkeys module', { - afterEach: function () - { - resetLogicDocument(oGlobalLogicDocument); + QUnit.test('Check page break shortcut', (assert) => + { + TurnOnRecalculate(); + ClearDocumentAndAddParagraph(); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertPageBreak); + assert.strictEqual(logicDocument.GetPagesCount(), 2, 'Check page break shortcut'); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertPageBreak); + assert.strictEqual(logicDocument.GetPagesCount(), 3, 'Check page break shortcut'); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertPageBreak); + assert.strictEqual(logicDocument.GetPagesCount(), 4, 'Check page break shortcut'); + TurnOffRecalculate(); + }); + + QUnit.test('Check line break shortcut', (assert) => + { + TurnOnRecalculate(); + let p = ClearDocumentAndAddParagraph(); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertLineBreak); + assert.strictEqual(p.GetLinesCount(), 2, 'Check line break shortcut'); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertLineBreak); + assert.strictEqual(p.GetLinesCount(), 3, 'Check line break shortcut'); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertLineBreak); + assert.strictEqual(p.GetLinesCount(), 4, 'Check line break shortcut'); + TurnOffRecalculate(); + }); + + QUnit.test('Check column break shortcut', (assert) => + { + TurnOnRecalculate(); + let p = ClearDocumentAndAddParagraph(); + let sectionPr = AscTest.GetFinalSection(); + sectionPr.SetColumnsNum(3); + AscTest.Recalculate(); + + function CheckColumns(colCount) + { + assert.strictEqual(logicDocument.GetPagesCount(), 1, 'Check logic document page count'); + assert.strictEqual(p.GetPagesCount(), colCount, 'Check paragraph page count'); + for (let i = 0; i < colCount; ++i) + { + assert.strictEqual(p.GetAbsoluteColumn(i), i, 'Check paragraph column index'); + assert.strictEqual(p.GetAbsolutePage(i), 0, 'Check paragraph page index'); + } } - }) - QUnit.test("test remove back symbol", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - selectAll(); - oAssert.strictEqual(getSelectedText(), 'Hello Worl', 'Test remove back symbol'); - }, oTestTypes.removeBackSymbol); - }); - - QUnit.test("test remove back word", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - selectAll(); - oAssert.strictEqual(getSelectedText(), 'Hello ', 'Test remove back word'); - }, oTestTypes.removeBackWord); - }); - - QUnit.test("test remove shape", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs([''], true); - moveToParagraph(oParagraph); - const oDrawing = createShape(); - selectParaDrawing(oDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(oParagraph.GetRunByElement(oDrawing), null, 'Test remove shape'); - }, oTestTypes.removeShape); - }); - - QUnit.test("test remove form", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['']); - moveToParagraph(oParagraph); - const oInlineLvlSdt = createComboBox(); - onKeyDown(oEvent); - oAssert.strictEqual(oParagraph.GetPosByElement(oInlineLvlSdt), null, 'Test remove form'); - }, oTestTypes.removeForm); - }); - - - QUnit.test("test move to next form", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs(['']); - const oInlineSdt1 = createComboBox(); - moveCursorRight(); - const oInlineSdt2 = createComboBox(); - moveCursorRight(); - const oInlineSdt3 = createComboBox(); - setFillingFormsMode(true); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt1, 'Test move to next form'); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt2, 'Test move to next form'); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt3, 'Test move to next form'); - - setFillingFormsMode(false); - }, oTestTypes.moveToNextForm); - }); - - - QUnit.test("test move to previous form", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['']); - const oInlineSdt1 = createComboBox(); - moveCursorRight(); - const oInlineSdt2 = createComboBox(); - moveCursorRight(); - const oInlineSdt3 = createComboBox(); - setFillingFormsMode(true); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt2, 'Test move to next form'); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt1, 'Test move to next form'); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt3, 'Test move to next form'); - - setFillingFormsMode(false); - }, oTestTypes.moveToPreviousForm); - }); - - - - QUnit.test("Test handle tab in math", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs([''], true); - createMath(); - addText('abcd+abcd+abcd'); - moveToParagraph(oParagraph); - moveCursorLeft(); - moveCursorLeft(); - moveCursorLeft(); - moveCursorLeft(); - moveCursorLeft(); - insertManualBreak(); - onKeyDown(oEvent); - moveCursorRight(); - const oContentPosition = oGlobalLogicDocument.GetContentPosition(); - const oCurRun = oContentPosition[oContentPosition.length - 1].Class; - - oAssert.strictEqual(oCurRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); - }, oTestTypes.handleTab); - }); - - QUnit.test("test move to cell", (oAssert) => - { - startTest((oEvent) => - { - const oTable = createTable(3, 3); - moveToTable(oTable, true); - onKeyDown(oEvent); - oAssert.strictEqual(oTable.CurCell.Index, 1, 'Test move to next cell'); - }, oTestTypes.moveToNextCell); - }); - - QUnit.test("test move to cell", (oAssert) => - { - startTest((oEvent) => - { - const oTable = createTable(3, 3); - moveToTable(oTable, true); - moveCursorRight(); - onKeyDown(oEvent); - oAssert.strictEqual(oTable.CurCell.Index, 0, 'Test move to previous cell'); - }, oTestTypes.moveToPreviousCell); - }); - - QUnit.test("test select next object", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const oFirstParaDrawing = createShape(); - const oSecondParaDrawing = createShape(); - selectParaDrawing(oFirstParaDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oSecondParaDrawing.GraphicObj, true, 'Test select next object'); - - }, oTestTypes.selectNextObject); - }); - - QUnit.test("test select previous object", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const oFirstParaDrawing = createShape(); - const oSecondParaDrawing = createShape(); - const oThirdParaDrawing = createShape(); - selectParaDrawing(oFirstParaDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oThirdParaDrawing.GraphicObj, true, 'Test select previous object'); - onKeyDown(oEvent); - oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oSecondParaDrawing.GraphicObj, true, 'Test select previous object'); - }, oTestTypes.selectPreviousObject); - }); - - QUnit.test("test indent", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs(['Hello world', "Hello world"]); - const oFirstParagraph = logicContent()[0]; - const oSecondParagraph = logicContent()[1]; - selectAll(); - onKeyDown(oEvent); - let arrSteps = []; - moveToParagraph(oFirstParagraph); - arrSteps.push(directParaPr().GetIndLeft()); - moveToParagraph(oSecondParagraph); - arrSteps.push(directParaPr().GetIndLeft()); - oAssert.deepEqual(arrSteps, [12.5, 12.5], 'Test indent'); - - moveToParagraph(oFirstParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(); - }, oTestTypes.testIndent); - }); - - QUnit.test("test unindent", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs(['hello', 'hello']); - const oFirstParagraph = logicContent()[0]; - const oSecondParagraph = logicContent()[1]; - oFirstParagraph.Set_Ind({Left: 12.5}); - oSecondParagraph.Set_Ind({Left: 12.5}); - selectAll(); - onKeyDown(oEvent); - - const arrSteps = []; - moveToParagraph(oFirstParagraph); - arrSteps.push(directParaPr().GetIndLeft()); - moveToParagraph(oSecondParagraph); - arrSteps.push(directParaPr().GetIndLeft()); - - oAssert.deepEqual(arrSteps, [0, 0], 'Test unindent'); - }, oTestTypes.testUnIndent); - }); - - - QUnit.test("test add tab to paragraph", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - moveToParagraph(oParagraph, true); - moveCursorRight(); - onKeyDown(oEvent); - selectAll(); - - oAssert.strictEqual(getSelectedText(), 'H\tello World', 'Test indent'); - }, oTestTypes.addTabToParagraph); - }); - - QUnit.test("test visit hyperlink", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['']); - addBreakPage(); - createHyperlink(); - moveCursorLeft(); - moveCursorLeft(); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetCurrentParagraph(), logicContent()[0]); - oAssert.strictEqual(oGlobalLogicDocument.Get_CurPage(), 0); - }, oTestTypes.visitHyperlink); - }); - - QUnit.test("Test add break line to inlinelvlsdt", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const oInlineSdt = createComplexForm(); - onKeyDown(oEvent); - oAssert.strictEqual(oInlineSdt.Lines[0], 2); - }, oTestTypes.addBreakLineInlineLvlSdt); - }); - - QUnit.test("Test create textBoxContent", (oAssert) => - { - startTest((oEvent) => - { - const oParaDrawing = createShape(); - selectParaDrawing(oParaDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(!!oParaDrawing.GraphicObj.textBoxContent, true); - }, oTestTypes.createTextBoxContent); - }); - - QUnit.test("Test create txBody", (oAssert) => - { - startTest((oEvent) => - { - const oParaDrawing = createShape(); - oParaDrawing.GraphicObj.setWordShape(false); - selectParaDrawing(oParaDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(!!oParaDrawing.GraphicObj.txBody, true); - }, oTestTypes.createTextBody); - }); - - QUnit.test("Test add new line to math", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['']); - createMath(c_oAscMathType.FractionVertical); - moveCursorLeft(); - moveCursorLeft(); - addText('Hello'); - moveCursorLeft(); - moveCursorLeft(); - onKeyDown(oEvent); - const oParaMath = oParagraph.GetAllParaMaths()[0]; - const oFraction = oParaMath.Root.GetFirstElement(); - const oNumerator = oFraction.getNumerator(); - const oEqArray = oNumerator.GetFirstElement(); - oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); - }, oTestTypes.addNewLineToMath); - }); - - QUnit.test("Test move cursor to start position shape", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const oParaDrawing = createShape(); - const oShape = oParaDrawing.GraphicObj; - oShape.createTextBoxContent(); - selectParaDrawing(oParaDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(oShape.getDocContent().IsCursorAtBegin(), true); - }, oTestTypes.moveCursorToStartPositionShapeEnter); - }); - - QUnit.test("Test select all in shape", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true) - const oParaDrawing = createShape(); - const oShape = oParaDrawing.GraphicObj; - oShape.createTextBoxContent(); - moveToParagraph(oShape.getDocContent().Content[0]); - addText('Hello'); - selectParaDrawing(oParaDrawing); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'Hello'); - }, oTestTypes.selectAllShapeEnter); - }); - - QUnit.test("Test move cursor to start position chart title", (oAssert) => - { - startTest((oEvent) => - { - const oParaDrawing = createChart(); - const oChart = oParaDrawing.GraphicObj; - const oTitles = oChart.getAllTitles(); - const oContent = AscFormat.CreateDocContentFromString('', drawingObjects().getDrawingDocument(), oTitles[0].txBody); - oTitles[0].txBody.content = oContent; - selectParaDrawing(oParaDrawing); - - const oController = drawingObjects(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); - - onKeyDown(oEvent); - oAssert.true(oContent.IsCursorAtBegin(), 'Check move cursor to begin pos in title'); - }, oTestTypes.moveCursorToStartPositionTitleEnter); - }); - - QUnit.test("Test select all in chart title", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const oParaDrawing = createChart(); - const oChart = oParaDrawing.GraphicObj; - selectParaDrawing(oParaDrawing); - const oTitles = oChart.getAllTitles(); - const oController = drawingObjects(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); - - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'Diagram Title', 'Check select all title'); - }, oTestTypes.selectAllInChartTitle); - }); - - QUnit.test("Test add new paragraph", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Text']); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph to content'); - }, oTestTypes.addNewParagraphContent); - }); - - QUnit.test("Test add new paragraph", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs(['']); - createMath(); - addText('abcd'); - moveCursorLeft(); - onKeyDown(oEvent); - oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph with math'); - }, oTestTypes.addNewParagraphMath); - }); - - QUnit.test("Test close all window popups", (oAssert) => - { - startTest((oEvent) => - { - executeTestWithCatchEvent('asc_onMouseMoveStart', () => true, true, oEvent, oAssert); - executeTestWithCatchEvent('asc_onMouseMove', () => true, true, oEvent, oAssert); - executeTestWithCatchEvent('asc_onMouseMoveEnd', () => true, true, oEvent, oAssert); - }, oTestTypes.closeAllWindowsPopups); - }); - - QUnit.test("Test reset shape selection", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const arrDrawings = [createShape(), createShape()]; - const oGroup = createGroup(arrDrawings); - const oChart = createChart(); - selectOnlyObjects([oChart, oGroup, arrDrawings[0]]); - onKeyDown(oEvent); - oAssert.strictEqual(drawingObjects().getSelectedArray().length, 0, "Test reset shape selection"); - }, oTestTypes.resetShapeSelection); - }); - - QUnit.test("Test reset add shape", (oAssert) => - { - startTest((oEvent) => - { - editor.StartAddShape('rect'); - onKeyDown(oEvent); - oAssert.strictEqual(editor.isStartAddShape, false, "Test reset add shape"); - }, oTestTypes.resetStartAddShape); - }); - - QUnit.test("Test reset formatting by example", (oAssert) => - { - startTest((oEvent) => - { - editor.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOn); - onKeyDown(oEvent); - oAssert.strictEqual(editor.isFormatPainterOn(), false, "Test reset formatting by example"); - }, oTestTypes.resetFormattingByExample); - }); - - QUnit.test("Test reset", (oAssert) => - { - startTest((oEvent) => - { - editor.SetMarkerFormat(true, true, 0, 0, 0); - onKeyDown(oEvent); - oAssert.strictEqual(editor.isMarkerFormat, false, "Test reset marker"); - }, oTestTypes.resetMarkerFormat); - - }); - - QUnit.test("Test reset drag'n'drop", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Hello'], true); - moveToParagraph(oParagraph, true); - moveCursorRight(true, true); - mouseDown(5, 10, 0, false, 1); - mouseMove(35, 10, 0, false, 1); - onKeyDown(oEvent); - oAssert.strictEqual(editor.WordControl.m_oDrawingDocument.IsTrackText(), false, "Test reset drag'n'drop"); - mouseUp(35, 10, 0, false, 1); - }, oTestTypes.resetDragNDrop); - }); - - QUnit.test("Test end editing form", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs([''], true); - const oCheckBox = createCheckBox(); - oCheckBox.MoveCursorToContentControl(true); - setFillingFormsMode(true); - onKeyDown(oEvent); - const oSelectedInfo = oGlobalLogicDocument.GetSelectedElementsInfo(); - oAssert.strictEqual(!!oSelectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); - setFillingFormsMode(false); - - editor.GoToHeader(0); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - editor.asc_RemoveHeader(0); - - editor.GoToFooter(0); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - editor.asc_RemoveFooter(0); - }, oTestTypes.endEditing); - }); - - QUnit.test("Test toggle checkbox", (oAssert) => - { - startTest((oEvent) => - { - getLogicDocumentWithParagraphs(['']); - const oInlineSdt = createCheckBox(); - setFillingFormsMode(true); - onKeyDown(oEvent); - oAssert.strictEqual(oInlineSdt.IsCheckBoxChecked(), true); - setFillingFormsMode(false); - }, oTestTypes.toggleCheckBox); - }); - - QUnit.test("Test actions to page up", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 125); - }, oTestTypes.moveToPreviousPage); - }); - - QUnit.test("Test actions to page up", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 90); - }, oTestTypes.moveToStartPreviousPage); - }); - - QUnit.test("Test move to previous header or footer", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - editor.GoToHeader(2); - editor.GoToFooter(2); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[2].Header); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Footer); - }, oTestTypes.moveToPreviousHeaderFooter); - editor.asc_RemoveHeader(2); - editor.asc_RemoveFooter(2); - }); - - QUnit.test("Test actions to page up", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - - editor.GoToHeader(2); - editor.GoToFooter(2); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[0].Header); - }, oTestTypes.moveToPreviousHeader); - editor.asc_RemoveHeader(2); - editor.asc_RemoveFooter(2); - }); - function drawingDocument() - { - return editor.WordControl.m_oDrawingDocument; - } - QUnit.test("Test select to previous page", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), ' World Hello World Hello World Hello World Hello World Hello World Hello World Hello World'); - }, oTestTypes.selectToPreviousPage); - }); - - - QUnit.test("Test select to start previous page", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World'); - }, oTestTypes.selectToStartPreviousPage); - }); - - QUnit.test("Test select to start of next page", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello ', "Test select to begin of next page"); - }, oTestTypes.selectToStartNextPage); - }); - QUnit.test("Test move to start of next page", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 90, "Test move to begin of next page"); - }, oTestTypes.moveToStartNextPage); - }); - QUnit.test("Test select to next page", (oAssert) => - { - startTest((oEvent) => - { - - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - moveCursorRight(); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello W', "Test select to next page"); - }, oTestTypes.selectToNextPage); - }); - QUnit.test("Test move to next page", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - moveCursorRight(); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 91, "Test move to next page"); - }, oTestTypes.moveToNextPage); - }); - QUnit.test("Test move to next header/footer", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - editor.GoToFooter(0); - editor.GoToHeader(0); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[0].Footer); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); - }, oTestTypes.moveToNextHeaderFooter); - }); - QUnit.test("Test move to next header", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - editor.GoToFooter(0); - editor.GoToHeader(0); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[2].Header); - }, oTestTypes.moveToNextHeader); - }); - - QUnit.test("Test actions to end", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 107, "Test move to end of document"); - }, oTestTypes.moveToEndDocument); - }); - - QUnit.test("Test actions to end", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 18, "Test move to end of line"); - }, oTestTypes.moveToEndLine); - }); - - QUnit.test("Test actions to end", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), "Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World", "Test select to end of document"); - - }, oTestTypes.selectToEndDocument); - }); - - QUnit.test("Test actions to end", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), "Hello World Hello ", "Test select to end of line"); - }, oTestTypes.selectToEndLine); - }); - - QUnit.test("Test actions to home", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), "World Hello World", "Test select to home of line"); - }, oTestTypes.selectToStartLine); - }); - - QUnit.test("Test actions to home", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), "Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World", "Test select to home of document"); - - }, oTestTypes.selectToStartDocument); - - }); - - QUnit.test("Test actions to home", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 90, "Test move to home of line"); - }, oTestTypes.moveToStartLine); - }); - - QUnit.test("Test actions to home", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph); - - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 0, "Test move to home of document"); - }, oTestTypes.moveToStartDocument); - }); - - QUnit.test("Test actions to left", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'World', "Test select to previous word"); - }, oTestTypes.selectLeftWord); - }); - - QUnit.test("Test actions to left", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 18, "Test move to previous word"); - }, oTestTypes.moveToLeftWord); - let oEvent; - }); - - QUnit.test("Test actions to left", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'd', "Test select to previous symbol"); - }, oTestTypes.selectLeftSymbol); - }); - - QUnit.test("Test actions to left", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - moveToParagraph(oParagraph); - - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 22, "Test move to previous symbol"); - }, oTestTypes.moveToLeftChar); - }); - - QUnit.test("Test actions to left", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(-1, 0, oAssert, oEvent); - }, oTestTypes.littleMoveGraphicObjectLeft); - }); - - QUnit.test("Test actions to left", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(-5, 0, oAssert, oEvent); - }, oTestTypes.bigMoveGraphicObjectLeft); - }); - - QUnit.test("Test actions to right", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(1, 0, oAssert, oEvent); - }, oTestTypes.littleMoveGraphicObjectRight); - }); - - QUnit.test("Test actions to right", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(5, 0, oAssert, oEvent); - }, oTestTypes.bigMoveGraphicObjectRight); - }); - - QUnit.test("Test actions to up", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(0, -1, oAssert, oEvent); - }, oTestTypes.littleMoveGraphicObjectUp); - }); - - QUnit.test("Test actions to up", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(0, -5, oAssert, oEvent); - }, oTestTypes.bigMoveGraphicObjectUp); - }); - - QUnit.test("Test actions to down", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(0, 1, oAssert, oEvent); - }, oTestTypes.littleMoveGraphicObjectDown); - }); - - QUnit.test("Test actions to down", (oAssert) => - { - startTest((oEvent) => - { - moveShapeHelper(0, 5, oAssert, oEvent); - }, oTestTypes.bigMoveGraphicObjectDown); - }); - - QUnit.test("Test actions to right", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(contentPosition(), 1, "Test move to next symbol"); - }, oTestTypes.moveToRightChar); - }); - - QUnit.test("Test actions to right", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), "H", "Test select to next symbol"); - }, oTestTypes.selectRightChar); - }); - - QUnit.test("Test actions to right", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.deepEqual(contentPosition(), 6, "Test move to next word"); - }, oTestTypes.moveToRightWord); - }); - - QUnit.test("Test actions to right", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'Hello ', "Test select to next word"); - }, oTestTypes.selectRightWord); - }); - - QUnit.test("Test actions to up", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - moveCursorDown(); - onKeyDown(oEvent); - oAssert.deepEqual(contentPosition(), 0, "Test move to upper line"); - }, oTestTypes.moveUp); - }); - - QUnit.test("Test actions to up", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - moveCursorDown(); - oEvent = createNativeEvent(38, false, true, false, false); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'Hello World Hello ', "Test select to upper line"); - }, oTestTypes.selectUp); - }); - - QUnit.test("Test actions to up", (oAssert) => - { - startTest((oEvent) => - { - clean(); - getLogicDocumentWithParagraphs(['']); - createComboBox(); - setFillingFormsMode(true); - onKeyDown(oEvent); - oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'Hello', "Test select previous option in combo box"); - - onKeyDown(oEvent); - oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'yo', "Test select previous option in combo box"); - setFillingFormsMode(false); - }, oTestTypes.previousOptionComboBox); - }); - - QUnit.test("Test actions to down", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.deepEqual(contentPosition(), 18, "Test move to down line"); - }, oTestTypes.moveDown); - }); - - QUnit.test("Test actions to down", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), 'Hello World Hello ', "Test select to down line"); - }, oTestTypes.selectDown); - }); - - QUnit.test("Test actions to down", (oAssert) => - { - startTest((oEvent) => - { - clean(); - getLogicDocumentWithParagraphs(['']); - createComboBox(); - setFillingFormsMode(true); - onKeyDown(oEvent); - oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'Hello', "Test select next option in combo box"); - onKeyDown(oEvent); - oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'World', "Test select next option in combo box"); - setFillingFormsMode(false); - }, oTestTypes.nextOptionComboBox); - }); - - QUnit.test("Test remove front", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World"]); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - selectAll(); - oAssert.strictEqual(getSelectedText(), 'ello World', 'Test remove front symbol'); - }, oTestTypes.removeFrontSymbol); - }); - - QUnit.test("Test remove front", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World"]); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - selectAll(); - oAssert.strictEqual(getSelectedText(), 'World', 'Test remove front word'); - }, oTestTypes.removeFrontWord); - }); - - QUnit.test("Test replace unicode code to symbol", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["2601"]); - moveToParagraph(oParagraph, true); - moveCursorRight(true, true); - onKeyDown(oEvent); - oAssert.strictEqual(getSelectedText(), '☁', 'Test replace unicode code to symbol'); - }, oTestTypes.unicodeToChar); - }); - - QUnit.test("Test show context menu", (oAssert) => - { - startTest((oEvent) => - { - const {oParagraph} = getLogicDocumentWithParagraphs(["Hello Text"]); - moveToParagraph(oParagraph, true); - - oEvent = createNativeEvent(93, false, false, false, false); - executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - - AscCommon.AscBrowser.isOpera = true; - oEvent = createNativeEvent(57351, false, false, false, false); - executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - AscCommon.AscBrowser.isOpera = false; - - oEvent = createNativeEvent(121, false, true, false, false); - executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - }, oTestTypes.showContextMenu); - - }); - - QUnit.test("Test disable numlock", (oAssert) => - { - startTest((oEvent) => - { - oEvent = createNativeEvent(144, false, false, false, false); - onKeyDown(oEvent); - oAssert.strictEqual(oEvent.isDefaultPrevented, true, 'Test prevent default on numlock'); - }, oTestTypes.disableNumLock); - }); - - QUnit.test("Test disable scroll lock", (oAssert) => - { - startTest((oEvent) => - { - oEvent = createNativeEvent(145, false, false, false, false); - onKeyDown(oEvent); - oAssert.strictEqual(oEvent.isDefaultPrevented, true, 'Test prevent default on scroll lock'); - }, oTestTypes.disableScrollLock); - }); - - QUnit.test("Test add SJK test", (oAssert) => - { - startTest((oEvent) => - { - checkTextAfterKeyDownHelperEmpty(' ', oEvent, oAssert, 'Check add space after SJK space'); - }, oTestTypes.addSJKSpace); - }); + + CheckColumns(1); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertColumnBreak); + CheckColumns(2); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertColumnBreak); + CheckColumns(3); + + sectionPr.SetColumnsNum(1); + TurnOffRecalculate(); + }); + + QUnit.test('Check reset char shortcut', (assert) => + { + ClearDocumentAndAddParagraph('Hello world'); + logicDocument.SelectAll(); + ApplyTextPrToDocument({Bold: true, Italic: true, Underline: true}); + + let textPr = GetDirectTextPr(); + assert.true(true === textPr.GetBold() && true === textPr.GetItalic() && true === textPr.GetUnderline(), 'Check before reset'); + ExecuteShortcut(c_oAscDocumentShortcutType.ResetChar); + textPr = GetDirectTextPr(); + assert.true(undefined === textPr.GetBold() && undefined === textPr.GetItalic() && undefined === textPr.GetUnderline(), 'Check after reset'); + }); + + QUnit.test('Check adding various characters', (assert) => + { + let p = ClearDocumentAndAddParagraph(); + + ExecuteShortcut(c_oAscDocumentShortcutType.NonBreakingSpace); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0), 'Check add non breaking space'); + ExecuteShortcut(c_oAscDocumentShortcutType.CopyrightSign); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9), 'Check add CopyrightSign'); + ExecuteShortcut(c_oAscDocumentShortcutType.EuroSign); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC), 'Check add EuroSign'); + ExecuteShortcut(c_oAscDocumentShortcutType.RegisteredSign); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE), 'Check add RegisteredSign'); + ExecuteShortcut(c_oAscDocumentShortcutType.TrademarkSign); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122), 'Check add TrademarkSign'); + ExecuteShortcut(c_oAscDocumentShortcutType.EnDash); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013), 'Check add EnDash'); + ExecuteShortcut(c_oAscDocumentShortcutType.EmDash); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014), 'Check add EmDash'); + ExecuteShortcut(c_oAscDocumentShortcutType.NonBreakingHyphen); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D), 'Check add NonBreakingHyphen'); + ExecuteShortcut(c_oAscDocumentShortcutType.HorizontalEllipsis); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026), 'Check add HorizontalEllipsis'); + }); + + QUnit.test('Check changing text properties', (assert) => + { + ClearDocumentAndAddParagraph('Hello world'); + logicDocument.SelectAll(); + + ExecuteShortcut(c_oAscDocumentShortcutType.Bold); + assert.strictEqual(GetDirectTextPr().GetBold(), true, 'Check turn on bold'); + ExecuteShortcut(c_oAscDocumentShortcutType.Bold); + assert.strictEqual(GetDirectTextPr().GetBold(), false, 'Check turn off bold'); + + ExecuteShortcut(c_oAscDocumentShortcutType.Italic); + assert.strictEqual(GetDirectTextPr().GetItalic(), true, 'Check turn on italic'); + ExecuteShortcut(c_oAscDocumentShortcutType.Italic); + assert.strictEqual(GetDirectTextPr().GetItalic(), false, 'Check turn off italic'); + + ExecuteShortcut(c_oAscDocumentShortcutType.Strikeout); + assert.strictEqual(GetDirectTextPr().GetStrikeout(), true, 'Check turn on strikeout'); + ExecuteShortcut(c_oAscDocumentShortcutType.Strikeout); + assert.strictEqual(GetDirectTextPr().GetStrikeout(), false, 'Check turn off strikeout'); + + ExecuteShortcut(c_oAscDocumentShortcutType.Underline); + assert.strictEqual(GetDirectTextPr().GetUnderline(), true, 'Check turn on underline'); + ExecuteShortcut(c_oAscDocumentShortcutType.Underline); + assert.strictEqual(GetDirectTextPr().GetUnderline(), false, 'Check turn off underline'); + + ExecuteShortcut(c_oAscDocumentShortcutType.Superscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_SuperScript, 'Check turn on superscript'); + ExecuteShortcut(c_oAscDocumentShortcutType.Superscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off superscript'); + + // defaultSize = 10 + // 10 -> 11 -> 12 -> 14 -> 16 -> 14 -> 12 -> 11 -> 10 + ExecuteShortcut(c_oAscDocumentShortcutType.IncreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 11, 'Check increase font size'); + ExecuteShortcut(c_oAscDocumentShortcutType.IncreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 12, 'Check increase font size'); + ExecuteShortcut(c_oAscDocumentShortcutType.IncreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 14, 'Check increase font size'); + ExecuteShortcut(c_oAscDocumentShortcutType.IncreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 16, 'Check increase font size'); + + ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 14, 'Check decrease font size'); + ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 12, 'Check decrease font size'); + ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 11, 'Check decrease font size'); + ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 10, 'Check decrease font size'); + }); + + QUnit.test('Check select all shortcut', (assert) => + { + logicDocument.RemoveSelection(); + let p = ClearDocumentAndAddParagraph('Hello world'); + let table = AscTest.CreateTable(2, 2); + logicDocument.AddToContent(1, table); + assert.strictEqual(logicDocument.IsSelectionUse(), false, 'Check document selection'); + ExecuteShortcut(c_oAscDocumentShortcutType.EditSelectAll); + assert.strictEqual(logicDocument.IsSelectionUse(), true, 'Check document selection'); + assert.strictEqual(p.IsSelectedAll(), true, 'Check paragraph selection'); + assert.strictEqual(table.IsSelectedAll(), true, 'Check table selection'); + }); + + // + // QUnit.test('Check show non printing characters shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ShowAll}; + // editor.put_ShowParaMarks(false); + // onKeyDown(createNativeEvent()); + // oAssert.true(editor.get_ShowParaMarks(), 'Check show non printing characters shortcut'); + // }); + // + // + // + // QUnit.test('Check copy format shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.CopyFormat}; + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); + // oParagraph.SetThisElementCurrent(); + // oGlobalLogicDocument.SelectAll(); + // addPropertyToDocument({Bold: true, Italic: true, Underline: true}); + // + // onKeyDown(createNativeEvent()); + // const oCopyParagraphTextPr = new AscCommonWord.CTextPr(); + // oCopyParagraphTextPr.SetUnderline(true); + // oCopyParagraphTextPr.SetBold(true); + // oCopyParagraphTextPr.BoldCS = true; + // oCopyParagraphTextPr.SetItalic(true); + // oCopyParagraphTextPr.ItalicCS = true; + // oAssert.deepEqual(editor.getFormatPainterData().TextPr, oCopyParagraphTextPr, 'Check copy format shortcut'); + // }); + // + // + // QUnit.test('Check insert endnote shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertEndnoteNow}; + // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello']); + // oLogicDocument.SelectAll(); + // onKeyDown(createNativeEvent()); + // const arrEndnotes = oLogicDocument.GetEndnotesList(); + // oAssert.deepEqual(arrEndnotes.length, 1, 'Check insert endnote shortcut'); + // }); + // + // QUnit.test('Check center para shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.CenterPara}; + // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Center, 'Check center para shortcut', createNativeEvent(), oAssert); + // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); + // }); + // + // + // + // QUnit.test('Check justify para shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.JustifyPara}; + // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Justify, 'Check justify para shortcut', createNativeEvent(), oAssert); + // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check justify para shortcut', createNativeEvent(), oAssert); + // }); + // + // QUnit.test('Check bullet list shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyListBullet}; + // const {oLogicDocument, oParagraph} = getLogicDocumentWithParagraphs(['Hello']); + // oLogicDocument.SelectAll(); + // onKeyDown(createNativeEvent()); + // + // oAssert.true(oParagraph.IsBulletedNumbering(), 'check apply bullet list'); + // }); + // + // QUnit.test('Check left para shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.LeftPara}; + // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Justify, 'Check center para shortcut', createNativeEvent(), oAssert); + // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); + // }); + // + // QUnit.test('Check indent shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.Indent}; + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello']); + // oParagraph.Pr.SetInd(0, 0, 0); + // moveToParagraph(oParagraph, true); + // + // onKeyDown(createNativeEvent()); + // oAssert.strictEqual(directParaPr().GetIndLeft(), 12.5, 'Check increase indent'); + // }); + // + // QUnit.test('Check unindent shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.UnIndent}; + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello']); + // oParagraph.Pr.SetInd(0, 12.5, 0); + // moveToParagraph(oParagraph, true); + // + // onKeyDown(createNativeEvent()); + // oAssert.true(AscFormat.fApproxEqual(directParaPr().GetIndLeft(), 0), 'Check decrease indent'); + // }); + // + // QUnit.test('Check insert page number shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertPageNumber}; + // checkInsertElementByType(para_PageNum, 'Check insert page number shortcut', oAssert, createNativeEvent()); + // }); + // + // QUnit.test('Check right para shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.RightPara}; + // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Right, 'Check center para shortcut', createNativeEvent(), oAssert); + // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); + // }); + // + // + // + // QUnit.test('Check paste format shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.PasteFormat}; + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); + // oParagraph.SetThisElementCurrent(); + // oGlobalLogicDocument.SelectAll(); + // addPropertyToDocument({Bold: true, Italic: true}); + // oGlobalLogicDocument.Document_Format_Copy(); + // remove(); + // addParagraphToDocumentWithText('Hello'); + // oGlobalLogicDocument.SelectAll(); + // onKeyDown(createNativeEvent()); + // const oDirectTextPr = directTextPr(); + // oAssert.true(oDirectTextPr.Get_Bold() && oDirectTextPr.Get_Italic(), 'Check paste format shortcut'); + // }); + // + // QUnit.test('Check redo shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditRedo}; + // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello World']); + // oLogicDocument.SelectAll(); + // oLogicDocument.Remove(undefined, undefined, true); + // oLogicDocument.Document_Undo(); + // onKeyDown(createNativeEvent()); + // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), '', 'Check redo shortcut'); + // }); + // + // QUnit.test('Check undo shortcut', (oAssert) => + // { + // getLogicDocumentWithParagraphs(['Hello World']); + // selectAll(); + // editor.asc_Remove(); + // + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditUndo}; + // onKeyDown(createNativeEvent()); + // selectAll(); + // oAssert.strictEqual(getSelectedText(), 'Hello World', 'Check redo shortcut'); + // }); + // + // + // QUnit.test('Check update fields shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.UpdateFields}; + // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello', 'Hello', 'Hello'], true); + // for (let i = 0; i < logicContent().length; i += 1) + // { + // oLogicDocument.Set_CurrentElement(i, true); + // oLogicDocument.SetParagraphStyle("Heading 1"); + // } + // oLogicDocument.MoveCursorToStartPos(); + // const props = new Asc.CTableOfContentsPr(); + // props.put_OutlineRange(1, 9); + // props.put_Hyperlink(true); + // props.put_ShowPageNumbers(true); + // props.put_RightAlignTab(true); + // props.put_TabLeader(Asc.c_oAscTabLeader.Dot); + // editor.asc_AddTableOfContents(null, props); + // + // oLogicDocument.MoveCursorToEndPos(); + // const oParagraph = createParagraphWithText('Hello'); + // oLogicDocument.AddToContent(logicContent().length, oParagraph); + // moveToParagraph(oParagraph); + // oLogicDocument.SetParagraphStyle("Heading 1"); + // + // logicContent()[0].SetThisElementCurrent(); + // onKeyDown(createNativeEvent()); + // oAssert.strictEqual(logicContent()[0].Content.Content.length, 5, 'Check update fields shortcut'); + // }); + // + // + // QUnit.test('Check show hyperlink menu shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertHyperlink}; + // executeTestWithCatchEvent('asc_onDialogAddHyperlink', () => true, true, createNativeEvent(), oAssert, () => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); + // moveToParagraph(oParagraph); + // oGlobalLogicDocument.SelectAll(); + // }); + // }); + // + // QUnit.test('Check print shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.PrintPreviewAndPrint}; + // executeTestWithCatchEvent('asc_onPrint', () => true, true, createNativeEvent(), oAssert); + // }); + // + // QUnit.test('Check save shortcut', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.Save}; + // const fOldSave = editor._onSaveCallbackInner; + // let bCheck = false; + // editor._onSaveCallbackInner = function () + // { + // bCheck = true; + // editor.canSave = true; + // }; + // onKeyDown(createNativeEvent()); + // oAssert.strictEqual(bCheck, true, 'Check save shortcut'); + // editor._onSaveCallbackInner = fOldSave; + // }); + // + // + // QUnit.test('Check apply heading 1', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading1}; + // checkApplyParagraphStyle('Heading 1', 'Check apply heading 1 shortcut', createNativeEvent(), oAssert); + // }); + // QUnit.test('Check apply heading 2', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading2}; + // checkApplyParagraphStyle('Heading 2', 'Check apply heading 2 shortcut', createNativeEvent(), oAssert); + // }); + // + // QUnit.test('Check apply heading 3', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading3}; + // checkApplyParagraphStyle('Heading 3', 'Check apply heading 3 shortcut', createNativeEvent(), oAssert); + // }); + // + // QUnit.test('Check insert footnotes now', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertFootnoteNow}; + // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello']); + // oLogicDocument.SelectAll(); + // onKeyDown(createNativeEvent()); + // const arrFootnotes = oLogicDocument.GetFootnotesList(); + // oAssert.deepEqual(arrFootnotes.length, 1, 'Check insert footnote shortcut'); + // }); + // + // QUnit.test('Check insert equation', (oAssert) => + // { + // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertEquation}; + // const {oLogicDocument} = getLogicDocumentWithParagraphs(['']); + // onKeyDown(createNativeEvent()); + // const oMath = oLogicDocument.GetCurrentMath(); + // oAssert.true(!!oMath, 'Check insert equation shortcut'); + // }); + // + // QUnit.module("Test getting desired action by event") + // QUnit.test("Test getting common desired action by event", (oAssert) => + // { + // editor.initDefaultShortcuts(); + // oAssert.strictEqual(editor.getShortcut(createEvent(13, true, false, false, false, false, false)), c_oAscDocumentShortcutType.InsertPageBreak, 'Check getting c_oAscDocumentShortcutType.InsertPageBreak action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(13, false, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertLineBreak, 'Check getting c_oAscDocumentShortcutType.InsertLineBreak action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(13, true, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertColumnBreak, 'Check getting c_oAscDocumentShortcutType.InsertColumnBreak action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(32, true, false, false, false, false, false)), c_oAscDocumentShortcutType.ResetChar, 'Check getting c_oAscDocumentShortcutType.ResetChar action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(32, true, true, false, false, false, false)), c_oAscDocumentShortcutType.NonBreakingSpace, 'Check getting c_oAscDocumentShortcutType.NonBreakingSpace action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(53, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Strikeout, 'Check getting c_oAscDocumentShortcutType.Strikeout action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(56, true, true, false, false, false, false)), c_oAscDocumentShortcutType.ShowAll, 'Check getting c_oAscDocumentShortcutType.ShowAll action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(65, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditSelectAll, 'Check getting c_oAscDocumentShortcutType.EditSelectAll action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(66, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Bold, 'Check getting c_oAscDocumentShortcutType.Bold action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(67, true, false, true, false, false, false)), c_oAscDocumentShortcutType.CopyFormat, 'Check getting c_oAscDocumentShortcutType.CopyFormat action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(71, true, false, true, false, false, false)), c_oAscDocumentShortcutType.CopyrightSign, 'Check getting c_oAscDocumentShortcutType.CopyrightSign action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(68, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEndnoteNow, 'Check getting c_oAscDocumentShortcutType.InsertEndnoteNow action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(69, true, false, false, false, false, false)), c_oAscDocumentShortcutType.CenterPara, 'Check getting c_oAscDocumentShortcutType.CenterPara action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(69, true, false, true, false, false, false)), c_oAscDocumentShortcutType.EuroSign, 'Check getting c_oAscDocumentShortcutType.EuroSign action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(73, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Italic, 'Check getting c_oAscDocumentShortcutType.Italic action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(74, true, false, false, false, false, false)), c_oAscDocumentShortcutType.JustifyPara, 'Check getting c_oAscDocumentShortcutType.JustifyPara action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(75, true, false, false, false, false, false)), c_oAscDocumentShortcutType.InsertHyperlink, 'Check getting c_oAscDocumentShortcutType.InsertHyperlink action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(76, true, true, false, false, false, false)), c_oAscDocumentShortcutType.ApplyListBullet, 'Check getting c_oAscDocumentShortcutType.ApplyListBullet action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(76, true, false, false, false, false, false)), c_oAscDocumentShortcutType.LeftPara, 'Check getting c_oAscDocumentShortcutType.LeftPara action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(77, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Indent, 'Check getting c_oAscDocumentShortcutType.Indent action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(77, true, true, false, false, false, false)), c_oAscDocumentShortcutType.UnIndent, 'Check getting c_oAscDocumentShortcutType.UnIndent action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(80, true, false, false, false, false, false)), c_oAscDocumentShortcutType.PrintPreviewAndPrint, 'Check getting c_oAscDocumentShortcutType.PrintPreviewAndPrint action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(80, true, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertPageNumber, 'Check getting c_oAscDocumentShortcutType.InsertPageNumber action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(82, true, false, false, false, false, false)), c_oAscDocumentShortcutType.RightPara, 'Check getting c_oAscDocumentShortcutType.RightPara action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(82, true, false, true, false, false, false)), c_oAscDocumentShortcutType.RegisteredSign, 'Check getting c_oAscDocumentShortcutType.RegisteredSign action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(83, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Save, 'Check getting c_oAscDocumentShortcutType.Save action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(84, true, false, true, false, false, false)), c_oAscDocumentShortcutType.TrademarkSign, 'Check getting c_oAscDocumentShortcutType.TrademarkSign action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(85, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Underline, 'Check getting c_oAscDocumentShortcutType.Underline action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(86, true, false, true, false, false, false)), c_oAscDocumentShortcutType.PasteFormat, 'Check getting c_oAscDocumentShortcutType.PasteFormat action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(89, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditRedo, 'Check getting c_oAscDocumentShortcutType.EditRedo action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(90, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditUndo, 'Check getting c_oAscDocumentShortcutType.EditUndo action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(109, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EnDash, 'Check getting c_oAscDocumentShortcutType.EnDash action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(109, true, false, true, false, false, false)), c_oAscDocumentShortcutType.EmDash, 'Check getting c_oAscDocumentShortcutType.EmDash action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(120, false, false, false, false, false, false)), c_oAscDocumentShortcutType.UpdateFields, 'Check getting c_oAscDocumentShortcutType.UpdateFields action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(188, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Superscript, 'Check getting c_oAscDocumentShortcutType.Superscript action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(189, true, true, false, false, false, false)), c_oAscDocumentShortcutType.NonBreakingHyphen, 'Check getting c_oAscDocumentShortcutType.NonBreakingHyphen action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(190, true, false, true, false, false, false)), c_oAscDocumentShortcutType.HorizontalEllipsis, 'Check getting c_oAscDocumentShortcutType.HorizontalEllipsis action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(190, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Subscript, 'Check getting c_oAscDocumentShortcutType.Subscript action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(219, true, false, false, false, false, false)), c_oAscDocumentShortcutType.DecreaseFontSize, 'Check getting c_oAscDocumentShortcutType.DecreaseFontSize action'); + // oAssert.strictEqual(editor.getShortcut(createEvent(221, true, false, false, false, false, false)), c_oAscDocumentShortcutType.IncreaseFontSize, 'Check getting c_oAscDocumentShortcutType.IncreaseFontSize action'); + // editor.Shortcuts = new AscCommon.CShortcuts(); + // }); + // + // QUnit.test("Test getting windows desired action by event", (oAssert) => + // { + // editor.initDefaultShortcuts(); + // oAssert.strictEqual(editor.getShortcut(createEvent(49, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading1, 'Check getting c_oAscDocumentShortcutType.ApplyHeading1 shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(50, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading2, 'Check getting c_oAscDocumentShortcutType.ApplyHeading2 shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(51, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading3, 'Check getting c_oAscDocumentShortcutType.ApplyHeading3 shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(70, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertFootnoteNow, 'Check getting c_oAscDocumentShortcutType.InsertFootnoteNow shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(187, false, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEquation, 'Check getting c_oAscDocumentShortcutType.InsertEquation shortcut type'); + // editor.Shortcuts = new AscCommon.CShortcuts(); + // }); + // + // QUnit.test("Test getting macOs desired action by event", (oAssert) => + // { + // const bOldMacOs = AscCommon.AscBrowser.isMacOs; + // AscCommon.AscBrowser.isMacOs = true; + // editor.initDefaultShortcuts(); + // oAssert.strictEqual(editor.getShortcut(createEvent(49, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading1, 'Check getting c_oAscDocumentShortcutType.ApplyHeading1 shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(50, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading2, 'Check getting c_oAscDocumentShortcutType.ApplyHeading2 shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(51, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading3, 'Check getting c_oAscDocumentShortcutType.ApplyHeading3 shortcut type'); + // oAssert.strictEqual(editor.getShortcut(createEvent(187, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEquation, 'Check getting c_oAscDocumentShortcutType.InsertEquation shortcut type'); + // editor.Shortcuts = new AscCommon.CShortcuts(); + // AscCommon.AscBrowser.isMacOs = bOldMacOs; + // }); + // + // QUnit.module('Test hotkeys module', { + // afterEach: function () + // { + // resetLogicDocument(oGlobalLogicDocument); + // } + // }) + // QUnit.test("test remove back symbol", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // selectAll(); + // oAssert.strictEqual(getSelectedText(), 'Hello Worl', 'Test remove back symbol'); + // }, oTestTypes.removeBackSymbol); + // }); + // + // QUnit.test("test remove back word", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // selectAll(); + // oAssert.strictEqual(getSelectedText(), 'Hello ', 'Test remove back word'); + // }, oTestTypes.removeBackWord); + // }); + // + // QUnit.test("test remove shape", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs([''], true); + // moveToParagraph(oParagraph); + // const oDrawing = createShape(); + // selectParaDrawing(oDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(oParagraph.GetRunByElement(oDrawing), null, 'Test remove shape'); + // }, oTestTypes.removeShape); + // }); + // + // QUnit.test("test remove form", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['']); + // moveToParagraph(oParagraph); + // const oInlineLvlSdt = createComboBox(); + // onKeyDown(oEvent); + // oAssert.strictEqual(oParagraph.GetPosByElement(oInlineLvlSdt), null, 'Test remove form'); + // }, oTestTypes.removeForm); + // }); + // + // + // QUnit.test("test move to next form", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs(['']); + // const oInlineSdt1 = createComboBox(); + // moveCursorRight(); + // const oInlineSdt2 = createComboBox(); + // moveCursorRight(); + // const oInlineSdt3 = createComboBox(); + // setFillingFormsMode(true); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt1, 'Test move to next form'); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt2, 'Test move to next form'); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt3, 'Test move to next form'); + // + // setFillingFormsMode(false); + // }, oTestTypes.moveToNextForm); + // }); + // + // + // QUnit.test("test move to previous form", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['']); + // const oInlineSdt1 = createComboBox(); + // moveCursorRight(); + // const oInlineSdt2 = createComboBox(); + // moveCursorRight(); + // const oInlineSdt3 = createComboBox(); + // setFillingFormsMode(true); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt2, 'Test move to next form'); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt1, 'Test move to next form'); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt3, 'Test move to next form'); + // + // setFillingFormsMode(false); + // }, oTestTypes.moveToPreviousForm); + // }); + // + // + // + // QUnit.test("Test handle tab in math", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs([''], true); + // createMath(); + // addText('abcd+abcd+abcd'); + // moveToParagraph(oParagraph); + // moveCursorLeft(); + // moveCursorLeft(); + // moveCursorLeft(); + // moveCursorLeft(); + // moveCursorLeft(); + // insertManualBreak(); + // onKeyDown(oEvent); + // moveCursorRight(); + // const oContentPosition = oGlobalLogicDocument.GetContentPosition(); + // const oCurRun = oContentPosition[oContentPosition.length - 1].Class; + // + // oAssert.strictEqual(oCurRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); + // }, oTestTypes.handleTab); + // }); + // + // QUnit.test("test move to cell", (oAssert) => + // { + // startTest((oEvent) => + // { + // const oTable = createTable(3, 3); + // moveToTable(oTable, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(oTable.CurCell.Index, 1, 'Test move to next cell'); + // }, oTestTypes.moveToNextCell); + // }); + // + // QUnit.test("test move to cell", (oAssert) => + // { + // startTest((oEvent) => + // { + // const oTable = createTable(3, 3); + // moveToTable(oTable, true); + // moveCursorRight(); + // onKeyDown(oEvent); + // oAssert.strictEqual(oTable.CurCell.Index, 0, 'Test move to previous cell'); + // }, oTestTypes.moveToPreviousCell); + // }); + // + // QUnit.test("test select next object", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const oFirstParaDrawing = createShape(); + // const oSecondParaDrawing = createShape(); + // selectParaDrawing(oFirstParaDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oSecondParaDrawing.GraphicObj, true, 'Test select next object'); + // + // }, oTestTypes.selectNextObject); + // }); + // + // QUnit.test("test select previous object", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const oFirstParaDrawing = createShape(); + // const oSecondParaDrawing = createShape(); + // const oThirdParaDrawing = createShape(); + // selectParaDrawing(oFirstParaDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oThirdParaDrawing.GraphicObj, true, 'Test select previous object'); + // onKeyDown(oEvent); + // oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oSecondParaDrawing.GraphicObj, true, 'Test select previous object'); + // }, oTestTypes.selectPreviousObject); + // }); + // + // QUnit.test("test indent", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs(['Hello world', "Hello world"]); + // const oFirstParagraph = logicContent()[0]; + // const oSecondParagraph = logicContent()[1]; + // selectAll(); + // onKeyDown(oEvent); + // let arrSteps = []; + // moveToParagraph(oFirstParagraph); + // arrSteps.push(directParaPr().GetIndLeft()); + // moveToParagraph(oSecondParagraph); + // arrSteps.push(directParaPr().GetIndLeft()); + // oAssert.deepEqual(arrSteps, [12.5, 12.5], 'Test indent'); + // + // moveToParagraph(oFirstParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(); + // }, oTestTypes.testIndent); + // }); + // + // QUnit.test("test unindent", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs(['hello', 'hello']); + // const oFirstParagraph = logicContent()[0]; + // const oSecondParagraph = logicContent()[1]; + // oFirstParagraph.Set_Ind({Left: 12.5}); + // oSecondParagraph.Set_Ind({Left: 12.5}); + // selectAll(); + // onKeyDown(oEvent); + // + // const arrSteps = []; + // moveToParagraph(oFirstParagraph); + // arrSteps.push(directParaPr().GetIndLeft()); + // moveToParagraph(oSecondParagraph); + // arrSteps.push(directParaPr().GetIndLeft()); + // + // oAssert.deepEqual(arrSteps, [0, 0], 'Test unindent'); + // }, oTestTypes.testUnIndent); + // }); + // + // + // QUnit.test("test add tab to paragraph", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); + // moveToParagraph(oParagraph, true); + // moveCursorRight(); + // onKeyDown(oEvent); + // selectAll(); + // + // oAssert.strictEqual(getSelectedText(), 'H\tello World', 'Test indent'); + // }, oTestTypes.addTabToParagraph); + // }); + // + // QUnit.test("test visit hyperlink", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['']); + // addBreakPage(); + // createHyperlink(); + // moveCursorLeft(); + // moveCursorLeft(); + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetCurrentParagraph(), logicContent()[0]); + // oAssert.strictEqual(oGlobalLogicDocument.Get_CurPage(), 0); + // }, oTestTypes.visitHyperlink); + // }); + // + // QUnit.test("Test add break line to inlinelvlsdt", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const oInlineSdt = createComplexForm(); + // onKeyDown(oEvent); + // oAssert.strictEqual(oInlineSdt.Lines[0], 2); + // }, oTestTypes.addBreakLineInlineLvlSdt); + // }); + // + // QUnit.test("Test create textBoxContent", (oAssert) => + // { + // startTest((oEvent) => + // { + // const oParaDrawing = createShape(); + // selectParaDrawing(oParaDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(!!oParaDrawing.GraphicObj.textBoxContent, true); + // }, oTestTypes.createTextBoxContent); + // }); + // + // QUnit.test("Test create txBody", (oAssert) => + // { + // startTest((oEvent) => + // { + // const oParaDrawing = createShape(); + // oParaDrawing.GraphicObj.setWordShape(false); + // selectParaDrawing(oParaDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(!!oParaDrawing.GraphicObj.txBody, true); + // }, oTestTypes.createTextBody); + // }); + // + // QUnit.test("Test add new line to math", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['']); + // createMath(c_oAscMathType.FractionVertical); + // moveCursorLeft(); + // moveCursorLeft(); + // addText('Hello'); + // moveCursorLeft(); + // moveCursorLeft(); + // onKeyDown(oEvent); + // const oParaMath = oParagraph.GetAllParaMaths()[0]; + // const oFraction = oParaMath.Root.GetFirstElement(); + // const oNumerator = oFraction.getNumerator(); + // const oEqArray = oNumerator.GetFirstElement(); + // oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); + // }, oTestTypes.addNewLineToMath); + // }); + // + // QUnit.test("Test move cursor to start position shape", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const oParaDrawing = createShape(); + // const oShape = oParaDrawing.GraphicObj; + // oShape.createTextBoxContent(); + // selectParaDrawing(oParaDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(oShape.getDocContent().IsCursorAtBegin(), true); + // }, oTestTypes.moveCursorToStartPositionShapeEnter); + // }); + // + // QUnit.test("Test select all in shape", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true) + // const oParaDrawing = createShape(); + // const oShape = oParaDrawing.GraphicObj; + // oShape.createTextBoxContent(); + // moveToParagraph(oShape.getDocContent().Content[0]); + // addText('Hello'); + // selectParaDrawing(oParaDrawing); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'Hello'); + // }, oTestTypes.selectAllShapeEnter); + // }); + // + // QUnit.test("Test move cursor to start position chart title", (oAssert) => + // { + // startTest((oEvent) => + // { + // const oParaDrawing = createChart(); + // const oChart = oParaDrawing.GraphicObj; + // const oTitles = oChart.getAllTitles(); + // const oContent = AscFormat.CreateDocContentFromString('', drawingObjects().getDrawingDocument(), oTitles[0].txBody); + // oTitles[0].txBody.content = oContent; + // selectParaDrawing(oParaDrawing); + // + // const oController = drawingObjects(); + // oController.selection.chartSelection = oChart; + // oChart.selectTitle(oTitles[0], 0); + // + // onKeyDown(oEvent); + // oAssert.true(oContent.IsCursorAtBegin(), 'Check move cursor to begin pos in title'); + // }, oTestTypes.moveCursorToStartPositionTitleEnter); + // }); + // + // QUnit.test("Test select all in chart title", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const oParaDrawing = createChart(); + // const oChart = oParaDrawing.GraphicObj; + // selectParaDrawing(oParaDrawing); + // const oTitles = oChart.getAllTitles(); + // const oController = drawingObjects(); + // oController.selection.chartSelection = oChart; + // oChart.selectTitle(oTitles[0], 0); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'Diagram Title', 'Check select all title'); + // }, oTestTypes.selectAllInChartTitle); + // }); + // + // QUnit.test("Test add new paragraph", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Text']); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph to content'); + // }, oTestTypes.addNewParagraphContent); + // }); + // + // QUnit.test("Test add new paragraph", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs(['']); + // createMath(); + // addText('abcd'); + // moveCursorLeft(); + // onKeyDown(oEvent); + // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph with math'); + // }, oTestTypes.addNewParagraphMath); + // }); + // + // QUnit.test("Test close all window popups", (oAssert) => + // { + // startTest((oEvent) => + // { + // executeTestWithCatchEvent('asc_onMouseMoveStart', () => true, true, oEvent, oAssert); + // executeTestWithCatchEvent('asc_onMouseMove', () => true, true, oEvent, oAssert); + // executeTestWithCatchEvent('asc_onMouseMoveEnd', () => true, true, oEvent, oAssert); + // }, oTestTypes.closeAllWindowsPopups); + // }); + // + // QUnit.test("Test reset shape selection", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const arrDrawings = [createShape(), createShape()]; + // const oGroup = createGroup(arrDrawings); + // const oChart = createChart(); + // selectOnlyObjects([oChart, oGroup, arrDrawings[0]]); + // onKeyDown(oEvent); + // oAssert.strictEqual(drawingObjects().getSelectedArray().length, 0, "Test reset shape selection"); + // }, oTestTypes.resetShapeSelection); + // }); + // + // QUnit.test("Test reset add shape", (oAssert) => + // { + // startTest((oEvent) => + // { + // editor.StartAddShape('rect'); + // onKeyDown(oEvent); + // oAssert.strictEqual(editor.isStartAddShape, false, "Test reset add shape"); + // }, oTestTypes.resetStartAddShape); + // }); + // + // QUnit.test("Test reset formatting by example", (oAssert) => + // { + // startTest((oEvent) => + // { + // editor.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOn); + // onKeyDown(oEvent); + // oAssert.strictEqual(editor.isFormatPainterOn(), false, "Test reset formatting by example"); + // }, oTestTypes.resetFormattingByExample); + // }); + // + // QUnit.test("Test reset", (oAssert) => + // { + // startTest((oEvent) => + // { + // editor.SetMarkerFormat(true, true, 0, 0, 0); + // onKeyDown(oEvent); + // oAssert.strictEqual(editor.isMarkerFormat, false, "Test reset marker"); + // }, oTestTypes.resetMarkerFormat); + // + // }); + // + // QUnit.test("Test reset drag'n'drop", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Hello'], true); + // moveToParagraph(oParagraph, true); + // moveCursorRight(true, true); + // mouseDown(5, 10, 0, false, 1); + // mouseMove(35, 10, 0, false, 1); + // onKeyDown(oEvent); + // oAssert.strictEqual(editor.WordControl.m_oDrawingDocument.IsTrackText(), false, "Test reset drag'n'drop"); + // mouseUp(35, 10, 0, false, 1); + // }, oTestTypes.resetDragNDrop); + // }); + // + // QUnit.test("Test end editing form", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs([''], true); + // const oCheckBox = createCheckBox(); + // oCheckBox.MoveCursorToContentControl(true); + // setFillingFormsMode(true); + // onKeyDown(oEvent); + // const oSelectedInfo = oGlobalLogicDocument.GetSelectedElementsInfo(); + // oAssert.strictEqual(!!oSelectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); + // setFillingFormsMode(false); + // + // editor.GoToHeader(0); + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); + // editor.asc_RemoveHeader(0); + // + // editor.GoToFooter(0); + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); + // editor.asc_RemoveFooter(0); + // }, oTestTypes.endEditing); + // }); + // + // QUnit.test("Test toggle checkbox", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs(['']); + // const oInlineSdt = createCheckBox(); + // setFillingFormsMode(true); + // onKeyDown(oEvent); + // oAssert.strictEqual(oInlineSdt.IsCheckBoxChecked(), true); + // setFillingFormsMode(false); + // }, oTestTypes.toggleCheckBox); + // }); + // + // QUnit.test("Test actions to page up", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 125); + // }, oTestTypes.moveToPreviousPage); + // }); + // + // QUnit.test("Test actions to page up", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 90); + // }, oTestTypes.moveToStartPreviousPage); + // }); + // + // QUnit.test("Test move to previous header or footer", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // editor.GoToHeader(2); + // editor.GoToFooter(2); + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[2].Header); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Footer); + // }, oTestTypes.moveToPreviousHeaderFooter); + // editor.asc_RemoveHeader(2); + // editor.asc_RemoveFooter(2); + // }); + // + // QUnit.test("Test actions to page up", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // + // editor.GoToHeader(2); + // editor.GoToFooter(2); + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[0].Header); + // }, oTestTypes.moveToPreviousHeader); + // editor.asc_RemoveHeader(2); + // editor.asc_RemoveFooter(2); + // }); + // function drawingDocument() + // { + // return editor.WordControl.m_oDrawingDocument; + // } + // QUnit.test("Test select to previous page", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), ' World Hello World Hello World Hello World Hello World Hello World Hello World Hello World'); + // }, oTestTypes.selectToPreviousPage); + // }); + // + // + // QUnit.test("Test select to start previous page", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World'); + // }, oTestTypes.selectToStartPreviousPage); + // }); + // + // QUnit.test("Test select to start of next page", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello ', "Test select to begin of next page"); + // }, oTestTypes.selectToStartNextPage); + // }); + // QUnit.test("Test move to start of next page", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 90, "Test move to begin of next page"); + // }, oTestTypes.moveToStartNextPage); + // }); + // QUnit.test("Test select to next page", (oAssert) => + // { + // startTest((oEvent) => + // { + // + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // moveCursorRight(); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello W', "Test select to next page"); + // }, oTestTypes.selectToNextPage); + // }); + // QUnit.test("Test move to next page", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // moveCursorRight(); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 91, "Test move to next page"); + // }, oTestTypes.moveToNextPage); + // }); + // QUnit.test("Test move to next header/footer", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // editor.GoToFooter(0); + // editor.GoToHeader(0); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[0].Footer); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); + // }, oTestTypes.moveToNextHeaderFooter); + // }); + // QUnit.test("Test move to next header", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // editor.GoToFooter(0); + // editor.GoToHeader(0); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); + // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[2].Header); + // }, oTestTypes.moveToNextHeader); + // }); + // + // QUnit.test("Test actions to end", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 107, "Test move to end of document"); + // }, oTestTypes.moveToEndDocument); + // }); + // + // QUnit.test("Test actions to end", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 18, "Test move to end of line"); + // }, oTestTypes.moveToEndLine); + // }); + // + // QUnit.test("Test actions to end", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), "Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World", "Test select to end of document"); + // + // }, oTestTypes.selectToEndDocument); + // }); + // + // QUnit.test("Test actions to end", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), "Hello World Hello ", "Test select to end of line"); + // }, oTestTypes.selectToEndLine); + // }); + // + // QUnit.test("Test actions to home", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), "World Hello World", "Test select to home of line"); + // }, oTestTypes.selectToStartLine); + // }); + // + // QUnit.test("Test actions to home", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), "Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World", "Test select to home of document"); + // + // }, oTestTypes.selectToStartDocument); + // + // }); + // + // QUnit.test("Test actions to home", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 90, "Test move to home of line"); + // }, oTestTypes.moveToStartLine); + // }); + // + // QUnit.test("Test actions to home", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 0, "Test move to home of document"); + // }, oTestTypes.moveToStartDocument); + // }); + // + // QUnit.test("Test actions to left", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'World', "Test select to previous word"); + // }, oTestTypes.selectLeftWord); + // }); + // + // QUnit.test("Test actions to left", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 18, "Test move to previous word"); + // }, oTestTypes.moveToLeftWord); + // let oEvent; + // }); + // + // QUnit.test("Test actions to left", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'd', "Test select to previous symbol"); + // }, oTestTypes.selectLeftSymbol); + // }); + // + // QUnit.test("Test actions to left", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); + // moveToParagraph(oParagraph); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 22, "Test move to previous symbol"); + // }, oTestTypes.moveToLeftChar); + // }); + // + // QUnit.test("Test actions to left", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(-1, 0, oAssert, oEvent); + // }, oTestTypes.littleMoveGraphicObjectLeft); + // }); + // + // QUnit.test("Test actions to left", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(-5, 0, oAssert, oEvent); + // }, oTestTypes.bigMoveGraphicObjectLeft); + // }); + // + // QUnit.test("Test actions to right", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(1, 0, oAssert, oEvent); + // }, oTestTypes.littleMoveGraphicObjectRight); + // }); + // + // QUnit.test("Test actions to right", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(5, 0, oAssert, oEvent); + // }, oTestTypes.bigMoveGraphicObjectRight); + // }); + // + // QUnit.test("Test actions to up", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(0, -1, oAssert, oEvent); + // }, oTestTypes.littleMoveGraphicObjectUp); + // }); + // + // QUnit.test("Test actions to up", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(0, -5, oAssert, oEvent); + // }, oTestTypes.bigMoveGraphicObjectUp); + // }); + // + // QUnit.test("Test actions to down", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(0, 1, oAssert, oEvent); + // }, oTestTypes.littleMoveGraphicObjectDown); + // }); + // + // QUnit.test("Test actions to down", (oAssert) => + // { + // startTest((oEvent) => + // { + // moveShapeHelper(0, 5, oAssert, oEvent); + // }, oTestTypes.bigMoveGraphicObjectDown); + // }); + // + // QUnit.test("Test actions to right", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(contentPosition(), 1, "Test move to next symbol"); + // }, oTestTypes.moveToRightChar); + // }); + // + // QUnit.test("Test actions to right", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), "H", "Test select to next symbol"); + // }, oTestTypes.selectRightChar); + // }); + // + // QUnit.test("Test actions to right", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.deepEqual(contentPosition(), 6, "Test move to next word"); + // }, oTestTypes.moveToRightWord); + // }); + // + // QUnit.test("Test actions to right", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'Hello ', "Test select to next word"); + // }, oTestTypes.selectRightWord); + // }); + // + // QUnit.test("Test actions to up", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // moveCursorDown(); + // onKeyDown(oEvent); + // oAssert.deepEqual(contentPosition(), 0, "Test move to upper line"); + // }, oTestTypes.moveUp); + // }); + // + // QUnit.test("Test actions to up", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // moveCursorDown(); + // oEvent = createNativeEvent(38, false, true, false, false); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'Hello World Hello ', "Test select to upper line"); + // }, oTestTypes.selectUp); + // }); + // + // QUnit.test("Test actions to up", (oAssert) => + // { + // startTest((oEvent) => + // { + // clean(); + // getLogicDocumentWithParagraphs(['']); + // createComboBox(); + // setFillingFormsMode(true); + // onKeyDown(oEvent); + // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'Hello', "Test select previous option in combo box"); + // + // onKeyDown(oEvent); + // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'yo', "Test select previous option in combo box"); + // setFillingFormsMode(false); + // }, oTestTypes.previousOptionComboBox); + // }); + // + // QUnit.test("Test actions to down", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.deepEqual(contentPosition(), 18, "Test move to down line"); + // }, oTestTypes.moveDown); + // }); + // + // QUnit.test("Test actions to down", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), 'Hello World Hello ', "Test select to down line"); + // }, oTestTypes.selectDown); + // }); + // + // QUnit.test("Test actions to down", (oAssert) => + // { + // startTest((oEvent) => + // { + // clean(); + // getLogicDocumentWithParagraphs(['']); + // createComboBox(); + // setFillingFormsMode(true); + // onKeyDown(oEvent); + // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'Hello', "Test select next option in combo box"); + // onKeyDown(oEvent); + // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'World', "Test select next option in combo box"); + // setFillingFormsMode(false); + // }, oTestTypes.nextOptionComboBox); + // }); + // + // QUnit.test("Test remove front", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World"]); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // selectAll(); + // oAssert.strictEqual(getSelectedText(), 'ello World', 'Test remove front symbol'); + // }, oTestTypes.removeFrontSymbol); + // }); + // + // QUnit.test("Test remove front", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World"]); + // moveToParagraph(oParagraph, true); + // onKeyDown(oEvent); + // selectAll(); + // oAssert.strictEqual(getSelectedText(), 'World', 'Test remove front word'); + // }, oTestTypes.removeFrontWord); + // }); + // + // QUnit.test("Test replace unicode code to symbol", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["2601"]); + // moveToParagraph(oParagraph, true); + // moveCursorRight(true, true); + // onKeyDown(oEvent); + // oAssert.strictEqual(getSelectedText(), '☁', 'Test replace unicode code to symbol'); + // }, oTestTypes.unicodeToChar); + // }); + // + // QUnit.test("Test show context menu", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello Text"]); + // moveToParagraph(oParagraph, true); + // + // oEvent = createNativeEvent(93, false, false, false, false); + // executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); + // + // AscCommon.AscBrowser.isOpera = true; + // oEvent = createNativeEvent(57351, false, false, false, false); + // executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); + // AscCommon.AscBrowser.isOpera = false; + // + // oEvent = createNativeEvent(121, false, true, false, false); + // executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); + // }, oTestTypes.showContextMenu); + // + // }); + // + // QUnit.test("Test disable numlock", (oAssert) => + // { + // startTest((oEvent) => + // { + // oEvent = createNativeEvent(144, false, false, false, false); + // onKeyDown(oEvent); + // oAssert.strictEqual(oEvent.isDefaultPrevented, true, 'Test prevent default on numlock'); + // }, oTestTypes.disableNumLock); + // }); + // + // QUnit.test("Test disable scroll lock", (oAssert) => + // { + // startTest((oEvent) => + // { + // oEvent = createNativeEvent(145, false, false, false, false); + // onKeyDown(oEvent); + // oAssert.strictEqual(oEvent.isDefaultPrevented, true, 'Test prevent default on scroll lock'); + // }, oTestTypes.disableScrollLock); + // }); + // + // QUnit.test("Test add SJK test", (oAssert) => + // { + // startTest((oEvent) => + // { + // checkTextAfterKeyDownHelperEmpty(' ', oEvent, oAssert, 'Check add space after SJK space'); + // }, oTestTypes.addSJKSpace); + // }); }); })(window); From d6a15e11e15883c8ce8b4f0d00df6733bec6c95b Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Thu, 22 Jun 2023 02:46:43 +0500 Subject: [PATCH 02/23] [de] Refactor tests --- tests/word/shortcuts/shortcuts.js | 104 +++++++++++++++--------------- word/Editor/Sections.js | 5 ++ word/Editor/Styles.js | 11 ++-- 3 files changed, 64 insertions(+), 56 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index c640a1bade..e17c7d1fa2 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -39,8 +39,6 @@ // addPropertyToDocument, // getLogicDocumentWithParagraphs, // checkTextAfterKeyDownHelperEmpty, - // checkDirectTextPrAfterKeyDown, - // checkDirectParaPrAfterKeyDown, // oGlobalLogicDocument, // addParagraphToDocumentWithText, // remove, @@ -109,8 +107,9 @@ } function ClearDocumentAndAddParagraph(text) { - let p = AscTest.CreateParagraph(); + logicDocument.RemoveSelection(); AscTest.ClearDocument(); + let p = AscTest.CreateParagraph(); logicDocument.AddToContent(0, p); if (text) @@ -141,6 +140,10 @@ { return logicDocument.GetDirectTextPr(); } + function GetDirectParaPr() + { + return logicDocument.GetDirectParaPr(); + } $(function () { @@ -176,7 +179,7 @@ assert.strictEqual(logicDocument.GetPagesCount(), 4, 'Check page break shortcut'); TurnOffRecalculate(); }); - + QUnit.test('Check line break shortcut', (assert) => { TurnOnRecalculate(); @@ -189,7 +192,7 @@ assert.strictEqual(p.GetLinesCount(), 4, 'Check line break shortcut'); TurnOffRecalculate(); }); - + QUnit.test('Check column break shortcut', (assert) => { TurnOnRecalculate(); @@ -218,7 +221,7 @@ sectionPr.SetColumnsNum(1); TurnOffRecalculate(); }); - + QUnit.test('Check reset char shortcut', (assert) => { ClearDocumentAndAddParagraph('Hello world'); @@ -235,7 +238,7 @@ QUnit.test('Check adding various characters', (assert) => { let p = ClearDocumentAndAddParagraph(); - + ExecuteShortcut(c_oAscDocumentShortcutType.NonBreakingSpace); assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0), 'Check add non breaking space'); ExecuteShortcut(c_oAscDocumentShortcutType.CopyrightSign); @@ -256,7 +259,7 @@ assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026), 'Check add HorizontalEllipsis'); }); - QUnit.test('Check changing text properties', (assert) => + QUnit.test('Check text property change', (assert) => { ClearDocumentAndAddParagraph('Hello world'); logicDocument.SelectAll(); @@ -309,7 +312,6 @@ QUnit.test('Check select all shortcut', (assert) => { - logicDocument.RemoveSelection(); let p = ClearDocumentAndAddParagraph('Hello world'); let table = AscTest.CreateTable(2, 2); logicDocument.AddToContent(1, table); @@ -320,6 +322,47 @@ assert.strictEqual(table.IsSelectedAll(), true, 'Check table selection'); }); + QUnit.test('Check paragraph property change', (assert) => + { + let p = ClearDocumentAndAddParagraph('Hello world'); + function GetStyleName() + { + return logicDocument.GetStyleManager().GetName(p.GetParagraphStyle()); + } + + assert.strictEqual(GetStyleName(), "", "Check style"); + ExecuteShortcut(c_oAscDocumentShortcutType.ApplyHeading1); + assert.strictEqual(GetStyleName(), "Heading 1", "Check apply heading 1"); + ExecuteShortcut(c_oAscDocumentShortcutType.ApplyHeading2); + assert.strictEqual(GetStyleName(), "Heading 2", "Check apply heading 2"); + ExecuteShortcut(c_oAscDocumentShortcutType.ApplyHeading3); + assert.strictEqual(GetStyleName(), "Heading 3", "Check apply heading 3"); + + assert.strictEqual(GetDirectParaPr().GetJc(), undefined, "Check justification"); + ExecuteShortcut(c_oAscDocumentShortcutType.CenterPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Center, "Check turn on center para"); + ExecuteShortcut(c_oAscDocumentShortcutType.CenterPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off center para"); + + ExecuteShortcut(c_oAscDocumentShortcutType.JustifyPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); + ExecuteShortcut(c_oAscDocumentShortcutType.JustifyPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off justify para"); + + ExecuteShortcut(c_oAscDocumentShortcutType.JustifyPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); + ExecuteShortcut(c_oAscDocumentShortcutType.LeftPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn on left para"); + ExecuteShortcut(c_oAscDocumentShortcutType.LeftPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn off left para"); + + ExecuteShortcut(c_oAscDocumentShortcutType.RightPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Right, "Check turn on right para"); + ExecuteShortcut(c_oAscDocumentShortcutType.RightPara); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off right para"); + }); + + // // QUnit.test('Check show non printing characters shortcut', (oAssert) => // { @@ -360,21 +403,6 @@ // oAssert.deepEqual(arrEndnotes.length, 1, 'Check insert endnote shortcut'); // }); // - // QUnit.test('Check center para shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.CenterPara}; - // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Center, 'Check center para shortcut', createNativeEvent(), oAssert); - // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); - // }); - // - // - // - // QUnit.test('Check justify para shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.JustifyPara}; - // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Justify, 'Check justify para shortcut', createNativeEvent(), oAssert); - // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check justify para shortcut', createNativeEvent(), oAssert); - // }); // // QUnit.test('Check bullet list shortcut', (oAssert) => // { @@ -386,12 +414,6 @@ // oAssert.true(oParagraph.IsBulletedNumbering(), 'check apply bullet list'); // }); // - // QUnit.test('Check left para shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.LeftPara}; - // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Justify, 'Check center para shortcut', createNativeEvent(), oAssert); - // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); - // }); // // QUnit.test('Check indent shortcut', (oAssert) => // { @@ -421,12 +443,6 @@ // checkInsertElementByType(para_PageNum, 'Check insert page number shortcut', oAssert, createNativeEvent()); // }); // - // QUnit.test('Check right para shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.RightPara}; - // const fAnotherCheck = checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.Get_Jc(), align_Right, 'Check center para shortcut', createNativeEvent(), oAssert); - // fAnotherCheck((oParaPr) => oParaPr.Get_Jc(), align_Left, 'Check center para shortcut', createNativeEvent(), oAssert); - // }); // // // @@ -533,22 +549,6 @@ // }); // // - // QUnit.test('Check apply heading 1', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading1}; - // checkApplyParagraphStyle('Heading 1', 'Check apply heading 1 shortcut', createNativeEvent(), oAssert); - // }); - // QUnit.test('Check apply heading 2', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading2}; - // checkApplyParagraphStyle('Heading 2', 'Check apply heading 2 shortcut', createNativeEvent(), oAssert); - // }); - // - // QUnit.test('Check apply heading 3', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyHeading3}; - // checkApplyParagraphStyle('Heading 3', 'Check apply heading 3 shortcut', createNativeEvent(), oAssert); - // }); // // QUnit.test('Check insert footnotes now', (oAssert) => // { diff --git a/word/Editor/Sections.js b/word/Editor/Sections.js index 36582f2eeb..4be052f675 100644 --- a/word/Editor/Sections.js +++ b/word/Editor/Sections.js @@ -583,6 +583,11 @@ CSectionPr.prototype = this.Columns.Num = Num; } }, + + SetColumnsNum : function(num) + { + return this.Set_Columns_Num(num); + }, Set_Columns_Sep : function(Sep) { diff --git a/word/Editor/Styles.js b/word/Editor/Styles.js index 3e82bfd09d..d1872ced86 100644 --- a/word/Editor/Styles.js +++ b/word/Editor/Styles.js @@ -9036,11 +9036,14 @@ CStyles.prototype = Get_Name : function(StyleId) { - if ( undefined != this.Style[StyleId] ) - return this.Style[StyleId].Name; - - return ""; + return this.GetName(StyleId); }, + + GetName : function(styleId) + { + let style = this.Get(styleId); + return style ? style.GetName() : ""; + }, Get_Default_Paragraph : function() { From 8852ec042ae4fa6183730e1504e3c0c3f4d294f5 Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Thu, 22 Jun 2023 02:56:35 +0500 Subject: [PATCH 03/23] Add name of the test to the console --- tests/runAll.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/runAll.js b/tests/runAll.js index 58e3000274..9d4aa9fdfd 100644 --- a/tests/runAll.js +++ b/tests/runAll.js @@ -94,6 +94,7 @@ const { .then(result => { count++; + console.log("\n" + allTests[nIndex].yellow.bold); printResultSummary(result, console); if (result.stats.failed > 0) From 3a4c39ea24304608c2e90b844c54fdc958351abe Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 10 Aug 2023 01:05:53 +0300 Subject: [PATCH 04/23] Refactor main shortcuts --- tests/word/common/editor.js | 12 +- tests/word/shortcuts/events.js | 234 +++-- tests/word/shortcuts/helpers.js | 24 +- tests/word/shortcuts/shortcuts.html | 2 +- tests/word/shortcuts/shortcuts.js | 1268 +++++++++++++++++++++++++-- word/Editor/Math.js | 2 +- 6 files changed, 1312 insertions(+), 230 deletions(-) diff --git a/tests/word/common/editor.js b/tests/word/common/editor.js index 1e3623d00a..9b584bc570 100644 --- a/tests/word/common/editor.js +++ b/tests/word/common/editor.js @@ -63,7 +63,13 @@ GetDotsPerMM : function(value) {return 72;}, EndTrackTable : function() {}, SetCurrentPage : function(pageNum) {}, - SelectClear : function() {} + SelectClear : function() {}, + OnRePaintAttack : function() {}, + IsFreezePage : function() {}, + Set_RulerState_HdrFtr : function() {}, + IsTrackText : function() {}, + ConvertCoordsToCursorWR : function(X, Y) {return {X: X, Y: Y}}, + OnUpdateOverlay : function() {} }; drawingDocument.CanvasHit = document.createElement('canvas'); @@ -74,6 +80,8 @@ const editor = new AscCommon.baseEditorsApi({}); editor.WordControl = drawingDocument; editor.WordControl.m_oDrawingDocument = drawingDocument; + editor.WordControl.m_oDrawingDocument.m_oWordControl = drawingDocument; + editor.WordControl.m_oDrawingDocument.m_oWordControl.m_oApi = editor; editor.sync_BeginCatchRevisionsChanges = function(){}; editor.sync_EndCatchRevisionsChanges = function(){}; editor.sync_ChangeCommentLogicalPosition = function(){}; @@ -101,7 +109,7 @@ editor.sync_ColumnsPropsCallback = function(){}; editor.sync_LineNumbersPropsCollback = function(){}; editor.sync_SectionPropsCallback = function(){}; - + //--------------------------------------------------------export---------------------------------------------------- AscTest.DrawingDocument = drawingDocument; AscTest.Editor = editor; diff --git a/tests/word/shortcuts/events.js b/tests/word/shortcuts/events.js index 81ae440248..13d8ce5887 100644 --- a/tests/word/shortcuts/events.js +++ b/tests/word/shortcuts/events.js @@ -32,15 +32,7 @@ (function (window) { - const {createNativeEvent} = AscTestShortcut; - const testAll = 0; - const testMacOs = 1; - const testWindows = 2; - function CTestEvent(oEvent, nType) - { - this.type = nType || testAll; - this.event = oEvent; - } + window.AscTestShortcut = {}; const oTestTypes = { removeBackSymbol : 0, removeBackWord : 1, @@ -63,7 +55,6 @@ addNewLineToMath : 18, moveCursorToStartPositionShapeEnter: 19, selectAllShapeEnter : 20, - moveCursorToStartPositionTitleEnter: 21, selectAllInChartTitle : 22, addNewParagraphContent : 23, addNewParagraphMath : 24, @@ -87,7 +78,7 @@ moveToStartDocument : 42, selectLeftWord : 43, moveToLeftWord : 44, - selectLeftSymbol : 45, + selectLeftChar : 45, moveToLeftChar : 46, moveToRightChar : 47, selectRightChar : 48, @@ -129,135 +120,128 @@ }; const oTestEvents = {}; - oTestEvents[oTestTypes.bigMoveGraphicObjectLeft] = [new CTestEvent(createNativeEvent(37, false, false, false, false, false))]; - oTestEvents[oTestTypes.littleMoveGraphicObjectLeft] = [new CTestEvent(createNativeEvent(37, true, false, false, false, false))]; - oTestEvents[oTestTypes.bigMoveGraphicObjectRight] = [new CTestEvent(createNativeEvent(39, false, false, false, false, false))]; - oTestEvents[oTestTypes.littleMoveGraphicObjectRight] = [new CTestEvent(createNativeEvent(39, true, false, false, false, false))]; - oTestEvents[oTestTypes.bigMoveGraphicObjectDown] = [new CTestEvent(createNativeEvent(40, false, false, false, false, false))]; - oTestEvents[oTestTypes.littleMoveGraphicObjectDown] = [new CTestEvent(createNativeEvent(40, true, false, false, false, false))]; - oTestEvents[oTestTypes.bigMoveGraphicObjectUp] = [new CTestEvent(createNativeEvent(38, false, false, false, false, false))]; - oTestEvents[oTestTypes.littleMoveGraphicObjectUp] = [new CTestEvent(createNativeEvent(38, true, false, false, false, false))]; - oTestEvents[oTestTypes.removeBackSymbol] = [new CTestEvent(createNativeEvent(8, false, false, false, false))]; - oTestEvents[oTestTypes.removeBackWord] = [new CTestEvent(createNativeEvent(8, true, false, false, false))]; + oTestEvents[oTestTypes.bigMoveGraphicObjectLeft] = [new CTestEvent(37, false, false, false, false, false)]; + oTestEvents[oTestTypes.littleMoveGraphicObjectLeft] = [new CTestEvent(37, true, false, false, false, false)]; + oTestEvents[oTestTypes.bigMoveGraphicObjectRight] = [new CTestEvent(39, false, false, false, false, false)]; + oTestEvents[oTestTypes.littleMoveGraphicObjectRight] = [new CTestEvent(39, true, false, false, false, false)]; + oTestEvents[oTestTypes.bigMoveGraphicObjectDown] = [new CTestEvent(40, false, false, false, false, false)]; + oTestEvents[oTestTypes.littleMoveGraphicObjectDown] = [new CTestEvent(40, true, false, false, false, false)]; + oTestEvents[oTestTypes.bigMoveGraphicObjectUp] = [new CTestEvent(38, false, false, false, false, false)]; + oTestEvents[oTestTypes.littleMoveGraphicObjectUp] = [new CTestEvent(38, true, false, false, false, false)]; + oTestEvents[oTestTypes.removeBackSymbol] = [new CTestEvent(8, false, false, false, false)]; + oTestEvents[oTestTypes.removeBackWord] = [new CTestEvent(8, true, false, false, false)]; oTestEvents[oTestTypes.removeShape] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false)) + new CTestEvent(8, false, false, false, false, false), + new CTestEvent(46, false, false, false, false, false) ]; oTestEvents[oTestTypes.removeForm] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false)) + new CTestEvent(8, false, false, false, false, false), + new CTestEvent(46, false, false, false, false, false) ]; - oTestEvents[oTestTypes.moveToNextForm] = [new CTestEvent(createNativeEvent(9, false, false, false, false, false))]; - oTestEvents[oTestTypes.moveToPreviousForm] = [new CTestEvent(createNativeEvent(9, false, true, false, false, false))]; - oTestEvents[oTestTypes.handleTab] = [new CTestEvent(createNativeEvent(9, false, false, false, false, false))]; - oTestEvents[oTestTypes.moveToNextCell] = [new CTestEvent(createNativeEvent(9, false, false, false, false))]; - oTestEvents[oTestTypes.moveToPreviousCell] = [new CTestEvent(createNativeEvent(9, false, true, false, false))]; - oTestEvents[oTestTypes.selectNextObject] = [new CTestEvent(createNativeEvent(9, false, false, false, false))]; - oTestEvents[oTestTypes.selectPreviousObject] = [new CTestEvent(createNativeEvent(9, false, true, false, false))]; - oTestEvents[oTestTypes.testIndent] = [new CTestEvent(createNativeEvent(9, false, false, false, false))]; - oTestEvents[oTestTypes.testUnIndent] = [new CTestEvent(createNativeEvent(9, false, true, false, false))]; - oTestEvents[oTestTypes.addTabToParagraph] = [new CTestEvent(createNativeEvent(9, false, false, false))]; - oTestEvents[oTestTypes.visitHyperlink] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.addBreakLineInlineLvlSdt] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.createTextBoxContent] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.createTextBody] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.addNewLineToMath] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.moveCursorToStartPositionShapeEnter] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.selectAllShapeEnter] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.moveCursorToStartPositionTitleEnter] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.selectAllInChartTitle] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false))]; - oTestEvents[oTestTypes.addNewParagraphContent] = [new CTestEvent(createNativeEvent(13, false, false, false, false))]; - oTestEvents[oTestTypes.addNewParagraphMath] = [new CTestEvent(createNativeEvent(13, false, false, false, false))]; - oTestEvents[oTestTypes.closeAllWindowsPopups] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.resetShapeSelection] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.resetStartAddShape] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.resetFormattingByExample] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.resetMarkerFormat] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.resetDragNDrop] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.endEditing] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false))]; - oTestEvents[oTestTypes.toggleCheckBox] = [new CTestEvent(createNativeEvent(32, false, false, false, false, false))]; - oTestEvents[oTestTypes.pageUp] = [new CTestEvent()]; - oTestEvents[oTestTypes.pageDown] = [new CTestEvent()]; - oTestEvents[oTestTypes.moveToEndDocument] = [new CTestEvent(createNativeEvent(35, true, false, false))]; - oTestEvents[oTestTypes.moveToEndLine] = [new CTestEvent(createNativeEvent(35, false, false, false, false))]; - oTestEvents[oTestTypes.selectToEndDocument] = [new CTestEvent(createNativeEvent(35, true, true, false, false))]; - oTestEvents[oTestTypes.selectToEndLine] = [new CTestEvent(createNativeEvent(35, false, true, false, false))]; - oTestEvents[oTestTypes.selectToStartLine] = [new CTestEvent(createNativeEvent(36, false, true, false, false))]; - oTestEvents[oTestTypes.selectToStartDocument] = [new CTestEvent(createNativeEvent(36, true, true, false, false))]; - oTestEvents[oTestTypes.moveToStartLine] = [new CTestEvent(createNativeEvent(36, false, false, false, false))]; - oTestEvents[oTestTypes.moveToStartDocument] = [new CTestEvent(createNativeEvent(36, true, false, false))]; - oTestEvents[oTestTypes.selectLeftWord] = [new CTestEvent(createNativeEvent(37, true, true, false, false))]; - oTestEvents[oTestTypes.moveToLeftWord] = [new CTestEvent(createNativeEvent(37, true, false, false, false))]; - oTestEvents[oTestTypes.selectLeftSymbol] = [new CTestEvent(createNativeEvent(37, false, true, false, false))]; - oTestEvents[oTestTypes.moveToLeftChar] = [new CTestEvent(createNativeEvent(37, false, false, false, false))]; - oTestEvents[oTestTypes.moveToRightChar] = [new CTestEvent(createNativeEvent(39, false, false, false, false))]; - oTestEvents[oTestTypes.selectRightChar] = [new CTestEvent(createNativeEvent(39, false, true, false, false))]; - oTestEvents[oTestTypes.moveToRightWord] = [new CTestEvent(createNativeEvent(39, true, false, false, false))]; - oTestEvents[oTestTypes.selectRightWord] = [new CTestEvent(createNativeEvent(39, true, true, false, false))]; - oTestEvents[oTestTypes.moveUp] = [new CTestEvent(createNativeEvent(38, false, false, false, false))]; - oTestEvents[oTestTypes.selectUp] = [new CTestEvent(createNativeEvent(38, false, true, false, false))]; - oTestEvents[oTestTypes.previousOptionComboBox] = [new CTestEvent(createNativeEvent(38, false, false, false, false, false))]; - oTestEvents[oTestTypes.moveDown] = [new CTestEvent(createNativeEvent(40, false, false, false, false))]; - oTestEvents[oTestTypes.selectDown] = [new CTestEvent(createNativeEvent(40, false, true, false, false))]; - oTestEvents[oTestTypes.nextOptionComboBox] = [new CTestEvent(createNativeEvent(40, false, false, false, false, false))]; - oTestEvents[oTestTypes.removeFrontSymbol] = [new CTestEvent(createNativeEvent(46, false, false, false, false))]; - oTestEvents[oTestTypes.removeFrontWord] = [new CTestEvent(createNativeEvent(46, true, false, false, false))]; + oTestEvents[oTestTypes.moveToNextForm] = [new CTestEvent(9, false, false, false, false, false)]; + oTestEvents[oTestTypes.moveToPreviousForm] = [new CTestEvent(9, false, true, false, false, false)]; + oTestEvents[oTestTypes.handleTab] = [new CTestEvent(9, false, false, false, false, false)]; + oTestEvents[oTestTypes.moveToNextCell] = [new CTestEvent(9, false, false, false, false)]; + oTestEvents[oTestTypes.moveToPreviousCell] = [new CTestEvent(9, false, true, false, false)]; + oTestEvents[oTestTypes.selectNextObject] = [new CTestEvent(9, false, false, false, false)]; + oTestEvents[oTestTypes.selectPreviousObject] = [new CTestEvent(9, false, true, false, false)]; + oTestEvents[oTestTypes.testIndent] = [new CTestEvent(9, false, false, false, false)]; + oTestEvents[oTestTypes.testUnIndent] = [new CTestEvent(9, false, true, false, false)]; + oTestEvents[oTestTypes.addTabToParagraph] = [new CTestEvent(9, false, false, false)]; + oTestEvents[oTestTypes.visitHyperlink] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.addBreakLineInlineLvlSdt] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.createTextBoxContent] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.createTextBody] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.addNewLineToMath] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.moveCursorToStartPositionShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.selectAllShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.selectAllInChartTitle] = [new CTestEvent(13, false, false, false, false, false)]; + oTestEvents[oTestTypes.addNewParagraphContent] = [new CTestEvent(13, false, false, false, false)]; + oTestEvents[oTestTypes.addNewParagraphMath] = [new CTestEvent(13, false, false, false, false)]; + oTestEvents[oTestTypes.closeAllWindowsPopups] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.resetShapeSelection] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.resetStartAddShape] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.resetFormattingByExample] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.resetMarkerFormat] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.resetDragNDrop] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.endEditing] = [new CTestEvent(27, false, false, false, false, false)]; + oTestEvents[oTestTypes.toggleCheckBox] = [new CTestEvent(32, false, false, false, false, false)]; + oTestEvents[oTestTypes.moveToEndDocument] = [new CTestEvent(35, true, false, false)]; + oTestEvents[oTestTypes.moveToEndLine] = [new CTestEvent(35, false, false, false, false)]; + oTestEvents[oTestTypes.selectToEndDocument] = [new CTestEvent(35, true, true, false, false)]; + oTestEvents[oTestTypes.selectToEndLine] = [new CTestEvent(35, false, true, false, false)]; + oTestEvents[oTestTypes.selectToStartLine] = [new CTestEvent(36, false, true, false, false)]; + oTestEvents[oTestTypes.selectToStartDocument] = [new CTestEvent(36, true, true, false, false)]; + oTestEvents[oTestTypes.moveToStartLine] = [new CTestEvent(36, false, false, false, false)]; + oTestEvents[oTestTypes.moveToStartDocument] = [new CTestEvent(36, true, false, false)]; + oTestEvents[oTestTypes.selectLeftWord] = [new CTestEvent(37, true, true, false, false)]; + oTestEvents[oTestTypes.moveToLeftWord] = [new CTestEvent(37, true, false, false, false)]; + oTestEvents[oTestTypes.selectLeftChar] = [new CTestEvent(37, false, true, false, false)]; + oTestEvents[oTestTypes.moveToLeftChar] = [new CTestEvent(37, false, false, false, false)]; + oTestEvents[oTestTypes.moveToRightChar] = [new CTestEvent(39, false, false, false, false)]; + oTestEvents[oTestTypes.selectRightChar] = [new CTestEvent(39, false, true, false, false)]; + oTestEvents[oTestTypes.moveToRightWord] = [new CTestEvent(39, true, false, false, false)]; + oTestEvents[oTestTypes.selectRightWord] = [new CTestEvent(39, true, true, false, false)]; + oTestEvents[oTestTypes.moveUp] = [new CTestEvent(38, false, false, false, false)]; + oTestEvents[oTestTypes.selectUp] = [new CTestEvent(38, false, true, false, false)]; + oTestEvents[oTestTypes.previousOptionComboBox] = [new CTestEvent(38, false, false, false, false, false)]; + oTestEvents[oTestTypes.moveDown] = [new CTestEvent(40, false, false, false, false)]; + oTestEvents[oTestTypes.selectDown] = [new CTestEvent(40, false, true, false, false)]; + oTestEvents[oTestTypes.nextOptionComboBox] = [new CTestEvent(40, false, false, false, false, false)]; + oTestEvents[oTestTypes.removeFrontSymbol] = [new CTestEvent(46, false, false, false, false)]; + oTestEvents[oTestTypes.removeFrontWord] = [new CTestEvent(46, true, false, false, false)]; oTestEvents[oTestTypes.unicodeToChar] = [ - new CTestEvent(createNativeEvent(88, false, false, true, false), testWindows), - new CTestEvent(createNativeEvent(88, true, false, true, false), testMacOs) + new CTestEvent(88, false, false, true, false), + new CTestEvent(88, true, false, true, false) ]; oTestEvents[oTestTypes.showContextMenu] = [ - new CTestEvent(createNativeEvent(93, false, false, false, false)), - new CTestEvent(createNativeEvent(57351, false, false, false, false)), - new CTestEvent(createNativeEvent(121, false, true, false, false)) + new CTestEvent(93, false, false, false, false), + new CTestEvent(57351, false, false, false, false), + new CTestEvent(121, false, true, false, false) ]; - oTestEvents[oTestTypes.disableNumLock] = [new CTestEvent(createNativeEvent(144, false, false, false, false))]; - oTestEvents[oTestTypes.disableScrollLock] = [new CTestEvent(createNativeEvent(145, false, false, false, false))]; - oTestEvents[oTestTypes.addSJKSpace] = [new CTestEvent(createNativeEvent(12288, false, false, false, false))]; - oTestEvents[oTestTypes.moveToStartPreviousPage] = [new CTestEvent(createNativeEvent(33, true, false, true, false))]; - oTestEvents[oTestTypes.moveToPreviousPage] = [new CTestEvent(createNativeEvent(33, false, false, false, false))]; - oTestEvents[oTestTypes.moveToPreviousHeaderFooter] = [new CTestEvent(createNativeEvent(33, false, false, false, false))]; + oTestEvents[oTestTypes.disableNumLock] = [new CTestEvent(144, false, false, false, false)]; + oTestEvents[oTestTypes.disableScrollLock] = [new CTestEvent(145, false, false, false, false)]; + oTestEvents[oTestTypes.addSJKSpace] = [new CTestEvent(12288, false, false, false, false)]; + oTestEvents[oTestTypes.moveToStartPreviousPage] = [new CTestEvent(33, true, false, true, false)]; + oTestEvents[oTestTypes.moveToPreviousPage] = [new CTestEvent(33, false, false, false, false)]; + oTestEvents[oTestTypes.moveToPreviousHeaderFooter] = [new CTestEvent(33, false, false, false, false)]; oTestEvents[oTestTypes.moveToPreviousHeader] = [ - new CTestEvent(createNativeEvent(33, true, false, true, false)), - new CTestEvent(createNativeEvent(33, false, false, true, false)) + new CTestEvent(33, true, false, true, false), + new CTestEvent(33, false, false, true, false) ]; - oTestEvents[oTestTypes.selectToStartPreviousPage] = [new CTestEvent(createNativeEvent(33, true, true, false, false))]; - oTestEvents[oTestTypes.selectToPreviousPage] = [new CTestEvent(createNativeEvent(33, false, true, false, false))]; - oTestEvents[oTestTypes.moveToStartNextPage] = [new CTestEvent(createNativeEvent(34, true, false, true, false))]; - oTestEvents[oTestTypes.moveToNextPage] = [new CTestEvent(createNativeEvent(34, false, false, false, false))]; - oTestEvents[oTestTypes.moveToNextHeaderFooter] = [new CTestEvent(createNativeEvent(34, false, false, false, false))]; + oTestEvents[oTestTypes.selectToStartPreviousPage] = [new CTestEvent(33, true, true, false, false)]; + oTestEvents[oTestTypes.selectToPreviousPage] = [new CTestEvent(33, false, true, false, false)]; + oTestEvents[oTestTypes.moveToStartNextPage] = [new CTestEvent(34, true, false, true, false)]; + oTestEvents[oTestTypes.moveToNextPage] = [new CTestEvent(34, false, false, false, false)]; + oTestEvents[oTestTypes.moveToNextHeaderFooter] = [new CTestEvent(34, false, false, false, false)]; oTestEvents[oTestTypes.moveToNextHeader] = [ - new CTestEvent(createNativeEvent(34, true, false, true, false)), - new CTestEvent(createNativeEvent(34, false, false, true, false)) + new CTestEvent(34, true, false, true, false), + new CTestEvent(34, false, false, true, false) ]; - oTestEvents[oTestTypes.selectToStartNextPage] = [new CTestEvent(createNativeEvent(34, true, true, false, false))]; - oTestEvents[oTestTypes.selectToNextPage] = [new CTestEvent(createNativeEvent(34, false, true, false, false))]; + oTestEvents[oTestTypes.selectToStartNextPage] = [new CTestEvent(34, true, true, false, false)]; + oTestEvents[oTestTypes.selectToNextPage] = [new CTestEvent(34, false, true, false, false)]; + - function startTest(fCallback, nShortcutType) + function CTestEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) { - const arrTestEvents = oTestEvents[nShortcutType]; + this.isDefaultPrevented = false; + this.isPropagationStopped = false; + this.KeyCode = nKeyCode; + this.CtrlKey = !!bIsCtrl; + this.ShiftKey = !!bIsShift; + this.AltKey = !!bIsAlt; + this.MacCmdKey = !!bIsMetaKey; + } - for (let i = 0; i < arrTestEvents.length; i += 1) - { - const nTestType = arrTestEvents[i].type; - if (nTestType === testAll) - { - AscCommon.AscBrowser.isMacOs = true; - fCallback(arrTestEvents[i].event); + CTestEvent.prototype.preventDefault = function () + { + this.isDefaultPrevented = true; + }; + CTestEvent.prototype.stopPropagation = function () + { + this.isPropagationStopped = true; + }; - AscCommon.AscBrowser.isMacOs = false; - fCallback(arrTestEvents[i].event); - } else if (nTestType === testMacOs) - { - AscCommon.AscBrowser.isMacOs = true; - fCallback(arrTestEvents[i].event); - AscCommon.AscBrowser.isMacOs = false; - } else if (nTestType === testWindows) - { - fCallback(arrTestEvents[i].event); - } - } - } AscTestShortcut.oTestTypes = oTestTypes; - AscTestShortcut.startTest = startTest; + AscTestShortcut.oTestEvents = oTestEvents; })(window); diff --git a/tests/word/shortcuts/helpers.js b/tests/word/shortcuts/helpers.js index 86a143ec0a..29fc5e79a3 100644 --- a/tests/word/shortcuts/helpers.js +++ b/tests/word/shortcuts/helpers.js @@ -689,18 +689,18 @@ let fOldCheckOFormUserMaster; function setFillingFormsMode(bState) { - if (bState) - { - fOldCheckOFormUserMaster = oGlobalLogicDocument.CheckOFormUserMaster; - oGlobalLogicDocument.CheckOFormUserMaster = function () - { - return true; - } - } - else - { - oGlobalLogicDocument.CheckOFormUserMaster = fOldCheckOFormUserMaster; - } + // if (bState) + // { + // fOldCheckOFormUserMaster = oGlobalLogicDocument.CheckOFormUserMaster; + // oGlobalLogicDocument.CheckOFormUserMaster = function () + // { + // return true; + // } + // } + // else + // { + // oGlobalLogicDocument.CheckOFormUserMaster = fOldCheckOFormUserMaster; + // } var oRole = new AscCommon.CRestrictionSettings(); oRole.put_OFormRole("Anyone"); editor.asc_setRestriction(bState ? Asc.c_oAscRestrictionType.OnlyForms : Asc.c_oAscRestrictionType.None, oRole); diff --git a/tests/word/shortcuts/shortcuts.html b/tests/word/shortcuts/shortcuts.html index 2bce53d2ad..14e162da3d 100644 --- a/tests/word/shortcuts/shortcuts.html +++ b/tests/word/shortcuts/shortcuts.html @@ -36,7 +36,7 @@ - + diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index e17c7d1fa2..c14bf0fed2 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -35,111 +35,204 @@ (function (window) { - // const { - // addPropertyToDocument, - // getLogicDocumentWithParagraphs, - // checkTextAfterKeyDownHelperEmpty, - // oGlobalLogicDocument, - // addParagraphToDocumentWithText, - // remove, - // clean, - // recalculate, - // onKeyDown, - // moveToParagraph, - // createNativeEvent, - // moveCursorDown, - // moveCursorLeft, - // moveCursorRight, - // selectAll, - // getSelectedText, - // executeTestWithCatchEvent, - // startTest, - // createChart, - // createEvent, - // checkInsertElementByType, - // createParagraphWithText, - // checkApplyParagraphStyle, - // createHyperlink, - // createTable, - // moveToTable, - // createShape, - // createGroup, - // selectOnlyObjects, - // selectParaDrawing, - // drawingObjects, - // logicContent, - // directParaPr, - // directTextPr, - // addBreakPage, - // createMath, - // resetLogicDocument, - // addText, - // moveShapeHelper, - // setFillingFormsMode, - // createCheckBox, - // createComboBox, - // createComplexForm, - // contentPosition, - // oTestTypes, - // mouseMove, - // mouseDown, - // mouseUp, - // insertManualBreak - // } = AscTestShortcut; - + const oEvents = AscTestShortcut.oTestEvents; + const oTestTypes = AscTestShortcut.oTestTypes; + let logicDocument = AscTest.CreateLogicDocument(); - editor.getShortcut = function(e) + logicDocument.UpdateAllSectionsInfo(); + const pageWidth = 100; + const pageHeight = 100; + logicDocument.Set_DocumentPageSize(pageWidth, pageHeight); + var props = new Asc.CDocumentSectionProps(); + props.put_TopMargin(0); + props.put_LeftMargin(0); + props.put_BottomMargin(0); + props.put_RightMargin(0); + logicDocument.Set_SectionProps(props); + logicDocument.UpdateAllSectionsInfo(); + editor.WordControl.m_oDrawingDocument.GetVisibleMMHeight = function () + { + return 100; + }; + editor.WordControl.m_oDrawingDocument.SetCursorType = function () + { + + }; + let bStartTrackText = false; + editor.WordControl.m_oDrawingDocument.StartTrackText = function () {bStartTrackText = true}; + editor.WordControl.m_oDrawingDocument.EndTrackText = function () {bStartTrackText = false}; + editor.WordControl.m_oDrawingDocument.CancelTrackText = function () {return bStartTrackText}; + AscFormat.CHART_STYLE_MANAGER.init(); + + + + editor.getShortcut = function (e) { - return e; + if (typeof e === 'number') + { + return e; + } }; - editor.FontSizeIn = function() + editor.FontSizeIn = function () { logicDocument.IncreaseDecreaseFontSize(true); }; - editor.FontSizeOut = function() + editor.FontSizeOut = function () { logicDocument.IncreaseDecreaseFontSize(false); }; - + editor.StartAddShape = function () + { + this.isStartAddShape = true; + }; + + + + function GoToHeader(nPage) + { + logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); + const oEvent = new AscCommon.CMouseEventHandler(); + oEvent.ClickCount = 1; + oEvent.Button = 0; + oEvent.Type = AscCommon.g_mouse_event_type_down; + + logicDocument.OnMouseDown(oEvent, 0, 0, nPage); + + oEvent.Type = AscCommon.g_mouse_event_type_up; + logicDocument.OnMouseUp(oEvent, 0, 0, nPage); + logicDocument.MoveCursorLeft(); + } + + function GoToFooter(nPage) + { + logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); + const oEvent = new AscCommon.CMouseEventHandler(); + oEvent.ClickCount = 1; + oEvent.Button = 0; + oEvent.Type = AscCommon.g_mouse_event_type_down; + + logicDocument.OnMouseDown(oEvent, 0, pageHeight, nPage); + + oEvent.Type = AscCommon.g_mouse_event_type_up; + logicDocument.OnMouseUp(oEvent, 0, pageHeight, nPage); + logicDocument.MoveCursorLeft(); + } + + function RemoveHeader(nPage) + { + logicDocument.RemoveHdrFtr(nPage, true); + } + + function RemoveFooter(nPage) + { + logicDocument.RemoveHdrFtr(nPage, false); + } + + AscFonts.FontPickerByCharacter.checkText = function (text, _this, _callback, isCodes, isOnlyAsync, isCheckSymbols) + { + _callback.call(_this); + } + + editor.WordControl.m_oApi = editor; + editor.retrieveFormatPainterData = Asc.asc_docs_api.prototype.retrieveFormatPainterData.bind(editor); + editor.get_ShowParaMarks = Asc.asc_docs_api.prototype.get_ShowParaMarks.bind(editor); + editor.put_ShowParaMarks = Asc.asc_docs_api.prototype.put_ShowParaMarks.bind(editor); + editor.sync_ShowParaMarks = Asc.asc_docs_api.prototype.sync_ShowParaMarks.bind(editor); + editor.private_GetLogicDocument = Asc.asc_docs_api.prototype.private_GetLogicDocument.bind(editor); + editor.asc_AddTableOfContents = Asc.asc_docs_api.prototype.asc_AddTableOfContents.bind(editor); + editor.asc_registerCallback = Asc.asc_docs_api.prototype.asc_registerCallback.bind(editor); + editor.asc_unregisterCallback = Asc.asc_docs_api.prototype.asc_unregisterCallback.bind(editor); + editor.sendEvent = Asc.asc_docs_api.prototype.sendEvent.bind(editor); + editor.sync_DialogAddHyperlink = Asc.asc_docs_api.prototype.sync_DialogAddHyperlink.bind(editor); + editor.sync_ParaStyleName = Asc.asc_docs_api.prototype.sync_ParaStyleName.bind(editor); + editor.sync_MouseMoveStartCallback = Asc.asc_docs_api.prototype.sync_MouseMoveStartCallback.bind(editor); + editor.sync_MouseMoveCallback = Asc.asc_docs_api.prototype.sync_MouseMoveCallback .bind(editor); + editor.sync_MouseMoveEndCallback = Asc.asc_docs_api.prototype.sync_MouseMoveEndCallback.bind(editor); + editor.sync_HideComment = Asc.asc_docs_api.prototype.sync_HideComment .bind(editor); + editor.sync_ContextMenuCallback = Asc.asc_docs_api.prototype.sync_ContextMenuCallback .bind(editor); + editor.asc_AddMath = Asc.asc_docs_api.prototype.asc_AddMath2.bind(editor); + editor._onEndLoadSdk = Asc.asc_docs_api.prototype._onEndLoadSdk.bind(editor); + editor.sync_StartAddShapeCallback = Asc.asc_docs_api.prototype.sync_StartAddShapeCallback .bind(editor); + editor.SetPaintFormat = Asc.asc_docs_api.prototype.SetPaintFormat.bind(editor); + editor.SetMarkerFormat = Asc.asc_docs_api.prototype.SetMarkerFormat .bind(editor); + editor.sync_MarkerFormatCallback = Asc.asc_docs_api.prototype.sync_MarkerFormatCallback.bind(editor); + editor.sync_PaintFormatCallback = Asc.asc_docs_api.prototype.sync_PaintFormatCallback.bind(editor); + editor.sync_EndAddShape = function () {}; + + editor.isDocumentEditor = true; + function ExecuteShortcut(type) { - logicDocument.OnKeyDown(type); + return logicDocument.OnKeyDown(type); + } + function ExecuteShortcut2(nType, nEventIndex) + { + const oEvent = oEvents[nType][nEventIndex || 0]; + return ExecuteShortcut(oEvent); } + + + AscCommon.CDocsCoApi.prototype.askSaveChanges = function(callback) + { + window.setTimeout(function() { + callback({"saveLock": false}); + }, 0); + }; function ClearDocumentAndAddParagraph(text) { logicDocument.RemoveSelection(); AscTest.ClearDocument(); - let p = AscTest.CreateParagraph(); + const p = CreateParagraphWithText(text); logicDocument.AddToContent(0, p); - + return p; + } + + function CreateParagraphWithText(text) + { + let p = AscTest.CreateParagraph(); + if (text) { let run = AscTest.CreateRun(); run.AddText(text); p.AddToContentToEnd(run); } - + return p; } - + logicDocument.Start_SilentMode(); + function TurnOnRecalculate() { logicDocument.TurnOn_Recalculate(); } + function TurnOffRecalculate() { logicDocument.TurnOff_Recalculate(); } - + + function TurnOnRecalculateCurPos() + { + logicDocument.TurnOn_RecalculateCurPos(); + } + + function TurnOffRecalculateCurPos() + { + logicDocument.TurnOff_RecalculateCurPos(); + } + function ApplyTextPrToDocument(textPr) { logicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(textPr)); } + function GetDirectTextPr() { return logicDocument.GetDirectTextPr(); } + function GetDirectParaPr() { return logicDocument.GetDirectParaPr(); @@ -179,7 +272,7 @@ assert.strictEqual(logicDocument.GetPagesCount(), 4, 'Check page break shortcut'); TurnOffRecalculate(); }); - + QUnit.test('Check line break shortcut', (assert) => { TurnOnRecalculate(); @@ -192,7 +285,7 @@ assert.strictEqual(p.GetLinesCount(), 4, 'Check line break shortcut'); TurnOffRecalculate(); }); - + QUnit.test('Check column break shortcut', (assert) => { TurnOnRecalculate(); @@ -200,7 +293,7 @@ let sectionPr = AscTest.GetFinalSection(); sectionPr.SetColumnsNum(3); AscTest.Recalculate(); - + function CheckColumns(colCount) { assert.strictEqual(logicDocument.GetPagesCount(), 1, 'Check logic document page count'); @@ -211,34 +304,34 @@ assert.strictEqual(p.GetAbsolutePage(i), 0, 'Check paragraph page index'); } } - + CheckColumns(1); ExecuteShortcut(c_oAscDocumentShortcutType.InsertColumnBreak); CheckColumns(2); ExecuteShortcut(c_oAscDocumentShortcutType.InsertColumnBreak); CheckColumns(3); - + sectionPr.SetColumnsNum(1); TurnOffRecalculate(); }); - + QUnit.test('Check reset char shortcut', (assert) => { ClearDocumentAndAddParagraph('Hello world'); logicDocument.SelectAll(); ApplyTextPrToDocument({Bold: true, Italic: true, Underline: true}); - + let textPr = GetDirectTextPr(); assert.true(true === textPr.GetBold() && true === textPr.GetItalic() && true === textPr.GetUnderline(), 'Check before reset'); ExecuteShortcut(c_oAscDocumentShortcutType.ResetChar); textPr = GetDirectTextPr(); assert.true(undefined === textPr.GetBold() && undefined === textPr.GetItalic() && undefined === textPr.GetUnderline(), 'Check after reset'); }); - + QUnit.test('Check adding various characters', (assert) => { let p = ClearDocumentAndAddParagraph(); - + ExecuteShortcut(c_oAscDocumentShortcutType.NonBreakingSpace); assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0), 'Check add non breaking space'); ExecuteShortcut(c_oAscDocumentShortcutType.CopyrightSign); @@ -257,38 +350,45 @@ assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D), 'Check add NonBreakingHyphen'); ExecuteShortcut(c_oAscDocumentShortcutType.HorizontalEllipsis); assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026), 'Check add HorizontalEllipsis'); + ExecuteShortcut2(oTestTypes.addSJKSpace); + assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026, 0x0020), 'Check add HorizontalEllipsis'); }); - + QUnit.test('Check text property change', (assert) => { ClearDocumentAndAddParagraph('Hello world'); logicDocument.SelectAll(); - + ExecuteShortcut(c_oAscDocumentShortcutType.Bold); assert.strictEqual(GetDirectTextPr().GetBold(), true, 'Check turn on bold'); ExecuteShortcut(c_oAscDocumentShortcutType.Bold); assert.strictEqual(GetDirectTextPr().GetBold(), false, 'Check turn off bold'); - + ExecuteShortcut(c_oAscDocumentShortcutType.Italic); assert.strictEqual(GetDirectTextPr().GetItalic(), true, 'Check turn on italic'); ExecuteShortcut(c_oAscDocumentShortcutType.Italic); assert.strictEqual(GetDirectTextPr().GetItalic(), false, 'Check turn off italic'); - + ExecuteShortcut(c_oAscDocumentShortcutType.Strikeout); assert.strictEqual(GetDirectTextPr().GetStrikeout(), true, 'Check turn on strikeout'); ExecuteShortcut(c_oAscDocumentShortcutType.Strikeout); assert.strictEqual(GetDirectTextPr().GetStrikeout(), false, 'Check turn off strikeout'); - + ExecuteShortcut(c_oAscDocumentShortcutType.Underline); assert.strictEqual(GetDirectTextPr().GetUnderline(), true, 'Check turn on underline'); ExecuteShortcut(c_oAscDocumentShortcutType.Underline); assert.strictEqual(GetDirectTextPr().GetUnderline(), false, 'Check turn off underline'); - + ExecuteShortcut(c_oAscDocumentShortcutType.Superscript); assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_SuperScript, 'Check turn on superscript'); ExecuteShortcut(c_oAscDocumentShortcutType.Superscript); assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off superscript'); - + + ExecuteShortcut(c_oAscDocumentShortcutType.Subscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_SubScript, 'Check turn on subscript'); + ExecuteShortcut(c_oAscDocumentShortcutType.Subscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off subscript'); + // defaultSize = 10 // 10 -> 11 -> 12 -> 14 -> 16 -> 14 -> 12 -> 11 -> 10 ExecuteShortcut(c_oAscDocumentShortcutType.IncreaseFontSize); @@ -299,7 +399,7 @@ assert.strictEqual(GetDirectTextPr().GetFontSize(), 14, 'Check increase font size'); ExecuteShortcut(c_oAscDocumentShortcutType.IncreaseFontSize); assert.strictEqual(GetDirectTextPr().GetFontSize(), 16, 'Check increase font size'); - + ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); assert.strictEqual(GetDirectTextPr().GetFontSize(), 14, 'Check decrease font size'); ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); @@ -309,7 +409,7 @@ ExecuteShortcut(c_oAscDocumentShortcutType.DecreaseFontSize); assert.strictEqual(GetDirectTextPr().GetFontSize(), 10, 'Check decrease font size'); }); - + QUnit.test('Check select all shortcut', (assert) => { let p = ClearDocumentAndAddParagraph('Hello world'); @@ -321,15 +421,16 @@ assert.strictEqual(p.IsSelectedAll(), true, 'Check paragraph selection'); assert.strictEqual(table.IsSelectedAll(), true, 'Check table selection'); }); - + QUnit.test('Check paragraph property change', (assert) => { let p = ClearDocumentAndAddParagraph('Hello world'); + function GetStyleName() { return logicDocument.GetStyleManager().GetName(p.GetParagraphStyle()); } - + assert.strictEqual(GetStyleName(), "", "Check style"); ExecuteShortcut(c_oAscDocumentShortcutType.ApplyHeading1); assert.strictEqual(GetStyleName(), "Heading 1", "Check apply heading 1"); @@ -337,32 +438,1021 @@ assert.strictEqual(GetStyleName(), "Heading 2", "Check apply heading 2"); ExecuteShortcut(c_oAscDocumentShortcutType.ApplyHeading3); assert.strictEqual(GetStyleName(), "Heading 3", "Check apply heading 3"); - + assert.strictEqual(GetDirectParaPr().GetJc(), undefined, "Check justification"); ExecuteShortcut(c_oAscDocumentShortcutType.CenterPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Center, "Check turn on center para"); ExecuteShortcut(c_oAscDocumentShortcutType.CenterPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off center para"); - + ExecuteShortcut(c_oAscDocumentShortcutType.JustifyPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); ExecuteShortcut(c_oAscDocumentShortcutType.JustifyPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off justify para"); - + ExecuteShortcut(c_oAscDocumentShortcutType.JustifyPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); ExecuteShortcut(c_oAscDocumentShortcutType.LeftPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn on left para"); ExecuteShortcut(c_oAscDocumentShortcutType.LeftPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn off left para"); - + ExecuteShortcut(c_oAscDocumentShortcutType.RightPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Right, "Check turn on right para"); ExecuteShortcut(c_oAscDocumentShortcutType.RightPara); assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off right para"); + + ExecuteShortcut(c_oAscDocumentShortcutType.Indent); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5); + + ExecuteShortcut(c_oAscDocumentShortcutType.UnIndent); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0); + + const p2 = CreateParagraphWithText('Hello'); + + logicDocument.SelectAll(); + + ExecuteShortcut2(oTestTypes.testIndent); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5); + + ExecuteShortcut2(oTestTypes.testUnIndent); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0); + }); + + QUnit.test('Check insert document elements', (assert) => + { + let p = ClearDocumentAndAddParagraph(''); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertFootnoteNow); + const arrFootnotes = logicDocument.GetFootnotesList(); + assert.equal(arrFootnotes.length, 1, 'Check insert footnote shortcut'); + + p.SetThisElementCurrent(); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertEndnoteNow); + const arrEndNotes = logicDocument.GetEndnotesList(); + assert.equal(arrEndNotes.length, 1, 'Check insert endnote shortcut'); + logicDocument.MoveCursorToStartPos(); + }); + + + QUnit.test('Check shortcuts with sending event to interface', (assert) => + { + function checkSendingEvent(sSendEvent, oEvent, fCustomCheck, customExpectedValue) + { + let bCheck = false; + const fCheck = function (...args) + { + if (fCustomCheck) + { + bCheck = fCustomCheck(...args); + } else + { + bCheck = true; + } + } + editor.asc_registerCallback(sSendEvent, fCheck); + + ExecuteShortcut(oEvent); + assert.strictEqual(bCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); + editor.asc_unregisterCallback(sSendEvent, fCheck); + } + + checkSendingEvent("asc_onDialogAddHyperlink", c_oAscDocumentShortcutType.InsertHyperlink); + checkSendingEvent("asc_onPrint", c_oAscDocumentShortcutType.PrintPreviewAndPrint); + + checkSendingEvent('asc_onMouseMoveStart', oEvents[oTestTypes.closeAllWindowsPopups][0]); + checkSendingEvent('asc_onMouseMove', oEvents[oTestTypes.closeAllWindowsPopups][0]); + checkSendingEvent('asc_onMouseMoveEnd', oEvents[oTestTypes.closeAllWindowsPopups][0]); + + checkSendingEvent('asc_onContextMenu', oEvents[oTestTypes.showContextMenu][0]); + AscCommon.AscBrowser.isOpera = true; + checkSendingEvent('asc_onContextMenu', oEvents[oTestTypes.showContextMenu][1]); + AscCommon.AscBrowser.isOpera = false; + checkSendingEvent('asc_onContextMenu', oEvents[oTestTypes.showContextMenu][2]); }); - - + + QUnit.test('Check insert equation shortcut', (assert) => + { + ClearDocumentAndAddParagraph(''); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertEquation); + const oMath = logicDocument.GetCurrentMath(); + assert.true(!!oMath, 'Check insert equation shortcut'); + }); + + QUnit.test('Check insert elements shortcut', (assert) => + { + const p = ClearDocumentAndAddParagraph(''); + ExecuteShortcut(c_oAscDocumentShortcutType.InsertPageNumber); + + const r = p.Content[0]; + assert.strictEqual(r.Content[0].Type, para_PageNum); + }); + + QUnit.test('Check bullet list shortcut', (assert) => + { + const p = ClearDocumentAndAddParagraph(''); + assert.false(p.IsBulletedNumbering(), 'check apply bullet list'); + ExecuteShortcut(c_oAscDocumentShortcutType.ApplyListBullet); + assert.true(p.IsBulletedNumbering(), 'check apply bullet list'); + }); + + QUnit.test('Check copy/paste format shortcuts', (assert) => + { + let p = ClearDocumentAndAddParagraph('Hello'); + ApplyTextPrToDocument({Bold: true, Italic: true, Underline: true}); + GetDirectTextPr(); + ExecuteShortcut(c_oAscDocumentShortcutType.CopyFormat); + let tPr = editor.getFormatPainterData().TextPr; + assert.true(tPr.Get_Bold()); + assert.true(tPr.Get_Italic()); + assert.true(tPr.Get_Underline()); + + p = ClearDocumentAndAddParagraph(''); + ExecuteShortcut(c_oAscDocumentShortcutType.PasteFormat); + tPr = GetDirectTextPr(); + assert.true(tPr.Get_Bold()); + assert.true(tPr.Get_Italic()); + assert.true(tPr.Get_Underline()); + }); + + QUnit.test('Check history shortcuts', (assert) => + { + let p = ClearDocumentAndAddParagraph('Hello'); + p.MoveCursorToEndPos(); + logicDocument.AddTextWithPr(' World'); + ExecuteShortcut(c_oAscDocumentShortcutType.EditUndo); + assert.strictEqual(AscTest.GetParagraphText(p), 'Hello'); + + ExecuteShortcut(c_oAscDocumentShortcutType.EditRedo); + assert.strictEqual(AscTest.GetParagraphText(p), 'Hello World'); + }); + + QUnit.test('Check show paramarks shortcut', (assert) => + { + ExecuteShortcut(c_oAscDocumentShortcutType.ShowAll); + assert.true(editor.ShowParaMarks, 'Check show non printing characters shortcut'); + }); + + QUnit.test('Check save shortcut', (assert) => + { + assert.timeout(100); + const done = assert.async(); + + const fOldSave = editor._onSaveCallbackInner; + editor._onSaveCallbackInner = function () + { + assert.true(true, 'Check save shortcut'); + done(); + editor._onSaveCallbackInner = fOldSave; + }; + editor._saveCheck = () => true; + editor.asc_isDocumentCanSave = () => true; + ExecuteShortcut(c_oAscDocumentShortcutType.Save); + }); + + //todo + // QUnit.test.todo('Check update fields shortcut', (assert) => + // { + // const p = ClearDocumentAndAddParagraph('Hello'); + // const p2 = CreateParagraphWithText('Hello'); + // const p3 = CreateParagraphWithText('Hello'); + // logicDocument.AddToContent(logicDocument.Content.length, p2); + // logicDocument.AddToContent(logicDocument.Content.length, p3); + // for (let i = 0; i < logicDocument.Content.length; i += 1) + // { + // logicDocument.Set_CurrentElement(i, true); + // logicDocument.SetParagraphStyle("Heading 1"); + // } + // logicDocument.MoveCursorToStartPos(); + // const props = new Asc.CTableOfContentsPr(); + // props.put_OutlineRange(1, 9); + // props.put_Hyperlink(true); + // props.put_ShowPageNumbers(true); + // props.put_RightAlignTab(true); + // props.put_TabLeader(Asc.c_oAscTabLeader.Dot); + // editor.asc_AddTableOfContents(null, props); + // + // logicDocument.MoveCursorToEndPos(); + // const p4 = CreateParagraphWithText('Hello'); + // logicDocument.AddToContent(logicDocument.Content.length, p4); + // p4.SetThisElementCurrent(true); + // logicDocument.SetParagraphStyle("Heading 1"); + // + // logicDocument.Content[0].SetThisElementCurrent(); + // logicDocument.Content[0].MoveCursorToEndPos(); + // + // ExecuteShortcut(c_oAscDocumentShortcutType.UpdateFields); + // assert.strictEqual(logicDocument.Content[0].Content.Content.length, 5, 'Check update fields shortcut'); + // }); + + QUnit.test('Check remove hotkeys', (assert) => + { + const p = ClearDocumentAndAddParagraph('Hello Hello Hello Hello'); + + ExecuteShortcut2(oTestTypes.removeBackSymbol); + assert.strictEqual(AscTest.GetParagraphText(p), 'Hello Hello Hello Hell'); + + ExecuteShortcut2(oTestTypes.removeBackWord); + assert.strictEqual(AscTest.GetParagraphText(p), 'Hello Hello Hello '); + + logicDocument.MoveCursorToStartPos(); + ExecuteShortcut2(oTestTypes.removeFrontSymbol); + assert.strictEqual(AscTest.GetParagraphText(p), 'ello Hello Hello '); + ExecuteShortcut2(oTestTypes.removeFrontWord); + assert.strictEqual(AscTest.GetParagraphText(p), 'Hello Hello '); + }); + QUnit.test('Check move/select in text hotkeys', (assert) => + { + function CheckCursorPosition(nExpected) + { + const pos = logicDocument.GetContentPosition(); + assert.strictEqual(pos[pos.length - 1].Position, nExpected); + } + + const p = ClearDocumentAndAddParagraph( + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'World Hello World'); + + logicDocument.MoveCursorToStartPos(); + TurnOnRecalculate(); + TurnOnRecalculateCurPos(); + AscTest.Recalculate(); + TurnOffRecalculate(); + TurnOffRecalculateCurPos(); + + ExecuteShortcut2(oTestTypes.moveToEndLine); + CheckCursorPosition(18); + + ExecuteShortcut2(oTestTypes.moveToRightChar); + CheckCursorPosition(19); + + ExecuteShortcut2(oTestTypes.moveToLeftChar); + CheckCursorPosition(18); + + ExecuteShortcut2(oTestTypes.moveToLeftWord); + CheckCursorPosition(12); + + ExecuteShortcut2(oTestTypes.moveToRightWord); + CheckCursorPosition(18); + + ExecuteShortcut2(oTestTypes.moveToRightWord); + CheckCursorPosition(24); + + + ExecuteShortcut2(oTestTypes.moveToStartLine); + CheckCursorPosition(18); + + ExecuteShortcut2(oTestTypes.moveDown); + CheckCursorPosition(36); + + ExecuteShortcut2(oTestTypes.moveUp); + CheckCursorPosition(18); + + ExecuteShortcut2(oTestTypes.moveToEndDocument); + CheckCursorPosition(161); + + ExecuteShortcut2(oTestTypes.moveToStartDocument); + CheckCursorPosition(0); + + AscTest.MoveCursorRight(); + + ExecuteShortcut2(oTestTypes.moveToNextPage); + CheckCursorPosition(91); + + ExecuteShortcut2(oTestTypes.moveToPreviousPage); + CheckCursorPosition(1); + + ExecuteShortcut2(oTestTypes.moveToStartNextPage); + CheckCursorPosition(90); + + ExecuteShortcut2(oTestTypes.moveToStartPreviousPage); + CheckCursorPosition(0); + + function CheckSelectedText(sExpectedText) + { + const sSelectedText = logicDocument.GetSelectedText(); + assert.strictEqual(sSelectedText, sExpectedText); + } + + ExecuteShortcut2(oTestTypes.selectToEndLine); + CheckSelectedText('Hello World Hello '); + + + ExecuteShortcut2(oTestTypes.selectRightChar); + CheckSelectedText('Hello World Hello W'); + + ExecuteShortcut2(oTestTypes.selectLeftChar); + CheckSelectedText('Hello World Hello '); + + ExecuteShortcut2(oTestTypes.selectLeftWord); + CheckSelectedText('Hello World '); + + ExecuteShortcut2(oTestTypes.selectRightWord); + CheckSelectedText('Hello World Hello '); + + ExecuteShortcut2(oTestTypes.selectRightWord); + CheckSelectedText('Hello World Hello World '); + + ExecuteShortcut2(oTestTypes.selectRightWord); + CheckSelectedText('Hello World Hello World Hello '); + + ExecuteShortcut2(oTestTypes.selectToStartLine); + CheckSelectedText('Hello World Hello '); + + ExecuteShortcut2(oTestTypes.selectDown); + CheckSelectedText('Hello World Hello World Hello World '); + + ExecuteShortcut2(oTestTypes.selectUp); + CheckSelectedText('Hello World Hello '); + + ExecuteShortcut2(oTestTypes.selectToEndDocument); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World'); + + ExecuteShortcut2(oTestTypes.selectToStartDocument); + CheckSelectedText(''); + + logicDocument.MoveCursorToEndPos(); + ExecuteShortcut2(oTestTypes.selectLeftChar); + CheckSelectedText('d'); + + ExecuteShortcut2(oTestTypes.selectLeftWord); + CheckSelectedText('World'); + + logicDocument.MoveCursorToStartPos(); + AscTest.MoveCursorRight(); + ExecuteShortcut2(oTestTypes.selectToNextPage); + CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H'); + AscTest.MoveCursorRight(); + + ExecuteShortcut2(oTestTypes.selectToPreviousPage); + CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H'); + AscTest.MoveCursorLeft(); + ExecuteShortcut2(oTestTypes.selectToStartNextPage); + CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello '); + AscTest.MoveCursorRight(); + ExecuteShortcut2(oTestTypes.selectToStartPreviousPage); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello '); + }); + + function createShape(x, y, h, w) + { + const oDrawing = new ParaDrawing(w, h, null, logicDocument.GetDrawingDocument(), logicDocument, null); + const oShapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, logicDocument.theme, null, null, null, 0); + oShapeTrack.track({}, x, y); + const oShape = oShapeTrack.getShape(true, logicDocument.GetDrawingDocument(), null); + oShape.spPr.xfrm.setExtX(w); + oShape.spPr.xfrm.setExtY(h); + oShape.setBDeleted(false); + + oShape.setParent(oDrawing); + oDrawing.Set_GraphicObject(oShape); + oDrawing.Set_DrawingType(drawing_Anchor); + oDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); + oDrawing.Set_Distance(0, 0, 0, 0); + const oNearestPos = logicDocument.Get_NearestPos(0, oShape.x, oShape.y, true, oDrawing); + oDrawing.Set_XYForAdd(oShape.x, oShape.y, oNearestPos, 0); + oDrawing.AddToDocument(oNearestPos); + AscTest.Recalculate(); + return oDrawing; + } + + function selectDrawing(arrDrawings) + { + logicDocument.SelectDrawings(arrDrawings, logicDocument); + } + + function GetDrawingObjects() + { + return logicDocument.DrawingObjects; + } + + function round(nNumber, nAmount) + { + const nPower = Math.pow(10, nAmount); + return Math.round(nNumber * nPower) / nPower; + } + QUnit.test('Check move/select drawings', (assert) => + { + TurnOnRecalculate(); + const p = ClearDocumentAndAddParagraph(''); + p.SetThisElementCurrent(); + AscTest.Recalculate(); + const drawing1 = createShape(0, 0, 100, 200); + + const dotsPerMM = logicDocument.DrawingDocument.GetDotsPerMM(); + function CheckShapePosition(X, Y) + { + assert.deepEqual([round(drawing1.X * dotsPerMM, 10), round(drawing1.Y * dotsPerMM, 10), drawing1.Extent.W, drawing1.Extent.H], [X, Y, 200, 100]); + } + + selectDrawing([drawing1]); + + ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectLeft); + CheckShapePosition(-5, 0); + + ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectLeft); + CheckShapePosition(-6, 0); + + ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectRight); + CheckShapePosition(-1, 0); + + ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectRight); + CheckShapePosition(0, 0); + + ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectDown); + CheckShapePosition(0, 5); + + ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectDown); + CheckShapePosition(0, 6); + + ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectUp); + CheckShapePosition(0, 1); + + ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectUp); + CheckShapePosition(0, 0); + + + function CheckSelectedObjects(arrOfDrawings) + { + const nLength = Math.max(arrOfDrawings.length, GetDrawingObjects().selectedObjects.length); + for (let i = 0; i < nLength; i++) + { + assert.true(GetDrawingObjects().selectedObjects[i] === arrOfDrawings[i].GraphicObj); + } + } + + const drawing2 = createShape(0, 0, 10, 10); + const drawing3 = createShape(0, 0, 10, 10); + selectDrawing([drawing3]); + + ExecuteShortcut2(oTestTypes.selectNextObject); + CheckSelectedObjects([drawing1]); + + ExecuteShortcut2(oTestTypes.selectNextObject); + CheckSelectedObjects([drawing2]); + + ExecuteShortcut2(oTestTypes.selectNextObject); + CheckSelectedObjects([drawing3]); + + ExecuteShortcut2(oTestTypes.selectPreviousObject); + CheckSelectedObjects([drawing2]); + + ExecuteShortcut2(oTestTypes.selectPreviousObject); + CheckSelectedObjects([drawing1]); + + ExecuteShortcut2(oTestTypes.selectPreviousObject); + CheckSelectedObjects([drawing3]); + TurnOffRecalculate(); + }); + + QUnit.test('Check actions with selected shape', (assert) => + { + TurnOnRecalculate(); + const p = CreateParagraphWithText(''); + AscTest.Recalculate(); + let sp = createShape(0, 0, 10, 10); + selectDrawing([sp]); + + ExecuteShortcut2(oTestTypes.createTextBoxContent); + assert.true(!!sp.GraphicObj.textBoxContent); + + sp = createShape(0, 0, 10, 10); + sp.GraphicObj.setWordShape(false); + selectDrawing([sp]); + + ExecuteShortcut2(oTestTypes.createTextBody); + assert.true(!!sp.GraphicObj.txBody); + + selectDrawing([sp]); + ExecuteShortcut2(oTestTypes.moveCursorToStartPositionShapeEnter); + assert.true(sp.GraphicObj.getDocContent().IsCursorAtBegin()); + + AscTest.EnterText('Hello'); + selectDrawing([sp]); + + ExecuteShortcut2(oTestTypes.selectAllShapeEnter); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); + TurnOffRecalculate(); + }); + + + QUnit.test('Check move in headers/footers', (assert) => + { + TurnOnRecalculate(); + TurnOnRecalculateCurPos(); + const p = ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); + AscTest.Recalculate(); + + + logicDocument.GoToPage(2); + GoToFooter(2); + GoToHeader(2); + TurnOffRecalculateCurPos(); + TurnOffRecalculate(); + + ExecuteShortcut2(oTestTypes.moveToPreviousHeaderFooter); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer); + ExecuteShortcut2(oTestTypes.moveToPreviousHeaderFooter); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); + + ExecuteShortcut2(oTestTypes.moveToNextHeaderFooter); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer); + ExecuteShortcut2(oTestTypes.moveToNextHeaderFooter); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header); + + ExecuteShortcut2(oTestTypes.moveToPreviousHeader); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); + ExecuteShortcut2(oTestTypes.moveToPreviousHeader); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[0].Header); + + ExecuteShortcut2(oTestTypes.moveToNextHeader); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); + ExecuteShortcut2(oTestTypes.moveToNextHeader); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header); + + RemoveHeader(2); + RemoveFooter(2); + }); + + QUnit.test('Check reset selection shortcut', (assert) => + { + TurnOnRecalculate(); + const p = ClearDocumentAndAddParagraph(""); + AscTest.Recalculate(); + + const dr1 = createShape(0, 0, 10, 10); + const dr2 = createShape(0, 0, 10, 10); + + selectDrawing([dr1, dr2]); + + const group = GetDrawingObjects().groupSelectedObjects(); + group.GraphicObj.selectObject(dr1.GraphicObj, 0); + GetDrawingObjects().selection.groupSelection = group.GraphicObj; + + ExecuteShortcut2(oTestTypes.resetShapeSelection); + assert.strictEqual(GetDrawingObjects().selectedObjects.length, 0); + TurnOffRecalculate(); + }); + + QUnit.test('Check reset actions shortcut', (assert) => + { + TurnOnRecalculate(); + const p = ClearDocumentAndAddParagraph(""); + AscTest.Recalculate() + editor.StartAddShape('rect'); + ExecuteShortcut2(oTestTypes.resetStartAddShape); + assert.strictEqual(editor.isStartAddShape, false, "Test reset add shape"); + TurnOffRecalculate(); + editor.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOn); + ExecuteShortcut2(oTestTypes.resetFormattingByExample); + assert.strictEqual(editor.isFormatPainterOn(), false, "Test reset formatting by example"); + + editor.SetMarkerFormat(true, true, 0, 0, 0); + ExecuteShortcut2(oTestTypes.resetMarkerFormat); + assert.strictEqual(editor.isMarkerFormat, false, "Test reset marker"); + }); + + QUnit.test('Check disable shortcuts', (assert) => + { + assert.strictEqual(ExecuteShortcut2(oTestTypes.disableNumLock) & keydownresult_PreventAll, keydownresult_PreventAll); + assert.strictEqual(ExecuteShortcut2(oTestTypes.disableScrollLock) & keydownresult_PreventAll, keydownresult_PreventAll); + }); + + let nKeyId = 0; + function AddCheckBox() + { + const oCheckBox = logicDocument.AddContentControlCheckBox(); + var specProps = new AscCommon.CSdtCheckBoxPr(); + oCheckBox.ApplyCheckBoxPr(specProps); + oCheckBox.SetFormPr(new AscCommon.CSdtFormPr('key' + nKeyId++, '', '', false)); + return oCheckBox; + } + + function AddComboBox(arrItems) + { + const oComboBox = logicDocument.AddContentControlComboBox(); + var specProps = new AscCommon.CSdtComboBoxPr(); + specProps.clear(); + for (let i = 0; i < arrItems.length; i++) + { + specProps.add_Item(arrItems[i], arrItems[i]); + } + + oComboBox.ApplyComboBoxPr(specProps); + oComboBox.SetFormPr(new AscCommon.CSdtFormPr('key' + nKeyId++, '', '', false)); + + return oComboBox; + } + + QUnit.test('Check boxes shortcuts', (assert) => + { + AscTest.SetFillingFormMode(false); + let p = ClearDocumentAndAddParagraph(''); + + const checkBox = AddCheckBox(); + AscTest.SetFillingFormMode(true); + ExecuteShortcut2(oTestTypes.toggleCheckBox); + assert.true(checkBox.IsCheckBoxChecked()); + + ExecuteShortcut2(oTestTypes.toggleCheckBox); + assert.false(checkBox.IsCheckBoxChecked()); + AscTest.SetFillingFormMode(false); + + ClearDocumentAndAddParagraph(''); + const oComboBox = AddComboBox(['Hello', 'World', 'yo']); + AscTest.SetFillingFormMode(true); + ExecuteShortcut2(oTestTypes.nextOptionComboBox); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); + + ExecuteShortcut2(oTestTypes.nextOptionComboBox); + assert.strictEqual(logicDocument.GetSelectedText(), 'World'); + + ExecuteShortcut2(oTestTypes.nextOptionComboBox); + assert.strictEqual(logicDocument.GetSelectedText(), 'yo'); + + ExecuteShortcut2(oTestTypes.previousOptionComboBox); + assert.strictEqual(logicDocument.GetSelectedText(), 'World'); + + ExecuteShortcut2(oTestTypes.previousOptionComboBox); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); + + ExecuteShortcut2(oTestTypes.previousOptionComboBox); + assert.strictEqual(logicDocument.GetSelectedText(), 'yo'); + AscTest.SetEditingMode(); + }); + + QUnit.test('Check remove objects shortcut', (assert) => + { + console.log(!!(editor.restrictions & Asc.c_oAscRestrictionType.OnlyForms)) + TurnOnRecalculate(); + const p = ClearDocumentAndAddParagraph(''); + AscTest.Recalculate(); + let dr = createShape(0, 0 , 10, 10); + selectDrawing([dr]); + + ExecuteShortcut2(oTestTypes.removeShape, 0); + assert.strictEqual(p.GetRunByElement(dr), null, 'Test remove shape'); + + dr = createShape(0, 0 , 10, 10); + selectDrawing([dr]); + + ExecuteShortcut2(oTestTypes.removeShape, 1); + assert.strictEqual(p.GetRunByElement(dr), null, 'Test remove shape'); + TurnOffRecalculate(); + }); + + QUnit.test('Check move on forms', (assert) => + { + const p = ClearDocumentAndAddParagraph(''); + let oCC1 = AddCheckBox(); + AscTest.MoveCursorRight(); + let oCC2 = AddCheckBox(); + AscTest.MoveCursorRight(); + let oCC3 = AddCheckBox(); + AscTest.SetFillingFormMode(true); + + + ExecuteShortcut2(oTestTypes.moveToNextForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC1, 'Test move to next form'); + + ExecuteShortcut2(oTestTypes.moveToNextForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC2, 'Test move to next form'); + + ExecuteShortcut2(oTestTypes.moveToNextForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC3, 'Test move to next form'); + + ExecuteShortcut2(oTestTypes.moveToPreviousForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC2, 'Test move to previous form'); + ExecuteShortcut2(oTestTypes.moveToPreviousForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC1, 'Test move to previous form'); + ExecuteShortcut2(oTestTypes.moveToPreviousForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC3, 'Test move to previous form'); + + AscTest.SetEditingMode(); + }); + + function AddTable(row, column) + { + let table = AscTest.CreateTable(row, column); + logicDocument.PushToContent(table); + return table; + } + + QUnit.test('Check move in table shortcuts', (assert) => + { + ClearDocumentAndAddParagraph(); + const table = AddTable(3, 4); + table.Document_SetThisElementCurrent(); + table.MoveCursorToStartPos(); + ExecuteShortcut2(oTestTypes.moveToNextCell); + assert.strictEqual(table.CurCell.Index, 1); + ExecuteShortcut2(oTestTypes.moveToNextCell); + assert.strictEqual(table.CurCell.Index, 2); + ExecuteShortcut2(oTestTypes.moveToNextCell); + assert.strictEqual(table.CurCell.Index, 3); + + ExecuteShortcut2(oTestTypes.moveToPreviousCell); + assert.strictEqual(table.CurCell.Index, 2); + ExecuteShortcut2(oTestTypes.moveToPreviousCell); + assert.strictEqual(table.CurCell.Index, 1); + ExecuteShortcut2(oTestTypes.moveToPreviousCell); + assert.strictEqual(table.CurCell.Index, 0); + }); + + function AddChart() + { + const oDrawingDocument = editor.WordControl.m_oDrawingDocument; + const oDrawing = new ParaDrawing(100, 100, null, oDrawingDocument, null, null); + const oChartSpace = logicDocument.GetChartObject(Asc.c_oAscChartTypeSettings.lineNormal); + oChartSpace.spPr.setXfrm(new AscFormat.CXfrm()); + oChartSpace.spPr.xfrm.setOffX(0); + oChartSpace.spPr.xfrm.setOffY(0); + oChartSpace.spPr.xfrm.setExtX(100); + oChartSpace.spPr.xfrm.setExtY(100); + + oChartSpace.setParent(oDrawing); + oDrawing.Set_GraphicObject(oChartSpace); + oDrawing.setExtent(oChartSpace.spPr.xfrm.extX, oChartSpace.spPr.xfrm.extY); + + oDrawing.Set_DrawingType(drawing_Anchor); + oDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); + oDrawing.Set_Distance(0, 0, 0, 0); + const oNearestPos = logicDocument.Get_NearestPos(0, oChartSpace.x, oChartSpace.y, true, oDrawing); + oDrawing.Set_XYForAdd(oChartSpace.x, oChartSpace.y, oNearestPos, 0); + oDrawing.AddToDocument(oNearestPos); + AscTest.Recalculate(); + return oDrawing; + } + QUnit.test('Check Select all in chart title', (assert) => + { + TurnOnRecalculate(); + const p = ClearDocumentAndAddParagraph(''); + AscTest.Recalculate(); + const dr = AddChart(); + + const oChart = dr.GraphicObj; + selectDrawing([dr]); + const oTitles = oChart.getAllTitles(); + const oController = GetDrawingObjects(); + oController.selection.chartSelection = oChart; + oChart.selectTitle(oTitles[0], 0); + + ExecuteShortcut2(oTestTypes.selectAllInChartTitle); + assert.strictEqual(logicDocument.GetSelectedText(), 'Diagram Title', 'Check select all title'); + TurnOffRecalculate(); + }); + + QUnit.test('add new paragraph content', (assert) => + { + const p = ClearDocumentAndAddParagraph('Hello text'); + ExecuteShortcut2(oTestTypes.addNewParagraphContent); + assert.strictEqual(logicDocument.Content.length, 2); + }); + + QUnit.test('Check add new paragraph math', (assert) => + { + const p = ClearDocumentAndAddParagraph('Hello text'); + logicDocument.AddParaMath(); + AscTest.EnterText('abcd'); + AscTest.MoveCursorLeft(); + ExecuteShortcut2(oTestTypes.addNewParagraphMath) + assert.strictEqual(logicDocument.Content.length, 2, 'Test add new paragraph with math'); + }); + + QUnit.test("Test add new line to math", (oAssert) => + { + const p = ClearDocumentAndAddParagraph(''); + logicDocument.AddParaMath(c_oAscMathType.FractionVertical); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.EnterText('Hello'); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + ExecuteShortcut2(oTestTypes.addNewLineToMath); + const oParaMath = p.GetAllParaMaths()[0]; + const oFraction = oParaMath.Root.GetFirstElement(); + const oNumerator = oFraction.getNumerator(); + const oEqArray = oNumerator.GetFirstElement(); + oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); + }); + + function AddComplexForm() + { + let complexForm = logicDocument.AddComplexForm(); + const formPr = new AscWord.CSdtFormPr(); + var formTextPr = new AscCommon.CSdtTextFormPr(); + formTextPr.put_MultiLine(true); + complexForm.SetFormPr(formPr); + complexForm.SetTextFormPr(formTextPr); + return complexForm; + } + + // todo + // QUnit.test("Test remove form", (assert) => + // { + // AscTest.SetFillingFormMode(false) + // const p = ClearDocumentAndAddParagraph(''); + // const form = AddComboBox(['hdfh']); + // ExecuteShortcut2(oTestTypes.removeForm); + // assert.strictEqual(p.GetPosByElement(form), null, 'Check add new line math'); + // AscTest.SetEditingMode() + // }); + + QUnit.test("Add tab to paragraph", (assert) => + { + const p = ClearDocumentAndAddParagraph(''); + ExecuteShortcut2(oTestTypes.addTabToParagraph); + assert.true(p.GetPrevRunElement().IsTab()); + }); + + + QUnit.test("Test add break line to inlinelvlsdt", (assert) => + { + TurnOnRecalculate(); + const p = ClearDocumentAndAddParagraph(''); + const oInlineSdt = AddComplexForm(); + ExecuteShortcut2(oTestTypes.addBreakLineInlineLvlSdt); + assert.strictEqual(oInlineSdt.Lines[0], 2); + TurnOffRecalculate(); + }); + + QUnit.test("Test visit hyperlink", (assert) => + { + TurnOnRecalculate() + const p = ClearDocumentAndAddParagraph(''); + + logicDocument.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Page)) + logicDocument.AddHyperlink(new Asc.CHyperlinkProperty({Anchor: '_top', Text: "Beginning of document"})); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + ExecuteShortcut2(oTestTypes.visitHyperlink); + AscTest.Recalculate() + assert.strictEqual(logicDocument.GetCurrentParagraph(), logicDocument.Content[0]); + assert.strictEqual(logicDocument.Get_CurPage(), 0); + TurnOffRecalculate(); + }); + + QUnit.test("Test handle tab in math", (oAssert) => + { + + const p = ClearDocumentAndAddParagraph(''); + logicDocument.AddParaMath(); + AscTest.EnterText('abcd+abcd+abcd'); + logicDocument.MoveCursorToEndPos(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + + const oProps = new CMathMenuBase(); + oProps.insert_ManualBreak(); + logicDocument.Set_MathProps(oProps); + ExecuteShortcut2(oTestTypes.handleTab); + AscTest.MoveCursorRight(); + const oContentPosition = logicDocument.GetContentPosition(); + const oCurRun = oContentPosition[oContentPosition.length - 1].Class; + oAssert.strictEqual(oCurRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); + }); + + // todo + // QUnit.test("Test end editing", (assert) => + // { + // TurnOnRecalculate(); + // AscTest.SetFillingFormMode(false); + // const p = ClearDocumentAndAddParagraph(''); + // const oCheckBox = AddCheckBox(); + // AscTest.SetFillingFormMode(true); + // oCheckBox.MoveCursorToContentControl(true); + // ExecuteShortcut2(oTestTypes.endEditing); + // const oSelectedInfo = logicDocument.GetSelectedElementsInfo(); + // assert.strictEqual(!!oSelectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); + // AscTest.SetEditingMode(); + // + // GoToHeader(0); + // ExecuteShortcut2(oTestTypes.endEditing); + // assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); + // RemoveHeader(0); + // + // GoToFooter(0); + // ExecuteShortcut2(oTestTypes.endEditing); + // assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); + // RemoveFooter(0); + // TurnOffRecalculate(); + // }); + + QUnit.test("Test unicode to char hotkeys", (assert) => + { + const p = ClearDocumentAndAddParagraph('2601'); + AscTest.MoveCursorLeft(true, true); + ExecuteShortcut2(oTestTypes.unicodeToChar); + assert.strictEqual(logicDocument.GetSelectedText(), '☁', 'Test replace unicode code to symbol'); + }); + function mouseDown(x, y, page, isRight, count) + { + if (!logicDocument) + return; + + let e = new AscCommon.CMouseEventHandler(); + + e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; + e.ClickCount = count ? count : 1; + + e.Type = AscCommon.g_mouse_event_type_down; + logicDocument.OnMouseDown(e, x, y, page); + } + + function mouseUp(x, y, page, isRight, count) + { + if (!logicDocument) + return; + + let e = new AscCommon.CMouseEventHandler(); + + e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; + e.ClickCount = count ? count : 1; + + e.Type = AscCommon.g_mouse_event_type_up; + logicDocument.OnMouseUp(e, x, y, page); + } + + function mouseMove(x, y, page, isRight, count) + { + if (!logicDocument) + return; + + let e = new AscCommon.CMouseEventHandler(); + + e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; + e.ClickCount = count ? count : 1; + + e.Type = AscCommon.g_mouse_event_type_move; + logicDocument.OnMouseMove(e, x, y, page); + } + // todo + // QUnit.test("Test reset drag'n'drop", (oAssert) => + // { + // TurnOnRecalculate(); + // const p = ClearDocumentAndAddParagraph('Hello Hello'); + // AscTest.Recalculate(); + // logicDocument.MoveCursorToStartPos(); + // AscTest.MoveCursorRight(true, true); + // mouseDown(5, 10, 0, false, 1); + // mouseMove(15, 10, 0, false, 1); + // //ExecuteShortcut2(oTestTypes.resetDragNDrop); + // mouseUp(15, 10, 0, false, 1); + // logicDocument.SelectAll() + // oAssert.strictEqual(logicDocument.GetSelectedText(), 'Hello Hello', "Test reset drag'n'drop"); + // TurnOffRecalculate(); + // + // }); + + // QUnit.test("test visit hyperlink", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['']); + // addBreakPage(); + // createHyperlink(); + // moveCursorLeft(); + // moveCursorLeft(); + // onKeyDown(oEvent); + // oAssert.strictEqual(oGlobalLogicDocument.GetCurrentParagraph(), logicContent()[0]); + // oAssert.strictEqual(oGlobalLogicDocument.Get_CurPage(), 0); + // }, oTestTypes.visitHyperlink); + // }); + + + // QUnit.test("Test add new paragraph", (oAssert) => + // { + // startTest((oEvent) => + // { + // getLogicDocumentWithParagraphs(['']); + // createMath(); + // addText('abcd'); + // moveCursorLeft(); + // onKeyDown(oEvent); + // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph with math'); + // }, oTestTypes.addNewParagraphMath); + // }); + + // QUnit.test("Test add new paragraph", (oAssert) => + // { + // startTest((oEvent) => + // { + // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Text']); + // moveToParagraph(oParagraph); + // onKeyDown(oEvent); + // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph to content'); + // }, oTestTypes.addNewParagraphContent); + // }); + // // QUnit.test('Check show non printing characters shortcut', (oAssert) => // { diff --git a/word/Editor/Math.js b/word/Editor/Math.js index c86afa7638..dda649d9f9 100644 --- a/word/Editor/Math.js +++ b/word/Editor/Math.js @@ -1069,7 +1069,7 @@ function ParaMath() this.DefaultTextPr.RFonts.SetAll("Cambria Math", -1); // Добавляем данный класс в таблицу Id (обязательно в конце конструктора) - g_oTableId.Add( this, this.Id ); + AscCommon.g_oTableId.Add( this, this.Id ); } ParaMath.prototype = Object.create(CParagraphContentWithContentBase.prototype); From f37d5180e3bc42b0fe1e5c5023a4562f9411d1bf Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 10 Aug 2023 13:17:53 +0300 Subject: [PATCH 05/23] Refactor document shortcuts --- tests/word/common/editor.js | 10 +- tests/word/shortcuts/events.js | 172 +- tests/word/shortcuts/helpers.js | 821 --------- tests/word/shortcuts/shortcuts.html | 18 +- tests/word/shortcuts/shortcuts.js | 2555 ++++++--------------------- 5 files changed, 639 insertions(+), 2937 deletions(-) delete mode 100644 tests/word/shortcuts/helpers.js diff --git a/tests/word/common/editor.js b/tests/word/common/editor.js index 9b584bc570..2fe0950329 100644 --- a/tests/word/common/editor.js +++ b/tests/word/common/editor.js @@ -63,13 +63,7 @@ GetDotsPerMM : function(value) {return 72;}, EndTrackTable : function() {}, SetCurrentPage : function(pageNum) {}, - SelectClear : function() {}, - OnRePaintAttack : function() {}, - IsFreezePage : function() {}, - Set_RulerState_HdrFtr : function() {}, - IsTrackText : function() {}, - ConvertCoordsToCursorWR : function(X, Y) {return {X: X, Y: Y}}, - OnUpdateOverlay : function() {} + SelectClear : function() {} }; drawingDocument.CanvasHit = document.createElement('canvas'); @@ -81,7 +75,7 @@ editor.WordControl = drawingDocument; editor.WordControl.m_oDrawingDocument = drawingDocument; editor.WordControl.m_oDrawingDocument.m_oWordControl = drawingDocument; - editor.WordControl.m_oDrawingDocument.m_oWordControl.m_oApi = editor; + editor.WordControl.m_oApi = editor; editor.sync_BeginCatchRevisionsChanges = function(){}; editor.sync_EndCatchRevisionsChanges = function(){}; editor.sync_ChangeCommentLogicalPosition = function(){}; diff --git a/tests/word/shortcuts/events.js b/tests/word/shortcuts/events.js index 13d8ce5887..f24d1e1ff6 100644 --- a/tests/word/shortcuts/events.js +++ b/tests/word/shortcuts/events.js @@ -33,7 +33,7 @@ (function (window) { window.AscTestShortcut = {}; - const oTestTypes = { + const testHotkeyActions = { removeBackSymbol : 0, removeBackWord : 1, removeShape : 2, @@ -78,7 +78,7 @@ moveToStartDocument : 42, selectLeftWord : 43, moveToLeftWord : 44, - selectLeftChar : 45, + selectLeftChar : 45, moveToLeftChar : 46, moveToRightChar : 47, selectRightChar : 48, @@ -119,107 +119,107 @@ moveToNextHeader : 83 }; - const oTestEvents = {}; - oTestEvents[oTestTypes.bigMoveGraphicObjectLeft] = [new CTestEvent(37, false, false, false, false, false)]; - oTestEvents[oTestTypes.littleMoveGraphicObjectLeft] = [new CTestEvent(37, true, false, false, false, false)]; - oTestEvents[oTestTypes.bigMoveGraphicObjectRight] = [new CTestEvent(39, false, false, false, false, false)]; - oTestEvents[oTestTypes.littleMoveGraphicObjectRight] = [new CTestEvent(39, true, false, false, false, false)]; - oTestEvents[oTestTypes.bigMoveGraphicObjectDown] = [new CTestEvent(40, false, false, false, false, false)]; - oTestEvents[oTestTypes.littleMoveGraphicObjectDown] = [new CTestEvent(40, true, false, false, false, false)]; - oTestEvents[oTestTypes.bigMoveGraphicObjectUp] = [new CTestEvent(38, false, false, false, false, false)]; - oTestEvents[oTestTypes.littleMoveGraphicObjectUp] = [new CTestEvent(38, true, false, false, false, false)]; - oTestEvents[oTestTypes.removeBackSymbol] = [new CTestEvent(8, false, false, false, false)]; - oTestEvents[oTestTypes.removeBackWord] = [new CTestEvent(8, true, false, false, false)]; - oTestEvents[oTestTypes.removeShape] = [ + const testHotkeyEvents = {}; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectLeft] = [new CTestEvent(37, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectLeft] = [new CTestEvent(37, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectRight] = [new CTestEvent(39, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectRight] = [new CTestEvent(39, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectDown] = [new CTestEvent(40, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectDown] = [new CTestEvent(40, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectUp] = [new CTestEvent(38, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectUp] = [new CTestEvent(38, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeBackSymbol] = [new CTestEvent(8, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeBackWord] = [new CTestEvent(8, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeShape] = [ new CTestEvent(8, false, false, false, false, false), new CTestEvent(46, false, false, false, false, false) ]; - oTestEvents[oTestTypes.removeForm] = [ + testHotkeyEvents[testHotkeyActions.removeForm] = [ new CTestEvent(8, false, false, false, false, false), new CTestEvent(46, false, false, false, false, false) ]; - oTestEvents[oTestTypes.moveToNextForm] = [new CTestEvent(9, false, false, false, false, false)]; - oTestEvents[oTestTypes.moveToPreviousForm] = [new CTestEvent(9, false, true, false, false, false)]; - oTestEvents[oTestTypes.handleTab] = [new CTestEvent(9, false, false, false, false, false)]; - oTestEvents[oTestTypes.moveToNextCell] = [new CTestEvent(9, false, false, false, false)]; - oTestEvents[oTestTypes.moveToPreviousCell] = [new CTestEvent(9, false, true, false, false)]; - oTestEvents[oTestTypes.selectNextObject] = [new CTestEvent(9, false, false, false, false)]; - oTestEvents[oTestTypes.selectPreviousObject] = [new CTestEvent(9, false, true, false, false)]; - oTestEvents[oTestTypes.testIndent] = [new CTestEvent(9, false, false, false, false)]; - oTestEvents[oTestTypes.testUnIndent] = [new CTestEvent(9, false, true, false, false)]; - oTestEvents[oTestTypes.addTabToParagraph] = [new CTestEvent(9, false, false, false)]; - oTestEvents[oTestTypes.visitHyperlink] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.addBreakLineInlineLvlSdt] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.createTextBoxContent] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.createTextBody] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.addNewLineToMath] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.moveCursorToStartPositionShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.selectAllShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.selectAllInChartTitle] = [new CTestEvent(13, false, false, false, false, false)]; - oTestEvents[oTestTypes.addNewParagraphContent] = [new CTestEvent(13, false, false, false, false)]; - oTestEvents[oTestTypes.addNewParagraphMath] = [new CTestEvent(13, false, false, false, false)]; - oTestEvents[oTestTypes.closeAllWindowsPopups] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.resetShapeSelection] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.resetStartAddShape] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.resetFormattingByExample] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.resetMarkerFormat] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.resetDragNDrop] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.endEditing] = [new CTestEvent(27, false, false, false, false, false)]; - oTestEvents[oTestTypes.toggleCheckBox] = [new CTestEvent(32, false, false, false, false, false)]; - oTestEvents[oTestTypes.moveToEndDocument] = [new CTestEvent(35, true, false, false)]; - oTestEvents[oTestTypes.moveToEndLine] = [new CTestEvent(35, false, false, false, false)]; - oTestEvents[oTestTypes.selectToEndDocument] = [new CTestEvent(35, true, true, false, false)]; - oTestEvents[oTestTypes.selectToEndLine] = [new CTestEvent(35, false, true, false, false)]; - oTestEvents[oTestTypes.selectToStartLine] = [new CTestEvent(36, false, true, false, false)]; - oTestEvents[oTestTypes.selectToStartDocument] = [new CTestEvent(36, true, true, false, false)]; - oTestEvents[oTestTypes.moveToStartLine] = [new CTestEvent(36, false, false, false, false)]; - oTestEvents[oTestTypes.moveToStartDocument] = [new CTestEvent(36, true, false, false)]; - oTestEvents[oTestTypes.selectLeftWord] = [new CTestEvent(37, true, true, false, false)]; - oTestEvents[oTestTypes.moveToLeftWord] = [new CTestEvent(37, true, false, false, false)]; - oTestEvents[oTestTypes.selectLeftChar] = [new CTestEvent(37, false, true, false, false)]; - oTestEvents[oTestTypes.moveToLeftChar] = [new CTestEvent(37, false, false, false, false)]; - oTestEvents[oTestTypes.moveToRightChar] = [new CTestEvent(39, false, false, false, false)]; - oTestEvents[oTestTypes.selectRightChar] = [new CTestEvent(39, false, true, false, false)]; - oTestEvents[oTestTypes.moveToRightWord] = [new CTestEvent(39, true, false, false, false)]; - oTestEvents[oTestTypes.selectRightWord] = [new CTestEvent(39, true, true, false, false)]; - oTestEvents[oTestTypes.moveUp] = [new CTestEvent(38, false, false, false, false)]; - oTestEvents[oTestTypes.selectUp] = [new CTestEvent(38, false, true, false, false)]; - oTestEvents[oTestTypes.previousOptionComboBox] = [new CTestEvent(38, false, false, false, false, false)]; - oTestEvents[oTestTypes.moveDown] = [new CTestEvent(40, false, false, false, false)]; - oTestEvents[oTestTypes.selectDown] = [new CTestEvent(40, false, true, false, false)]; - oTestEvents[oTestTypes.nextOptionComboBox] = [new CTestEvent(40, false, false, false, false, false)]; - oTestEvents[oTestTypes.removeFrontSymbol] = [new CTestEvent(46, false, false, false, false)]; - oTestEvents[oTestTypes.removeFrontWord] = [new CTestEvent(46, true, false, false, false)]; - oTestEvents[oTestTypes.unicodeToChar] = [ + testHotkeyEvents[testHotkeyActions.moveToNextForm] = [new CTestEvent(9, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousForm] = [new CTestEvent(9, false, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.handleTab] = [new CTestEvent(9, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextCell] = [new CTestEvent(9, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousCell] = [new CTestEvent(9, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectNextObject] = [new CTestEvent(9, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectPreviousObject] = [new CTestEvent(9, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.testIndent] = [new CTestEvent(9, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.testUnIndent] = [new CTestEvent(9, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.addTabToParagraph] = [new CTestEvent(9, false, false, false)]; + testHotkeyEvents[testHotkeyActions.visitHyperlink] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addBreakLineInlineLvlSdt] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.createTextBoxContent] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.createTextBody] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addNewLineToMath] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveCursorToStartPositionShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectAllShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectAllInChartTitle] = [new CTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addNewParagraphContent] = [new CTestEvent(13, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addNewParagraphMath] = [new CTestEvent(13, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.closeAllWindowsPopups] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetShapeSelection] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetStartAddShape] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetFormattingByExample] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetMarkerFormat] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetDragNDrop] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.endEditing] = [new CTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.toggleCheckBox] = [new CTestEvent(32, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToEndDocument] = [new CTestEvent(35, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToEndLine] = [new CTestEvent(35, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToEndDocument] = [new CTestEvent(35, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToEndLine] = [new CTestEvent(35, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartLine] = [new CTestEvent(36, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartDocument] = [new CTestEvent(36, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartLine] = [new CTestEvent(36, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartDocument] = [new CTestEvent(36, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectLeftWord] = [new CTestEvent(37, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToLeftWord] = [new CTestEvent(37, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectLeftChar] = [new CTestEvent(37, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToLeftChar] = [new CTestEvent(37, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToRightChar] = [new CTestEvent(39, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectRightChar] = [new CTestEvent(39, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToRightWord] = [new CTestEvent(39, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectRightWord] = [new CTestEvent(39, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveUp] = [new CTestEvent(38, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectUp] = [new CTestEvent(38, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.previousOptionComboBox] = [new CTestEvent(38, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveDown] = [new CTestEvent(40, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectDown] = [new CTestEvent(40, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.nextOptionComboBox] = [new CTestEvent(40, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeFrontSymbol] = [new CTestEvent(46, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeFrontWord] = [new CTestEvent(46, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.unicodeToChar] = [ new CTestEvent(88, false, false, true, false), new CTestEvent(88, true, false, true, false) ]; - oTestEvents[oTestTypes.showContextMenu] = [ + testHotkeyEvents[testHotkeyActions.showContextMenu] = [ new CTestEvent(93, false, false, false, false), new CTestEvent(57351, false, false, false, false), new CTestEvent(121, false, true, false, false) ]; - oTestEvents[oTestTypes.disableNumLock] = [new CTestEvent(144, false, false, false, false)]; - oTestEvents[oTestTypes.disableScrollLock] = [new CTestEvent(145, false, false, false, false)]; - oTestEvents[oTestTypes.addSJKSpace] = [new CTestEvent(12288, false, false, false, false)]; - oTestEvents[oTestTypes.moveToStartPreviousPage] = [new CTestEvent(33, true, false, true, false)]; - oTestEvents[oTestTypes.moveToPreviousPage] = [new CTestEvent(33, false, false, false, false)]; - oTestEvents[oTestTypes.moveToPreviousHeaderFooter] = [new CTestEvent(33, false, false, false, false)]; - oTestEvents[oTestTypes.moveToPreviousHeader] = [ + testHotkeyEvents[testHotkeyActions.disableNumLock] = [new CTestEvent(144, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.disableScrollLock] = [new CTestEvent(145, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addSJKSpace] = [new CTestEvent(12288, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartPreviousPage] = [new CTestEvent(33, true, false, true, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousPage] = [new CTestEvent(33, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousHeaderFooter] = [new CTestEvent(33, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousHeader] = [ new CTestEvent(33, true, false, true, false), new CTestEvent(33, false, false, true, false) ]; - oTestEvents[oTestTypes.selectToStartPreviousPage] = [new CTestEvent(33, true, true, false, false)]; - oTestEvents[oTestTypes.selectToPreviousPage] = [new CTestEvent(33, false, true, false, false)]; - oTestEvents[oTestTypes.moveToStartNextPage] = [new CTestEvent(34, true, false, true, false)]; - oTestEvents[oTestTypes.moveToNextPage] = [new CTestEvent(34, false, false, false, false)]; - oTestEvents[oTestTypes.moveToNextHeaderFooter] = [new CTestEvent(34, false, false, false, false)]; - oTestEvents[oTestTypes.moveToNextHeader] = [ + testHotkeyEvents[testHotkeyActions.selectToStartPreviousPage] = [new CTestEvent(33, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToPreviousPage] = [new CTestEvent(33, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartNextPage] = [new CTestEvent(34, true, false, true, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextPage] = [new CTestEvent(34, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextHeaderFooter] = [new CTestEvent(34, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextHeader] = [ new CTestEvent(34, true, false, true, false), new CTestEvent(34, false, false, true, false) ]; - oTestEvents[oTestTypes.selectToStartNextPage] = [new CTestEvent(34, true, true, false, false)]; - oTestEvents[oTestTypes.selectToNextPage] = [new CTestEvent(34, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartNextPage] = [new CTestEvent(34, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToNextPage] = [new CTestEvent(34, false, true, false, false)]; function CTestEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) @@ -242,6 +242,6 @@ this.isPropagationStopped = true; }; - AscTestShortcut.oTestTypes = oTestTypes; - AscTestShortcut.oTestEvents = oTestEvents; + AscTestShortcut.testHotkeyActions = testHotkeyActions; + AscTestShortcut.testHotkeyEvents = testHotkeyEvents; })(window); diff --git a/tests/word/shortcuts/helpers.js b/tests/word/shortcuts/helpers.js deleted file mode 100644 index 29fc5e79a3..0000000000 --- a/tests/word/shortcuts/helpers.js +++ /dev/null @@ -1,821 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -(function (window) -{ - window.setTimeout = function (callback) - { - callback(); - } - - window.AscFonts = window.AscFonts || {}; - AscFonts.g_fontApplication = { - GetFontInfo : function (sFontName) - { - if (sFontName === 'Cambria Math') - { - return new AscFonts.CFontInfo('Cambria Math', 40, 1, 433, 1, -1, -1, -1, -1, -1, -1); - } - }, - Init : function () - { - - }, - LoadFont : function () - { - - }, - GetFontInfoName: function () {} - } - - window.g_fontApplication = AscFonts.g_fontApplication; - AscCommon.CTableId = Object; - const AscTestShortcut = window.AscTestShortcut = {}; - - AscCommon.CGraphics.prototype.SetFontSlot = function () {}; - AscCommon.CGraphics.prototype.SetFont = function () {}; - AscCommon.CGraphics.prototype.SetFontInternal = function () {}; - AscCommon.loadSmartArtBinary = function () - { - - }; - - Asc.asc_docs_api.prototype._loadModules = function () {}; - AscCommon.baseEditorsApi.prototype._onEndLoadSdk = function() { - this.ImageLoader = AscCommon.g_image_loader; - this.chartPreviewManager = new AscCommon.ChartPreviewManager(); - this.textArtPreviewManager = new AscCommon.TextArtPreviewManager(); - - AscFormat.initStyleManager(); - }; - let editor = new Asc.asc_docs_api({'id-view': 'editor_sdk'}); - window.editor = editor; - editor.WordControl.m_oDrawingDocument.GetVisibleMMHeight = () => 100; - editor.WordControl.OnUpdateOverlay = () => {}; - AscCommon.loadSdk = function () - { - editor._onEndLoadSdk(); - } - - Asc.createPluginsManager = function () - { - - }; - - AscFonts.FontPickerByCharacter = { - checkText : function (text, _this, callback) - { - callback.call(_this); - }, - getFontBySymbol: function () - { - - } - }; - - AscCommon.CDocsCoApi.prototype.askSaveChanges = function (callback) - { - callback({"saveLock": false}); - }; - - let oGlobalLogicDocument; - - function createLogicDocument() - { - if (oGlobalLogicDocument) - return oGlobalLogicDocument; - - editor.InitEditor(); - editor.bInit_word_control = true; - editor.WordControl.StartMainTimer = function () - { - - }; - editor.WordControl.InitControl(); - - oGlobalLogicDocument = editor.WordControl.m_oLogicDocument; - editor.WordControl.m_oDrawingDocument.m_oLogicDocument = oGlobalLogicDocument; - oGlobalLogicDocument.UpdateAllSectionsInfo(); - oGlobalLogicDocument.Set_DocumentPageSize(100, 100); - var props = new Asc.CDocumentSectionProps(); - props.put_TopMargin(0); - props.put_LeftMargin(0); - props.put_BottomMargin(0); - props.put_RightMargin(0); - oGlobalLogicDocument.Set_SectionProps(props); - oGlobalLogicDocument.private_IsStartTimeoutOnRecalc = function () - { - return false; - } - return oGlobalLogicDocument; - } - - createLogicDocument(); - oGlobalLogicDocument.UpdateAllSectionsInfo(); - - AscCommon.g_font_loader.LoadFont = function () - { - return false; - } - editor.WordControl.m_oLogicDocument.Document_UpdateInterfaceState = function () - { - }; - AscTest.CreateParagraph = function () - { - return new AscWord.CParagraph(editor.WordControl.m_oDrawingDocument); - } - - function addPropertyToDocument(oPr) - { - oGlobalLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(oPr), true); - } - - function checkTextAfterKeyDownHelperEmpty(sCheckText, oEvent, oAssert, sPrompt) - { - checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, ''); - } - - function moveCursorDown(AddToSelect, CtrlKey) - { - oGlobalLogicDocument.MoveCursorDown(AddToSelect, CtrlKey); - } - - function moveCursorUp(AddToSelect, CtrlKey) - { - oGlobalLogicDocument.MoveCursorUp(AddToSelect, CtrlKey); - } - - function moveToParagraph(oParagraph, bIsStart, bSkipRemoveSelection) - { - if (!bSkipRemoveSelection) - { - oGlobalLogicDocument.RemoveSelection(); - } - if (oParagraph.Parent.SetThisElementCurrent) - { - oParagraph.Parent.SetThisElementCurrent(); - } - - oParagraph.SetThisElementCurrent(); - if (bIsStart) - { - oParagraph.MoveCursorToStartPos(); - } else - { - oParagraph.MoveCursorToEndPos(); - } - oGlobalLogicDocument.private_UpdateCursorXY(true, true); - } - - function insertManualBreak() - { - const oProps = new CMathMenuBase(); - oProps.insert_ManualBreak() - editor.asc_SetMathProps(oProps); - } - - function resetLogicDocument(oLogicDocument) - { - oLogicDocument.SetDocPosType(AscCommonWord.docpostype_Content); - } - - function clean() - { - oGlobalLogicDocument.RemoveFromContent(0, oGlobalLogicDocument.GetElementsCount(), false); - } - - function getLogicDocumentWithParagraphs(arrText, bRecalculate) - { - resetLogicDocument(oGlobalLogicDocument); - if (!oGlobalLogicDocument.TurnOffRecalc) - { - oGlobalLogicDocument.Start_SilentMode(); - } - clean(); - if (Array.isArray(arrText)) - { - for (let i = 0; i < arrText.length; i += 1) - { - addParagraphToDocumentWithText(arrText[i]); - } - } - if (oGlobalLogicDocument.TurnOffRecalc && bRecalculate) - { - oGlobalLogicDocument.End_SilentMode(true); - oGlobalLogicDocument.private_UpdateCursorXY(true, true); - recalculate(); - } - - const oFirstParagraph = oGlobalLogicDocument.Content[0]; - return {oLogicDocument: oGlobalLogicDocument, oParagraph: oFirstParagraph}; - } - - function recalculate() - { - oGlobalLogicDocument.RecalculateFromStart(false); - } - - function addParagraphToDocumentWithText(sText) - { - const oParagraph = AscTest.CreateParagraph(); - oParagraph.Set_Ind({FirstLine: 0, Left: 0, Right: 0}); - oGlobalLogicDocument.Internal_Content_Add(oGlobalLogicDocument.Content.length, oParagraph); - oParagraph.MoveCursorToEndPos(); - const oRun = new AscWord.CRun(); - oParagraph.AddToContent(0, oRun); - oRun.AddText(sText); - return oParagraph; - } - - function remove() - { - oGlobalLogicDocument.Remove(); - } - - function checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, sInitText) - { - const {oLogicDocument, oParagraph} = getLogicDocumentWithParagraphs([sInitText]); - oParagraph.SetThisElementCurrent(); - oLogicDocument.MoveCursorToEndPos(); - onKeyDown(oEvent); - const sTextAfterKeyDown = AscTest.GetParagraphText(oParagraph); - oAssert.strictEqual(sTextAfterKeyDown, sCheckText, sPrompt); - } - - function onKeyDown(oEvent) - { - editor.WordControl.onKeyDown(oEvent); - } - - const arrCheckCodes = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 189, 187, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 219, 221, 186, 222, 220, 188, 190, 191, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 111, 106, - 109, 110, 107]; - - function createNativeEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) - { - const bIsMacOs = AscCommon.AscBrowser.isMacOs; - const oEvent = {}; - oEvent.isDefaultPrevented = false; - oEvent.isPropagationStopped = false; - oEvent.preventDefault = function () - { - if (bIsMacOs && oEvent.altKey && !(oEvent.ctrlKey || oEvent.metaKey) && (arrCheckCodes.indexOf(nKeyCode) !== -1)) - { - throw new Error('Alt key must not be disabled on macOS'); - } - oEvent.isDefaultPrevented = true; - }; - oEvent.stopPropagation = function () - { - oEvent.isPropagationStopped = true; - }; - - oEvent.keyCode = nKeyCode; - oEvent.ctrlKey = bIsCtrl; - oEvent.shiftKey = bIsShift; - oEvent.altKey = bIsAlt; - oEvent.metaKey = bIsMetaKey; - return oEvent; - } - - function checkDirectTextPrAfterKeyDown(fCallback, nExpectedValue, sPrompt, oEvent, oAssert) - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - let oTextPr = getDirectTextPrHelper(oParagraph, oEvent); - oAssert.strictEqual(fCallback(oTextPr), nExpectedValue, sPrompt); - return function recursive(fCallback2, nExpectedValue2, sPrompt2, oEvent2, oAssert2) - { - oTextPr = getDirectTextPrHelper(oParagraph, oEvent2); - oAssert2.strictEqual(fCallback2(oTextPr), nExpectedValue2, sPrompt2); - return recursive; - } - } - - function checkDirectParaPrAfterKeyDown(fCallback, nExpectedValue, sPrompt, oEvent, oAssert) - { - const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - let oParaPr = getDirectParaPrHelper(oParagraph, oEvent); - oAssert.strictEqual(fCallback(oParaPr), nExpectedValue, sPrompt); - return function recursive(fCallback2, nExpectedValue2, sPrompt2, oEvent2, oAssert2) - { - oParaPr = getDirectParaPrHelper(oParagraph, oEvent2); - oAssert2.strictEqual(fCallback2(oParaPr), nExpectedValue2, sPrompt2); - return recursive; - } - } - - function getDirectTextPrHelper(oParagraph, oEvent) - { - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - onKeyDown(oEvent); - return oGlobalLogicDocument.GetDirectTextPr(); - } - - function getDirectParaPrHelper(oParagraph, oEvent) - { - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - onKeyDown(oEvent); - return oGlobalLogicDocument.GetDirectParaPr(); - } - - function getParagraphText(oParagraph) - { - return AscTest.GetParagraphText(oParagraph); - } - - function executeTestWithCatchEvent(sSendEvent, fCustomCheck, customExpectedValue, oEvent, oAssert, fBeforeCallback) - { - fBeforeCallback && fBeforeCallback(); - - let bCheck = false; - - const fCheck = function (...args) - { - if (fCustomCheck) - { - bCheck = fCustomCheck(...args); - } else - { - bCheck = true; - } - } - editor.asc_registerCallback(sSendEvent, fCheck); - - onKeyDown(oEvent); - oAssert.strictEqual(bCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); - editor.asc_unregisterCallback(sSendEvent, fCheck); - } - - function moveCursorRight(AddToSelect, Word) - { - oGlobalLogicDocument.MoveCursorRight(AddToSelect, Word); - } - - function moveCursorLeft(AddToSelect, Word) - { - oGlobalLogicDocument.MoveCursorLeft(AddToSelect, Word); - } - - function selectAll() - { - oGlobalLogicDocument.SelectAll(); - } - - function getSelectedText() - { - return oGlobalLogicDocument.GetSelectedText(false, {TabSymbol: '\t'}); - } - - function createTest(oAssert) - { - return {deep: oAssert.deepEqual.bind(oAssert), equal: oAssert.strictEqual.bind(oAssert)}; - } - - function createChart() - { - var oDrawingDocument = editor.WordControl.m_oDrawingDocument; - - var oDrawing = new ParaDrawing(100, 100, null, oDrawingDocument, null, null); - const oChartSpace = editor.asc_getChartObject(Asc.c_oAscChartTypeSettings.lineNormal); - oChartSpace.spPr.setXfrm(new AscFormat.CXfrm()); - oChartSpace.spPr.xfrm.setOffX(0); - oChartSpace.spPr.xfrm.setOffY(0); - oChartSpace.spPr.xfrm.setExtX(100); - oChartSpace.spPr.xfrm.setExtY(100); - - oChartSpace.setParent(oDrawing); - oDrawing.Set_GraphicObject(oChartSpace); - oDrawing.setExtent(oChartSpace.spPr.xfrm.extX, oChartSpace.spPr.xfrm.extY); - - oDrawing.Set_DrawingType(drawing_Anchor); - oDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); - oDrawing.Set_Distance(0, 0, 0, 0); - const oNearestPos = oGlobalLogicDocument.Get_NearestPos(0, oChartSpace.x, oChartSpace.y, true, oDrawing); - oDrawing.Set_XYForAdd(oChartSpace.x, oChartSpace.y, oNearestPos, 0); - oDrawing.AddToDocument(oNearestPos); - oDrawing.CheckWH(); - recalculate(); - - return oDrawing; - } - - function createEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsAltGr, bIsMacCmdKey) - { - const oKeyBoardEvent = new AscCommon.CKeyboardEvent(); - oKeyBoardEvent.KeyCode = nKeyCode; - oKeyBoardEvent.ShiftKey = bIsShift; - oKeyBoardEvent.AltKey = bIsAlt; - oKeyBoardEvent.CtrlKey = bIsCtrl; - oKeyBoardEvent.MacCmdKey = bIsMacCmdKey; - oKeyBoardEvent.AltGr = bIsAltGr; - return oKeyBoardEvent; - } - - function checkInsertElementByType(nType, sPrompt, oAssert, oEvent) - { - const {oParagraph} = getLogicDocumentWithParagraphs(['']); - onKeyDown(oEvent); - let bCheck = false; - for (let i = 0; i < oParagraph.Content.length; i += 1) - { - const oRun = oParagraph.Content[i]; - for (let j = 0; j < oRun.Content.length; j += 1) - { - if (oRun.Content[j].Type === nType) - { - bCheck = true; - } - } - } - oAssert.true(bCheck, sPrompt); - } - - function createParagraphWithText(sText) - { - const oParagraph = AscTest.CreateParagraph(); - const oRun = new AscWord.CRun(); - oParagraph.AddToContent(0, oRun); - oRun.AddText(sText); - return oParagraph; - } - - function checkApplyParagraphStyle(sStyleName, sPrompt, oEvent, oAssert) - { - const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello World']); - oLogicDocument.SelectAll(); - onKeyDown(oEvent); - const oParagraphPr = oLogicDocument.GetDirectParaPr(); - const sPStyleName = oLogicDocument.Styles.Get_Name(oParagraphPr.Get_PStyle()); - oAssert.strictEqual(sPStyleName, sStyleName, sPrompt); - } - - function createHyperlink() - { - const oProps = new Asc.CHyperlinkProperty({Anchor: '_top', Text: "Beginning of document"}); - editor.add_Hyperlink(oProps); - } - - function createTable(nRows, nCols) - { - const {oLogicDocument} = getLogicDocumentWithParagraphs(['']); - return oLogicDocument.AddInlineTable(nCols, nRows); - } - - function moveToTable(oTable, bToStart) - { - oTable.Document_SetThisElementCurrent(); - if (bToStart) - { - oTable.MoveCursorToStartPos(); - } else - { - oTable.MoveCursorToEndPos(); - } - } - - function createShape() - { - AscCommon.History.Create_NewPoint(); - const oDrawing = new ParaDrawing(200, 100, null, oGlobalLogicDocument.GetDrawingDocument(), oGlobalLogicDocument, null); - const oShapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, oGlobalLogicDocument.theme, null, null, null, 0); - oShapeTrack.track({}, 0, 0); - const oShape = oShapeTrack.getShape(true, oGlobalLogicDocument.GetDrawingDocument(), null); - oShape.setBDeleted(false); - oShape.setParent(oDrawing); - oDrawing.Set_GraphicObject(oShape); - oDrawing.Set_DrawingType(drawing_Anchor); - oDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); - oDrawing.Set_Distance(0, 0, 0, 0); - const oNearestPos = oGlobalLogicDocument.Get_NearestPos(0, oShape.x, oShape.y, true, oDrawing); - oDrawing.Set_XYForAdd(oShape.x, oShape.y, oNearestPos, 0); - oDrawing.AddToDocument(oNearestPos); - oDrawing.CheckWH(); - recalculate(); - return oDrawing; - } - - function getShapeWithText(sText, bStartRecalculate) - { - const oParaDrawing = createShape(); - selectParaDrawing(oParaDrawing); - const oShape = oParaDrawing.GraphicObj; - oShape.createTextBoxContent(); - const oParagraph = oShape.getDocContent().Content[0]; - moveToParagraph(oParagraph); - addText(sText) - if (bStartRecalculate) - { - startRecalculate(); - } - return {oParaDrawing, oParagraph}; - } - - function createGroup(arrDrawings) - { - selectOnlyObjects(arrDrawings); - return drawingObjects().groupSelectedObjects(); - } - - function selectOnlyObjects(arrDrawings) - { - const oController = drawingObjects(); - oController.resetSelection(); - for (let i = 0; i < arrDrawings.length; i += 1) - { - const oObject = arrDrawings[i].GraphicObj; - if (oObject.group) - { - const oMainGroup = oObject.group.getMainGroup(); - oMainGroup.select(oController, 0); - oController.selection.groupSelection = oMainGroup; - } - oObject.select(oController, 0); - } - } - - function selectParaDrawing(oParaDrawing) - { - oGlobalLogicDocument.SelectDrawings([oParaDrawing], oGlobalLogicDocument); - } - - function drawingObjects() - { - return oGlobalLogicDocument.DrawingObjects; - } - - function logicContent() - { - return oGlobalLogicDocument.Content; - } - - function directParaPr() - { - return oGlobalLogicDocument.GetDirectParaPr(); - } - - function mouseClick(x, y, page, isRight, count) - { - mouseDown(x, y, page, isRight, count); - mouseUp(x, y, page, isRight, count); - } - - function mouseDown(x, y, page, isRight, count) - { - if (!oGlobalLogicDocument) - return; - - let e = new AscCommon.CMouseEventHandler(); - - e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; - e.ClickCount = count ? count : 1; - - e.Type = AscCommon.g_mouse_event_type_down; - oGlobalLogicDocument.OnMouseDown(e, x, y, page); - } - - function mouseUp(x, y, page, isRight, count) - { - if (!oGlobalLogicDocument) - return; - - let e = new AscCommon.CMouseEventHandler(); - - e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; - e.ClickCount = count ? count : 1; - - e.Type = AscCommon.g_mouse_event_type_up; - oGlobalLogicDocument.OnMouseUp(e, x, y, page); - } - - function mouseMove(x, y, page, isRight, count) - { - if (!oGlobalLogicDocument) - return; - - let e = new AscCommon.CMouseEventHandler(); - - e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; - e.ClickCount = count ? count : 1; - - e.Type = AscCommon.g_mouse_event_type_move; - oGlobalLogicDocument.OnMouseMove(e, x, y, page); - } - - function directTextPr() - { - return oGlobalLogicDocument.GetDirectTextPr(); - } - - function addToParagraph(oElement) - { - oGlobalLogicDocument.AddToParagraph(oElement); - } - - function addBreakPage() - { - addToParagraph(new AscWord.CRunBreak(AscWord.break_Page)); - } - - function startRecalculate() - { - if (oGlobalLogicDocument.TurnOffRecalc) - { - oGlobalLogicDocument.End_SilentMode(true); - } - recalculate(); - oGlobalLogicDocument.private_UpdateCursorXY(true, true); - } - - function createMath(nType) - { - return editor.asc_AddMath(nType); - } - - function addText(sText) - { - oGlobalLogicDocument.AddTextWithPr(sText); - } - - function moveShapeHelper(nX, nY, oAssert, oEvent) - { - getLogicDocumentWithParagraphs([''], true); - const oParaDrawing = createShape(); - const oShape = oParaDrawing.GraphicObj; - selectOnlyObjects([oParaDrawing]); - onKeyDown(oEvent); - oAssert.deepEqual({x: round(oShape.x, 13), y: round(oShape.y, 13)}, { - x: round(nX * AscCommon.g_dKoef_pix_to_mm, 13), - y: round(nY * AscCommon.g_dKoef_pix_to_mm, 13) - }); - } - - function drawingContentPosition() - { - const arrPos = drawingObjects().getTargetDocContent().GetContentPosition(); - return arrPos[arrPos.length - 1].Position; - } - - let fOldCheckOFormUserMaster; - function setFillingFormsMode(bState) - { - // if (bState) - // { - // fOldCheckOFormUserMaster = oGlobalLogicDocument.CheckOFormUserMaster; - // oGlobalLogicDocument.CheckOFormUserMaster = function () - // { - // return true; - // } - // } - // else - // { - // oGlobalLogicDocument.CheckOFormUserMaster = fOldCheckOFormUserMaster; - // } - var oRole = new AscCommon.CRestrictionSettings(); - oRole.put_OFormRole("Anyone"); - editor.asc_setRestriction(bState ? Asc.c_oAscRestrictionType.OnlyForms : Asc.c_oAscRestrictionType.None, oRole); - editor.asc_SetPerformContentControlActionByClick(bState); - editor.asc_SetHighlightRequiredFields(bState); - } - - let nKeyId = 0; - - function createCheckBox() - { - const oCheckBox = oGlobalLogicDocument.AddContentControlCheckBox(); - var props = new AscCommon.CContentControlPr(); - var specProps = new AscCommon.CSdtCheckBoxPr(); - var oFormProps = new AscCommon.CSdtFormPr('key' + nKeyId++, '', '', false); - props.SetFormPr(oFormProps); - props.put_CheckBoxPr(specProps); - editor.asc_SetContentControlProperties(props, oCheckBox.GetId()); - return oCheckBox; - } - - function createComboBox() - { - const oComboBox = oGlobalLogicDocument.AddContentControlComboBox(); - var props = new AscCommon.CContentControlPr(); - var specProps = new AscCommon.CSdtComboBoxPr(); - var oFormProps = new AscCommon.CSdtFormPr('key' + nKeyId++, '', '', false); - props.SetFormPr(oFormProps); - specProps.clear(); - specProps.add_Item('Hello', 'Hello'); - specProps.add_Item('World', 'World'); - specProps.add_Item('yo', 'yo'); - props.put_ComboBoxPr(specProps); - editor.asc_SetContentControlProperties(props, oComboBox.GetId()); - return oComboBox; - } - function round(nNumber, nAmount) - { - const nPower = Math.pow(10, nAmount); - return Math.round(nNumber * nPower) / nPower; - } - function createComplexForm() - { - const oComplexForm = oGlobalLogicDocument.AddComplexForm(); - var props = new AscCommon.CContentControlPr(); - var formTextPr = new AscCommon.CSdtTextFormPr(); - formTextPr.put_MultiLine(true); - props.put_TextFormPr(formTextPr); - editor.asc_SetContentControlProperties(props, oComplexForm.GetId()); - return oComplexForm; - } - - function contentPosition() - { - const oPos = oGlobalLogicDocument.GetContentPosition(); - return oPos[oPos.length - 1].Position; - } - - AscTestShortcut.addPropertyToDocument = addPropertyToDocument; - AscTestShortcut.checkTextAfterKeyDownHelperEmpty = checkTextAfterKeyDownHelperEmpty; - AscTestShortcut.getLogicDocumentWithParagraphs = getLogicDocumentWithParagraphs; - AscTestShortcut.resetLogicDocument = resetLogicDocument; - AscTestShortcut.oGlobalLogicDocument = oGlobalLogicDocument; - AscTestShortcut.onKeyDown = onKeyDown; - AscTestShortcut.moveToParagraph = moveToParagraph; - AscTestShortcut.createNativeEvent = createNativeEvent; - AscTestShortcut.addParagraphToDocumentWithText = addParagraphToDocumentWithText; - - AscTestShortcut.checkDirectTextPrAfterKeyDown = checkDirectTextPrAfterKeyDown; - AscTestShortcut.checkDirectParaPrAfterKeyDown = checkDirectParaPrAfterKeyDown; - AscTestShortcut.executeTestWithCatchEvent = executeTestWithCatchEvent; - AscTestShortcut.remove = remove; - AscTestShortcut.recalculate = recalculate; - AscTestShortcut.clean = clean; - AscTestShortcut.moveCursorDown = moveCursorDown; - AscTestShortcut.moveCursorUp = moveCursorUp; - AscTestShortcut.moveCursorLeft = moveCursorLeft; - AscTestShortcut.moveCursorRight = moveCursorRight; - AscTestShortcut.selectAll = selectAll; - AscTestShortcut.getSelectedText = getSelectedText; - AscTestShortcut.createTest = createTest; - AscTestShortcut.createChart = createChart; - AscTestShortcut.createEvent = createEvent; - AscTestShortcut.checkInsertElementByType = checkInsertElementByType; - AscTestShortcut.createParagraphWithText = createParagraphWithText; - AscTestShortcut.checkApplyParagraphStyle = checkApplyParagraphStyle; - AscTestShortcut.createHyperlink = createHyperlink; - AscTestShortcut.createTable = createTable; - AscTestShortcut.moveToTable = moveToTable; - AscTestShortcut.createShape = createShape; - AscTestShortcut.getShapeWithText = getShapeWithText; - AscTestShortcut.createGroup = createGroup; - AscTestShortcut.selectOnlyObjects = selectOnlyObjects; - AscTestShortcut.selectParaDrawing = selectParaDrawing; - AscTestShortcut.drawingObjects = drawingObjects; - AscTestShortcut.logicContent = logicContent; - AscTestShortcut.directParaPr = directParaPr; - AscTestShortcut.directTextPr = directTextPr; - AscTestShortcut.addToParagraph = addToParagraph; - AscTestShortcut.addBreakPage = addBreakPage; - AscTestShortcut.startRecalculate = startRecalculate; - AscTestShortcut.createMath = createMath; - AscTestShortcut.addText = addText; - AscTestShortcut.moveShapeHelper = moveShapeHelper; - AscTestShortcut.drawingContentPosition = drawingContentPosition; - AscTestShortcut.setFillingFormsMode = setFillingFormsMode; - AscTestShortcut.createCheckBox = createCheckBox; - AscTestShortcut.createComboBox = createComboBox; - AscTestShortcut.createComplexForm = createComplexForm; - AscTestShortcut.contentPosition = contentPosition; - - AscTestShortcut.mouseDown = mouseDown; - AscTestShortcut.mouseUp = mouseUp; - AscTestShortcut.mouseClick = mouseClick; - AscTestShortcut.mouseMove = mouseMove; - AscTestShortcut.resetLogicDocument = resetLogicDocument; - AscTestShortcut.insertManualBreak = insertManualBreak; -})(window); diff --git a/tests/word/shortcuts/shortcuts.html b/tests/word/shortcuts/shortcuts.html index 14e162da3d..8af37c9155 100644 --- a/tests/word/shortcuts/shortcuts.html +++ b/tests/word/shortcuts/shortcuts.html @@ -14,29 +14,13 @@ window.sdk_scripts.forEach(function(item) { document.write(' - - + diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index c14bf0fed2..47be85d11d 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -35,11 +35,11 @@ (function (window) { - const oEvents = AscTestShortcut.oTestEvents; - const oTestTypes = AscTestShortcut.oTestTypes; + const testHotkeyEvents = AscTestShortcut.testHotkeyEvents; + const testHotkeyActions = AscTestShortcut.testHotkeyActions; let logicDocument = AscTest.CreateLogicDocument(); - logicDocument.UpdateAllSectionsInfo(); + const pageWidth = 100; const pageHeight = 100; logicDocument.Set_DocumentPageSize(pageWidth, pageHeight); @@ -49,22 +49,41 @@ props.put_BottomMargin(0); props.put_RightMargin(0); logicDocument.Set_SectionProps(props); - logicDocument.UpdateAllSectionsInfo(); - editor.WordControl.m_oDrawingDocument.GetVisibleMMHeight = function () + + AscFormat.CHART_STYLE_MANAGER.init(); + + const drawingDocument = editor.WordControl.m_oDrawingDocument; + drawingDocument.GetVisibleMMHeight = function () { return 100; }; - editor.WordControl.m_oDrawingDocument.SetCursorType = function () - { + let isTrack = false; + drawingDocument.StartTrackText = function () + { + isTrack = true; + }; + drawingDocument.EndTrackText = function () + { + isTrack = false; + }; + drawingDocument.CancelTrackText = function () + { + isTrack = false; }; - let bStartTrackText = false; - editor.WordControl.m_oDrawingDocument.StartTrackText = function () {bStartTrackText = true}; - editor.WordControl.m_oDrawingDocument.EndTrackText = function () {bStartTrackText = false}; - editor.WordControl.m_oDrawingDocument.CancelTrackText = function () {return bStartTrackText}; - AscFormat.CHART_STYLE_MANAGER.init(); + drawingDocument.IsTrackText = function () + { + return isTrack; + }; + drawingDocument.SetCursorType = function () {}; + drawingDocument.OnRePaintAttack = function() {}; + drawingDocument.IsFreezePage = function() {}; + drawingDocument.Set_RulerState_HdrFtr = function() {}; + drawingDocument.IsTrackText = function() {}; + drawingDocument.ConvertCoordsToCursorWR = function(X, Y) {return {X: X, Y: Y}}; + drawingDocument.OnUpdateOverlay = function() {}; editor.getShortcut = function (e) { @@ -86,119 +105,112 @@ this.isStartAddShape = true; }; + editor.retrieveFormatPainterData = Asc.asc_docs_api.prototype.retrieveFormatPainterData.bind(editor); + editor.get_ShowParaMarks = Asc.asc_docs_api.prototype.get_ShowParaMarks.bind(editor); + editor.put_ShowParaMarks = Asc.asc_docs_api.prototype.put_ShowParaMarks.bind(editor); + editor.sync_ShowParaMarks = Asc.asc_docs_api.prototype.sync_ShowParaMarks.bind(editor); + editor.private_GetLogicDocument = Asc.asc_docs_api.prototype.private_GetLogicDocument.bind(editor); + editor.asc_AddTableOfContents = Asc.asc_docs_api.prototype.asc_AddTableOfContents.bind(editor); + editor.asc_registerCallback = Asc.asc_docs_api.prototype.asc_registerCallback.bind(editor); + editor.asc_unregisterCallback = Asc.asc_docs_api.prototype.asc_unregisterCallback.bind(editor); + editor.sendEvent = Asc.asc_docs_api.prototype.sendEvent.bind(editor); + editor.sync_DialogAddHyperlink = Asc.asc_docs_api.prototype.sync_DialogAddHyperlink.bind(editor); + editor.sync_ParaStyleName = Asc.asc_docs_api.prototype.sync_ParaStyleName.bind(editor); + editor.sync_MouseMoveStartCallback = Asc.asc_docs_api.prototype.sync_MouseMoveStartCallback.bind(editor); + editor.sync_MouseMoveCallback = Asc.asc_docs_api.prototype.sync_MouseMoveCallback.bind(editor); + editor.sync_MouseMoveEndCallback = Asc.asc_docs_api.prototype.sync_MouseMoveEndCallback.bind(editor); + editor.sync_HideComment = Asc.asc_docs_api.prototype.sync_HideComment.bind(editor); + editor.sync_ContextMenuCallback = Asc.asc_docs_api.prototype.sync_ContextMenuCallback.bind(editor); + editor.asc_AddMath = Asc.asc_docs_api.prototype.asc_AddMath2.bind(editor); + editor._onEndLoadSdk = Asc.asc_docs_api.prototype._onEndLoadSdk.bind(editor); + editor.sync_StartAddShapeCallback = Asc.asc_docs_api.prototype.sync_StartAddShapeCallback.bind(editor); + editor.SetPaintFormat = Asc.asc_docs_api.prototype.SetPaintFormat.bind(editor); + editor.SetMarkerFormat = Asc.asc_docs_api.prototype.SetMarkerFormat.bind(editor); + editor.sync_MarkerFormatCallback = Asc.asc_docs_api.prototype.sync_MarkerFormatCallback.bind(editor); + editor.sync_PaintFormatCallback = Asc.asc_docs_api.prototype.sync_PaintFormatCallback.bind(editor); + editor.sync_EndAddShape = function () {}; + editor.isDocumentEditor = true; + AscCommon.CDocsCoApi.prototype.askSaveChanges = function (callback) + { + window.setTimeout(function () + { + callback({"saveLock": false}); + }, 0); + }; - function GoToHeader(nPage) + function GoToHeader(page) { logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); - const oEvent = new AscCommon.CMouseEventHandler(); - oEvent.ClickCount = 1; - oEvent.Button = 0; - oEvent.Type = AscCommon.g_mouse_event_type_down; + const event = new AscCommon.CMouseEventHandler(); + event.ClickCount = 1; + event.Button = 0; + event.Type = AscCommon.g_mouse_event_type_down; - logicDocument.OnMouseDown(oEvent, 0, 0, nPage); + logicDocument.OnMouseDown(event, 0, 0, page); - oEvent.Type = AscCommon.g_mouse_event_type_up; - logicDocument.OnMouseUp(oEvent, 0, 0, nPage); + event.Type = AscCommon.g_mouse_event_type_up; + logicDocument.OnMouseUp(event, 0, 0, page); logicDocument.MoveCursorLeft(); } - function GoToFooter(nPage) + function GoToFooter(page) { logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); - const oEvent = new AscCommon.CMouseEventHandler(); - oEvent.ClickCount = 1; - oEvent.Button = 0; - oEvent.Type = AscCommon.g_mouse_event_type_down; + const event = new AscCommon.CMouseEventHandler(); + event.ClickCount = 1; + event.Button = 0; + event.Type = AscCommon.g_mouse_event_type_down; - logicDocument.OnMouseDown(oEvent, 0, pageHeight, nPage); + logicDocument.OnMouseDown(event, 0, pageHeight, page); - oEvent.Type = AscCommon.g_mouse_event_type_up; - logicDocument.OnMouseUp(oEvent, 0, pageHeight, nPage); + event.Type = AscCommon.g_mouse_event_type_up; + logicDocument.OnMouseUp(event, 0, pageHeight, page); logicDocument.MoveCursorLeft(); } - function RemoveHeader(nPage) - { - logicDocument.RemoveHdrFtr(nPage, true); - } - - function RemoveFooter(nPage) + function RemoveHeader(page) { - logicDocument.RemoveHdrFtr(nPage, false); + logicDocument.RemoveHdrFtr(page, true); } - AscFonts.FontPickerByCharacter.checkText = function (text, _this, _callback, isCodes, isOnlyAsync, isCheckSymbols) + function RemoveFooter(page) { - _callback.call(_this); + logicDocument.RemoveHdrFtr(page, false); } - editor.WordControl.m_oApi = editor; - editor.retrieveFormatPainterData = Asc.asc_docs_api.prototype.retrieveFormatPainterData.bind(editor); - editor.get_ShowParaMarks = Asc.asc_docs_api.prototype.get_ShowParaMarks.bind(editor); - editor.put_ShowParaMarks = Asc.asc_docs_api.prototype.put_ShowParaMarks.bind(editor); - editor.sync_ShowParaMarks = Asc.asc_docs_api.prototype.sync_ShowParaMarks.bind(editor); - editor.private_GetLogicDocument = Asc.asc_docs_api.prototype.private_GetLogicDocument.bind(editor); - editor.asc_AddTableOfContents = Asc.asc_docs_api.prototype.asc_AddTableOfContents.bind(editor); - editor.asc_registerCallback = Asc.asc_docs_api.prototype.asc_registerCallback.bind(editor); - editor.asc_unregisterCallback = Asc.asc_docs_api.prototype.asc_unregisterCallback.bind(editor); - editor.sendEvent = Asc.asc_docs_api.prototype.sendEvent.bind(editor); - editor.sync_DialogAddHyperlink = Asc.asc_docs_api.prototype.sync_DialogAddHyperlink.bind(editor); - editor.sync_ParaStyleName = Asc.asc_docs_api.prototype.sync_ParaStyleName.bind(editor); - editor.sync_MouseMoveStartCallback = Asc.asc_docs_api.prototype.sync_MouseMoveStartCallback.bind(editor); - editor.sync_MouseMoveCallback = Asc.asc_docs_api.prototype.sync_MouseMoveCallback .bind(editor); - editor.sync_MouseMoveEndCallback = Asc.asc_docs_api.prototype.sync_MouseMoveEndCallback.bind(editor); - editor.sync_HideComment = Asc.asc_docs_api.prototype.sync_HideComment .bind(editor); - editor.sync_ContextMenuCallback = Asc.asc_docs_api.prototype.sync_ContextMenuCallback .bind(editor); - editor.asc_AddMath = Asc.asc_docs_api.prototype.asc_AddMath2.bind(editor); - editor._onEndLoadSdk = Asc.asc_docs_api.prototype._onEndLoadSdk.bind(editor); - editor.sync_StartAddShapeCallback = Asc.asc_docs_api.prototype.sync_StartAddShapeCallback .bind(editor); - editor.SetPaintFormat = Asc.asc_docs_api.prototype.SetPaintFormat.bind(editor); - editor.SetMarkerFormat = Asc.asc_docs_api.prototype.SetMarkerFormat .bind(editor); - editor.sync_MarkerFormatCallback = Asc.asc_docs_api.prototype.sync_MarkerFormatCallback.bind(editor); - editor.sync_PaintFormatCallback = Asc.asc_docs_api.prototype.sync_PaintFormatCallback.bind(editor); - editor.sync_EndAddShape = function () {}; - - editor.isDocumentEditor = true; - function ExecuteShortcut(type) { return logicDocument.OnKeyDown(type); } - function ExecuteShortcut2(nType, nEventIndex) + + function ExecuteHotkey(type, eventIndex) { - const oEvent = oEvents[nType][nEventIndex || 0]; - return ExecuteShortcut(oEvent); + const event = testHotkeyEvents[type][eventIndex || 0]; + return ExecuteShortcut(event); } - - AscCommon.CDocsCoApi.prototype.askSaveChanges = function(callback) - { - window.setTimeout(function() { - callback({"saveLock": false}); - }, 0); - }; function ClearDocumentAndAddParagraph(text) { logicDocument.RemoveSelection(); AscTest.ClearDocument(); - const p = CreateParagraphWithText(text); - logicDocument.AddToContent(0, p); - return p; + const paragraph = CreateParagraphWithText(text); + logicDocument.AddToContent(0, paragraph); + return paragraph; } function CreateParagraphWithText(text) { - let p = AscTest.CreateParagraph(); + let paragraph = AscTest.CreateParagraph(); if (text) { let run = AscTest.CreateRun(); run.AddText(text); - p.AddToContentToEnd(run); + paragraph.AddToContentToEnd(run); } - return p; + return paragraph; } logicDocument.Start_SilentMode(); @@ -238,28 +250,116 @@ return logicDocument.GetDirectParaPr(); } - $(function () + function AddShape(x, y, h, w) { - let fOldGetShortcut; - QUnit.module("Test shortcut actions", { - before : function () - { - editor.initDefaultShortcuts(); - }, - beforeEach: function () - { - fOldGetShortcut = editor.getShortcut; - }, - afterEach : function () - { - editor.getShortcut = fOldGetShortcut; - }, - after : function () - { - editor.Shortcuts = new AscCommon.CShortcuts(); - } - }); + const drawing = new ParaDrawing(w, h, null, logicDocument.GetDrawingDocument(), logicDocument, null); + const shapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, logicDocument.theme, null, null, null, 0); + shapeTrack.track({}, x, y); + const shape = shapeTrack.getShape(true, logicDocument.GetDrawingDocument(), null); + shape.spPr.xfrm.setExtX(w); + shape.spPr.xfrm.setExtY(h); + shape.spPr.xfrm.setOffX(0); + shape.spPr.xfrm.setOffY(0); + shape.setBDeleted(false); + + shape.setParent(drawing); + drawing.Set_GraphicObject(shape); + drawing.Set_DrawingType(drawing_Anchor); + drawing.Set_WrappingType(WRAPPING_TYPE_NONE); + drawing.Set_Distance(0, 0, 0, 0); + const nearestPos = logicDocument.Get_NearestPos(0, x, y, true, drawing); + drawing.Set_XYForAdd(x, y, nearestPos, 0); + drawing.AddToDocument(nearestPos); + AscTest.Recalculate(); + return drawing; + } + + function SelectDrawings(drawings) + { + logicDocument.SelectDrawings(drawings, logicDocument); + } + + function GetDrawingObjects() + { + return logicDocument.DrawingObjects; + } + + function AddCheckBox() + { + const checkBox = logicDocument.AddContentControlCheckBox(); + var specProps = new AscCommon.CSdtCheckBoxPr(); + checkBox.ApplyCheckBoxPr(specProps); + checkBox.SetFormPr(new AscCommon.CSdtFormPr()); + return checkBox; + } + + function AddComboBox(items) + { + const comboBox = logicDocument.AddContentControlComboBox(); + var specProps = new AscCommon.CSdtComboBoxPr(); + specProps.clear(); + for (let i = 0; i < items.length; i++) + { + specProps.add_Item(items[i], items[i]); + } + + comboBox.ApplyComboBoxPr(specProps); + comboBox.SetFormPr(new AscCommon.CSdtFormPr()); + + return comboBox; + } + function AddTable(row, column) + { + let table = AscTest.CreateTable(row, column); + logicDocument.PushToContent(table); + return table; + } + + function AddChart() + { + const drawing = new ParaDrawing(100, 100, null, drawingDocument, null, null); + const chartSpace = logicDocument.GetChartObject(Asc.c_oAscChartTypeSettings.lineNormal); + chartSpace.spPr.setXfrm(new AscFormat.CXfrm()); + chartSpace.spPr.xfrm.setOffX(0); + chartSpace.spPr.xfrm.setOffY(0); + chartSpace.spPr.xfrm.setExtX(100); + chartSpace.spPr.xfrm.setExtY(100); + + chartSpace.setParent(drawing); + drawing.Set_GraphicObject(chartSpace); + drawing.setExtent(chartSpace.spPr.xfrm.extX, chartSpace.spPr.xfrm.extY); + + drawing.Set_DrawingType(drawing_Anchor); + drawing.Set_WrappingType(WRAPPING_TYPE_NONE); + drawing.Set_Distance(0, 0, 0, 0); + const nearestPos = logicDocument.Get_NearestPos(0, chartSpace.x, chartSpace.y, true, drawing); + drawing.Set_XYForAdd(chartSpace.x, chartSpace.y, nearestPos, 0); + drawing.AddToDocument(nearestPos); + AscTest.Recalculate(); + return drawing; + } + + function AddComplexForm() + { + let complexForm = logicDocument.AddComplexForm(); + const formPr = new AscWord.CSdtFormPr(); + var formTextPr = new AscCommon.CSdtTextFormPr(); + formTextPr.put_MultiLine(true); + complexForm.SetFormPr(formPr); + complexForm.SetTextFormPr(formTextPr); + return complexForm; + } + + function round(number, amount) + { + const power = Math.pow(10, amount); + return Math.round(number * power) / power; + } + + $(function () + { + QUnit.module("Test shortcut actions"); QUnit.test('Check page break shortcut', (assert) => { TurnOnRecalculate(); @@ -276,20 +376,20 @@ QUnit.test('Check line break shortcut', (assert) => { TurnOnRecalculate(); - let p = ClearDocumentAndAddParagraph(); + let paragraph = ClearDocumentAndAddParagraph(); ExecuteShortcut(c_oAscDocumentShortcutType.InsertLineBreak); - assert.strictEqual(p.GetLinesCount(), 2, 'Check line break shortcut'); + assert.strictEqual(paragraph.GetLinesCount(), 2, 'Check line break shortcut'); ExecuteShortcut(c_oAscDocumentShortcutType.InsertLineBreak); - assert.strictEqual(p.GetLinesCount(), 3, 'Check line break shortcut'); + assert.strictEqual(paragraph.GetLinesCount(), 3, 'Check line break shortcut'); ExecuteShortcut(c_oAscDocumentShortcutType.InsertLineBreak); - assert.strictEqual(p.GetLinesCount(), 4, 'Check line break shortcut'); + assert.strictEqual(paragraph.GetLinesCount(), 4, 'Check line break shortcut'); TurnOffRecalculate(); }); QUnit.test('Check column break shortcut', (assert) => { TurnOnRecalculate(); - let p = ClearDocumentAndAddParagraph(); + let paragraph = ClearDocumentAndAddParagraph(); let sectionPr = AscTest.GetFinalSection(); sectionPr.SetColumnsNum(3); AscTest.Recalculate(); @@ -297,11 +397,11 @@ function CheckColumns(colCount) { assert.strictEqual(logicDocument.GetPagesCount(), 1, 'Check logic document page count'); - assert.strictEqual(p.GetPagesCount(), colCount, 'Check paragraph page count'); + assert.strictEqual(paragraph.GetPagesCount(), colCount, 'Check paragraph page count'); for (let i = 0; i < colCount; ++i) { - assert.strictEqual(p.GetAbsoluteColumn(i), i, 'Check paragraph column index'); - assert.strictEqual(p.GetAbsolutePage(i), 0, 'Check paragraph page index'); + assert.strictEqual(paragraph.GetAbsoluteColumn(i), i, 'Check paragraph column index'); + assert.strictEqual(paragraph.GetAbsolutePage(i), 0, 'Check paragraph page index'); } } @@ -330,28 +430,28 @@ QUnit.test('Check adding various characters', (assert) => { - let p = ClearDocumentAndAddParagraph(); + let paragraph = ClearDocumentAndAddParagraph(); ExecuteShortcut(c_oAscDocumentShortcutType.NonBreakingSpace); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0), 'Check add non breaking space'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0), 'Check add non breaking space'); ExecuteShortcut(c_oAscDocumentShortcutType.CopyrightSign); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9), 'Check add CopyrightSign'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9), 'Check add CopyrightSign'); ExecuteShortcut(c_oAscDocumentShortcutType.EuroSign); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC), 'Check add EuroSign'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC), 'Check add EuroSign'); ExecuteShortcut(c_oAscDocumentShortcutType.RegisteredSign); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE), 'Check add RegisteredSign'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE), 'Check add RegisteredSign'); ExecuteShortcut(c_oAscDocumentShortcutType.TrademarkSign); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122), 'Check add TrademarkSign'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122), 'Check add TrademarkSign'); ExecuteShortcut(c_oAscDocumentShortcutType.EnDash); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013), 'Check add EnDash'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013), 'Check add EnDash'); ExecuteShortcut(c_oAscDocumentShortcutType.EmDash); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014), 'Check add EmDash'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014), 'Check add EmDash'); ExecuteShortcut(c_oAscDocumentShortcutType.NonBreakingHyphen); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D), 'Check add NonBreakingHyphen'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D), 'Check add NonBreakingHyphen'); ExecuteShortcut(c_oAscDocumentShortcutType.HorizontalEllipsis); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026), 'Check add HorizontalEllipsis'); - ExecuteShortcut2(oTestTypes.addSJKSpace); - assert.strictEqual(AscTest.GetParagraphText(p), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026, 0x0020), 'Check add HorizontalEllipsis'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026), 'Check add HorizontalEllipsis'); + ExecuteHotkey(testHotkeyActions.addSJKSpace); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026, 0x0020), 'Check add HorizontalEllipsis'); }); QUnit.test('Check text property change', (assert) => @@ -412,23 +512,23 @@ QUnit.test('Check select all shortcut', (assert) => { - let p = ClearDocumentAndAddParagraph('Hello world'); - let table = AscTest.CreateTable(2, 2); + const paragraph = ClearDocumentAndAddParagraph('Hello world'); + const table = AscTest.CreateTable(2, 2); logicDocument.AddToContent(1, table); assert.strictEqual(logicDocument.IsSelectionUse(), false, 'Check document selection'); ExecuteShortcut(c_oAscDocumentShortcutType.EditSelectAll); assert.strictEqual(logicDocument.IsSelectionUse(), true, 'Check document selection'); - assert.strictEqual(p.IsSelectedAll(), true, 'Check paragraph selection'); + assert.strictEqual(paragraph.IsSelectedAll(), true, 'Check paragraph selection'); assert.strictEqual(table.IsSelectedAll(), true, 'Check table selection'); }); QUnit.test('Check paragraph property change', (assert) => { - let p = ClearDocumentAndAddParagraph('Hello world'); + let paragraph = ClearDocumentAndAddParagraph('Hello world'); function GetStyleName() { - return logicDocument.GetStyleManager().GetName(p.GetParagraphStyle()); + return logicDocument.GetStyleManager().GetName(paragraph.GetParagraphStyle()); } assert.strictEqual(GetStyleName(), "", "Check style"); @@ -468,28 +568,28 @@ ExecuteShortcut(c_oAscDocumentShortcutType.UnIndent); assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0); - const p2 = CreateParagraphWithText('Hello'); + const paragraph2 = CreateParagraphWithText('Hello'); logicDocument.SelectAll(); - ExecuteShortcut2(oTestTypes.testIndent); + ExecuteHotkey(testHotkeyActions.testIndent); assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5); - ExecuteShortcut2(oTestTypes.testUnIndent); + ExecuteHotkey(testHotkeyActions.testUnIndent); assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0); }); QUnit.test('Check insert document elements', (assert) => { - let p = ClearDocumentAndAddParagraph(''); + let paragraph = ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.InsertFootnoteNow); - const arrFootnotes = logicDocument.GetFootnotesList(); - assert.equal(arrFootnotes.length, 1, 'Check insert footnote shortcut'); + const footnotes = logicDocument.GetFootnotesList(); + assert.equal(footnotes.length, 1, 'Check insert footnote shortcut'); - p.SetThisElementCurrent(); + paragraph.SetThisElementCurrent(); ExecuteShortcut(c_oAscDocumentShortcutType.InsertEndnoteNow); - const arrEndNotes = logicDocument.GetEndnotesList(); - assert.equal(arrEndNotes.length, 1, 'Check insert endnote shortcut'); + const endNotes = logicDocument.GetEndnotesList(); + assert.equal(endNotes.length, 1, 'Check insert endnote shortcut'); logicDocument.MoveCursorToStartPos(); }); @@ -498,92 +598,93 @@ { function checkSendingEvent(sSendEvent, oEvent, fCustomCheck, customExpectedValue) { - let bCheck = false; + let isCheck = false; const fCheck = function (...args) { if (fCustomCheck) { - bCheck = fCustomCheck(...args); - } else + isCheck = fCustomCheck(...args); + } + else { - bCheck = true; + isCheck = true; } } editor.asc_registerCallback(sSendEvent, fCheck); ExecuteShortcut(oEvent); - assert.strictEqual(bCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); + assert.strictEqual(isCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); editor.asc_unregisterCallback(sSendEvent, fCheck); } checkSendingEvent("asc_onDialogAddHyperlink", c_oAscDocumentShortcutType.InsertHyperlink); checkSendingEvent("asc_onPrint", c_oAscDocumentShortcutType.PrintPreviewAndPrint); - checkSendingEvent('asc_onMouseMoveStart', oEvents[oTestTypes.closeAllWindowsPopups][0]); - checkSendingEvent('asc_onMouseMove', oEvents[oTestTypes.closeAllWindowsPopups][0]); - checkSendingEvent('asc_onMouseMoveEnd', oEvents[oTestTypes.closeAllWindowsPopups][0]); + checkSendingEvent('asc_onMouseMoveStart', testHotkeyEvents[testHotkeyActions.closeAllWindowsPopups][0]); + checkSendingEvent('asc_onMouseMove', testHotkeyEvents[testHotkeyActions.closeAllWindowsPopups][0]); + checkSendingEvent('asc_onMouseMoveEnd', testHotkeyEvents[testHotkeyActions.closeAllWindowsPopups][0]); - checkSendingEvent('asc_onContextMenu', oEvents[oTestTypes.showContextMenu][0]); + checkSendingEvent('asc_onContextMenu', testHotkeyEvents[testHotkeyActions.showContextMenu][0]); AscCommon.AscBrowser.isOpera = true; - checkSendingEvent('asc_onContextMenu', oEvents[oTestTypes.showContextMenu][1]); + checkSendingEvent('asc_onContextMenu', testHotkeyEvents[testHotkeyActions.showContextMenu][1]); AscCommon.AscBrowser.isOpera = false; - checkSendingEvent('asc_onContextMenu', oEvents[oTestTypes.showContextMenu][2]); + checkSendingEvent('asc_onContextMenu', testHotkeyEvents[testHotkeyActions.showContextMenu][2]); }); QUnit.test('Check insert equation shortcut', (assert) => { ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.InsertEquation); - const oMath = logicDocument.GetCurrentMath(); - assert.true(!!oMath, 'Check insert equation shortcut'); + const math = logicDocument.GetCurrentMath(); + assert.true(!!math, 'Check insert equation shortcut'); }); QUnit.test('Check insert elements shortcut', (assert) => { - const p = ClearDocumentAndAddParagraph(''); + const paragraph = ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.InsertPageNumber); - const r = p.Content[0]; - assert.strictEqual(r.Content[0].Type, para_PageNum); + const firstRun = paragraph.Content[0]; + assert.strictEqual(firstRun.Content[0].Type, para_PageNum); }); QUnit.test('Check bullet list shortcut', (assert) => { - const p = ClearDocumentAndAddParagraph(''); - assert.false(p.IsBulletedNumbering(), 'check apply bullet list'); + const paragraph = ClearDocumentAndAddParagraph(''); + assert.false(paragraph.IsBulletedNumbering(), 'check apply bullet list'); ExecuteShortcut(c_oAscDocumentShortcutType.ApplyListBullet); - assert.true(p.IsBulletedNumbering(), 'check apply bullet list'); + assert.true(paragraph.IsBulletedNumbering(), 'check apply bullet list'); }); QUnit.test('Check copy/paste format shortcuts', (assert) => { - let p = ClearDocumentAndAddParagraph('Hello'); + let paragraph = ClearDocumentAndAddParagraph('Hello'); ApplyTextPrToDocument({Bold: true, Italic: true, Underline: true}); GetDirectTextPr(); ExecuteShortcut(c_oAscDocumentShortcutType.CopyFormat); - let tPr = editor.getFormatPainterData().TextPr; - assert.true(tPr.Get_Bold()); - assert.true(tPr.Get_Italic()); - assert.true(tPr.Get_Underline()); + let textPr = editor.getFormatPainterData().TextPr; + assert.true(textPr.Get_Bold()); + assert.true(textPr.Get_Italic()); + assert.true(textPr.Get_Underline()); - p = ClearDocumentAndAddParagraph(''); + paragraph = ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.PasteFormat); - tPr = GetDirectTextPr(); - assert.true(tPr.Get_Bold()); - assert.true(tPr.Get_Italic()); - assert.true(tPr.Get_Underline()); + textPr = GetDirectTextPr(); + assert.true(textPr.Get_Bold()); + assert.true(textPr.Get_Italic()); + assert.true(textPr.Get_Underline()); }); QUnit.test('Check history shortcuts', (assert) => { - let p = ClearDocumentAndAddParagraph('Hello'); - p.MoveCursorToEndPos(); + let paragraph = ClearDocumentAndAddParagraph('Hello'); + paragraph.MoveCursorToEndPos(); logicDocument.AddTextWithPr(' World'); ExecuteShortcut(c_oAscDocumentShortcutType.EditUndo); - assert.strictEqual(AscTest.GetParagraphText(p), 'Hello'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello'); ExecuteShortcut(c_oAscDocumentShortcutType.EditRedo); - assert.strictEqual(AscTest.GetParagraphText(p), 'Hello World'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello World'); }); QUnit.test('Check show paramarks shortcut', (assert) => @@ -604,71 +705,66 @@ done(); editor._onSaveCallbackInner = fOldSave; }; - editor._saveCheck = () => true; + editor._saveCheck = () => true; editor.asc_isDocumentCanSave = () => true; ExecuteShortcut(c_oAscDocumentShortcutType.Save); }); - //todo - // QUnit.test.todo('Check update fields shortcut', (assert) => - // { - // const p = ClearDocumentAndAddParagraph('Hello'); - // const p2 = CreateParagraphWithText('Hello'); - // const p3 = CreateParagraphWithText('Hello'); - // logicDocument.AddToContent(logicDocument.Content.length, p2); - // logicDocument.AddToContent(logicDocument.Content.length, p3); - // for (let i = 0; i < logicDocument.Content.length; i += 1) - // { - // logicDocument.Set_CurrentElement(i, true); - // logicDocument.SetParagraphStyle("Heading 1"); - // } - // logicDocument.MoveCursorToStartPos(); - // const props = new Asc.CTableOfContentsPr(); - // props.put_OutlineRange(1, 9); - // props.put_Hyperlink(true); - // props.put_ShowPageNumbers(true); - // props.put_RightAlignTab(true); - // props.put_TabLeader(Asc.c_oAscTabLeader.Dot); - // editor.asc_AddTableOfContents(null, props); - // - // logicDocument.MoveCursorToEndPos(); - // const p4 = CreateParagraphWithText('Hello'); - // logicDocument.AddToContent(logicDocument.Content.length, p4); - // p4.SetThisElementCurrent(true); - // logicDocument.SetParagraphStyle("Heading 1"); - // - // logicDocument.Content[0].SetThisElementCurrent(); - // logicDocument.Content[0].MoveCursorToEndPos(); - // - // ExecuteShortcut(c_oAscDocumentShortcutType.UpdateFields); - // assert.strictEqual(logicDocument.Content[0].Content.Content.length, 5, 'Check update fields shortcut'); - // }); + QUnit.test('Check update fields shortcut', (assert) => + { + const paragraph = ClearDocumentAndAddParagraph('Hello'); + const paragraph2 = CreateParagraphWithText('Hello'); + const paragraph3 = CreateParagraphWithText('Hello'); + + logicDocument.PushToContent(paragraph2); + logicDocument.PushToContent(paragraph3); + for (let i = 0; i < logicDocument.Content.length; i += 1) + { + logicDocument.Set_CurrentElement(i, true); + logicDocument.SetParagraphStyle("Heading 1"); + } + + logicDocument.MoveCursorToStartPos(); + logicDocument.AddTableOfContents(null, new Asc.CTableOfContentsPr()); + + logicDocument.MoveCursorToEndPos(); + const paragraph4 = CreateParagraphWithText('Hello'); + logicDocument.PushToContent(paragraph4); + paragraph4.SetThisElementCurrent(true); + logicDocument.SetParagraphStyle("Heading 1"); + + logicDocument.MoveCursorToStartPos(); + AscTest.MoveCursorRight() + + ExecuteShortcut(c_oAscDocumentShortcutType.UpdateFields); + assert.strictEqual(logicDocument.Content[0].Content.Content.length, 5, 'Check update fields shortcut'); + }); QUnit.test('Check remove hotkeys', (assert) => { - const p = ClearDocumentAndAddParagraph('Hello Hello Hello Hello'); + const paragraph = ClearDocumentAndAddParagraph('Hello Hello Hello Hello'); - ExecuteShortcut2(oTestTypes.removeBackSymbol); - assert.strictEqual(AscTest.GetParagraphText(p), 'Hello Hello Hello Hell'); + ExecuteHotkey(testHotkeyActions.removeBackSymbol); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hell'); - ExecuteShortcut2(oTestTypes.removeBackWord); - assert.strictEqual(AscTest.GetParagraphText(p), 'Hello Hello Hello '); + ExecuteHotkey(testHotkeyActions.removeBackWord); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello '); logicDocument.MoveCursorToStartPos(); - ExecuteShortcut2(oTestTypes.removeFrontSymbol); - assert.strictEqual(AscTest.GetParagraphText(p), 'ello Hello Hello '); - ExecuteShortcut2(oTestTypes.removeFrontWord); - assert.strictEqual(AscTest.GetParagraphText(p), 'Hello Hello '); + ExecuteHotkey(testHotkeyActions.removeFrontSymbol); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello '); + ExecuteHotkey(testHotkeyActions.removeFrontWord); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello '); }); QUnit.test('Check move/select in text hotkeys', (assert) => { function CheckCursorPosition(nExpected) { - const pos = logicDocument.GetContentPosition(); - assert.strictEqual(pos[pos.length - 1].Position, nExpected); + const position = logicDocument.GetContentPosition(); + assert.strictEqual(position[position.length - 1].Position, nExpected); } - const p = ClearDocumentAndAddParagraph( + const paragraph = ClearDocumentAndAddParagraph( 'Hello World Hello ' + 'World Hello World ' + 'Hello World Hello ' + @@ -686,227 +782,191 @@ TurnOffRecalculate(); TurnOffRecalculateCurPos(); - ExecuteShortcut2(oTestTypes.moveToEndLine); + ExecuteHotkey(testHotkeyActions.moveToEndLine); CheckCursorPosition(18); - ExecuteShortcut2(oTestTypes.moveToRightChar); + ExecuteHotkey(testHotkeyActions.moveToRightChar); CheckCursorPosition(19); - ExecuteShortcut2(oTestTypes.moveToLeftChar); + ExecuteHotkey(testHotkeyActions.moveToLeftChar); CheckCursorPosition(18); - ExecuteShortcut2(oTestTypes.moveToLeftWord); + ExecuteHotkey(testHotkeyActions.moveToLeftWord); CheckCursorPosition(12); - ExecuteShortcut2(oTestTypes.moveToRightWord); + ExecuteHotkey(testHotkeyActions.moveToRightWord); CheckCursorPosition(18); - ExecuteShortcut2(oTestTypes.moveToRightWord); + ExecuteHotkey(testHotkeyActions.moveToRightWord); CheckCursorPosition(24); - ExecuteShortcut2(oTestTypes.moveToStartLine); + ExecuteHotkey(testHotkeyActions.moveToStartLine); CheckCursorPosition(18); - ExecuteShortcut2(oTestTypes.moveDown); + ExecuteHotkey(testHotkeyActions.moveDown); CheckCursorPosition(36); - ExecuteShortcut2(oTestTypes.moveUp); + ExecuteHotkey(testHotkeyActions.moveUp); CheckCursorPosition(18); - ExecuteShortcut2(oTestTypes.moveToEndDocument); + ExecuteHotkey(testHotkeyActions.moveToEndDocument); CheckCursorPosition(161); - ExecuteShortcut2(oTestTypes.moveToStartDocument); + ExecuteHotkey(testHotkeyActions.moveToStartDocument); CheckCursorPosition(0); AscTest.MoveCursorRight(); - ExecuteShortcut2(oTestTypes.moveToNextPage); + ExecuteHotkey(testHotkeyActions.moveToNextPage); CheckCursorPosition(91); - ExecuteShortcut2(oTestTypes.moveToPreviousPage); + ExecuteHotkey(testHotkeyActions.moveToPreviousPage); CheckCursorPosition(1); - ExecuteShortcut2(oTestTypes.moveToStartNextPage); + ExecuteHotkey(testHotkeyActions.moveToStartNextPage); CheckCursorPosition(90); - ExecuteShortcut2(oTestTypes.moveToStartPreviousPage); + ExecuteHotkey(testHotkeyActions.moveToStartPreviousPage); CheckCursorPosition(0); function CheckSelectedText(sExpectedText) { - const sSelectedText = logicDocument.GetSelectedText(); - assert.strictEqual(sSelectedText, sExpectedText); + const selectedText = logicDocument.GetSelectedText(); + assert.strictEqual(selectedText, sExpectedText); } - ExecuteShortcut2(oTestTypes.selectToEndLine); + ExecuteHotkey(testHotkeyActions.selectToEndLine); CheckSelectedText('Hello World Hello '); - ExecuteShortcut2(oTestTypes.selectRightChar); + ExecuteHotkey(testHotkeyActions.selectRightChar); CheckSelectedText('Hello World Hello W'); - ExecuteShortcut2(oTestTypes.selectLeftChar); + ExecuteHotkey(testHotkeyActions.selectLeftChar); CheckSelectedText('Hello World Hello '); - ExecuteShortcut2(oTestTypes.selectLeftWord); + ExecuteHotkey(testHotkeyActions.selectLeftWord); CheckSelectedText('Hello World '); - ExecuteShortcut2(oTestTypes.selectRightWord); + ExecuteHotkey(testHotkeyActions.selectRightWord); CheckSelectedText('Hello World Hello '); - ExecuteShortcut2(oTestTypes.selectRightWord); + ExecuteHotkey(testHotkeyActions.selectRightWord); CheckSelectedText('Hello World Hello World '); - ExecuteShortcut2(oTestTypes.selectRightWord); + ExecuteHotkey(testHotkeyActions.selectRightWord); CheckSelectedText('Hello World Hello World Hello '); - ExecuteShortcut2(oTestTypes.selectToStartLine); + ExecuteHotkey(testHotkeyActions.selectToStartLine); CheckSelectedText('Hello World Hello '); - ExecuteShortcut2(oTestTypes.selectDown); + ExecuteHotkey(testHotkeyActions.selectDown); CheckSelectedText('Hello World Hello World Hello World '); - ExecuteShortcut2(oTestTypes.selectUp); + ExecuteHotkey(testHotkeyActions.selectUp); CheckSelectedText('Hello World Hello '); - ExecuteShortcut2(oTestTypes.selectToEndDocument); + ExecuteHotkey(testHotkeyActions.selectToEndDocument); CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World'); - ExecuteShortcut2(oTestTypes.selectToStartDocument); + ExecuteHotkey(testHotkeyActions.selectToStartDocument); CheckSelectedText(''); logicDocument.MoveCursorToEndPos(); - ExecuteShortcut2(oTestTypes.selectLeftChar); + ExecuteHotkey(testHotkeyActions.selectLeftChar); CheckSelectedText('d'); - ExecuteShortcut2(oTestTypes.selectLeftWord); + ExecuteHotkey(testHotkeyActions.selectLeftWord); CheckSelectedText('World'); logicDocument.MoveCursorToStartPos(); AscTest.MoveCursorRight(); - ExecuteShortcut2(oTestTypes.selectToNextPage); + ExecuteHotkey(testHotkeyActions.selectToNextPage); CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H'); AscTest.MoveCursorRight(); - ExecuteShortcut2(oTestTypes.selectToPreviousPage); + ExecuteHotkey(testHotkeyActions.selectToPreviousPage); CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H'); AscTest.MoveCursorLeft(); - ExecuteShortcut2(oTestTypes.selectToStartNextPage); + ExecuteHotkey(testHotkeyActions.selectToStartNextPage); CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello '); AscTest.MoveCursorRight(); - ExecuteShortcut2(oTestTypes.selectToStartPreviousPage); + ExecuteHotkey(testHotkeyActions.selectToStartPreviousPage); CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello '); }); - function createShape(x, y, h, w) - { - const oDrawing = new ParaDrawing(w, h, null, logicDocument.GetDrawingDocument(), logicDocument, null); - const oShapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, logicDocument.theme, null, null, null, 0); - oShapeTrack.track({}, x, y); - const oShape = oShapeTrack.getShape(true, logicDocument.GetDrawingDocument(), null); - oShape.spPr.xfrm.setExtX(w); - oShape.spPr.xfrm.setExtY(h); - oShape.setBDeleted(false); - - oShape.setParent(oDrawing); - oDrawing.Set_GraphicObject(oShape); - oDrawing.Set_DrawingType(drawing_Anchor); - oDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); - oDrawing.Set_Distance(0, 0, 0, 0); - const oNearestPos = logicDocument.Get_NearestPos(0, oShape.x, oShape.y, true, oDrawing); - oDrawing.Set_XYForAdd(oShape.x, oShape.y, oNearestPos, 0); - oDrawing.AddToDocument(oNearestPos); - AscTest.Recalculate(); - return oDrawing; - } - - function selectDrawing(arrDrawings) - { - logicDocument.SelectDrawings(arrDrawings, logicDocument); - } - - function GetDrawingObjects() - { - return logicDocument.DrawingObjects; - } - - function round(nNumber, nAmount) - { - const nPower = Math.pow(10, nAmount); - return Math.round(nNumber * nPower) / nPower; - } QUnit.test('Check move/select drawings', (assert) => { TurnOnRecalculate(); - const p = ClearDocumentAndAddParagraph(''); - p.SetThisElementCurrent(); + const paragraph = ClearDocumentAndAddParagraph(''); + paragraph.SetThisElementCurrent(); AscTest.Recalculate(); - const drawing1 = createShape(0, 0, 100, 200); + const drawing1 = AddShape(0, 0, 100, 200); const dotsPerMM = logicDocument.DrawingDocument.GetDotsPerMM(); + function CheckShapePosition(X, Y) { assert.deepEqual([round(drawing1.X * dotsPerMM, 10), round(drawing1.Y * dotsPerMM, 10), drawing1.Extent.W, drawing1.Extent.H], [X, Y, 200, 100]); } - selectDrawing([drawing1]); + SelectDrawings([drawing1]); - ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectLeft); + ExecuteHotkey(testHotkeyActions.bigMoveGraphicObjectLeft); CheckShapePosition(-5, 0); - ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectLeft); + ExecuteHotkey(testHotkeyActions.littleMoveGraphicObjectLeft); CheckShapePosition(-6, 0); - ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectRight); + ExecuteHotkey(testHotkeyActions.bigMoveGraphicObjectRight); CheckShapePosition(-1, 0); - ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectRight); + ExecuteHotkey(testHotkeyActions.littleMoveGraphicObjectRight); CheckShapePosition(0, 0); - ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectDown); + ExecuteHotkey(testHotkeyActions.bigMoveGraphicObjectDown); CheckShapePosition(0, 5); - ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectDown); + ExecuteHotkey(testHotkeyActions.littleMoveGraphicObjectDown); CheckShapePosition(0, 6); - ExecuteShortcut2(oTestTypes.bigMoveGraphicObjectUp); + ExecuteHotkey(testHotkeyActions.bigMoveGraphicObjectUp); CheckShapePosition(0, 1); - ExecuteShortcut2(oTestTypes.littleMoveGraphicObjectUp); + ExecuteHotkey(testHotkeyActions.littleMoveGraphicObjectUp); CheckShapePosition(0, 0); function CheckSelectedObjects(arrOfDrawings) { - const nLength = Math.max(arrOfDrawings.length, GetDrawingObjects().selectedObjects.length); - for (let i = 0; i < nLength; i++) + const length = Math.max(arrOfDrawings.length, GetDrawingObjects().selectedObjects.length); + for (let i = 0; i < length; i++) { assert.true(GetDrawingObjects().selectedObjects[i] === arrOfDrawings[i].GraphicObj); } } - const drawing2 = createShape(0, 0, 10, 10); - const drawing3 = createShape(0, 0, 10, 10); - selectDrawing([drawing3]); + const drawing2 = AddShape(0, 0, 10, 10); + const drawing3 = AddShape(0, 0, 10, 10); + SelectDrawings([drawing3]); - ExecuteShortcut2(oTestTypes.selectNextObject); + ExecuteHotkey(testHotkeyActions.selectNextObject); CheckSelectedObjects([drawing1]); - ExecuteShortcut2(oTestTypes.selectNextObject); + ExecuteHotkey(testHotkeyActions.selectNextObject); CheckSelectedObjects([drawing2]); - ExecuteShortcut2(oTestTypes.selectNextObject); + ExecuteHotkey(testHotkeyActions.selectNextObject); CheckSelectedObjects([drawing3]); - ExecuteShortcut2(oTestTypes.selectPreviousObject); + ExecuteHotkey(testHotkeyActions.selectPreviousObject); CheckSelectedObjects([drawing2]); - ExecuteShortcut2(oTestTypes.selectPreviousObject); + ExecuteHotkey(testHotkeyActions.selectPreviousObject); CheckSelectedObjects([drawing1]); - ExecuteShortcut2(oTestTypes.selectPreviousObject); + ExecuteHotkey(testHotkeyActions.selectPreviousObject); CheckSelectedObjects([drawing3]); TurnOffRecalculate(); }); @@ -914,29 +974,29 @@ QUnit.test('Check actions with selected shape', (assert) => { TurnOnRecalculate(); - const p = CreateParagraphWithText(''); + const paragraph = CreateParagraphWithText(''); AscTest.Recalculate(); - let sp = createShape(0, 0, 10, 10); - selectDrawing([sp]); + let paraDrawing = AddShape(0, 0, 10, 10); + SelectDrawings([paraDrawing]); - ExecuteShortcut2(oTestTypes.createTextBoxContent); - assert.true(!!sp.GraphicObj.textBoxContent); + ExecuteHotkey(testHotkeyActions.createTextBoxContent); + assert.true(!!paraDrawing.GraphicObj.textBoxContent); - sp = createShape(0, 0, 10, 10); - sp.GraphicObj.setWordShape(false); - selectDrawing([sp]); + paraDrawing = AddShape(0, 0, 10, 10); + paraDrawing.GraphicObj.setWordShape(false); + SelectDrawings([paraDrawing]); - ExecuteShortcut2(oTestTypes.createTextBody); - assert.true(!!sp.GraphicObj.txBody); + ExecuteHotkey(testHotkeyActions.createTextBody); + assert.true(!!paraDrawing.GraphicObj.txBody); - selectDrawing([sp]); - ExecuteShortcut2(oTestTypes.moveCursorToStartPositionShapeEnter); - assert.true(sp.GraphicObj.getDocContent().IsCursorAtBegin()); + SelectDrawings([paraDrawing]); + ExecuteHotkey(testHotkeyActions.moveCursorToStartPositionShapeEnter); + assert.true(paraDrawing.GraphicObj.getDocContent().IsCursorAtBegin()); AscTest.EnterText('Hello'); - selectDrawing([sp]); + SelectDrawings([paraDrawing]); - ExecuteShortcut2(oTestTypes.selectAllShapeEnter); + ExecuteHotkey(testHotkeyActions.selectAllShapeEnter); assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); TurnOffRecalculate(); }); @@ -946,7 +1006,7 @@ { TurnOnRecalculate(); TurnOnRecalculateCurPos(); - const p = ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); + const paragraph = ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); AscTest.Recalculate(); @@ -956,24 +1016,24 @@ TurnOffRecalculateCurPos(); TurnOffRecalculate(); - ExecuteShortcut2(oTestTypes.moveToPreviousHeaderFooter); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeaderFooter); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer); - ExecuteShortcut2(oTestTypes.moveToPreviousHeaderFooter); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeaderFooter); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); - ExecuteShortcut2(oTestTypes.moveToNextHeaderFooter); + ExecuteHotkey(testHotkeyActions.moveToNextHeaderFooter); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer); - ExecuteShortcut2(oTestTypes.moveToNextHeaderFooter); + ExecuteHotkey(testHotkeyActions.moveToNextHeaderFooter); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header); - ExecuteShortcut2(oTestTypes.moveToPreviousHeader); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeader); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); - ExecuteShortcut2(oTestTypes.moveToPreviousHeader); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeader); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[0].Header); - ExecuteShortcut2(oTestTypes.moveToNextHeader); + ExecuteHotkey(testHotkeyActions.moveToNextHeader); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); - ExecuteShortcut2(oTestTypes.moveToNextHeader); + ExecuteHotkey(testHotkeyActions.moveToNextHeader); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header); RemoveHeader(2); @@ -983,19 +1043,19 @@ QUnit.test('Check reset selection shortcut', (assert) => { TurnOnRecalculate(); - const p = ClearDocumentAndAddParagraph(""); + const paragraph = ClearDocumentAndAddParagraph(""); AscTest.Recalculate(); - const dr1 = createShape(0, 0, 10, 10); - const dr2 = createShape(0, 0, 10, 10); + const drawing1 = AddShape(0, 0, 10, 10); + const drawing2 = AddShape(0, 0, 10, 10); - selectDrawing([dr1, dr2]); + SelectDrawings([drawing1, drawing2]); const group = GetDrawingObjects().groupSelectedObjects(); - group.GraphicObj.selectObject(dr1.GraphicObj, 0); + group.GraphicObj.selectObject(drawing1.GraphicObj, 0); GetDrawingObjects().selection.groupSelection = group.GraphicObj; - ExecuteShortcut2(oTestTypes.resetShapeSelection); + ExecuteHotkey(testHotkeyActions.resetShapeSelection); assert.strictEqual(GetDrawingObjects().selectedObjects.length, 0); TurnOffRecalculate(); }); @@ -1003,86 +1063,59 @@ QUnit.test('Check reset actions shortcut', (assert) => { TurnOnRecalculate(); - const p = ClearDocumentAndAddParagraph(""); + const paragraph = ClearDocumentAndAddParagraph(""); AscTest.Recalculate() editor.StartAddShape('rect'); - ExecuteShortcut2(oTestTypes.resetStartAddShape); + ExecuteHotkey(testHotkeyActions.resetStartAddShape); assert.strictEqual(editor.isStartAddShape, false, "Test reset add shape"); TurnOffRecalculate(); editor.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOn); - ExecuteShortcut2(oTestTypes.resetFormattingByExample); + ExecuteHotkey(testHotkeyActions.resetFormattingByExample); assert.strictEqual(editor.isFormatPainterOn(), false, "Test reset formatting by example"); editor.SetMarkerFormat(true, true, 0, 0, 0); - ExecuteShortcut2(oTestTypes.resetMarkerFormat); + ExecuteHotkey(testHotkeyActions.resetMarkerFormat); assert.strictEqual(editor.isMarkerFormat, false, "Test reset marker"); }); QUnit.test('Check disable shortcuts', (assert) => { - assert.strictEqual(ExecuteShortcut2(oTestTypes.disableNumLock) & keydownresult_PreventAll, keydownresult_PreventAll); - assert.strictEqual(ExecuteShortcut2(oTestTypes.disableScrollLock) & keydownresult_PreventAll, keydownresult_PreventAll); + assert.strictEqual(ExecuteHotkey(testHotkeyActions.disableNumLock) & keydownresult_PreventAll, keydownresult_PreventAll); + assert.strictEqual(ExecuteHotkey(testHotkeyActions.disableScrollLock) & keydownresult_PreventAll, keydownresult_PreventAll); }); - let nKeyId = 0; - function AddCheckBox() - { - const oCheckBox = logicDocument.AddContentControlCheckBox(); - var specProps = new AscCommon.CSdtCheckBoxPr(); - oCheckBox.ApplyCheckBoxPr(specProps); - oCheckBox.SetFormPr(new AscCommon.CSdtFormPr('key' + nKeyId++, '', '', false)); - return oCheckBox; - } - - function AddComboBox(arrItems) - { - const oComboBox = logicDocument.AddContentControlComboBox(); - var specProps = new AscCommon.CSdtComboBoxPr(); - specProps.clear(); - for (let i = 0; i < arrItems.length; i++) - { - specProps.add_Item(arrItems[i], arrItems[i]); - } - - oComboBox.ApplyComboBoxPr(specProps); - oComboBox.SetFormPr(new AscCommon.CSdtFormPr('key' + nKeyId++, '', '', false)); - - return oComboBox; - } - QUnit.test('Check boxes shortcuts', (assert) => { - AscTest.SetFillingFormMode(false); - let p = ClearDocumentAndAddParagraph(''); + let paragraph = ClearDocumentAndAddParagraph(''); const checkBox = AddCheckBox(); AscTest.SetFillingFormMode(true); - ExecuteShortcut2(oTestTypes.toggleCheckBox); + ExecuteHotkey(testHotkeyActions.toggleCheckBox); assert.true(checkBox.IsCheckBoxChecked()); - ExecuteShortcut2(oTestTypes.toggleCheckBox); + ExecuteHotkey(testHotkeyActions.toggleCheckBox); assert.false(checkBox.IsCheckBoxChecked()); - AscTest.SetFillingFormMode(false); + AscTest.SetEditingMode(); ClearDocumentAndAddParagraph(''); - const oComboBox = AddComboBox(['Hello', 'World', 'yo']); + const comboBox = AddComboBox(['Hello', 'World', 'yo']); AscTest.SetFillingFormMode(true); - ExecuteShortcut2(oTestTypes.nextOptionComboBox); + ExecuteHotkey(testHotkeyActions.nextOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); - ExecuteShortcut2(oTestTypes.nextOptionComboBox); + ExecuteHotkey(testHotkeyActions.nextOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'World'); - ExecuteShortcut2(oTestTypes.nextOptionComboBox); + ExecuteHotkey(testHotkeyActions.nextOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'yo'); - ExecuteShortcut2(oTestTypes.previousOptionComboBox); + ExecuteHotkey(testHotkeyActions.previousOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'World'); - ExecuteShortcut2(oTestTypes.previousOptionComboBox); + ExecuteHotkey(testHotkeyActions.previousOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); - ExecuteShortcut2(oTestTypes.previousOptionComboBox); + ExecuteHotkey(testHotkeyActions.previousOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'yo'); AscTest.SetEditingMode(); }); @@ -1091,207 +1124,163 @@ { console.log(!!(editor.restrictions & Asc.c_oAscRestrictionType.OnlyForms)) TurnOnRecalculate(); - const p = ClearDocumentAndAddParagraph(''); + const paragraph = ClearDocumentAndAddParagraph(''); AscTest.Recalculate(); - let dr = createShape(0, 0 , 10, 10); - selectDrawing([dr]); + let paraDrawing = AddShape(0, 0, 10, 10); + SelectDrawings([paraDrawing]); - ExecuteShortcut2(oTestTypes.removeShape, 0); - assert.strictEqual(p.GetRunByElement(dr), null, 'Test remove shape'); + ExecuteHotkey(testHotkeyActions.removeShape, 0); + assert.strictEqual(paragraph.GetRunByElement(paraDrawing), null, 'Test remove shape'); - dr = createShape(0, 0 , 10, 10); - selectDrawing([dr]); + paraDrawing = AddShape(0, 0, 10, 10); + SelectDrawings([paraDrawing]); - ExecuteShortcut2(oTestTypes.removeShape, 1); - assert.strictEqual(p.GetRunByElement(dr), null, 'Test remove shape'); + ExecuteHotkey(testHotkeyActions.removeShape, 1); + assert.strictEqual(paragraph.GetRunByElement(paraDrawing), null, 'Test remove shape'); TurnOffRecalculate(); }); QUnit.test('Check move on forms', (assert) => { - const p = ClearDocumentAndAddParagraph(''); - let oCC1 = AddCheckBox(); + const paragraph = ClearDocumentAndAddParagraph(''); + let checkBox1 = AddCheckBox(); AscTest.MoveCursorRight(); - let oCC2 = AddCheckBox(); + let checkBox2 = AddCheckBox(); AscTest.MoveCursorRight(); - let oCC3 = AddCheckBox(); + let checkBox3 = AddCheckBox(); AscTest.SetFillingFormMode(true); - ExecuteShortcut2(oTestTypes.moveToNextForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC1, 'Test move to next form'); + ExecuteHotkey(testHotkeyActions.moveToNextForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox1, 'Test move to next form'); - ExecuteShortcut2(oTestTypes.moveToNextForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC2, 'Test move to next form'); + ExecuteHotkey(testHotkeyActions.moveToNextForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox2, 'Test move to next form'); - ExecuteShortcut2(oTestTypes.moveToNextForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC3, 'Test move to next form'); + ExecuteHotkey(testHotkeyActions.moveToNextForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox3, 'Test move to next form'); - ExecuteShortcut2(oTestTypes.moveToPreviousForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC2, 'Test move to previous form'); - ExecuteShortcut2(oTestTypes.moveToPreviousForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC1, 'Test move to previous form'); - ExecuteShortcut2(oTestTypes.moveToPreviousForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === oCC3, 'Test move to previous form'); + ExecuteHotkey(testHotkeyActions.moveToPreviousForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox2, 'Test move to previous form'); + ExecuteHotkey(testHotkeyActions.moveToPreviousForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox1, 'Test move to previous form'); + ExecuteHotkey(testHotkeyActions.moveToPreviousForm); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox3, 'Test move to previous form'); AscTest.SetEditingMode(); }); - function AddTable(row, column) - { - let table = AscTest.CreateTable(row, column); - logicDocument.PushToContent(table); - return table; - } - QUnit.test('Check move in table shortcuts', (assert) => { ClearDocumentAndAddParagraph(); const table = AddTable(3, 4); table.Document_SetThisElementCurrent(); table.MoveCursorToStartPos(); - ExecuteShortcut2(oTestTypes.moveToNextCell); + ExecuteHotkey(testHotkeyActions.moveToNextCell); assert.strictEqual(table.CurCell.Index, 1); - ExecuteShortcut2(oTestTypes.moveToNextCell); + ExecuteHotkey(testHotkeyActions.moveToNextCell); assert.strictEqual(table.CurCell.Index, 2); - ExecuteShortcut2(oTestTypes.moveToNextCell); + ExecuteHotkey(testHotkeyActions.moveToNextCell); assert.strictEqual(table.CurCell.Index, 3); - ExecuteShortcut2(oTestTypes.moveToPreviousCell); + ExecuteHotkey(testHotkeyActions.moveToPreviousCell); assert.strictEqual(table.CurCell.Index, 2); - ExecuteShortcut2(oTestTypes.moveToPreviousCell); + ExecuteHotkey(testHotkeyActions.moveToPreviousCell); assert.strictEqual(table.CurCell.Index, 1); - ExecuteShortcut2(oTestTypes.moveToPreviousCell); + ExecuteHotkey(testHotkeyActions.moveToPreviousCell); assert.strictEqual(table.CurCell.Index, 0); }); - function AddChart() - { - const oDrawingDocument = editor.WordControl.m_oDrawingDocument; - const oDrawing = new ParaDrawing(100, 100, null, oDrawingDocument, null, null); - const oChartSpace = logicDocument.GetChartObject(Asc.c_oAscChartTypeSettings.lineNormal); - oChartSpace.spPr.setXfrm(new AscFormat.CXfrm()); - oChartSpace.spPr.xfrm.setOffX(0); - oChartSpace.spPr.xfrm.setOffY(0); - oChartSpace.spPr.xfrm.setExtX(100); - oChartSpace.spPr.xfrm.setExtY(100); - - oChartSpace.setParent(oDrawing); - oDrawing.Set_GraphicObject(oChartSpace); - oDrawing.setExtent(oChartSpace.spPr.xfrm.extX, oChartSpace.spPr.xfrm.extY); - - oDrawing.Set_DrawingType(drawing_Anchor); - oDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); - oDrawing.Set_Distance(0, 0, 0, 0); - const oNearestPos = logicDocument.Get_NearestPos(0, oChartSpace.x, oChartSpace.y, true, oDrawing); - oDrawing.Set_XYForAdd(oChartSpace.x, oChartSpace.y, oNearestPos, 0); - oDrawing.AddToDocument(oNearestPos); - AscTest.Recalculate(); - return oDrawing; - } QUnit.test('Check Select all in chart title', (assert) => { TurnOnRecalculate(); - const p = ClearDocumentAndAddParagraph(''); + const paragraph = ClearDocumentAndAddParagraph(''); AscTest.Recalculate(); - const dr = AddChart(); + const paraDrawing = AddChart(); - const oChart = dr.GraphicObj; - selectDrawing([dr]); - const oTitles = oChart.getAllTitles(); - const oController = GetDrawingObjects(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); + const chart = paraDrawing.GraphicObj; + SelectDrawings([paraDrawing]); + const titles = chart.getAllTitles(); + const controller = GetDrawingObjects(); + controller.selection.chartSelection = chart; + chart.selectTitle(titles[0], 0); - ExecuteShortcut2(oTestTypes.selectAllInChartTitle); + ExecuteHotkey(testHotkeyActions.selectAllInChartTitle); assert.strictEqual(logicDocument.GetSelectedText(), 'Diagram Title', 'Check select all title'); TurnOffRecalculate(); }); QUnit.test('add new paragraph content', (assert) => { - const p = ClearDocumentAndAddParagraph('Hello text'); - ExecuteShortcut2(oTestTypes.addNewParagraphContent); + const paragraph = ClearDocumentAndAddParagraph('Hello text'); + ExecuteHotkey(testHotkeyActions.addNewParagraphContent); assert.strictEqual(logicDocument.Content.length, 2); }); QUnit.test('Check add new paragraph math', (assert) => { - const p = ClearDocumentAndAddParagraph('Hello text'); + const paragraph = ClearDocumentAndAddParagraph('Hello text'); logicDocument.AddParaMath(); AscTest.EnterText('abcd'); AscTest.MoveCursorLeft(); - ExecuteShortcut2(oTestTypes.addNewParagraphMath) + ExecuteHotkey(testHotkeyActions.addNewParagraphMath) assert.strictEqual(logicDocument.Content.length, 2, 'Test add new paragraph with math'); }); QUnit.test("Test add new line to math", (oAssert) => { - const p = ClearDocumentAndAddParagraph(''); - logicDocument.AddParaMath(c_oAscMathType.FractionVertical); - AscTest.MoveCursorLeft(); - AscTest.MoveCursorLeft(); - AscTest.EnterText('Hello'); - AscTest.MoveCursorLeft(); - AscTest.MoveCursorLeft(); - ExecuteShortcut2(oTestTypes.addNewLineToMath); - const oParaMath = p.GetAllParaMaths()[0]; - const oFraction = oParaMath.Root.GetFirstElement(); - const oNumerator = oFraction.getNumerator(); - const oEqArray = oNumerator.GetFirstElement(); - oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); + const paragraph = ClearDocumentAndAddParagraph(''); + logicDocument.AddParaMath(c_oAscMathType.FractionVertical); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.EnterText('Hello'); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + ExecuteHotkey(testHotkeyActions.addNewLineToMath); + const paraMath = paragraph.GetAllParaMaths()[0]; + const fraction = paraMath.Root.GetFirstElement(); + const numerator = fraction.getNumerator(); + const eqArray = numerator.GetFirstElement(); + oAssert.strictEqual(eqArray.getRowsCount(), 2, 'Check add new line math'); }); - function AddComplexForm() + QUnit.test("Test remove form", (assert) => { - let complexForm = logicDocument.AddComplexForm(); - const formPr = new AscWord.CSdtFormPr(); - var formTextPr = new AscCommon.CSdtTextFormPr(); - formTextPr.put_MultiLine(true); - complexForm.SetFormPr(formPr); - complexForm.SetTextFormPr(formTextPr); - return complexForm; - } - - // todo - // QUnit.test("Test remove form", (assert) => - // { - // AscTest.SetFillingFormMode(false) - // const p = ClearDocumentAndAddParagraph(''); - // const form = AddComboBox(['hdfh']); - // ExecuteShortcut2(oTestTypes.removeForm); - // assert.strictEqual(p.GetPosByElement(form), null, 'Check add new line math'); - // AscTest.SetEditingMode() - // }); + const paragraph = ClearDocumentAndAddParagraph(''); + const form = AddComboBox(['hdfh']); + ExecuteHotkey(testHotkeyActions.removeForm); + assert.strictEqual(paragraph.GetPosByElement(form), null, 'Check add new line math'); + AscTest.SetEditingMode(); + }); QUnit.test("Add tab to paragraph", (assert) => { - const p = ClearDocumentAndAddParagraph(''); - ExecuteShortcut2(oTestTypes.addTabToParagraph); - assert.true(p.GetPrevRunElement().IsTab()); + const paragraph = ClearDocumentAndAddParagraph(''); + ExecuteHotkey(testHotkeyActions.addTabToParagraph); + assert.true(paragraph.GetPrevRunElement().IsTab()); }); QUnit.test("Test add break line to inlinelvlsdt", (assert) => { TurnOnRecalculate(); - const p = ClearDocumentAndAddParagraph(''); - const oInlineSdt = AddComplexForm(); - ExecuteShortcut2(oTestTypes.addBreakLineInlineLvlSdt); - assert.strictEqual(oInlineSdt.Lines[0], 2); + const paragraph = ClearDocumentAndAddParagraph(''); + const complexForm = AddComplexForm(); + ExecuteHotkey(testHotkeyActions.addBreakLineInlineLvlSdt); + assert.strictEqual(complexForm.Lines[0], 2); TurnOffRecalculate(); }); QUnit.test("Test visit hyperlink", (assert) => { TurnOnRecalculate() - const p = ClearDocumentAndAddParagraph(''); + const paragraph = ClearDocumentAndAddParagraph(''); logicDocument.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Page)) logicDocument.AddHyperlink(new Asc.CHyperlinkProperty({Anchor: '_top', Text: "Beginning of document"})); AscTest.MoveCursorLeft(); AscTest.MoveCursorLeft(); - ExecuteShortcut2(oTestTypes.visitHyperlink); + ExecuteHotkey(testHotkeyActions.visitHyperlink); AscTest.Recalculate() assert.strictEqual(logicDocument.GetCurrentParagraph(), logicDocument.Content[0]); assert.strictEqual(logicDocument.Get_CurPage(), 0); @@ -1301,1528 +1290,84 @@ QUnit.test("Test handle tab in math", (oAssert) => { - const p = ClearDocumentAndAddParagraph(''); - logicDocument.AddParaMath(); - AscTest.EnterText('abcd+abcd+abcd'); - logicDocument.MoveCursorToEndPos(); - AscTest.MoveCursorLeft(); - AscTest.MoveCursorLeft(); - AscTest.MoveCursorLeft(); - AscTest.MoveCursorLeft(); - AscTest.MoveCursorLeft(); - - const oProps = new CMathMenuBase(); - oProps.insert_ManualBreak(); - logicDocument.Set_MathProps(oProps); - ExecuteShortcut2(oTestTypes.handleTab); + const paragraph = ClearDocumentAndAddParagraph(''); + logicDocument.AddParaMath(); + AscTest.EnterText('abcd+abcd+abcd'); + logicDocument.MoveCursorToEndPos(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + AscTest.MoveCursorLeft(); + + const props = new CMathMenuBase(); + props.insert_ManualBreak(); + logicDocument.Set_MathProps(props); + ExecuteHotkey(testHotkeyActions.handleTab); AscTest.MoveCursorRight(); - const oContentPosition = logicDocument.GetContentPosition(); - const oCurRun = oContentPosition[oContentPosition.length - 1].Class; - oAssert.strictEqual(oCurRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); + const contentPosition = logicDocument.GetContentPosition(); + const currentRun = contentPosition[contentPosition.length - 1].Class; + oAssert.strictEqual(currentRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); }); - // todo - // QUnit.test("Test end editing", (assert) => - // { - // TurnOnRecalculate(); - // AscTest.SetFillingFormMode(false); - // const p = ClearDocumentAndAddParagraph(''); - // const oCheckBox = AddCheckBox(); - // AscTest.SetFillingFormMode(true); - // oCheckBox.MoveCursorToContentControl(true); - // ExecuteShortcut2(oTestTypes.endEditing); - // const oSelectedInfo = logicDocument.GetSelectedElementsInfo(); - // assert.strictEqual(!!oSelectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); - // AscTest.SetEditingMode(); - // - // GoToHeader(0); - // ExecuteShortcut2(oTestTypes.endEditing); - // assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - // RemoveHeader(0); - // - // GoToFooter(0); - // ExecuteShortcut2(oTestTypes.endEditing); - // assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - // RemoveFooter(0); - // TurnOffRecalculate(); - // }); + + QUnit.test("Test end editing", (assert) => + { + TurnOnRecalculate(); + const paragraph = ClearDocumentAndAddParagraph(''); + const checkBox = AddCheckBox(); + AscTest.SetFillingFormMode(true); + checkBox.MoveCursorToContentControl(true); + ExecuteHotkey(testHotkeyActions.endEditing); + const selectedInfo = logicDocument.GetSelectedElementsInfo(); + assert.strictEqual(!!selectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); + AscTest.SetEditingMode(); + + GoToHeader(0); + ExecuteHotkey(testHotkeyActions.endEditing); + assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); + RemoveHeader(0); + + GoToFooter(0); + ExecuteHotkey(testHotkeyActions.endEditing); + assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); + RemoveFooter(0); + TurnOffRecalculate(); + }); QUnit.test("Test unicode to char hotkeys", (assert) => { - const p = ClearDocumentAndAddParagraph('2601'); + const paragraph = ClearDocumentAndAddParagraph('2601'); AscTest.MoveCursorLeft(true, true); - ExecuteShortcut2(oTestTypes.unicodeToChar); + ExecuteHotkey(testHotkeyActions.unicodeToChar); assert.strictEqual(logicDocument.GetSelectedText(), '☁', 'Test replace unicode code to symbol'); }); - function mouseDown(x, y, page, isRight, count) + + QUnit.test("Test reset drag'n'drop", (oAssert) => { - if (!logicDocument) - return; + TurnOnRecalculate(); + const paragraph = ClearDocumentAndAddParagraph('Hello Hello'); + AscTest.Recalculate(); + logicDocument.MoveCursorToStartPos(); + AscTest.MoveCursorRight(true, true); let e = new AscCommon.CMouseEventHandler(); - - e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; - e.ClickCount = count ? count : 1; + e.Button = AscCommon.g_mouse_button_left; + e.ClickCount = 1; e.Type = AscCommon.g_mouse_event_type_down; - logicDocument.OnMouseDown(e, x, y, page); - } - - function mouseUp(x, y, page, isRight, count) - { - if (!logicDocument) - return; + logicDocument.OnMouseDown(e, 5, 10, 0); - let e = new AscCommon.CMouseEventHandler(); + e.Type = AscCommon.g_mouse_event_type_move; + logicDocument.OnMouseMove(e, 45, 10, 0); - e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; - e.ClickCount = count ? count : 1; + ExecuteHotkey(testHotkeyActions.resetDragNDrop); + oAssert.true(!drawingDocument.IsTrackText(), "Test reset drag'n'drop"); e.Type = AscCommon.g_mouse_event_type_up; - logicDocument.OnMouseUp(e, x, y, page); - } - - function mouseMove(x, y, page, isRight, count) - { - if (!logicDocument) - return; - - let e = new AscCommon.CMouseEventHandler(); + logicDocument.OnMouseUp(e, 45, 10, 0); - e.Button = isRight ? AscCommon.g_mouse_button_right : AscCommon.g_mouse_button_left; - e.ClickCount = count ? count : 1; - - e.Type = AscCommon.g_mouse_event_type_move; - logicDocument.OnMouseMove(e, x, y, page); - } - // todo - // QUnit.test("Test reset drag'n'drop", (oAssert) => - // { - // TurnOnRecalculate(); - // const p = ClearDocumentAndAddParagraph('Hello Hello'); - // AscTest.Recalculate(); - // logicDocument.MoveCursorToStartPos(); - // AscTest.MoveCursorRight(true, true); - // mouseDown(5, 10, 0, false, 1); - // mouseMove(15, 10, 0, false, 1); - // //ExecuteShortcut2(oTestTypes.resetDragNDrop); - // mouseUp(15, 10, 0, false, 1); - // logicDocument.SelectAll() - // oAssert.strictEqual(logicDocument.GetSelectedText(), 'Hello Hello', "Test reset drag'n'drop"); - // TurnOffRecalculate(); - // - // }); - - // QUnit.test("test visit hyperlink", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['']); - // addBreakPage(); - // createHyperlink(); - // moveCursorLeft(); - // moveCursorLeft(); - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetCurrentParagraph(), logicContent()[0]); - // oAssert.strictEqual(oGlobalLogicDocument.Get_CurPage(), 0); - // }, oTestTypes.visitHyperlink); - // }); - - - // QUnit.test("Test add new paragraph", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs(['']); - // createMath(); - // addText('abcd'); - // moveCursorLeft(); - // onKeyDown(oEvent); - // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph with math'); - // }, oTestTypes.addNewParagraphMath); - // }); - - // QUnit.test("Test add new paragraph", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Text']); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph to content'); - // }, oTestTypes.addNewParagraphContent); - // }); - - // - // QUnit.test('Check show non printing characters shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ShowAll}; - // editor.put_ShowParaMarks(false); - // onKeyDown(createNativeEvent()); - // oAssert.true(editor.get_ShowParaMarks(), 'Check show non printing characters shortcut'); - // }); - // - // - // - // QUnit.test('Check copy format shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.CopyFormat}; - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - // oParagraph.SetThisElementCurrent(); - // oGlobalLogicDocument.SelectAll(); - // addPropertyToDocument({Bold: true, Italic: true, Underline: true}); - // - // onKeyDown(createNativeEvent()); - // const oCopyParagraphTextPr = new AscCommonWord.CTextPr(); - // oCopyParagraphTextPr.SetUnderline(true); - // oCopyParagraphTextPr.SetBold(true); - // oCopyParagraphTextPr.BoldCS = true; - // oCopyParagraphTextPr.SetItalic(true); - // oCopyParagraphTextPr.ItalicCS = true; - // oAssert.deepEqual(editor.getFormatPainterData().TextPr, oCopyParagraphTextPr, 'Check copy format shortcut'); - // }); - // - // - // QUnit.test('Check insert endnote shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertEndnoteNow}; - // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello']); - // oLogicDocument.SelectAll(); - // onKeyDown(createNativeEvent()); - // const arrEndnotes = oLogicDocument.GetEndnotesList(); - // oAssert.deepEqual(arrEndnotes.length, 1, 'Check insert endnote shortcut'); - // }); - // - // - // QUnit.test('Check bullet list shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.ApplyListBullet}; - // const {oLogicDocument, oParagraph} = getLogicDocumentWithParagraphs(['Hello']); - // oLogicDocument.SelectAll(); - // onKeyDown(createNativeEvent()); - // - // oAssert.true(oParagraph.IsBulletedNumbering(), 'check apply bullet list'); - // }); - // - // - // QUnit.test('Check indent shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.Indent}; - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello']); - // oParagraph.Pr.SetInd(0, 0, 0); - // moveToParagraph(oParagraph, true); - // - // onKeyDown(createNativeEvent()); - // oAssert.strictEqual(directParaPr().GetIndLeft(), 12.5, 'Check increase indent'); - // }); - // - // QUnit.test('Check unindent shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.UnIndent}; - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello']); - // oParagraph.Pr.SetInd(0, 12.5, 0); - // moveToParagraph(oParagraph, true); - // - // onKeyDown(createNativeEvent()); - // oAssert.true(AscFormat.fApproxEqual(directParaPr().GetIndLeft(), 0), 'Check decrease indent'); - // }); - // - // QUnit.test('Check insert page number shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertPageNumber}; - // checkInsertElementByType(para_PageNum, 'Check insert page number shortcut', oAssert, createNativeEvent()); - // }); - // - // - // - // - // QUnit.test('Check paste format shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.PasteFormat}; - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - // oParagraph.SetThisElementCurrent(); - // oGlobalLogicDocument.SelectAll(); - // addPropertyToDocument({Bold: true, Italic: true}); - // oGlobalLogicDocument.Document_Format_Copy(); - // remove(); - // addParagraphToDocumentWithText('Hello'); - // oGlobalLogicDocument.SelectAll(); - // onKeyDown(createNativeEvent()); - // const oDirectTextPr = directTextPr(); - // oAssert.true(oDirectTextPr.Get_Bold() && oDirectTextPr.Get_Italic(), 'Check paste format shortcut'); - // }); - // - // QUnit.test('Check redo shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditRedo}; - // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello World']); - // oLogicDocument.SelectAll(); - // oLogicDocument.Remove(undefined, undefined, true); - // oLogicDocument.Document_Undo(); - // onKeyDown(createNativeEvent()); - // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), '', 'Check redo shortcut'); - // }); - // - // QUnit.test('Check undo shortcut', (oAssert) => - // { - // getLogicDocumentWithParagraphs(['Hello World']); - // selectAll(); - // editor.asc_Remove(); - // - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.EditUndo}; - // onKeyDown(createNativeEvent()); - // selectAll(); - // oAssert.strictEqual(getSelectedText(), 'Hello World', 'Check redo shortcut'); - // }); - // - // - // QUnit.test('Check update fields shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.UpdateFields}; - // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello', 'Hello', 'Hello'], true); - // for (let i = 0; i < logicContent().length; i += 1) - // { - // oLogicDocument.Set_CurrentElement(i, true); - // oLogicDocument.SetParagraphStyle("Heading 1"); - // } - // oLogicDocument.MoveCursorToStartPos(); - // const props = new Asc.CTableOfContentsPr(); - // props.put_OutlineRange(1, 9); - // props.put_Hyperlink(true); - // props.put_ShowPageNumbers(true); - // props.put_RightAlignTab(true); - // props.put_TabLeader(Asc.c_oAscTabLeader.Dot); - // editor.asc_AddTableOfContents(null, props); - // - // oLogicDocument.MoveCursorToEndPos(); - // const oParagraph = createParagraphWithText('Hello'); - // oLogicDocument.AddToContent(logicContent().length, oParagraph); - // moveToParagraph(oParagraph); - // oLogicDocument.SetParagraphStyle("Heading 1"); - // - // logicContent()[0].SetThisElementCurrent(); - // onKeyDown(createNativeEvent()); - // oAssert.strictEqual(logicContent()[0].Content.Content.length, 5, 'Check update fields shortcut'); - // }); - // - // - // QUnit.test('Check show hyperlink menu shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertHyperlink}; - // executeTestWithCatchEvent('asc_onDialogAddHyperlink', () => true, true, createNativeEvent(), oAssert, () => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - // moveToParagraph(oParagraph); - // oGlobalLogicDocument.SelectAll(); - // }); - // }); - // - // QUnit.test('Check print shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.PrintPreviewAndPrint}; - // executeTestWithCatchEvent('asc_onPrint', () => true, true, createNativeEvent(), oAssert); - // }); - // - // QUnit.test('Check save shortcut', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.Save}; - // const fOldSave = editor._onSaveCallbackInner; - // let bCheck = false; - // editor._onSaveCallbackInner = function () - // { - // bCheck = true; - // editor.canSave = true; - // }; - // onKeyDown(createNativeEvent()); - // oAssert.strictEqual(bCheck, true, 'Check save shortcut'); - // editor._onSaveCallbackInner = fOldSave; - // }); - // - // - // - // QUnit.test('Check insert footnotes now', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertFootnoteNow}; - // const {oLogicDocument} = getLogicDocumentWithParagraphs(['Hello']); - // oLogicDocument.SelectAll(); - // onKeyDown(createNativeEvent()); - // const arrFootnotes = oLogicDocument.GetFootnotesList(); - // oAssert.deepEqual(arrFootnotes.length, 1, 'Check insert footnote shortcut'); - // }); - // - // QUnit.test('Check insert equation', (oAssert) => - // { - // editor.getShortcut = function () {return c_oAscDocumentShortcutType.InsertEquation}; - // const {oLogicDocument} = getLogicDocumentWithParagraphs(['']); - // onKeyDown(createNativeEvent()); - // const oMath = oLogicDocument.GetCurrentMath(); - // oAssert.true(!!oMath, 'Check insert equation shortcut'); - // }); - // - // QUnit.module("Test getting desired action by event") - // QUnit.test("Test getting common desired action by event", (oAssert) => - // { - // editor.initDefaultShortcuts(); - // oAssert.strictEqual(editor.getShortcut(createEvent(13, true, false, false, false, false, false)), c_oAscDocumentShortcutType.InsertPageBreak, 'Check getting c_oAscDocumentShortcutType.InsertPageBreak action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(13, false, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertLineBreak, 'Check getting c_oAscDocumentShortcutType.InsertLineBreak action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(13, true, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertColumnBreak, 'Check getting c_oAscDocumentShortcutType.InsertColumnBreak action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(32, true, false, false, false, false, false)), c_oAscDocumentShortcutType.ResetChar, 'Check getting c_oAscDocumentShortcutType.ResetChar action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(32, true, true, false, false, false, false)), c_oAscDocumentShortcutType.NonBreakingSpace, 'Check getting c_oAscDocumentShortcutType.NonBreakingSpace action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(53, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Strikeout, 'Check getting c_oAscDocumentShortcutType.Strikeout action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(56, true, true, false, false, false, false)), c_oAscDocumentShortcutType.ShowAll, 'Check getting c_oAscDocumentShortcutType.ShowAll action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(65, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditSelectAll, 'Check getting c_oAscDocumentShortcutType.EditSelectAll action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(66, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Bold, 'Check getting c_oAscDocumentShortcutType.Bold action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(67, true, false, true, false, false, false)), c_oAscDocumentShortcutType.CopyFormat, 'Check getting c_oAscDocumentShortcutType.CopyFormat action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(71, true, false, true, false, false, false)), c_oAscDocumentShortcutType.CopyrightSign, 'Check getting c_oAscDocumentShortcutType.CopyrightSign action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(68, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEndnoteNow, 'Check getting c_oAscDocumentShortcutType.InsertEndnoteNow action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(69, true, false, false, false, false, false)), c_oAscDocumentShortcutType.CenterPara, 'Check getting c_oAscDocumentShortcutType.CenterPara action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(69, true, false, true, false, false, false)), c_oAscDocumentShortcutType.EuroSign, 'Check getting c_oAscDocumentShortcutType.EuroSign action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(73, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Italic, 'Check getting c_oAscDocumentShortcutType.Italic action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(74, true, false, false, false, false, false)), c_oAscDocumentShortcutType.JustifyPara, 'Check getting c_oAscDocumentShortcutType.JustifyPara action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(75, true, false, false, false, false, false)), c_oAscDocumentShortcutType.InsertHyperlink, 'Check getting c_oAscDocumentShortcutType.InsertHyperlink action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(76, true, true, false, false, false, false)), c_oAscDocumentShortcutType.ApplyListBullet, 'Check getting c_oAscDocumentShortcutType.ApplyListBullet action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(76, true, false, false, false, false, false)), c_oAscDocumentShortcutType.LeftPara, 'Check getting c_oAscDocumentShortcutType.LeftPara action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(77, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Indent, 'Check getting c_oAscDocumentShortcutType.Indent action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(77, true, true, false, false, false, false)), c_oAscDocumentShortcutType.UnIndent, 'Check getting c_oAscDocumentShortcutType.UnIndent action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(80, true, false, false, false, false, false)), c_oAscDocumentShortcutType.PrintPreviewAndPrint, 'Check getting c_oAscDocumentShortcutType.PrintPreviewAndPrint action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(80, true, true, false, false, false, false)), c_oAscDocumentShortcutType.InsertPageNumber, 'Check getting c_oAscDocumentShortcutType.InsertPageNumber action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(82, true, false, false, false, false, false)), c_oAscDocumentShortcutType.RightPara, 'Check getting c_oAscDocumentShortcutType.RightPara action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(82, true, false, true, false, false, false)), c_oAscDocumentShortcutType.RegisteredSign, 'Check getting c_oAscDocumentShortcutType.RegisteredSign action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(83, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Save, 'Check getting c_oAscDocumentShortcutType.Save action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(84, true, false, true, false, false, false)), c_oAscDocumentShortcutType.TrademarkSign, 'Check getting c_oAscDocumentShortcutType.TrademarkSign action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(85, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Underline, 'Check getting c_oAscDocumentShortcutType.Underline action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(86, true, false, true, false, false, false)), c_oAscDocumentShortcutType.PasteFormat, 'Check getting c_oAscDocumentShortcutType.PasteFormat action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(89, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditRedo, 'Check getting c_oAscDocumentShortcutType.EditRedo action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(90, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EditUndo, 'Check getting c_oAscDocumentShortcutType.EditUndo action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(109, true, false, false, false, false, false)), c_oAscDocumentShortcutType.EnDash, 'Check getting c_oAscDocumentShortcutType.EnDash action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(109, true, false, true, false, false, false)), c_oAscDocumentShortcutType.EmDash, 'Check getting c_oAscDocumentShortcutType.EmDash action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(120, false, false, false, false, false, false)), c_oAscDocumentShortcutType.UpdateFields, 'Check getting c_oAscDocumentShortcutType.UpdateFields action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(188, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Superscript, 'Check getting c_oAscDocumentShortcutType.Superscript action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(189, true, true, false, false, false, false)), c_oAscDocumentShortcutType.NonBreakingHyphen, 'Check getting c_oAscDocumentShortcutType.NonBreakingHyphen action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(190, true, false, true, false, false, false)), c_oAscDocumentShortcutType.HorizontalEllipsis, 'Check getting c_oAscDocumentShortcutType.HorizontalEllipsis action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(190, true, false, false, false, false, false)), c_oAscDocumentShortcutType.Subscript, 'Check getting c_oAscDocumentShortcutType.Subscript action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(219, true, false, false, false, false, false)), c_oAscDocumentShortcutType.DecreaseFontSize, 'Check getting c_oAscDocumentShortcutType.DecreaseFontSize action'); - // oAssert.strictEqual(editor.getShortcut(createEvent(221, true, false, false, false, false, false)), c_oAscDocumentShortcutType.IncreaseFontSize, 'Check getting c_oAscDocumentShortcutType.IncreaseFontSize action'); - // editor.Shortcuts = new AscCommon.CShortcuts(); - // }); - // - // QUnit.test("Test getting windows desired action by event", (oAssert) => - // { - // editor.initDefaultShortcuts(); - // oAssert.strictEqual(editor.getShortcut(createEvent(49, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading1, 'Check getting c_oAscDocumentShortcutType.ApplyHeading1 shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(50, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading2, 'Check getting c_oAscDocumentShortcutType.ApplyHeading2 shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(51, false, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading3, 'Check getting c_oAscDocumentShortcutType.ApplyHeading3 shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(70, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertFootnoteNow, 'Check getting c_oAscDocumentShortcutType.InsertFootnoteNow shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(187, false, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEquation, 'Check getting c_oAscDocumentShortcutType.InsertEquation shortcut type'); - // editor.Shortcuts = new AscCommon.CShortcuts(); - // }); - // - // QUnit.test("Test getting macOs desired action by event", (oAssert) => - // { - // const bOldMacOs = AscCommon.AscBrowser.isMacOs; - // AscCommon.AscBrowser.isMacOs = true; - // editor.initDefaultShortcuts(); - // oAssert.strictEqual(editor.getShortcut(createEvent(49, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading1, 'Check getting c_oAscDocumentShortcutType.ApplyHeading1 shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(50, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading2, 'Check getting c_oAscDocumentShortcutType.ApplyHeading2 shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(51, true, false, true, false, false, false)), c_oAscDocumentShortcutType.ApplyHeading3, 'Check getting c_oAscDocumentShortcutType.ApplyHeading3 shortcut type'); - // oAssert.strictEqual(editor.getShortcut(createEvent(187, true, false, true, false, false, false)), c_oAscDocumentShortcutType.InsertEquation, 'Check getting c_oAscDocumentShortcutType.InsertEquation shortcut type'); - // editor.Shortcuts = new AscCommon.CShortcuts(); - // AscCommon.AscBrowser.isMacOs = bOldMacOs; - // }); - // - // QUnit.module('Test hotkeys module', { - // afterEach: function () - // { - // resetLogicDocument(oGlobalLogicDocument); - // } - // }) - // QUnit.test("test remove back symbol", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // selectAll(); - // oAssert.strictEqual(getSelectedText(), 'Hello Worl', 'Test remove back symbol'); - // }, oTestTypes.removeBackSymbol); - // }); - // - // QUnit.test("test remove back word", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // selectAll(); - // oAssert.strictEqual(getSelectedText(), 'Hello ', 'Test remove back word'); - // }, oTestTypes.removeBackWord); - // }); - // - // QUnit.test("test remove shape", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs([''], true); - // moveToParagraph(oParagraph); - // const oDrawing = createShape(); - // selectParaDrawing(oDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(oParagraph.GetRunByElement(oDrawing), null, 'Test remove shape'); - // }, oTestTypes.removeShape); - // }); - // - // QUnit.test("test remove form", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['']); - // moveToParagraph(oParagraph); - // const oInlineLvlSdt = createComboBox(); - // onKeyDown(oEvent); - // oAssert.strictEqual(oParagraph.GetPosByElement(oInlineLvlSdt), null, 'Test remove form'); - // }, oTestTypes.removeForm); - // }); - // - // - // QUnit.test("test move to next form", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs(['']); - // const oInlineSdt1 = createComboBox(); - // moveCursorRight(); - // const oInlineSdt2 = createComboBox(); - // moveCursorRight(); - // const oInlineSdt3 = createComboBox(); - // setFillingFormsMode(true); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt1, 'Test move to next form'); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt2, 'Test move to next form'); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt3, 'Test move to next form'); - // - // setFillingFormsMode(false); - // }, oTestTypes.moveToNextForm); - // }); - // - // - // QUnit.test("test move to previous form", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['']); - // const oInlineSdt1 = createComboBox(); - // moveCursorRight(); - // const oInlineSdt2 = createComboBox(); - // moveCursorRight(); - // const oInlineSdt3 = createComboBox(); - // setFillingFormsMode(true); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt2, 'Test move to next form'); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt1, 'Test move to next form'); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetSelectedElementsInfo().GetInlineLevelSdt(), oInlineSdt3, 'Test move to next form'); - // - // setFillingFormsMode(false); - // }, oTestTypes.moveToPreviousForm); - // }); - // - // - // - // QUnit.test("Test handle tab in math", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs([''], true); - // createMath(); - // addText('abcd+abcd+abcd'); - // moveToParagraph(oParagraph); - // moveCursorLeft(); - // moveCursorLeft(); - // moveCursorLeft(); - // moveCursorLeft(); - // moveCursorLeft(); - // insertManualBreak(); - // onKeyDown(oEvent); - // moveCursorRight(); - // const oContentPosition = oGlobalLogicDocument.GetContentPosition(); - // const oCurRun = oContentPosition[oContentPosition.length - 1].Class; - // - // oAssert.strictEqual(oCurRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); - // }, oTestTypes.handleTab); - // }); - // - // QUnit.test("test move to cell", (oAssert) => - // { - // startTest((oEvent) => - // { - // const oTable = createTable(3, 3); - // moveToTable(oTable, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(oTable.CurCell.Index, 1, 'Test move to next cell'); - // }, oTestTypes.moveToNextCell); - // }); - // - // QUnit.test("test move to cell", (oAssert) => - // { - // startTest((oEvent) => - // { - // const oTable = createTable(3, 3); - // moveToTable(oTable, true); - // moveCursorRight(); - // onKeyDown(oEvent); - // oAssert.strictEqual(oTable.CurCell.Index, 0, 'Test move to previous cell'); - // }, oTestTypes.moveToPreviousCell); - // }); - // - // QUnit.test("test select next object", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const oFirstParaDrawing = createShape(); - // const oSecondParaDrawing = createShape(); - // selectParaDrawing(oFirstParaDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oSecondParaDrawing.GraphicObj, true, 'Test select next object'); - // - // }, oTestTypes.selectNextObject); - // }); - // - // QUnit.test("test select previous object", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const oFirstParaDrawing = createShape(); - // const oSecondParaDrawing = createShape(); - // const oThirdParaDrawing = createShape(); - // selectParaDrawing(oFirstParaDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oThirdParaDrawing.GraphicObj, true, 'Test select previous object'); - // onKeyDown(oEvent); - // oAssert.strictEqual(drawingObjects().selectedObjects.length === 1 && drawingObjects().selectedObjects[0] === oSecondParaDrawing.GraphicObj, true, 'Test select previous object'); - // }, oTestTypes.selectPreviousObject); - // }); - // - // QUnit.test("test indent", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs(['Hello world', "Hello world"]); - // const oFirstParagraph = logicContent()[0]; - // const oSecondParagraph = logicContent()[1]; - // selectAll(); - // onKeyDown(oEvent); - // let arrSteps = []; - // moveToParagraph(oFirstParagraph); - // arrSteps.push(directParaPr().GetIndLeft()); - // moveToParagraph(oSecondParagraph); - // arrSteps.push(directParaPr().GetIndLeft()); - // oAssert.deepEqual(arrSteps, [12.5, 12.5], 'Test indent'); - // - // moveToParagraph(oFirstParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(); - // }, oTestTypes.testIndent); - // }); - // - // QUnit.test("test unindent", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs(['hello', 'hello']); - // const oFirstParagraph = logicContent()[0]; - // const oSecondParagraph = logicContent()[1]; - // oFirstParagraph.Set_Ind({Left: 12.5}); - // oSecondParagraph.Set_Ind({Left: 12.5}); - // selectAll(); - // onKeyDown(oEvent); - // - // const arrSteps = []; - // moveToParagraph(oFirstParagraph); - // arrSteps.push(directParaPr().GetIndLeft()); - // moveToParagraph(oSecondParagraph); - // arrSteps.push(directParaPr().GetIndLeft()); - // - // oAssert.deepEqual(arrSteps, [0, 0], 'Test unindent'); - // }, oTestTypes.testUnIndent); - // }); - // - // - // QUnit.test("test add tab to paragraph", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello World']); - // moveToParagraph(oParagraph, true); - // moveCursorRight(); - // onKeyDown(oEvent); - // selectAll(); - // - // oAssert.strictEqual(getSelectedText(), 'H\tello World', 'Test indent'); - // }, oTestTypes.addTabToParagraph); - // }); - // - // QUnit.test("test visit hyperlink", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['']); - // addBreakPage(); - // createHyperlink(); - // moveCursorLeft(); - // moveCursorLeft(); - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetCurrentParagraph(), logicContent()[0]); - // oAssert.strictEqual(oGlobalLogicDocument.Get_CurPage(), 0); - // }, oTestTypes.visitHyperlink); - // }); - // - // QUnit.test("Test add break line to inlinelvlsdt", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const oInlineSdt = createComplexForm(); - // onKeyDown(oEvent); - // oAssert.strictEqual(oInlineSdt.Lines[0], 2); - // }, oTestTypes.addBreakLineInlineLvlSdt); - // }); - // - // QUnit.test("Test create textBoxContent", (oAssert) => - // { - // startTest((oEvent) => - // { - // const oParaDrawing = createShape(); - // selectParaDrawing(oParaDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(!!oParaDrawing.GraphicObj.textBoxContent, true); - // }, oTestTypes.createTextBoxContent); - // }); - // - // QUnit.test("Test create txBody", (oAssert) => - // { - // startTest((oEvent) => - // { - // const oParaDrawing = createShape(); - // oParaDrawing.GraphicObj.setWordShape(false); - // selectParaDrawing(oParaDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(!!oParaDrawing.GraphicObj.txBody, true); - // }, oTestTypes.createTextBody); - // }); - // - // QUnit.test("Test add new line to math", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['']); - // createMath(c_oAscMathType.FractionVertical); - // moveCursorLeft(); - // moveCursorLeft(); - // addText('Hello'); - // moveCursorLeft(); - // moveCursorLeft(); - // onKeyDown(oEvent); - // const oParaMath = oParagraph.GetAllParaMaths()[0]; - // const oFraction = oParaMath.Root.GetFirstElement(); - // const oNumerator = oFraction.getNumerator(); - // const oEqArray = oNumerator.GetFirstElement(); - // oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); - // }, oTestTypes.addNewLineToMath); - // }); - // - // QUnit.test("Test move cursor to start position shape", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const oParaDrawing = createShape(); - // const oShape = oParaDrawing.GraphicObj; - // oShape.createTextBoxContent(); - // selectParaDrawing(oParaDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(oShape.getDocContent().IsCursorAtBegin(), true); - // }, oTestTypes.moveCursorToStartPositionShapeEnter); - // }); - // - // QUnit.test("Test select all in shape", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true) - // const oParaDrawing = createShape(); - // const oShape = oParaDrawing.GraphicObj; - // oShape.createTextBoxContent(); - // moveToParagraph(oShape.getDocContent().Content[0]); - // addText('Hello'); - // selectParaDrawing(oParaDrawing); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'Hello'); - // }, oTestTypes.selectAllShapeEnter); - // }); - // - // QUnit.test("Test move cursor to start position chart title", (oAssert) => - // { - // startTest((oEvent) => - // { - // const oParaDrawing = createChart(); - // const oChart = oParaDrawing.GraphicObj; - // const oTitles = oChart.getAllTitles(); - // const oContent = AscFormat.CreateDocContentFromString('', drawingObjects().getDrawingDocument(), oTitles[0].txBody); - // oTitles[0].txBody.content = oContent; - // selectParaDrawing(oParaDrawing); - // - // const oController = drawingObjects(); - // oController.selection.chartSelection = oChart; - // oChart.selectTitle(oTitles[0], 0); - // - // onKeyDown(oEvent); - // oAssert.true(oContent.IsCursorAtBegin(), 'Check move cursor to begin pos in title'); - // }, oTestTypes.moveCursorToStartPositionTitleEnter); - // }); - // - // QUnit.test("Test select all in chart title", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const oParaDrawing = createChart(); - // const oChart = oParaDrawing.GraphicObj; - // selectParaDrawing(oParaDrawing); - // const oTitles = oChart.getAllTitles(); - // const oController = drawingObjects(); - // oController.selection.chartSelection = oChart; - // oChart.selectTitle(oTitles[0], 0); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'Diagram Title', 'Check select all title'); - // }, oTestTypes.selectAllInChartTitle); - // }); - // - // QUnit.test("Test add new paragraph", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Text']); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph to content'); - // }, oTestTypes.addNewParagraphContent); - // }); - // - // QUnit.test("Test add new paragraph", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs(['']); - // createMath(); - // addText('abcd'); - // moveCursorLeft(); - // onKeyDown(oEvent); - // oAssert.strictEqual(logicContent().length, 2, 'Test add new paragraph with math'); - // }, oTestTypes.addNewParagraphMath); - // }); - // - // QUnit.test("Test close all window popups", (oAssert) => - // { - // startTest((oEvent) => - // { - // executeTestWithCatchEvent('asc_onMouseMoveStart', () => true, true, oEvent, oAssert); - // executeTestWithCatchEvent('asc_onMouseMove', () => true, true, oEvent, oAssert); - // executeTestWithCatchEvent('asc_onMouseMoveEnd', () => true, true, oEvent, oAssert); - // }, oTestTypes.closeAllWindowsPopups); - // }); - // - // QUnit.test("Test reset shape selection", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const arrDrawings = [createShape(), createShape()]; - // const oGroup = createGroup(arrDrawings); - // const oChart = createChart(); - // selectOnlyObjects([oChart, oGroup, arrDrawings[0]]); - // onKeyDown(oEvent); - // oAssert.strictEqual(drawingObjects().getSelectedArray().length, 0, "Test reset shape selection"); - // }, oTestTypes.resetShapeSelection); - // }); - // - // QUnit.test("Test reset add shape", (oAssert) => - // { - // startTest((oEvent) => - // { - // editor.StartAddShape('rect'); - // onKeyDown(oEvent); - // oAssert.strictEqual(editor.isStartAddShape, false, "Test reset add shape"); - // }, oTestTypes.resetStartAddShape); - // }); - // - // QUnit.test("Test reset formatting by example", (oAssert) => - // { - // startTest((oEvent) => - // { - // editor.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOn); - // onKeyDown(oEvent); - // oAssert.strictEqual(editor.isFormatPainterOn(), false, "Test reset formatting by example"); - // }, oTestTypes.resetFormattingByExample); - // }); - // - // QUnit.test("Test reset", (oAssert) => - // { - // startTest((oEvent) => - // { - // editor.SetMarkerFormat(true, true, 0, 0, 0); - // onKeyDown(oEvent); - // oAssert.strictEqual(editor.isMarkerFormat, false, "Test reset marker"); - // }, oTestTypes.resetMarkerFormat); - // - // }); - // - // QUnit.test("Test reset drag'n'drop", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(['Hello Hello'], true); - // moveToParagraph(oParagraph, true); - // moveCursorRight(true, true); - // mouseDown(5, 10, 0, false, 1); - // mouseMove(35, 10, 0, false, 1); - // onKeyDown(oEvent); - // oAssert.strictEqual(editor.WordControl.m_oDrawingDocument.IsTrackText(), false, "Test reset drag'n'drop"); - // mouseUp(35, 10, 0, false, 1); - // }, oTestTypes.resetDragNDrop); - // }); - // - // QUnit.test("Test end editing form", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs([''], true); - // const oCheckBox = createCheckBox(); - // oCheckBox.MoveCursorToContentControl(true); - // setFillingFormsMode(true); - // onKeyDown(oEvent); - // const oSelectedInfo = oGlobalLogicDocument.GetSelectedElementsInfo(); - // oAssert.strictEqual(!!oSelectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); - // setFillingFormsMode(false); - // - // editor.GoToHeader(0); - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - // editor.asc_RemoveHeader(0); - // - // editor.GoToFooter(0); - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - // editor.asc_RemoveFooter(0); - // }, oTestTypes.endEditing); - // }); - // - // QUnit.test("Test toggle checkbox", (oAssert) => - // { - // startTest((oEvent) => - // { - // getLogicDocumentWithParagraphs(['']); - // const oInlineSdt = createCheckBox(); - // setFillingFormsMode(true); - // onKeyDown(oEvent); - // oAssert.strictEqual(oInlineSdt.IsCheckBoxChecked(), true); - // setFillingFormsMode(false); - // }, oTestTypes.toggleCheckBox); - // }); - // - // QUnit.test("Test actions to page up", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 125); - // }, oTestTypes.moveToPreviousPage); - // }); - // - // QUnit.test("Test actions to page up", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 90); - // }, oTestTypes.moveToStartPreviousPage); - // }); - // - // QUnit.test("Test move to previous header or footer", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // editor.GoToHeader(2); - // editor.GoToFooter(2); - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[2].Header); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Footer); - // }, oTestTypes.moveToPreviousHeaderFooter); - // editor.asc_RemoveHeader(2); - // editor.asc_RemoveFooter(2); - // }); - // - // QUnit.test("Test actions to page up", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // - // editor.GoToHeader(2); - // editor.GoToFooter(2); - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[0].Header); - // }, oTestTypes.moveToPreviousHeader); - // editor.asc_RemoveHeader(2); - // editor.asc_RemoveFooter(2); - // }); - // function drawingDocument() - // { - // return editor.WordControl.m_oDrawingDocument; - // } - // QUnit.test("Test select to previous page", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), ' World Hello World Hello World Hello World Hello World Hello World Hello World Hello World'); - // }, oTestTypes.selectToPreviousPage); - // }); - // - // - // QUnit.test("Test select to start previous page", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World'); - // }, oTestTypes.selectToStartPreviousPage); - // }); - // - // QUnit.test("Test select to start of next page", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello ', "Test select to begin of next page"); - // }, oTestTypes.selectToStartNextPage); - // }); - // QUnit.test("Test move to start of next page", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 90, "Test move to begin of next page"); - // }, oTestTypes.moveToStartNextPage); - // }); - // QUnit.test("Test select to next page", (oAssert) => - // { - // startTest((oEvent) => - // { - // - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // moveCursorRight(); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello W', "Test select to next page"); - // }, oTestTypes.selectToNextPage); - // }); - // QUnit.test("Test move to next page", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // moveCursorRight(); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 91, "Test move to next page"); - // }, oTestTypes.moveToNextPage); - // }); - // QUnit.test("Test move to next header/footer", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // editor.GoToFooter(0); - // editor.GoToHeader(0); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[0].Footer); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); - // }, oTestTypes.moveToNextHeaderFooter); - // }); - // QUnit.test("Test move to next header", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // editor.GoToFooter(0); - // editor.GoToHeader(0); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[1].Header); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(oGlobalLogicDocument.GetDocPosType(), docpostype_HdrFtr); - // oAssert.strictEqual(oGlobalLogicDocument.Controller.HdrFtr.CurHdrFtr, oGlobalLogicDocument.Controller.HdrFtr.Pages[2].Header); - // }, oTestTypes.moveToNextHeader); - // }); - // - // QUnit.test("Test actions to end", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 107, "Test move to end of document"); - // }, oTestTypes.moveToEndDocument); - // }); - // - // QUnit.test("Test actions to end", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 18, "Test move to end of line"); - // }, oTestTypes.moveToEndLine); - // }); - // - // QUnit.test("Test actions to end", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), "Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World", "Test select to end of document"); - // - // }, oTestTypes.selectToEndDocument); - // }); - // - // QUnit.test("Test actions to end", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), "Hello World Hello ", "Test select to end of line"); - // }, oTestTypes.selectToEndLine); - // }); - // - // QUnit.test("Test actions to home", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), "World Hello World", "Test select to home of line"); - // }, oTestTypes.selectToStartLine); - // }); - // - // QUnit.test("Test actions to home", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), "Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World", "Test select to home of document"); - // - // }, oTestTypes.selectToStartDocument); - // - // }); - // - // QUnit.test("Test actions to home", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 90, "Test move to home of line"); - // }, oTestTypes.moveToStartLine); - // }); - // - // QUnit.test("Test actions to home", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 0, "Test move to home of document"); - // }, oTestTypes.moveToStartDocument); - // }); - // - // QUnit.test("Test actions to left", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'World', "Test select to previous word"); - // }, oTestTypes.selectLeftWord); - // }); - // - // QUnit.test("Test actions to left", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 18, "Test move to previous word"); - // }, oTestTypes.moveToLeftWord); - // let oEvent; - // }); - // - // QUnit.test("Test actions to left", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'd', "Test select to previous symbol"); - // }, oTestTypes.selectLeftSymbol); - // }); - // - // QUnit.test("Test actions to left", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World"], true); - // moveToParagraph(oParagraph); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 22, "Test move to previous symbol"); - // }, oTestTypes.moveToLeftChar); - // }); - // - // QUnit.test("Test actions to left", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(-1, 0, oAssert, oEvent); - // }, oTestTypes.littleMoveGraphicObjectLeft); - // }); - // - // QUnit.test("Test actions to left", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(-5, 0, oAssert, oEvent); - // }, oTestTypes.bigMoveGraphicObjectLeft); - // }); - // - // QUnit.test("Test actions to right", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(1, 0, oAssert, oEvent); - // }, oTestTypes.littleMoveGraphicObjectRight); - // }); - // - // QUnit.test("Test actions to right", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(5, 0, oAssert, oEvent); - // }, oTestTypes.bigMoveGraphicObjectRight); - // }); - // - // QUnit.test("Test actions to up", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(0, -1, oAssert, oEvent); - // }, oTestTypes.littleMoveGraphicObjectUp); - // }); - // - // QUnit.test("Test actions to up", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(0, -5, oAssert, oEvent); - // }, oTestTypes.bigMoveGraphicObjectUp); - // }); - // - // QUnit.test("Test actions to down", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(0, 1, oAssert, oEvent); - // }, oTestTypes.littleMoveGraphicObjectDown); - // }); - // - // QUnit.test("Test actions to down", (oAssert) => - // { - // startTest((oEvent) => - // { - // moveShapeHelper(0, 5, oAssert, oEvent); - // }, oTestTypes.bigMoveGraphicObjectDown); - // }); - // - // QUnit.test("Test actions to right", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(contentPosition(), 1, "Test move to next symbol"); - // }, oTestTypes.moveToRightChar); - // }); - // - // QUnit.test("Test actions to right", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), "H", "Test select to next symbol"); - // }, oTestTypes.selectRightChar); - // }); - // - // QUnit.test("Test actions to right", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.deepEqual(contentPosition(), 6, "Test move to next word"); - // }, oTestTypes.moveToRightWord); - // }); - // - // QUnit.test("Test actions to right", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'Hello ', "Test select to next word"); - // }, oTestTypes.selectRightWord); - // }); - // - // QUnit.test("Test actions to up", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // moveCursorDown(); - // onKeyDown(oEvent); - // oAssert.deepEqual(contentPosition(), 0, "Test move to upper line"); - // }, oTestTypes.moveUp); - // }); - // - // QUnit.test("Test actions to up", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // moveCursorDown(); - // oEvent = createNativeEvent(38, false, true, false, false); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'Hello World Hello ', "Test select to upper line"); - // }, oTestTypes.selectUp); - // }); - // - // QUnit.test("Test actions to up", (oAssert) => - // { - // startTest((oEvent) => - // { - // clean(); - // getLogicDocumentWithParagraphs(['']); - // createComboBox(); - // setFillingFormsMode(true); - // onKeyDown(oEvent); - // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'Hello', "Test select previous option in combo box"); - // - // onKeyDown(oEvent); - // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'yo', "Test select previous option in combo box"); - // setFillingFormsMode(false); - // }, oTestTypes.previousOptionComboBox); - // }); - // - // QUnit.test("Test actions to down", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.deepEqual(contentPosition(), 18, "Test move to down line"); - // }, oTestTypes.moveDown); - // }); - // - // QUnit.test("Test actions to down", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"], true); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), 'Hello World Hello ', "Test select to down line"); - // }, oTestTypes.selectDown); - // }); - // - // QUnit.test("Test actions to down", (oAssert) => - // { - // startTest((oEvent) => - // { - // clean(); - // getLogicDocumentWithParagraphs(['']); - // createComboBox(); - // setFillingFormsMode(true); - // onKeyDown(oEvent); - // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'Hello', "Test select next option in combo box"); - // onKeyDown(oEvent); - // oAssert.strictEqual(AscTest.GetParagraphText(logicContent()[0]), 'World', "Test select next option in combo box"); - // setFillingFormsMode(false); - // }, oTestTypes.nextOptionComboBox); - // }); - // - // QUnit.test("Test remove front", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World"]); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // selectAll(); - // oAssert.strictEqual(getSelectedText(), 'ello World', 'Test remove front symbol'); - // }, oTestTypes.removeFrontSymbol); - // }); - // - // QUnit.test("Test remove front", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello World"]); - // moveToParagraph(oParagraph, true); - // onKeyDown(oEvent); - // selectAll(); - // oAssert.strictEqual(getSelectedText(), 'World', 'Test remove front word'); - // }, oTestTypes.removeFrontWord); - // }); - // - // QUnit.test("Test replace unicode code to symbol", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["2601"]); - // moveToParagraph(oParagraph, true); - // moveCursorRight(true, true); - // onKeyDown(oEvent); - // oAssert.strictEqual(getSelectedText(), '☁', 'Test replace unicode code to symbol'); - // }, oTestTypes.unicodeToChar); - // }); - // - // QUnit.test("Test show context menu", (oAssert) => - // { - // startTest((oEvent) => - // { - // const {oParagraph} = getLogicDocumentWithParagraphs(["Hello Text"]); - // moveToParagraph(oParagraph, true); - // - // oEvent = createNativeEvent(93, false, false, false, false); - // executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - // - // AscCommon.AscBrowser.isOpera = true; - // oEvent = createNativeEvent(57351, false, false, false, false); - // executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - // AscCommon.AscBrowser.isOpera = false; - // - // oEvent = createNativeEvent(121, false, true, false, false); - // executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - // }, oTestTypes.showContextMenu); - // - // }); - // - // QUnit.test("Test disable numlock", (oAssert) => - // { - // startTest((oEvent) => - // { - // oEvent = createNativeEvent(144, false, false, false, false); - // onKeyDown(oEvent); - // oAssert.strictEqual(oEvent.isDefaultPrevented, true, 'Test prevent default on numlock'); - // }, oTestTypes.disableNumLock); - // }); - // - // QUnit.test("Test disable scroll lock", (oAssert) => - // { - // startTest((oEvent) => - // { - // oEvent = createNativeEvent(145, false, false, false, false); - // onKeyDown(oEvent); - // oAssert.strictEqual(oEvent.isDefaultPrevented, true, 'Test prevent default on scroll lock'); - // }, oTestTypes.disableScrollLock); - // }); - // - // QUnit.test("Test add SJK test", (oAssert) => - // { - // startTest((oEvent) => - // { - // checkTextAfterKeyDownHelperEmpty(' ', oEvent, oAssert, 'Check add space after SJK space'); - // }, oTestTypes.addSJKSpace); - // }); + TurnOffRecalculate(); + }); }); })(window); From e2c6664ef34be857d8c9166700e7217066f91cf7 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Fri, 11 Aug 2023 13:48:43 +0300 Subject: [PATCH 06/23] Add description for tests --- tests/word/shortcuts/events.js | 204 +++++++------- tests/word/shortcuts/shortcuts.js | 452 ++++++++++++++---------------- 2 files changed, 302 insertions(+), 354 deletions(-) diff --git a/tests/word/shortcuts/events.js b/tests/word/shortcuts/events.js index f24d1e1ff6..062f30b67f 100644 --- a/tests/word/shortcuts/events.js +++ b/tests/word/shortcuts/events.js @@ -120,127 +120,119 @@ }; const testHotkeyEvents = {}; - testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectLeft] = [new CTestEvent(37, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectLeft] = [new CTestEvent(37, true, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectRight] = [new CTestEvent(39, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectRight] = [new CTestEvent(39, true, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectDown] = [new CTestEvent(40, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectDown] = [new CTestEvent(40, true, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectUp] = [new CTestEvent(38, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectUp] = [new CTestEvent(38, true, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.removeBackSymbol] = [new CTestEvent(8, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.removeBackWord] = [new CTestEvent(8, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectLeft] = [CreateTestEvent(37, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectLeft] = [CreateTestEvent(37, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectRight] = [CreateTestEvent(39, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectRight] = [CreateTestEvent(39, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectDown] = [CreateTestEvent(40, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectDown] = [CreateTestEvent(40, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectUp] = [CreateTestEvent(38, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectUp] = [CreateTestEvent(38, true, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeBackSymbol] = [CreateTestEvent(8, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeBackWord] = [CreateTestEvent(8, true, false, false, false)]; testHotkeyEvents[testHotkeyActions.removeShape] = [ - new CTestEvent(8, false, false, false, false, false), - new CTestEvent(46, false, false, false, false, false) + CreateTestEvent(8, false, false, false, false, false), + CreateTestEvent(46, false, false, false, false, false) ]; testHotkeyEvents[testHotkeyActions.removeForm] = [ - new CTestEvent(8, false, false, false, false, false), - new CTestEvent(46, false, false, false, false, false) + CreateTestEvent(8, false, false, false, false, false), + CreateTestEvent(46, false, false, false, false, false) ]; - testHotkeyEvents[testHotkeyActions.moveToNextForm] = [new CTestEvent(9, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToPreviousForm] = [new CTestEvent(9, false, true, false, false, false)]; - testHotkeyEvents[testHotkeyActions.handleTab] = [new CTestEvent(9, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToNextCell] = [new CTestEvent(9, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToPreviousCell] = [new CTestEvent(9, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectNextObject] = [new CTestEvent(9, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectPreviousObject] = [new CTestEvent(9, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.testIndent] = [new CTestEvent(9, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.testUnIndent] = [new CTestEvent(9, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.addTabToParagraph] = [new CTestEvent(9, false, false, false)]; - testHotkeyEvents[testHotkeyActions.visitHyperlink] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.addBreakLineInlineLvlSdt] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.createTextBoxContent] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.createTextBody] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.addNewLineToMath] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveCursorToStartPositionShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectAllShapeEnter] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectAllInChartTitle] = [new CTestEvent(13, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.addNewParagraphContent] = [new CTestEvent(13, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.addNewParagraphMath] = [new CTestEvent(13, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.closeAllWindowsPopups] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.resetShapeSelection] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.resetStartAddShape] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.resetFormattingByExample] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.resetMarkerFormat] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.resetDragNDrop] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.endEditing] = [new CTestEvent(27, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.toggleCheckBox] = [new CTestEvent(32, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToEndDocument] = [new CTestEvent(35, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToEndLine] = [new CTestEvent(35, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToEndDocument] = [new CTestEvent(35, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToEndLine] = [new CTestEvent(35, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToStartLine] = [new CTestEvent(36, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToStartDocument] = [new CTestEvent(36, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToStartLine] = [new CTestEvent(36, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToStartDocument] = [new CTestEvent(36, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectLeftWord] = [new CTestEvent(37, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToLeftWord] = [new CTestEvent(37, true, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectLeftChar] = [new CTestEvent(37, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToLeftChar] = [new CTestEvent(37, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToRightChar] = [new CTestEvent(39, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectRightChar] = [new CTestEvent(39, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToRightWord] = [new CTestEvent(39, true, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectRightWord] = [new CTestEvent(39, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveUp] = [new CTestEvent(38, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectUp] = [new CTestEvent(38, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.previousOptionComboBox] = [new CTestEvent(38, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveDown] = [new CTestEvent(40, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectDown] = [new CTestEvent(40, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.nextOptionComboBox] = [new CTestEvent(40, false, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.removeFrontSymbol] = [new CTestEvent(46, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.removeFrontWord] = [new CTestEvent(46, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextForm] = [CreateTestEvent(9, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousForm] = [CreateTestEvent(9, false, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.handleTab] = [CreateTestEvent(9, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextCell] = [CreateTestEvent(9, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousCell] = [CreateTestEvent(9, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectNextObject] = [CreateTestEvent(9, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectPreviousObject] = [CreateTestEvent(9, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.testIndent] = [CreateTestEvent(9, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.testUnIndent] = [CreateTestEvent(9, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.addTabToParagraph] = [CreateTestEvent(9, false, false, false)]; + testHotkeyEvents[testHotkeyActions.visitHyperlink] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addBreakLineInlineLvlSdt] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.createTextBoxContent] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.createTextBody] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addNewLineToMath] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveCursorToStartPositionShapeEnter] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectAllShapeEnter] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectAllInChartTitle] = [CreateTestEvent(13, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addNewParagraphContent] = [CreateTestEvent(13, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addNewParagraphMath] = [CreateTestEvent(13, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.closeAllWindowsPopups] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetShapeSelection] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetStartAddShape] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetFormattingByExample] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetMarkerFormat] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.resetDragNDrop] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.endEditing] = [CreateTestEvent(27, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.toggleCheckBox] = [CreateTestEvent(32, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToEndDocument] = [CreateTestEvent(35, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToEndLine] = [CreateTestEvent(35, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToEndDocument] = [CreateTestEvent(35, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToEndLine] = [CreateTestEvent(35, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartLine] = [CreateTestEvent(36, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartDocument] = [CreateTestEvent(36, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartLine] = [CreateTestEvent(36, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartDocument] = [CreateTestEvent(36, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectLeftWord] = [CreateTestEvent(37, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToLeftWord] = [CreateTestEvent(37, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectLeftChar] = [CreateTestEvent(37, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToLeftChar] = [CreateTestEvent(37, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToRightChar] = [CreateTestEvent(39, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectRightChar] = [CreateTestEvent(39, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToRightWord] = [CreateTestEvent(39, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectRightWord] = [CreateTestEvent(39, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveUp] = [CreateTestEvent(38, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectUp] = [CreateTestEvent(38, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.previousOptionComboBox] = [CreateTestEvent(38, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveDown] = [CreateTestEvent(40, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectDown] = [CreateTestEvent(40, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.nextOptionComboBox] = [CreateTestEvent(40, false, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeFrontSymbol] = [CreateTestEvent(46, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeFrontWord] = [CreateTestEvent(46, true, false, false, false)]; testHotkeyEvents[testHotkeyActions.unicodeToChar] = [ - new CTestEvent(88, false, false, true, false), - new CTestEvent(88, true, false, true, false) + CreateTestEvent(88, false, false, true, false), + CreateTestEvent(88, true, false, true, false) ]; testHotkeyEvents[testHotkeyActions.showContextMenu] = [ - new CTestEvent(93, false, false, false, false), - new CTestEvent(57351, false, false, false, false), - new CTestEvent(121, false, true, false, false) + CreateTestEvent(93, false, false, false, false), + CreateTestEvent(57351, false, false, false, false), + CreateTestEvent(121, false, true, false, false) ]; - testHotkeyEvents[testHotkeyActions.disableNumLock] = [new CTestEvent(144, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.disableScrollLock] = [new CTestEvent(145, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.addSJKSpace] = [new CTestEvent(12288, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToStartPreviousPage] = [new CTestEvent(33, true, false, true, false)]; - testHotkeyEvents[testHotkeyActions.moveToPreviousPage] = [new CTestEvent(33, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToPreviousHeaderFooter] = [new CTestEvent(33, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.disableNumLock] = [CreateTestEvent(144, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.disableScrollLock] = [CreateTestEvent(145, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.addSJKSpace] = [CreateTestEvent(12288, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartPreviousPage] = [CreateTestEvent(33, true, false, true, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousPage] = [CreateTestEvent(33, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToPreviousHeaderFooter] = [CreateTestEvent(33, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.moveToPreviousHeader] = [ - new CTestEvent(33, true, false, true, false), - new CTestEvent(33, false, false, true, false) + CreateTestEvent(33, true, false, true, false), + CreateTestEvent(33, false, false, true, false) ]; - testHotkeyEvents[testHotkeyActions.selectToStartPreviousPage] = [new CTestEvent(33, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToPreviousPage] = [new CTestEvent(33, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToStartNextPage] = [new CTestEvent(34, true, false, true, false)]; - testHotkeyEvents[testHotkeyActions.moveToNextPage] = [new CTestEvent(34, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToNextHeaderFooter] = [new CTestEvent(34, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartPreviousPage] = [CreateTestEvent(33, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToPreviousPage] = [CreateTestEvent(33, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartNextPage] = [CreateTestEvent(34, true, false, true, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextPage] = [CreateTestEvent(34, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToNextHeaderFooter] = [CreateTestEvent(34, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.moveToNextHeader] = [ - new CTestEvent(34, true, false, true, false), - new CTestEvent(34, false, false, true, false) + CreateTestEvent(34, true, false, true, false), + CreateTestEvent(34, false, false, true, false) ]; - testHotkeyEvents[testHotkeyActions.selectToStartNextPage] = [new CTestEvent(34, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToNextPage] = [new CTestEvent(34, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToStartNextPage] = [CreateTestEvent(34, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToNextPage] = [CreateTestEvent(34, false, true, false, false)]; +function CreateTestEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) +{ + const event = new AscCommon.CKeyboardEvent(); + event.KeyCode = nKeyCode; + event.CtrlKey = !!bIsCtrl; + event.ShiftKey = !!bIsShift; + event.AltKey = !!bIsAlt; + event.MacCmdKey = !!bIsMetaKey; + return event; +} - function CTestEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) - { - this.isDefaultPrevented = false; - this.isPropagationStopped = false; - this.KeyCode = nKeyCode; - this.CtrlKey = !!bIsCtrl; - this.ShiftKey = !!bIsShift; - this.AltKey = !!bIsAlt; - this.MacCmdKey = !!bIsMetaKey; - } - CTestEvent.prototype.preventDefault = function () - { - this.isDefaultPrevented = true; - }; - CTestEvent.prototype.stopPropagation = function () - { - this.isPropagationStopped = true; - }; AscTestShortcut.testHotkeyActions = testHotkeyActions; AscTestShortcut.testHotkeyEvents = testHotkeyEvents; diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 47be85d11d..97b315913f 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -142,31 +142,13 @@ function GoToHeader(page) { logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); - const event = new AscCommon.CMouseEventHandler(); - event.ClickCount = 1; - event.Button = 0; - event.Type = AscCommon.g_mouse_event_type_down; - - logicDocument.OnMouseDown(event, 0, 0, page); - - event.Type = AscCommon.g_mouse_event_type_up; - logicDocument.OnMouseUp(event, 0, 0, page); - logicDocument.MoveCursorLeft(); + logicDocument.Create_SectionHdrFtr( AscCommon.hdrftr_Header, page ); } function GoToFooter(page) { logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); - const event = new AscCommon.CMouseEventHandler(); - event.ClickCount = 1; - event.Button = 0; - event.Type = AscCommon.g_mouse_event_type_down; - - logicDocument.OnMouseDown(event, 0, pageHeight, page); - - event.Type = AscCommon.g_mouse_event_type_up; - logicDocument.OnMouseUp(event, 0, pageHeight, page); - logicDocument.MoveCursorLeft(); + logicDocument.Create_SectionHdrFtr( AscCommon.hdrftr_Footer, page ); } function RemoveHeader(page) @@ -267,10 +249,7 @@ drawing.Set_DrawingType(drawing_Anchor); drawing.Set_WrappingType(WRAPPING_TYPE_NONE); drawing.Set_Distance(0, 0, 0, 0); - const nearestPos = logicDocument.Get_NearestPos(0, x, y, true, drawing); - drawing.Set_XYForAdd(x, y, nearestPos, 0); - drawing.AddToDocument(nearestPos); - AscTest.Recalculate(); + logicDocument.AddToParagraph(drawing); return drawing; } @@ -333,10 +312,8 @@ drawing.Set_DrawingType(drawing_Anchor); drawing.Set_WrappingType(WRAPPING_TYPE_NONE); drawing.Set_Distance(0, 0, 0, 0); - const nearestPos = logicDocument.Get_NearestPos(0, chartSpace.x, chartSpace.y, true, drawing); - drawing.Set_XYForAdd(chartSpace.x, chartSpace.y, nearestPos, 0); - drawing.AddToDocument(nearestPos); - AscTest.Recalculate(); + logicDocument.RemoveSelection(); + logicDocument.AddToParagraph(drawing); return drawing; } @@ -451,7 +428,7 @@ ExecuteShortcut(c_oAscDocumentShortcutType.HorizontalEllipsis); assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026), 'Check add HorizontalEllipsis'); ExecuteHotkey(testHotkeyActions.addSJKSpace); - assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026, 0x0020), 'Check add HorizontalEllipsis'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x00A9, 0x20AC, 0x00AE, 0x2122, 0x2013, 0x2014, 0x002D, 0x2026, 0x0020), 'Check add SJK space'); }); QUnit.test('Check text property change', (assert) => @@ -563,38 +540,38 @@ assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn off right para"); ExecuteShortcut(c_oAscDocumentShortcutType.Indent); - assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5, "Check indent"); ExecuteShortcut(c_oAscDocumentShortcutType.UnIndent); - assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0, "Check indent"); const paragraph2 = CreateParagraphWithText('Hello'); logicDocument.SelectAll(); ExecuteHotkey(testHotkeyActions.testIndent); - assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 12.5, "Check multi indent"); ExecuteHotkey(testHotkeyActions.testUnIndent); - assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0, "Check multi unindent"); }); - QUnit.test('Check insert document elements', (assert) => + QUnit.test('Check insert note elements', (assert) => { let paragraph = ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.InsertFootnoteNow); const footnotes = logicDocument.GetFootnotesList(); - assert.equal(footnotes.length, 1, 'Check insert footnote shortcut'); + assert.equal(footnotes.length, 1, 'Check insert footnote'); paragraph.SetThisElementCurrent(); ExecuteShortcut(c_oAscDocumentShortcutType.InsertEndnoteNow); const endNotes = logicDocument.GetEndnotesList(); - assert.equal(endNotes.length, 1, 'Check insert endnote shortcut'); + assert.equal(endNotes.length, 1, 'Check insert endnote'); logicDocument.MoveCursorToStartPos(); }); - QUnit.test('Check shortcuts with sending event to interface', (assert) => + QUnit.test('Check sending event to interface', (assert) => { function checkSendingEvent(sSendEvent, oEvent, fCustomCheck, customExpectedValue) { @@ -631,69 +608,72 @@ checkSendingEvent('asc_onContextMenu', testHotkeyEvents[testHotkeyActions.showContextMenu][2]); }); - QUnit.test('Check insert equation shortcut', (assert) => + QUnit.test('Check insert equation', (assert) => { ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.InsertEquation); const math = logicDocument.GetCurrentMath(); - assert.true(!!math, 'Check insert equation shortcut'); + assert.true(!!math, 'Check insert equation'); }); - QUnit.test('Check insert elements shortcut', (assert) => + QUnit.test('Check insert page number', (assert) => { const paragraph = ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.InsertPageNumber); const firstRun = paragraph.Content[0]; - assert.strictEqual(firstRun.Content[0].Type, para_PageNum); + assert.strictEqual(firstRun.Content[0].Type, para_PageNum, "Check insert page number"); }); - QUnit.test('Check bullet list shortcut', (assert) => + QUnit.test('Check toggle bullet list', (assert) => { const paragraph = ClearDocumentAndAddParagraph(''); assert.false(paragraph.IsBulletedNumbering(), 'check apply bullet list'); ExecuteShortcut(c_oAscDocumentShortcutType.ApplyListBullet); - assert.true(paragraph.IsBulletedNumbering(), 'check apply bullet list'); + assert.true(paragraph.IsBulletedNumbering(), 'check disable bullet list'); }); - QUnit.test('Check copy/paste format shortcuts', (assert) => + QUnit.test('Check copy/paste format', (assert) => { let paragraph = ClearDocumentAndAddParagraph('Hello'); ApplyTextPrToDocument({Bold: true, Italic: true, Underline: true}); GetDirectTextPr(); ExecuteShortcut(c_oAscDocumentShortcutType.CopyFormat); let textPr = editor.getFormatPainterData().TextPr; - assert.true(textPr.Get_Bold()); - assert.true(textPr.Get_Italic()); - assert.true(textPr.Get_Underline()); + assert.true(textPr.Get_Bold(), 'Check copy bold format from paragraph'); + assert.true(textPr.Get_Italic(), 'Check copy italic format from paragraph'); + assert.true(textPr.Get_Underline(), 'Check copy underline format from paragraph'); paragraph = ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.PasteFormat); textPr = GetDirectTextPr(); - assert.true(textPr.Get_Bold()); - assert.true(textPr.Get_Italic()); - assert.true(textPr.Get_Underline()); + assert.true(textPr.Get_Bold(), 'Check paste bold format from paragraph'); + assert.true(textPr.Get_Italic(), 'Check paste italic format from paragraph'); + assert.true(textPr.Get_Underline(), 'Check paste underline format from paragraph'); }); - QUnit.test('Check history shortcuts', (assert) => + QUnit.test('Check undo/redo history', (assert) => { let paragraph = ClearDocumentAndAddParagraph('Hello'); paragraph.MoveCursorToEndPos(); logicDocument.AddTextWithPr(' World'); ExecuteShortcut(c_oAscDocumentShortcutType.EditUndo); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello', 'Check undo'); ExecuteShortcut(c_oAscDocumentShortcutType.EditRedo); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello World'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello World', 'Check redo'); }); - QUnit.test('Check show paramarks shortcut', (assert) => + QUnit.test('Check show/hide non printing symbols', (assert) => { ExecuteShortcut(c_oAscDocumentShortcutType.ShowAll); assert.true(editor.ShowParaMarks, 'Check show non printing characters shortcut'); + + ExecuteShortcut(c_oAscDocumentShortcutType.ShowAll); + assert.false(editor.ShowParaMarks, 'Check hide non printing characters shortcut'); }); - QUnit.test('Check save shortcut', (assert) => + QUnit.test('Check save', (assert) => { assert.timeout(100); const done = assert.async(); @@ -707,10 +687,10 @@ }; editor._saveCheck = () => true; editor.asc_isDocumentCanSave = () => true; - ExecuteShortcut(c_oAscDocumentShortcutType.Save); + ExecuteShortcut(c_oAscDocumentShortcutType.Save, 'Check save'); }); - QUnit.test('Check update fields shortcut', (assert) => + QUnit.test('Check update fields', (assert) => { const paragraph = ClearDocumentAndAddParagraph('Hello'); const paragraph2 = CreateParagraphWithText('Hello'); @@ -737,31 +717,31 @@ AscTest.MoveCursorRight() ExecuteShortcut(c_oAscDocumentShortcutType.UpdateFields); - assert.strictEqual(logicDocument.Content[0].Content.Content.length, 5, 'Check update fields shortcut'); + assert.strictEqual(logicDocument.Content[0].Content.Content.length, 5, 'Check update fields from 3 to 4 items'); }); - QUnit.test('Check remove hotkeys', (assert) => + QUnit.test('Check remove symbols', (assert) => { const paragraph = ClearDocumentAndAddParagraph('Hello Hello Hello Hello'); ExecuteHotkey(testHotkeyActions.removeBackSymbol); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hell'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hell', 'Check removing back symbol'); ExecuteHotkey(testHotkeyActions.removeBackWord); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello '); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing back word'); logicDocument.MoveCursorToStartPos(); ExecuteHotkey(testHotkeyActions.removeFrontSymbol); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello '); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello ', 'Check removing front symbol'); ExecuteHotkey(testHotkeyActions.removeFrontWord); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello '); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello ', 'Check removing front word'); }); - QUnit.test('Check move/select in text hotkeys', (assert) => + QUnit.test('Check move/select in text', (assert) => { - function CheckCursorPosition(nExpected) + function CheckCursorPosition(expected, description) { const position = logicDocument.GetContentPosition(); - assert.strictEqual(position[position.length - 1].Position, nExpected); + assert.strictEqual(position[position.length - 1].Position, expected, description); } const paragraph = ClearDocumentAndAddParagraph( @@ -783,132 +763,132 @@ TurnOffRecalculateCurPos(); ExecuteHotkey(testHotkeyActions.moveToEndLine); - CheckCursorPosition(18); + CheckCursorPosition(18, 'Check move to end line'); ExecuteHotkey(testHotkeyActions.moveToRightChar); - CheckCursorPosition(19); + CheckCursorPosition(19, 'Check move to right char'); ExecuteHotkey(testHotkeyActions.moveToLeftChar); - CheckCursorPosition(18); + CheckCursorPosition(18, 'Check move to left char'); ExecuteHotkey(testHotkeyActions.moveToLeftWord); - CheckCursorPosition(12); + CheckCursorPosition(12, 'Check move to left word'); ExecuteHotkey(testHotkeyActions.moveToRightWord); - CheckCursorPosition(18); + CheckCursorPosition(18, 'Check move to right word'); ExecuteHotkey(testHotkeyActions.moveToRightWord); - CheckCursorPosition(24); + CheckCursorPosition(24, 'Check move to right word'); ExecuteHotkey(testHotkeyActions.moveToStartLine); - CheckCursorPosition(18); + CheckCursorPosition(18, 'Check move to start line'); ExecuteHotkey(testHotkeyActions.moveDown); - CheckCursorPosition(36); + CheckCursorPosition(36, 'Check move down'); ExecuteHotkey(testHotkeyActions.moveUp); - CheckCursorPosition(18); + CheckCursorPosition(18, 'Check move up'); ExecuteHotkey(testHotkeyActions.moveToEndDocument); - CheckCursorPosition(161); + CheckCursorPosition(161, 'Check move to end document'); ExecuteHotkey(testHotkeyActions.moveToStartDocument); - CheckCursorPosition(0); + CheckCursorPosition(0, 'Check move to start document'); AscTest.MoveCursorRight(); ExecuteHotkey(testHotkeyActions.moveToNextPage); - CheckCursorPosition(91); + CheckCursorPosition(91, 'Check move to next page'); ExecuteHotkey(testHotkeyActions.moveToPreviousPage); - CheckCursorPosition(1); + CheckCursorPosition(1, 'Check move to previous page'); ExecuteHotkey(testHotkeyActions.moveToStartNextPage); - CheckCursorPosition(90); + CheckCursorPosition(90, 'Check move to start next page'); ExecuteHotkey(testHotkeyActions.moveToStartPreviousPage); - CheckCursorPosition(0); + CheckCursorPosition(0, 'Check move to start previous page'); - function CheckSelectedText(sExpectedText) + function CheckSelectedText(expectedText, description) { const selectedText = logicDocument.GetSelectedText(); - assert.strictEqual(selectedText, sExpectedText); + assert.strictEqual(selectedText, expectedText, description); } ExecuteHotkey(testHotkeyActions.selectToEndLine); - CheckSelectedText('Hello World Hello '); + CheckSelectedText('Hello World Hello ', 'Select to end line'); ExecuteHotkey(testHotkeyActions.selectRightChar); - CheckSelectedText('Hello World Hello W'); + CheckSelectedText('Hello World Hello W', 'Select to right char'); ExecuteHotkey(testHotkeyActions.selectLeftChar); - CheckSelectedText('Hello World Hello '); + CheckSelectedText('Hello World Hello ', 'Select to left char'); ExecuteHotkey(testHotkeyActions.selectLeftWord); - CheckSelectedText('Hello World '); + CheckSelectedText('Hello World ', 'Select to left word'); ExecuteHotkey(testHotkeyActions.selectRightWord); - CheckSelectedText('Hello World Hello '); + CheckSelectedText('Hello World Hello ', 'Select to right word'); ExecuteHotkey(testHotkeyActions.selectRightWord); - CheckSelectedText('Hello World Hello World '); + CheckSelectedText('Hello World Hello World ', 'Select to right word'); ExecuteHotkey(testHotkeyActions.selectRightWord); - CheckSelectedText('Hello World Hello World Hello '); + CheckSelectedText('Hello World Hello World Hello ', 'Select to right word'); ExecuteHotkey(testHotkeyActions.selectToStartLine); - CheckSelectedText('Hello World Hello '); + CheckSelectedText('Hello World Hello ', 'Select to start line'); ExecuteHotkey(testHotkeyActions.selectDown); - CheckSelectedText('Hello World Hello World Hello World '); + CheckSelectedText('Hello World Hello World Hello World ', 'Select down'); ExecuteHotkey(testHotkeyActions.selectUp); - CheckSelectedText('Hello World Hello '); + CheckSelectedText('Hello World Hello ', 'Select up'); ExecuteHotkey(testHotkeyActions.selectToEndDocument); - CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World'); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World', 'Select to end document'); ExecuteHotkey(testHotkeyActions.selectToStartDocument); - CheckSelectedText(''); + CheckSelectedText('', 'Select to start document'); logicDocument.MoveCursorToEndPos(); ExecuteHotkey(testHotkeyActions.selectLeftChar); - CheckSelectedText('d'); + CheckSelectedText('d', 'Select to left char'); ExecuteHotkey(testHotkeyActions.selectLeftWord); - CheckSelectedText('World'); + CheckSelectedText('World', 'Select to left word'); logicDocument.MoveCursorToStartPos(); AscTest.MoveCursorRight(); ExecuteHotkey(testHotkeyActions.selectToNextPage); - CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H'); + CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H', 'Select to next page'); AscTest.MoveCursorRight(); ExecuteHotkey(testHotkeyActions.selectToPreviousPage); - CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H'); + CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello H', 'Select to previous word'); AscTest.MoveCursorLeft(); ExecuteHotkey(testHotkeyActions.selectToStartNextPage); - CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello '); + CheckSelectedText('ello World Hello World Hello World Hello World Hello World Hello World Hello World Hello ', 'Select to start next page'); AscTest.MoveCursorRight(); ExecuteHotkey(testHotkeyActions.selectToStartPreviousPage); - CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello '); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello ', 'Select to start previous page'); }); - QUnit.test('Check move/select drawings', (assert) => + QUnit.test('Check actions with shapes', (assert) => { - TurnOnRecalculate(); const paragraph = ClearDocumentAndAddParagraph(''); - paragraph.SetThisElementCurrent(); + TurnOnRecalculate(); AscTest.Recalculate(); + const drawing1 = AddShape(0, 0, 100, 200); const dotsPerMM = logicDocument.DrawingDocument.GetDotsPerMM(); function CheckShapePosition(X, Y) { - assert.deepEqual([round(drawing1.X * dotsPerMM, 10), round(drawing1.Y * dotsPerMM, 10), drawing1.Extent.W, drawing1.Extent.H], [X, Y, 200, 100]); + assert.deepEqual([round(drawing1.X * dotsPerMM, 10), round(drawing1.Y * dotsPerMM, 10), drawing1.Extent.W, drawing1.Extent.H], [X, Y, 200, 100], 'Check shape position after movement'); } SelectDrawings([drawing1]); @@ -943,10 +923,11 @@ const length = Math.max(arrOfDrawings.length, GetDrawingObjects().selectedObjects.length); for (let i = 0; i < length; i++) { - assert.true(GetDrawingObjects().selectedObjects[i] === arrOfDrawings[i].GraphicObj); + assert.true(GetDrawingObjects().selectedObjects[i] === arrOfDrawings[i].GraphicObj, 'Check selection movement between objects'); } } + logicDocument.RemoveSelection(); const drawing2 = AddShape(0, 0, 10, 10); const drawing3 = AddShape(0, 0, 10, 10); SelectDrawings([drawing3]); @@ -969,94 +950,86 @@ ExecuteHotkey(testHotkeyActions.selectPreviousObject); CheckSelectedObjects([drawing3]); TurnOffRecalculate(); - }); - - QUnit.test('Check actions with selected shape', (assert) => - { - TurnOnRecalculate(); - const paragraph = CreateParagraphWithText(''); - AscTest.Recalculate(); - let paraDrawing = AddShape(0, 0, 10, 10); - SelectDrawings([paraDrawing]); ExecuteHotkey(testHotkeyActions.createTextBoxContent); - assert.true(!!paraDrawing.GraphicObj.textBoxContent); + assert.true(!!drawing3.GraphicObj.textBoxContent, 'Check create textBoxContent after enter'); - paraDrawing = AddShape(0, 0, 10, 10); - paraDrawing.GraphicObj.setWordShape(false); - SelectDrawings([paraDrawing]); + drawing2.GraphicObj.setWordShape(false); + SelectDrawings([drawing2]); ExecuteHotkey(testHotkeyActions.createTextBody); - assert.true(!!paraDrawing.GraphicObj.txBody); + assert.true(!!drawing2.GraphicObj.txBody, 'Check create textBody after enter'); - SelectDrawings([paraDrawing]); + SelectDrawings([drawing2]); ExecuteHotkey(testHotkeyActions.moveCursorToStartPositionShapeEnter); - assert.true(paraDrawing.GraphicObj.getDocContent().IsCursorAtBegin()); + assert.true(drawing2.GraphicObj.getDocContent().IsCursorAtBegin(), 'Check movement to start position in empty content'); AscTest.EnterText('Hello'); - SelectDrawings([paraDrawing]); + SelectDrawings([drawing2]); ExecuteHotkey(testHotkeyActions.selectAllShapeEnter); - assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); - TurnOffRecalculate(); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello', 'Check select non empty content'); + + SelectDrawings([drawing1, drawing2]); + + const group = GetDrawingObjects().groupSelectedObjects(); + group.GraphicObj.selectObject(drawing1.GraphicObj, 0); + GetDrawingObjects().selection.groupSelection = group.GraphicObj; + + ExecuteHotkey(testHotkeyActions.resetShapeSelection); + assert.strictEqual(GetDrawingObjects().selectedObjects.length, 0, 'Check reset shape selection'); + + SelectDrawings([group]); + ExecuteHotkey(testHotkeyActions.removeShape, 0); + assert.strictEqual(paragraph.GetRunByElement(group), null, 'Check remove shape'); + + SelectDrawings([drawing3]); + + ExecuteHotkey(testHotkeyActions.removeShape, 1); + assert.strictEqual(paragraph.GetRunByElement(drawing3), null, 'Check remove shape'); + }); - QUnit.test('Check move in headers/footers', (assert) => + QUnit.test('Check actions with headers/footers', (assert) => { TurnOnRecalculate(); TurnOnRecalculateCurPos(); const paragraph = ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); AscTest.Recalculate(); - - logicDocument.GoToPage(2); GoToFooter(2); GoToHeader(2); - TurnOffRecalculateCurPos(); - TurnOffRecalculate(); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeaderFooter); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer, 'Check move to previous footer'); ExecuteHotkey(testHotkeyActions.moveToPreviousHeaderFooter); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header, 'Check move to previous header'); ExecuteHotkey(testHotkeyActions.moveToNextHeaderFooter); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer, 'Check move to next footer'); ExecuteHotkey(testHotkeyActions.moveToNextHeaderFooter); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header, 'Check move to next header'); - ExecuteHotkey(testHotkeyActions.moveToPreviousHeader); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); - ExecuteHotkey(testHotkeyActions.moveToPreviousHeader); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[0].Header); - - ExecuteHotkey(testHotkeyActions.moveToNextHeader); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header); - ExecuteHotkey(testHotkeyActions.moveToNextHeader); - assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header); - - RemoveHeader(2); - RemoveFooter(2); - }); - - QUnit.test('Check reset selection shortcut', (assert) => - { - TurnOnRecalculate(); - const paragraph = ClearDocumentAndAddParagraph(""); - AscTest.Recalculate(); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeader, 0); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header, 'Check move to previous header'); + ExecuteHotkey(testHotkeyActions.moveToPreviousHeader, 1); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[0].Header, 'Check move to previous header'); - const drawing1 = AddShape(0, 0, 10, 10); - const drawing2 = AddShape(0, 0, 10, 10); + ExecuteHotkey(testHotkeyActions.moveToNextHeader, 0); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header, 'Check move to next header'); + ExecuteHotkey(testHotkeyActions.moveToNextHeader, 1); + assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header, 'Check move to next header'); - SelectDrawings([drawing1, drawing2]); + ExecuteHotkey(testHotkeyActions.endEditing); + assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Check end editing footer"); - const group = GetDrawingObjects().groupSelectedObjects(); - group.GraphicObj.selectObject(drawing1.GraphicObj, 0); - GetDrawingObjects().selection.groupSelection = group.GraphicObj; + GoToFooter(0); + ExecuteHotkey(testHotkeyActions.endEditing); + assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Check end editing footer"); - ExecuteHotkey(testHotkeyActions.resetShapeSelection); - assert.strictEqual(GetDrawingObjects().selectedObjects.length, 0); + TurnOffRecalculateCurPos(); TurnOffRecalculate(); }); @@ -1067,15 +1040,15 @@ AscTest.Recalculate() editor.StartAddShape('rect'); ExecuteHotkey(testHotkeyActions.resetStartAddShape); - assert.strictEqual(editor.isStartAddShape, false, "Test reset add shape"); + assert.strictEqual(editor.isStartAddShape, false, "Check reset add shape"); TurnOffRecalculate(); editor.SetPaintFormat(AscCommon.c_oAscFormatPainterState.kOn); ExecuteHotkey(testHotkeyActions.resetFormattingByExample); - assert.strictEqual(editor.isFormatPainterOn(), false, "Test reset formatting by example"); + assert.strictEqual(editor.isFormatPainterOn(), false, "Check reset formatting by example"); editor.SetMarkerFormat(true, true, 0, 0, 0); ExecuteHotkey(testHotkeyActions.resetMarkerFormat); - assert.strictEqual(editor.isMarkerFormat, false, "Test reset marker"); + assert.strictEqual(editor.isMarkerFormat, false, "Check reset marker"); }); QUnit.test('Check disable shortcuts', (assert) => @@ -1084,63 +1057,45 @@ assert.strictEqual(ExecuteHotkey(testHotkeyActions.disableScrollLock) & keydownresult_PreventAll, keydownresult_PreventAll); }); - QUnit.test('Check boxes shortcuts', (assert) => + QUnit.test('Check filling forms', (assert) => { let paragraph = ClearDocumentAndAddParagraph(''); const checkBox = AddCheckBox(); AscTest.SetFillingFormMode(true); ExecuteHotkey(testHotkeyActions.toggleCheckBox); - assert.true(checkBox.IsCheckBoxChecked()); + assert.true(checkBox.IsCheckBoxChecked(), 'Check turn on checkbox'); ExecuteHotkey(testHotkeyActions.toggleCheckBox); - assert.false(checkBox.IsCheckBoxChecked()); + assert.false(checkBox.IsCheckBoxChecked(), 'Check turn off checkbox'); AscTest.SetEditingMode(); ClearDocumentAndAddParagraph(''); const comboBox = AddComboBox(['Hello', 'World', 'yo']); AscTest.SetFillingFormMode(true); ExecuteHotkey(testHotkeyActions.nextOptionComboBox); - assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello', 'Check select next option in combobox'); ExecuteHotkey(testHotkeyActions.nextOptionComboBox); - assert.strictEqual(logicDocument.GetSelectedText(), 'World'); + assert.strictEqual(logicDocument.GetSelectedText(), 'World', 'Check select next option in combobox'); ExecuteHotkey(testHotkeyActions.nextOptionComboBox); - assert.strictEqual(logicDocument.GetSelectedText(), 'yo'); + assert.strictEqual(logicDocument.GetSelectedText(), 'yo', 'Check select next option in combobox'); ExecuteHotkey(testHotkeyActions.previousOptionComboBox); - assert.strictEqual(logicDocument.GetSelectedText(), 'World'); + assert.strictEqual(logicDocument.GetSelectedText(), 'World', 'Check select previous option in combobox'); ExecuteHotkey(testHotkeyActions.previousOptionComboBox); - assert.strictEqual(logicDocument.GetSelectedText(), 'Hello'); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello', 'Check select previous option in combobox'); ExecuteHotkey(testHotkeyActions.previousOptionComboBox); - assert.strictEqual(logicDocument.GetSelectedText(), 'yo'); + assert.strictEqual(logicDocument.GetSelectedText(), 'yo', 'Check select previous option in combobox'); AscTest.SetEditingMode(); }); - QUnit.test('Check remove objects shortcut', (assert) => - { - console.log(!!(editor.restrictions & Asc.c_oAscRestrictionType.OnlyForms)) - TurnOnRecalculate(); - const paragraph = ClearDocumentAndAddParagraph(''); - AscTest.Recalculate(); - let paraDrawing = AddShape(0, 0, 10, 10); - SelectDrawings([paraDrawing]); - ExecuteHotkey(testHotkeyActions.removeShape, 0); - assert.strictEqual(paragraph.GetRunByElement(paraDrawing), null, 'Test remove shape'); - - paraDrawing = AddShape(0, 0, 10, 10); - SelectDrawings([paraDrawing]); - ExecuteHotkey(testHotkeyActions.removeShape, 1); - assert.strictEqual(paragraph.GetRunByElement(paraDrawing), null, 'Test remove shape'); - TurnOffRecalculate(); - }); - - QUnit.test('Check move on forms', (assert) => + QUnit.test('Check movement selecting forms', (assert) => { const paragraph = ClearDocumentAndAddParagraph(''); let checkBox1 = AddCheckBox(); @@ -1152,50 +1107,51 @@ ExecuteHotkey(testHotkeyActions.moveToNextForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox1, 'Test move to next form'); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox1, 'Check move to next form'); ExecuteHotkey(testHotkeyActions.moveToNextForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox2, 'Test move to next form'); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox2, 'Check move to next form'); ExecuteHotkey(testHotkeyActions.moveToNextForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox3, 'Test move to next form'); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox3, 'Check move to next form'); ExecuteHotkey(testHotkeyActions.moveToPreviousForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox2, 'Test move to previous form'); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox2, 'Check move to previous form'); ExecuteHotkey(testHotkeyActions.moveToPreviousForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox1, 'Test move to previous form'); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox1, 'Check move to previous form'); ExecuteHotkey(testHotkeyActions.moveToPreviousForm); - assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox3, 'Test move to previous form'); + assert.true(logicDocument.GetSelectedElementsInfo().GetInlineLevelSdt() === checkBox3, 'Check move to previous form'); AscTest.SetEditingMode(); }); - QUnit.test('Check move in table shortcuts', (assert) => + QUnit.test('Check movement in table', (assert) => { ClearDocumentAndAddParagraph(); const table = AddTable(3, 4); table.Document_SetThisElementCurrent(); table.MoveCursorToStartPos(); ExecuteHotkey(testHotkeyActions.moveToNextCell); - assert.strictEqual(table.CurCell.Index, 1); + assert.strictEqual(table.CurCell.Index, 1, 'Check move to next cell'); ExecuteHotkey(testHotkeyActions.moveToNextCell); - assert.strictEqual(table.CurCell.Index, 2); + assert.strictEqual(table.CurCell.Index, 2, 'Check move to next cell'); ExecuteHotkey(testHotkeyActions.moveToNextCell); - assert.strictEqual(table.CurCell.Index, 3); + assert.strictEqual(table.CurCell.Index, 3, 'Check move to next cell'); ExecuteHotkey(testHotkeyActions.moveToPreviousCell); - assert.strictEqual(table.CurCell.Index, 2); + assert.strictEqual(table.CurCell.Index, 2, 'Check move to previous cell'); ExecuteHotkey(testHotkeyActions.moveToPreviousCell); - assert.strictEqual(table.CurCell.Index, 1); + assert.strictEqual(table.CurCell.Index, 1, 'Check move to previous cell'); ExecuteHotkey(testHotkeyActions.moveToPreviousCell); - assert.strictEqual(table.CurCell.Index, 0); + assert.strictEqual(table.CurCell.Index, 0, 'Check move to previous cell'); }); - QUnit.test('Check Select all in chart title', (assert) => + QUnit.test('Check select all in chart title', (assert) => { TurnOnRecalculate(); const paragraph = ClearDocumentAndAddParagraph(''); AscTest.Recalculate(); + TurnOffRecalculate(); const paraDrawing = AddChart(); const chart = paraDrawing.GraphicObj; @@ -1206,15 +1162,14 @@ chart.selectTitle(titles[0], 0); ExecuteHotkey(testHotkeyActions.selectAllInChartTitle); - assert.strictEqual(logicDocument.GetSelectedText(), 'Diagram Title', 'Check select all title'); - TurnOffRecalculate(); + assert.strictEqual(logicDocument.GetSelectedText(), 'Diagram Title', 'Check select all in title'); }); - QUnit.test('add new paragraph content', (assert) => + QUnit.test('Check add new paragraph in content', (assert) => { const paragraph = ClearDocumentAndAddParagraph('Hello text'); ExecuteHotkey(testHotkeyActions.addNewParagraphContent); - assert.strictEqual(logicDocument.Content.length, 2); + assert.strictEqual(logicDocument.Content.length, 2, 'Check add new paragraph'); }); QUnit.test('Check add new paragraph math', (assert) => @@ -1224,7 +1179,7 @@ AscTest.EnterText('abcd'); AscTest.MoveCursorLeft(); ExecuteHotkey(testHotkeyActions.addNewParagraphMath) - assert.strictEqual(logicDocument.Content.length, 2, 'Test add new paragraph with math'); + assert.strictEqual(logicDocument.Content.length, 2, 'Check add new paragraph'); }); QUnit.test("Test add new line to math", (oAssert) => @@ -1241,55 +1196,57 @@ const fraction = paraMath.Root.GetFirstElement(); const numerator = fraction.getNumerator(); const eqArray = numerator.GetFirstElement(); - oAssert.strictEqual(eqArray.getRowsCount(), 2, 'Check add new line math'); + oAssert.strictEqual(eqArray.getRowsCount(), 2, 'Check add new line'); }); - QUnit.test("Test remove form", (assert) => + QUnit.test("Check remove form", (assert) => { const paragraph = ClearDocumentAndAddParagraph(''); - const form = AddComboBox(['hdfh']); - ExecuteHotkey(testHotkeyActions.removeForm); - assert.strictEqual(paragraph.GetPosByElement(form), null, 'Check add new line math'); + let form = AddComboBox(['hdfh']); + ExecuteHotkey(testHotkeyActions.removeForm, 0); + assert.strictEqual(paragraph.GetPosByElement(form), null, 'Check remove form'); + + AddComboBox(['hdfh']); + ExecuteHotkey(testHotkeyActions.removeForm, 1); + assert.strictEqual(paragraph.GetPosByElement(form), null, 'Check remove form'); AscTest.SetEditingMode(); }); - QUnit.test("Add tab to paragraph", (assert) => + QUnit.test("Check add tab to paragraph", (assert) => { const paragraph = ClearDocumentAndAddParagraph(''); ExecuteHotkey(testHotkeyActions.addTabToParagraph); - assert.true(paragraph.GetPrevRunElement().IsTab()); + assert.true(paragraph.GetPrevRunElement().IsTab(), "Check add tab to paragraph"); }); - QUnit.test("Test add break line to inlinelvlsdt", (assert) => + QUnit.test("Check add break line to inlinelvlsdt", (assert) => { TurnOnRecalculate(); const paragraph = ClearDocumentAndAddParagraph(''); const complexForm = AddComplexForm(); ExecuteHotkey(testHotkeyActions.addBreakLineInlineLvlSdt); - assert.strictEqual(complexForm.Lines[0], 2); + assert.strictEqual(complexForm.Lines[0], 2, "Check add break line"); TurnOffRecalculate(); }); - QUnit.test("Test visit hyperlink", (assert) => + QUnit.test("Check visit hyperlink", (assert) => { TurnOnRecalculate() const paragraph = ClearDocumentAndAddParagraph(''); - + AscTest.Recalculate() + TurnOffRecalculate(); logicDocument.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Page)) logicDocument.AddHyperlink(new Asc.CHyperlinkProperty({Anchor: '_top', Text: "Beginning of document"})); AscTest.MoveCursorLeft(); AscTest.MoveCursorLeft(); ExecuteHotkey(testHotkeyActions.visitHyperlink); - AscTest.Recalculate() - assert.strictEqual(logicDocument.GetCurrentParagraph(), logicDocument.Content[0]); - assert.strictEqual(logicDocument.Get_CurPage(), 0); - TurnOffRecalculate(); + assert.true(logicDocument.GetCurrentParagraph() === logicDocument.Content[0], "Check visit hyperlink"); + assert.strictEqual(logicDocument.Get_CurPage(), 0, "Check visit hyperlink"); }); - QUnit.test("Test handle tab in math", (oAssert) => + QUnit.test("Check handle tab in math", (assert) => { - const paragraph = ClearDocumentAndAddParagraph(''); logicDocument.AddParaMath(); AscTest.EnterText('abcd+abcd+abcd'); @@ -1307,43 +1264,42 @@ AscTest.MoveCursorRight(); const contentPosition = logicDocument.GetContentPosition(); const currentRun = contentPosition[contentPosition.length - 1].Class; - oAssert.strictEqual(currentRun.MathPrp.Get_AlnAt(), 1, 'Test move to next form'); + assert.strictEqual(currentRun.MathPrp.Get_AlnAt(), 1, "Check handle tab in math"); }); - QUnit.test("Test end editing", (assert) => + QUnit.test("Check end editing form", (assert) => { - TurnOnRecalculate(); + logicDocument.End_SilentMode(); const paragraph = ClearDocumentAndAddParagraph(''); const checkBox = AddCheckBox(); AscTest.SetFillingFormMode(true); checkBox.MoveCursorToContentControl(true); ExecuteHotkey(testHotkeyActions.endEditing); const selectedInfo = logicDocument.GetSelectedElementsInfo(); - assert.strictEqual(!!selectedInfo.GetInlineLevelSdt(), false, "Test end editing form"); + assert.strictEqual(!!selectedInfo.GetInlineLevelSdt(), false, "Check end editing form"); AscTest.SetEditingMode(); - - GoToHeader(0); - ExecuteHotkey(testHotkeyActions.endEditing); - assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - RemoveHeader(0); - - GoToFooter(0); - ExecuteHotkey(testHotkeyActions.endEditing); - assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Test end editing footer"); - RemoveFooter(0); - TurnOffRecalculate(); + logicDocument.Start_SilentMode(); }); - QUnit.test("Test unicode to char hotkeys", (assert) => + QUnit.test("Check replace unicode to char hotkeys", (assert) => { const paragraph = ClearDocumentAndAddParagraph('2601'); AscTest.MoveCursorLeft(true, true); - ExecuteHotkey(testHotkeyActions.unicodeToChar); - assert.strictEqual(logicDocument.GetSelectedText(), '☁', 'Test replace unicode code to symbol'); + ExecuteHotkey(testHotkeyActions.unicodeToChar, 0); + assert.strictEqual(logicDocument.GetSelectedText(), '☁', 'Check replace unicode code to symbol'); + AscTest.MoveCursorRight(); + AscTest.EnterText(' 261d'); + + AscTest.MoveCursorLeft(true, true); + + AscCommon.AscBrowser.isMacOs = true; + ExecuteHotkey(testHotkeyActions.unicodeToChar, 1); + assert.strictEqual(logicDocument.GetSelectedText(), '☝', 'Check replace unicode code to symbol'); + AscCommon.AscBrowser.isMacOs = false; }); - QUnit.test("Test reset drag'n'drop", (oAssert) => + QUnit.test("Check reset drag'n'drop", (oAssert) => { TurnOnRecalculate(); const paragraph = ClearDocumentAndAddParagraph('Hello Hello'); @@ -1362,7 +1318,7 @@ logicDocument.OnMouseMove(e, 45, 10, 0); ExecuteHotkey(testHotkeyActions.resetDragNDrop); - oAssert.true(!drawingDocument.IsTrackText(), "Test reset drag'n'drop"); + oAssert.true(!drawingDocument.IsTrackText(), "Check reset drag'n'drop"); e.Type = AscCommon.g_mouse_event_type_up; logicDocument.OnMouseUp(e, 45, 10, 0); From da70ca5112f69e1ede438359841f1545ef4f52ee Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Fri, 11 Aug 2023 14:12:45 +0300 Subject: [PATCH 07/23] Fix tests for document editor --- tests/word/shortcuts/shortcuts.js | 51 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 97b315913f..9dd789b7e6 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -79,32 +79,9 @@ drawingDocument.SetCursorType = function () {}; drawingDocument.OnRePaintAttack = function() {}; - drawingDocument.IsFreezePage = function() {}; - drawingDocument.Set_RulerState_HdrFtr = function() {}; - drawingDocument.IsTrackText = function() {}; drawingDocument.ConvertCoordsToCursorWR = function(X, Y) {return {X: X, Y: Y}}; drawingDocument.OnUpdateOverlay = function() {}; - editor.getShortcut = function (e) - { - if (typeof e === 'number') - { - return e; - } - }; - editor.FontSizeIn = function () - { - logicDocument.IncreaseDecreaseFontSize(true); - }; - editor.FontSizeOut = function () - { - logicDocument.IncreaseDecreaseFontSize(false); - }; - editor.StartAddShape = function () - { - this.isStartAddShape = true; - }; - editor.retrieveFormatPainterData = Asc.asc_docs_api.prototype.retrieveFormatPainterData.bind(editor); editor.get_ShowParaMarks = Asc.asc_docs_api.prototype.get_ShowParaMarks.bind(editor); editor.put_ShowParaMarks = Asc.asc_docs_api.prototype.put_ShowParaMarks.bind(editor); @@ -122,7 +99,6 @@ editor.sync_HideComment = Asc.asc_docs_api.prototype.sync_HideComment.bind(editor); editor.sync_ContextMenuCallback = Asc.asc_docs_api.prototype.sync_ContextMenuCallback.bind(editor); editor.asc_AddMath = Asc.asc_docs_api.prototype.asc_AddMath2.bind(editor); - editor._onEndLoadSdk = Asc.asc_docs_api.prototype._onEndLoadSdk.bind(editor); editor.sync_StartAddShapeCallback = Asc.asc_docs_api.prototype.sync_StartAddShapeCallback.bind(editor); editor.SetPaintFormat = Asc.asc_docs_api.prototype.SetPaintFormat.bind(editor); editor.SetMarkerFormat = Asc.asc_docs_api.prototype.SetMarkerFormat.bind(editor); @@ -131,6 +107,26 @@ editor.sync_EndAddShape = function () {}; editor.isDocumentEditor = true; + editor.getShortcut = function (e) + { + if (typeof e === 'number') + { + return e; + } + }; + editor.FontSizeIn = function () + { + logicDocument.IncreaseDecreaseFontSize(true); + }; + editor.FontSizeOut = function () + { + logicDocument.IncreaseDecreaseFontSize(false); + }; + editor.StartAddShape = function () + { + this.isStartAddShape = true; + }; + AscCommon.CDocsCoApi.prototype.askSaveChanges = function (callback) { window.setTimeout(function () @@ -628,9 +624,9 @@ QUnit.test('Check toggle bullet list', (assert) => { const paragraph = ClearDocumentAndAddParagraph(''); - assert.false(paragraph.IsBulletedNumbering(), 'check apply bullet list'); + assert.false(paragraph.IsBulletedNumbering(), 'check disable bullet list'); ExecuteShortcut(c_oAscDocumentShortcutType.ApplyListBullet); - assert.true(paragraph.IsBulletedNumbering(), 'check disable bullet list'); + assert.true(paragraph.IsBulletedNumbering(), 'check apply bullet list'); }); QUnit.test('Check copy/paste format', (assert) => @@ -962,7 +958,8 @@ SelectDrawings([drawing2]); ExecuteHotkey(testHotkeyActions.moveCursorToStartPositionShapeEnter); - assert.true(drawing2.GraphicObj.getDocContent().IsCursorAtBegin(), 'Check movement to start position in empty content'); + const para = drawing2.GraphicObj.getDocContent().Content[0]; + assert.true(para.IsThisElementCurrent() && para.IsCursorAtBegin(), 'Check movement to start position in empty content'); AscTest.EnterText('Hello'); SelectDrawings([drawing2]); From a9e89ff31a3e1d03434fe6b9afcbbaba7087ab08 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Fri, 15 Sep 2023 14:41:27 +0300 Subject: [PATCH 08/23] Refactor checkSendingEvent function --- tests/word/shortcuts/shortcuts.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 9dd789b7e6..a8b3e4ed6d 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -569,24 +569,17 @@ QUnit.test('Check sending event to interface', (assert) => { - function checkSendingEvent(sSendEvent, oEvent, fCustomCheck, customExpectedValue) + function checkSendingEvent(sSendEvent, oEvent) { let isCheck = false; - const fCheck = function (...args) + const fCheck = function () { - if (fCustomCheck) - { - isCheck = fCustomCheck(...args); - } - else - { isCheck = true; - } } editor.asc_registerCallback(sSendEvent, fCheck); ExecuteShortcut(oEvent); - assert.strictEqual(isCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); + assert.strictEqual(isCheck, true, 'Check catch ' + sSendEvent + ' event'); editor.asc_unregisterCallback(sSendEvent, fCheck); } From 6ad29f861ed1e3762260d65e15345735b17d03c7 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 21 Sep 2023 15:11:03 +0300 Subject: [PATCH 09/23] [pe]Refactor shortcut tests --- tests/slide/common/common.js | 19 - .../{controls.js => demonstrationManager.js} | 57 +- tests/slide/common/editor.js | 95 +- tests/slide/common/presentation.js | 55 +- tests/slide/common/thumbnails.js | 53 + tests/slide/shortcuts/events.js | 488 ++-- tests/slide/shortcuts/helpers.js | 502 ---- tests/slide/shortcuts/shortcuts.html | 23 +- tests/slide/shortcuts/shortcuts.js | 2400 +++++++---------- 9 files changed, 1404 insertions(+), 2288 deletions(-) rename tests/slide/common/{controls.js => demonstrationManager.js} (56%) create mode 100644 tests/slide/common/thumbnails.js delete mode 100644 tests/slide/shortcuts/helpers.js diff --git a/tests/slide/common/common.js b/tests/slide/common/common.js index 44ddbdf615..666d4e27d2 100644 --- a/tests/slide/common/common.js +++ b/tests/slide/common/common.js @@ -65,25 +65,6 @@ const AscTest = window.AscTest || {}; AscCommon.g_oIdCounter.m_bLoad = false; AscCommon.g_oIdCounter.m_bRead = false; - - - AscTest.createShape = function (oParent) { - AscCommon.History.Create_NewPoint(); - const nOldSpTreeLength = oParent.cSld.spTree.length - var oShapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, AscFormat.GetDefaultTheme(), null, null, null, 0); - oShapeTrack.track({}, 100, 100); - var oShape = oShapeTrack.getShape(false, AscTest.DrawingDocument, null); - oShape.setBDeleted(false); - oShape.setParent(oParent); - //oShape.createTextBody(); - oShape.addToDrawingObjects(); - if (oParent.cSld.spTree.length !== nOldSpTreeLength + 1) { - throw new Error("Shape didn't added"); - } - return oShape; - }; - - AscTest.Letter = Letter; })(window); diff --git a/tests/slide/common/controls.js b/tests/slide/common/demonstrationManager.js similarity index 56% rename from tests/slide/common/controls.js rename to tests/slide/common/demonstrationManager.js index 14017d2f7b..f8485dfcdc 100644 --- a/tests/slide/common/controls.js +++ b/tests/slide/common/demonstrationManager.js @@ -30,39 +30,30 @@ * */ -"use strict"; -function IsCanvas(sName) { - return true; -} -(function(window, undefined){ +'use strict'; - function CreateControlContainer(name) - { - var ctrl = new AscCommon.CControlContainer(); - ctrl.Name = name; - const oHtmlElement = document.createElement(IsCanvas(name) ? 'canvas' : 'div'); - oHtmlElement.style.display = 'none'; - oHtmlElement.style.width = '20px'; - oHtmlElement.style.height = '20px'; - document.body.appendChild(oHtmlElement); - ctrl.HtmlElement = oHtmlElement; - return ctrl; - } - function CreateControl(name) - { - var ctrl = new AscCommon.CControl(); - ctrl.Name = name; - const oHtmlElement = document.createElement(IsCanvas(name) ? 'canvas' : 'div'); - oHtmlElement.style.display = 'none'; - oHtmlElement.style.width = '20px'; - oHtmlElement.style.height = '20px'; - document.body.appendChild(oHtmlElement); - ctrl.HtmlElement = oHtmlElement; - return ctrl; - } +(function (window) +{ + editor.WordControl.DemonstrationManager = new CDemonstrationManager(editor.WordControl); + editor.WordControl.DemonstrationManager.HtmlPage = editor.WordControl; + editor.WordControl.DemonstrationManager.DemonstrationDiv = document.createElement('div'); + editor.WordControl.DemonstrationManager.Canvas = document.createElement('canvas'); + editor.WordControl.DemonstrationManager.DemonstrationDiv.appendChild(editor.WordControl.DemonstrationManager.Canvas); + editor.WordControl.DemonstrationManager.Start = function (main_div_id, start_slide_num, is_play_mode, is_no_fullscreen) + { + this.StartSlideNum = start_slide_num; + if (-1 === start_slide_num) + start_slide_num = 0; - //--------------------------------------------------------export---------------------------------------------------- - window['AscCommon'] = window['AscCommon'] || {}; - window['AscCommon'].CreateControlContainer = CreateControlContainer; - window['AscCommon'].CreateControl = CreateControl; + this.SlidesCount = this.HtmlPage.m_oDrawingDocument.SlidesCount; + this.Mode = true; + this.SlideNum = start_slide_num; + } + + editor.WordControl.DemonstrationManager.End = function (isNoUseFullScreen) + { + this.Mode = false; + this.HtmlPage.m_oApi.sync_endDemonstration(); + this.HtmlPage.GoToPage(this.SlideNum); + }; })(window); diff --git a/tests/slide/common/editor.js b/tests/slide/common/editor.js index 2f6b691a78..3bd3099fa6 100644 --- a/tests/slide/common/editor.js +++ b/tests/slide/common/editor.js @@ -34,22 +34,89 @@ (function (window) { - Asc.asc_docs_api.prototype._loadModules = function () {}; - AscCommon.baseEditorsApi.prototype._onEndLoadSdk = function() { - this.ImageLoader = AscCommon.g_image_loader; - this.chartPreviewManager = new AscCommon.ChartPreviewManager(); - this.textArtPreviewManager = new AscCommon.TextArtPreviewManager(); - - AscFormat.initStyleManager(); + const drawingDocument = { + CanvasHit : null, + CanvasHitContext : null, + GoToPage: function (slideNumber) + { + AscTest.DrawingDocument.m_oLogicDocument.Set_CurPage(slideNumber); + editor.WordControl.m_oDrawingDocument.SlideCurrent = slideNumber; + this.Thumbnails && this.Thumbnails.SelectPage(slideNumber); + }, + ConvertCoordsToCursorWR: function () {return {X:0,Y:0}}, + Notes_GetWidth: function () {return 100;}, + Notes_OnRecalculate: function () {return 100;}, + scrollToY: function () {}, + OnStartRecalculate: function () {}, + OnRecalculatePage: function () {}, + OnEndRecalculate: function () {}, + UpdateTargetTransform : function(){}, + SetTargetColor : function(){}, + ClearCachePages : function(){}, + FirePaint : function(){}, + SetTargetSize : function(){}, + UpdateTarget : function(){}, + Set_RulerState_Paragraph : function(){}, + SelectEnabled : function(){}, + SelectShow : function(){}, + TargetStart : function(){}, + SetCursorType : function(){}, + TargetShow : function(){}, + TargetEnd : function(){}, + Update_MathTrack : function(){}, + CheckTableStyles : function(){}, + OnUpdateOverlay : function(){}, + AddPageSelection : function(){}, + IsTrackText : function(){}, + Set_RulerState_Table : function(){}, + SelectClear : function() {}, + GetDotsPerMM : function(value) {return 72;}, + GetMMPerDot : function(value){return value / this.GetDotsPerMM(1);}, + m_oNotesApi: {}, + clear: function () {} }; - const editor = new Asc.asc_docs_api({'id-view': 'editor_sdk'}); - editor.ShowThumbnails(true); - AscCommon.loadSdk = function () - { - editor._onEndLoadSdk(); - } - editor.WordControl.DemonstrationManager.OnPaintSlide = function () {}; + drawingDocument.CanvasHit = document.createElement('canvas'); + drawingDocument.CanvasHitContext = drawingDocument.CanvasHit.getContext('2d'); + + window['asc_docs_api'] = AscCommon.baseEditorsApi; + + const editor = new AscCommon.baseEditorsApi({}); + editor.WordControl = drawingDocument; + editor.WordControl.m_oDrawingDocument = drawingDocument; + editor.WordControl.m_oDrawingDocument.m_oWordControl = drawingDocument; + editor.WordControl.m_oApi = editor; + + editor.textArtPreviewManager = drawingDocument; + + editor.asc_hideComments = function () {}; + editor.isSlideShow = function () {return false}; + editor.sync_HideComment = function () {}; + editor.sync_CanUndoCallback = function () {}; + editor.sync_CanRedoCallback = function () {}; + editor.CheckChangedDocument = function () {}; + editor.sync_BeginCatchSelectedElements = function(){}; + editor.ClearPropObjCallback = function(){}; + editor.sync_slidePropCallback = function(){}; + editor.sync_PrLineSpacingCallBack = function(){}; + editor.sync_EndCatchSelectedElements = function(){}; + editor.sync_CanAddHyperlinkCallback = function(){}; + editor.sync_shapePropCallback = function(){}; + editor.sync_VerticalTextAlign = function(){}; + editor.sync_Vert = function(){}; + editor.sync_animPropCallback = function(){}; + editor.sync_ImgPropCallback = function(){}; + editor.sync_TblPropCallback = function(){}; + editor.sync_EndCatchSelectedElements = function(){}; + editor.Update_ParaTab = function(){}; + editor.sync_ParaStyleName = function(){}; + editor.UpdateParagraphProp = function(){}; + editor.UpdateTextPr = function(){}; + editor.sync_MathPropCallback = function(){}; + editor.sync_HyperlinkPropCallback = function(){}; + editor.DemonstrationReporterEnd = function () {}; + editor.private_GetLogicDocument = function(){return this.WordControl.m_oLogicDocument;}; + editor.asc_getKeyboardLanguage = function(){return -1;}; //--------------------------------------------------------export---------------------------------------------------- AscTest.DrawingDocument = editor.WordControl.m_oDrawingDocument; AscTest.Editor = editor; diff --git a/tests/slide/common/presentation.js b/tests/slide/common/presentation.js index 5777291105..f1b8a2a615 100644 --- a/tests/slide/common/presentation.js +++ b/tests/slide/common/presentation.js @@ -34,39 +34,52 @@ (function(window) { - let oLogicDocument = null; + let logicDocument = null; - function CreateLogicDocument() - { - if (oLogicDocument) - return oLogicDocument; - - editor.InitEditor(); - editor.bInit_word_control = true; - editor.WordControl.Thumbnails.SetFont = function () { - - }; - editor.WordControl.StartMainTimer = function () - { + function CreateLogicDocument() + { + if (logicDocument) + return logicDocument; - }; - editor.WordControl.InitControl(); + logicDocument = new AscCommonSlide.CPresentation(AscTest.DrawingDocument, true); + logicDocument.Api = AscTest.Editor; - oLogicDocument = editor.WordControl.m_oLogicDocument; - oLogicDocument.createNecessaryObjectsIfNoPresent(); - AscTest.DrawingDocument.m_oLogicDocument = oLogicDocument; - - return oLogicDocument; - } + AscTest.DrawingDocument.m_oLogicDocument = logicDocument; + logicDocument.createNecessaryObjectsIfNoPresent(); + return logicDocument; + } function GetParagraphText(paragraph) { return paragraph.GetText({ParaEndToSpace : false}); } + function EnterText(text) + { + if (!logicDocument) + return; + + logicDocument.EnterText(text); + } + + function TurnOnRecalculate() + { + logicDocument.Recalculate = AscCommonSlide.CPresentation.prototype.Recalculate.bind(logicDocument); + logicDocument.Recalculate2 = AscCommonSlide.CPresentation.prototype.Recalculate2.bind(logicDocument); + } + + function TurnOffRecalculate() + { + logicDocument.Recalculate = function () {}; + logicDocument.Recalculate2 = function () {}; + } + //--------------------------------------------------------export---------------------------------------------------- AscTest.CreateLogicDocument = CreateLogicDocument; AscTest.GetParagraphText = GetParagraphText; + AscTest.EnterText = EnterText; + AscTest.TurnOnRecalculate = TurnOnRecalculate; + AscTest.TurnOffRecalculate = TurnOffRecalculate; })(window); diff --git a/tests/slide/common/thumbnails.js b/tests/slide/common/thumbnails.js new file mode 100644 index 0000000000..0a13c69401 --- /dev/null +++ b/tests/slide/common/thumbnails.js @@ -0,0 +1,53 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +'use strict'; + +(function (window) +{ + AscTest.DrawingDocument.m_oThumbnails = new AscCommon.CControl(); + AscTest.DrawingDocument.m_oScrollThumbApi = AscTest.DrawingDocument; + AscTest.DrawingDocument.Thumbnails = new CThumbnailsManager(); + AscTest.DrawingDocument.Thumbnails.m_bIsVisible = true; + AscTest.DrawingDocument.Thumbnails.m_oWordControl = AscTest.DrawingDocument; + AscTest.DrawingDocument.Thumbnails.OnUpdateOverlay = function () {}; + + AscTest.DrawingDocument.m_oThumbnails.Name = "id_th"; + AscTest.DrawingDocument.m_oThumbnails.HtmlElement = document.createElement('canvas'); + + AscTest.DrawingDocument.OnEndRecalculate = function () + { + AscTest.DrawingDocument.m_oDrawingDocument.SlidesCount = AscTest.DrawingDocument.m_oLogicDocument.Slides.length; + AscTest.DrawingDocument.Thumbnails.SlidesCount = AscTest.DrawingDocument.m_oLogicDocument.Slides.length; + AscTest.DrawingDocument.Thumbnails.CalculatePlaces(); + } +})(window); diff --git a/tests/slide/shortcuts/events.js b/tests/slide/shortcuts/events.js index 9b88e7dadb..7c1584bae7 100644 --- a/tests/slide/shortcuts/events.js +++ b/tests/slide/shortcuts/events.js @@ -33,18 +33,7 @@ (function (window) { - const {createNativeEvent} = AscTestShortcut; - const testAll = 0; - const testMacOs = 1; - const testWindows = 2; - - function CTestEvent(oEvent, nType) - { - this.type = nType || testAll; - this.event = oEvent; - } - - const oMainShortcutTypes = { + const mainShortcutTypes = { checkDeleteBack : 0, checkDeleteWordBack : 1, checkRemoveAnimation : 2, @@ -71,7 +60,6 @@ checkMoveCursorToStartPosShape : 23, checkSelectAllContentShape : 24, checkSelectAllContentChartTitle : 25, - checkMoveCursorToStartPosChartTitle : 26, checkRemoveAndMoveToStartPosTable : 27, checkSelectFirstCellContent : 28, checkResetAddShape : 29, @@ -115,126 +103,157 @@ checkIncreaseIndent : 67, checkDecreaseIndent : 68, checkNumLock : 69, - checkScrollLock : 70 + checkScrollLock : 70, + addNextSlide : 71, + moveToPreviousSlide : 72, + moveToNextSlide : 73, + moveToFirstSlide : 74, + selectToFirstSlide : 75, + moveToLastSlide : 76, + selectToLastSlide : 77 }; - const oMainEvents = {}; - oMainEvents[oMainShortcutTypes.checkDeleteBack] = [new CTestEvent(createNativeEvent(8, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkDeleteWordBack] = [new CTestEvent(createNativeEvent(8, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveAnimation] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveChart] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveShape] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveTable] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveGroup] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveShapeInGroup] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveToNextCell] = [new CTestEvent(createNativeEvent(9, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveToPreviousCell] = [new CTestEvent(createNativeEvent(9, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkIncreaseBulletIndent] = [new CTestEvent(createNativeEvent(9, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkDecreaseBulletIndent] = [new CTestEvent(createNativeEvent(9, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddTab] = [new CTestEvent(createNativeEvent(9, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectNextObject] = [new CTestEvent(createNativeEvent(9, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectPreviousObject] = [new CTestEvent(createNativeEvent(9, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkVisitHyperlink] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectNextObjectWithPlaceholder] = [new CTestEvent(createNativeEvent(13, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddNextSlideAfterSelectLastPlaceholderObject] = [new CTestEvent(createNativeEvent(13, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddBreakLine] = [new CTestEvent(createNativeEvent(13, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddMathBreakLine] = [ - new CTestEvent(createNativeEvent(13, false, true, false, false, false, false)), - new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddTitleBreakLine] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddParagraph] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddTxBodyShape] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorToStartPosShape] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectAllContentShape] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectAllContentChartTitle] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorToStartPosChartTitle] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkRemoveAndMoveToStartPosTable] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectFirstCellContent] = [new CTestEvent(createNativeEvent(13, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkResetAddShape] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkResetAllDrawingSelection] = [new CTestEvent(createNativeEvent(27, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkResetStepDrawingSelection] = [new CTestEvent(createNativeEvent(27, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkNonBreakingSpace] = [new CTestEvent(createNativeEvent(32, true, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkClearParagraphFormatting] = [new CTestEvent(createNativeEvent(32, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkAddSpace] = [new CTestEvent(createNativeEvent(32, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveToEndPosContent] = [new CTestEvent(createNativeEvent(35, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveToEndLineContent] = [new CTestEvent(createNativeEvent(35, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectToEndLineContent] = [new CTestEvent(createNativeEvent(35, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveToStartPosContent] = [new CTestEvent(createNativeEvent(36, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveToStartLineContent] = [new CTestEvent(createNativeEvent(36, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectToStartLineContent] = [new CTestEvent(createNativeEvent(36, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorLeft] = [new CTestEvent(createNativeEvent(37, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectCursorLeft] = [new CTestEvent(createNativeEvent(37, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectWordCursorLeft] = [new CTestEvent(createNativeEvent(37, true, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorWordLeft] = [new CTestEvent(createNativeEvent(37, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorLeftTable] = [new CTestEvent(createNativeEvent(37, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorRight] = [new CTestEvent(createNativeEvent(39, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorRightTable] = [new CTestEvent(createNativeEvent(39, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectCursorRight] = [new CTestEvent(createNativeEvent(39, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectWordCursorRight] = [new CTestEvent(createNativeEvent(39, true, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorWordRight] = [new CTestEvent(createNativeEvent(39, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorTop] = [new CTestEvent(createNativeEvent(38, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorTopTable] = [new CTestEvent(createNativeEvent(38, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectCursorTop] = [new CTestEvent(createNativeEvent(38, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorBottom] = [new CTestEvent(createNativeEvent(40, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveCursorBottomTable] = [new CTestEvent(createNativeEvent(40, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkSelectCursorBottom] = [new CTestEvent(createNativeEvent(40, false, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveShapeBottom] = [new CTestEvent(createNativeEvent(40, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkLittleMoveShapeBottom] = [new CTestEvent(createNativeEvent(40, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveShapeTop] = [new CTestEvent(createNativeEvent(38, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkLittleMoveShapeTop] = [new CTestEvent(createNativeEvent(38, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveShapeRight] = [new CTestEvent(createNativeEvent(39, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkLittleMoveShapeRight] = [new CTestEvent(createNativeEvent(39, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkMoveShapeLeft] = [new CTestEvent(createNativeEvent(37, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkLittleMoveShapeLeft] = [new CTestEvent(createNativeEvent(37, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkDeleteFront] = [new CTestEvent(createNativeEvent(46, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkDeleteWordFront] = [new CTestEvent(createNativeEvent(46, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkIncreaseIndent] = [new CTestEvent(createNativeEvent(77, true, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkDecreaseIndent] = [new CTestEvent(createNativeEvent(77, true, true, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkNumLock] = [new CTestEvent(createNativeEvent(144, false, false, false, false, false, false))]; - oMainEvents[oMainShortcutTypes.checkScrollLock] = [new CTestEvent(createNativeEvent(145, false, false, false, false, false, false))]; + const mainEvents = {}; + mainEvents[mainShortcutTypes.checkDeleteBack] = [CreateKeyboardEvent(8, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteWordBack] = [CreateKeyboardEvent(8, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveAnimation] = [ + CreateKeyboardEvent(8, false, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveChart] = [ + CreateKeyboardEvent(8, false, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveShape] = [ + CreateKeyboardEvent(8, false, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveTable] = [ + CreateKeyboardEvent(8, false, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveGroup] = [ + CreateKeyboardEvent(8, false, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveShapeInGroup] = [ + CreateKeyboardEvent(8, false, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToNextCell] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToPreviousCell] = [CreateKeyboardEvent(9, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkIncreaseBulletIndent] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDecreaseBulletIndent] = [CreateKeyboardEvent(9, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddTab] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectNextObject] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectPreviousObject] = [CreateKeyboardEvent(9, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkVisitHyperlink] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectNextObjectWithPlaceholder] = [CreateKeyboardEvent(13, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddNextSlideAfterSelectLastPlaceholderObject] = [CreateKeyboardEvent(13, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddBreakLine] = [CreateKeyboardEvent(13, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddMathBreakLine] = [ + CreateKeyboardEvent(13, false, true, false, false, false, false), + CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddTitleBreakLine] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddParagraph] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddTxBodyShape] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorToStartPosShape] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectAllContentShape] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectAllContentChartTitle] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveAndMoveToStartPosTable] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectFirstCellContent] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkResetAddShape] = [CreateKeyboardEvent(27, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkResetAllDrawingSelection] = [CreateKeyboardEvent(27, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkResetStepDrawingSelection] = [CreateKeyboardEvent(27, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkNonBreakingSpace] = [CreateKeyboardEvent(32, true, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkClearParagraphFormatting] = [CreateKeyboardEvent(32, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddSpace] = [CreateKeyboardEvent(32, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToEndPosContent] = [CreateKeyboardEvent(35, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToEndLineContent] = [CreateKeyboardEvent(35, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectToEndLineContent] = [CreateKeyboardEvent(35, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToStartPosContent] = [CreateKeyboardEvent(36, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToStartLineContent] = [CreateKeyboardEvent(36, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectToStartLineContent] = [CreateKeyboardEvent(36, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorLeft] = [CreateKeyboardEvent(37, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorLeft] = [CreateKeyboardEvent(37, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectWordCursorLeft] = [CreateKeyboardEvent(37, true, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorWordLeft] = [CreateKeyboardEvent(37, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorLeftTable] = [CreateKeyboardEvent(37, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorRight] = [CreateKeyboardEvent(39, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorRightTable] = [CreateKeyboardEvent(39, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorRight] = [CreateKeyboardEvent(39, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectWordCursorRight] = [CreateKeyboardEvent(39, true, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorWordRight] = [CreateKeyboardEvent(39, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorTop] = [CreateKeyboardEvent(38, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorTopTable] = [CreateKeyboardEvent(38, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorTop] = [CreateKeyboardEvent(38, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorBottom] = [CreateKeyboardEvent(40, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorBottomTable] = [CreateKeyboardEvent(40, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorBottom] = [CreateKeyboardEvent(40, false, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeBottom] = [CreateKeyboardEvent(40, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeBottom] = [CreateKeyboardEvent(40, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeTop] = [CreateKeyboardEvent(38, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeTop] = [CreateKeyboardEvent(38, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeRight] = [CreateKeyboardEvent(39, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeRight] = [CreateKeyboardEvent(39, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeLeft] = [CreateKeyboardEvent(37, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeLeft] = [CreateKeyboardEvent(37, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteFront] = [CreateKeyboardEvent(46, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteWordFront] = [CreateKeyboardEvent(46, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkIncreaseIndent] = [CreateKeyboardEvent(77, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDecreaseIndent] = [CreateKeyboardEvent(77, true, true, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkNumLock] = [CreateKeyboardEvent(144, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkScrollLock] = [CreateKeyboardEvent(145, false, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.addNextSlide] = [ + CreateKeyboardEvent(77, true, false, false, false, false, false) + ]; + mainEvents[mainShortcutTypes.moveToPreviousSlide] = [ + CreateKeyboardEvent(38, false, false, false, false, false, false), + CreateKeyboardEvent(37, false, false, false, false, false, false), + CreateKeyboardEvent(33, false, false, false, false, false, false) + ]; + mainEvents[mainShortcutTypes.moveToNextSlide] = [ + CreateKeyboardEvent(39, false, false, false, false, false, false), + CreateKeyboardEvent(40, false, false, false, false, false, false), + CreateKeyboardEvent(34, false, false, false, false, false, false) + ]; + mainEvents[mainShortcutTypes.moveToFirstSlide] = [ + CreateKeyboardEvent(36, false, false, false, false, false, false) + ]; + mainEvents[mainShortcutTypes.selectToFirstSlide] = [ + CreateKeyboardEvent(36, false, true, false, false, false, false) + ]; + mainEvents[mainShortcutTypes.moveToLastSlide] = [ + CreateKeyboardEvent(35, false, false, false, false, false, false) + ]; + mainEvents[mainShortcutTypes.selectToLastSlide] = [ + CreateKeyboardEvent(35, false, true, false, false, false, false) + ]; - const oDemonstrationTypes = { + const demonstrationTypes = { moveToNextSlide : 0, moveToPreviousSlide : 1, moveToFirstSlide : 2, moveToLastSlide : 3, exitFromDemonstrationMode: 4 }; - const oDemonstrationEvents = {}; - oDemonstrationEvents[oDemonstrationTypes.moveToNextSlide] = [ - new CTestEvent(createNativeEvent(13, false, false, false, false)), - new CTestEvent(createNativeEvent(32, false, false, false, false)), - new CTestEvent(createNativeEvent(34, false, false, false, false)), - new CTestEvent(createNativeEvent(39, false, false, false, false)), - new CTestEvent(createNativeEvent(40, false, false, false, false)) + const demonstrationEvents = {}; + demonstrationEvents[demonstrationTypes.moveToNextSlide] = [ + new CNativeEvent(13, false, false, false, false), + new CNativeEvent(32, false, false, false, false), + new CNativeEvent(34, false, false, false, false), + new CNativeEvent(39, false, false, false, false), + new CNativeEvent(40, false, false, false, false) ]; - oDemonstrationEvents[oDemonstrationTypes.moveToPreviousSlide] = [ - new CTestEvent(createNativeEvent(33, false, false, false, false)), - new CTestEvent(createNativeEvent(37, false, false, false, false)), - new CTestEvent(createNativeEvent(38, false, false, false, false)) + demonstrationEvents[demonstrationTypes.moveToPreviousSlide] = [ + new CNativeEvent(33, false, false, false, false), + new CNativeEvent(37, false, false, false, false), + new CNativeEvent(38, false, false, false, false) ]; - oDemonstrationEvents[oDemonstrationTypes.moveToFirstSlide] = [ - new CTestEvent(createNativeEvent(36, false, false, false, false)) + demonstrationEvents[demonstrationTypes.moveToFirstSlide] = [ + new CNativeEvent(36, false, false, false, false) ]; - oDemonstrationEvents[oDemonstrationTypes.moveToLastSlide] = [ - new CTestEvent(createNativeEvent(35, false, false, false, false)) + demonstrationEvents[demonstrationTypes.moveToLastSlide] = [ + new CNativeEvent(35, false, false, false, false) ]; - oDemonstrationEvents[oDemonstrationTypes.exitFromDemonstrationMode] = [ - new CTestEvent(createNativeEvent(27, false, false, false, false)) + demonstrationEvents[demonstrationTypes.exitFromDemonstrationMode] = [ + new CNativeEvent(27, false, false, false, false) ]; - const oThumbnailsTypes = { + const thumbnailsTypes = { addNextSlide : 0, removeSelectedSlides : 1, moveSelectedSlidesToEnd : 2, @@ -250,145 +269,156 @@ selectPreviousSlide : 12, moveToPreviousSlide : 13 }; - const oThumbnailsEvents = {}; - oThumbnailsEvents[oThumbnailsTypes.addNextSlide] = [ - new CTestEvent(createNativeEvent(13, false, false, false, false)), - new CTestEvent(createNativeEvent(77, true, false, false, false)) + const thumbnailsEvents = {}; + thumbnailsEvents[thumbnailsTypes.addNextSlide] = [ + new CNativeEvent(13, false, false, false, false), + new CNativeEvent(77, true, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.removeSelectedSlides] = [ - new CTestEvent(createNativeEvent(8, false, false, false, false)), - new CTestEvent(createNativeEvent(46, false, false, false, false)) + thumbnailsEvents[thumbnailsTypes.removeSelectedSlides] = [ + new CNativeEvent(8, false, false, false, false), + new CNativeEvent(46, false, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveSelectedSlidesToEnd] = [ - new CTestEvent(createNativeEvent(40, true, true, false, false)), - new CTestEvent(createNativeEvent(34, true, true, false, false)) + thumbnailsEvents[thumbnailsTypes.moveSelectedSlidesToEnd] = [ + new CNativeEvent(40, true, true, false, false), + new CNativeEvent(34, true, true, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveSelectedSlidesToNextPosition] = [ - new CTestEvent(createNativeEvent(40, true, false, false, false)), - new CTestEvent(createNativeEvent(34, true, false, false, false)) + thumbnailsEvents[thumbnailsTypes.moveSelectedSlidesToNextPosition] = [ + new CNativeEvent(40, true, false, false, false), + new CNativeEvent(34, true, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.selectNextSlide] = [ - new CTestEvent(createNativeEvent(40, false, true, false, false)), - new CTestEvent(createNativeEvent(34, false, true, false, false)) + thumbnailsEvents[thumbnailsTypes.selectNextSlide] = [ + new CNativeEvent(40, false, true, false, false), + new CNativeEvent(34, false, true, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveToNextSlide] = [ - new CTestEvent(createNativeEvent(40, true, false, false, false)), - new CTestEvent(createNativeEvent(34, true, false, false, false)) + thumbnailsEvents[thumbnailsTypes.moveToNextSlide] = [ + new CNativeEvent(40, true, false, false, false), + new CNativeEvent(34, true, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveToFirstSlide] = [ - new CTestEvent(createNativeEvent(36, false, false, false, false)) + thumbnailsEvents[thumbnailsTypes.moveToFirstSlide] = [ + new CNativeEvent(36, false, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.selectToFirstSlide] = [ - new CTestEvent(createNativeEvent(36, false, true, false, false)) + thumbnailsEvents[thumbnailsTypes.selectToFirstSlide] = [ + new CNativeEvent(36, false, true, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveToLastSlide] = [ - new CTestEvent(createNativeEvent(35, false, false, false, false)) + thumbnailsEvents[thumbnailsTypes.moveToLastSlide] = [ + new CNativeEvent(35, false, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.selectToLastSlide] = [ - new CTestEvent(createNativeEvent(35, false, true, false, false)) + thumbnailsEvents[thumbnailsTypes.selectToLastSlide] = [ + new CNativeEvent(35, false, true, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveSelectedSlidesToStart] = [ - new CTestEvent(createNativeEvent(33, true, true, false, false)), - new CTestEvent(createNativeEvent(38, true, true, false, false)) + thumbnailsEvents[thumbnailsTypes.moveSelectedSlidesToStart] = [ + new CNativeEvent(33, true, true, false, false), + new CNativeEvent(38, true, true, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveSelectedSlidesToPreviousPosition] = [ - new CTestEvent(createNativeEvent(33, true, false, false, false)), - new CTestEvent(createNativeEvent(38, true, false, false, false)) + thumbnailsEvents[thumbnailsTypes.moveSelectedSlidesToPreviousPosition] = [ + new CNativeEvent(33, true, false, false, false), + new CNativeEvent(38, true, false, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.selectPreviousSlide] = [ - new CTestEvent(createNativeEvent(38, false, true, false, false)), - new CTestEvent(createNativeEvent(33, false, true, false, false)) + thumbnailsEvents[thumbnailsTypes.selectPreviousSlide] = [ + new CNativeEvent(38, false, true, false, false), + new CNativeEvent(33, false, true, false, false) ]; - oThumbnailsEvents[oThumbnailsTypes.moveToPreviousSlide] = [ - new CTestEvent(createNativeEvent(33, true, false, false, false)), - new CTestEvent(createNativeEvent(38, true, false, false, false)) + thumbnailsEvents[thumbnailsTypes.moveToPreviousSlide] = [ + new CNativeEvent(33, true, false, false, false), + new CNativeEvent(38, true, false, false, false) ]; - const oThumbnailsMainFocusTypes = { - addNextSlide : 0, - moveToPreviousSlide : 1, - moveToNextSlide : 2, - moveToFirstSlide : 3, - selectToFirstSlide : 4, - moveSelectedSlidesToEnd : 5, - moveSelectedSlidesToNextPosition: 6, - moveToLastSlide : 7, - selectToLastSlide : 8 - }; - const oThumbnailsMainFocusEvents = {}; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.addNextSlide] = [ - new CTestEvent(createNativeEvent(77, true, false, false, false, false, false)) - ]; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.moveToPreviousSlide] = [ - new CTestEvent(createNativeEvent(38, false, false, false, false, false, false)), - new CTestEvent(createNativeEvent(37, false, false, false, false, false, false)), - new CTestEvent(createNativeEvent(33, false, false, false, false, false, false)) - ]; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.moveToNextSlide] = [ - new CTestEvent(createNativeEvent(39, false, false, false, false, false, false)), - new CTestEvent(createNativeEvent(40, false, false, false, false, false, false)), - new CTestEvent(createNativeEvent(34, false, false, false, false, false, false)) - ]; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.moveToFirstSlide] = [ - new CTestEvent(createNativeEvent(36, false, false, false, false, false, false)) - ]; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.selectToFirstSlide] = [ - new CTestEvent(createNativeEvent(36, false, true, false, false, false, false)) - ]; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.moveToLastSlide] = [ - new CTestEvent(createNativeEvent(35, false, false, false, false, false, false)) - ]; - oThumbnailsMainFocusEvents[oThumbnailsMainFocusTypes.selectToLastSlide] = [ - new CTestEvent(createNativeEvent(35, false, true, false, false, false, false)) - ]; - function privateStartTest(fCallback, nShortcutType, oTestEvents) + function CreateKeyboardEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) { - const arrTestEvents = oTestEvents[nShortcutType]; - - for (let i = 0; i < arrTestEvents.length; i += 1) + const event = new AscCommon.CKeyboardEvent(); + event.KeyCode = nKeyCode; + event.CtrlKey = !!bIsCtrl; + event.ShiftKey = !!bIsShift; + event.AltKey = !!bIsAlt; + event.MacCmdKey = !!bIsMetaKey; + event.isDefaultPrevented = false; + event.isPropagationStopped = false; + event.preventDefault = function () { - const nTestType = arrTestEvents[i].type; - if (nTestType === testAll) - { - AscCommon.AscBrowser.isMacOs = true; - fCallback(arrTestEvents[i].event); + event.isDefaultPrevented = true; + } + event.stopPropagation = function () + { + event.isPropagationStopped = true; + } + return event; + } - AscCommon.AscBrowser.isMacOs = false; - fCallback(arrTestEvents[i].event); - } else if (nTestType === testMacOs) - { - AscCommon.AscBrowser.isMacOs = true; - fCallback(arrTestEvents[i].event); - AscCommon.AscBrowser.isMacOs = false; - } else if (nTestType === testWindows) - { - fCallback(arrTestEvents[i].event); - } + function CNativeEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) + { + this.keyCode = nKeyCode; + this.ctrlKey = !!bIsCtrl; + this.shiftKey = !!bIsShift; + this.altKey = !!bIsAlt; + this.metaKey = !!bIsMetaKey; + this.isDefaultPrevented = false; + this.isPropagationStopped = false; + } + + CNativeEvent.prototype.preventDefault = function () + { + this.isDefaultPrevented = true; + }; + CNativeEvent.prototype.stopPropagation = function () + { + this.isPropagationStopped = true; + }; + + editor.getShortcut = function (e) + { + if (typeof e === 'number') + { + return e; } + }; + + function ExecuteMainHotkey(type, index) + { + const event = mainEvents[type][index || 0]; + return ExecuteMainShortcut(event); } - function startThumbnailsMainFocusTest(fCallback, nShortcutType) + function ExecuteThumbnailHotkey(e, index) { - privateStartTest(fCallback, nShortcutType, oThumbnailsMainFocusEvents); + const event = thumbnailsEvents[e][index || 0]; + return ExecuteThumbnailShortcut(event); } - function startMainTest(fCallback, nShortcutType) + function ExecuteMainShortcut(e) { - privateStartTest(fCallback, nShortcutType, oMainEvents); + return editor.WordControl.m_oLogicDocument.OnKeyDown(e); + } + + function ExecuteThumbnailShortcut(e) + { + const OldGetShortcut = editor.getShortcut; + if (typeof e === 'number') + { + const shortcutType = e; + editor.getShortcut = function () + { + return shortcutType; + }; + e = new CNativeEvent(); + } + const res = editor.WordControl.Thumbnails.onKeyDown(e); + editor.getShortcut = OldGetShortcut; + return res; } - function startThumbnailsFocusTest(fCallback, nShortcutType) + function ExecuteDemonstrationShortcut(e) { - privateStartTest(fCallback, nShortcutType, oThumbnailsEvents); + return editor.WordControl.DemonstrationManager.onKeyDown(e); } - AscTestShortcut.startThumbnailsMainFocusTest = startThumbnailsMainFocusTest; - AscTestShortcut.startMainTest = startMainTest; - AscTestShortcut.startThumbnailsFocusTest = startThumbnailsFocusTest; - AscTestShortcut.oThumbnailsMainFocusTypes = oThumbnailsMainFocusTypes; - AscTestShortcut.oMainShortcutTypes = oMainShortcutTypes; - AscTestShortcut.oThumbnailsTypes = oThumbnailsTypes; - AscTestShortcut.oDemonstrationTypes = oDemonstrationTypes; - AscTestShortcut.oDemonstrationEvents = oDemonstrationEvents; + AscTest.mainShortcutTypes = mainShortcutTypes; + AscTest.thumbnailsTypes = thumbnailsTypes; + AscTest.demonstrationTypes = demonstrationTypes; + AscTest.demonstrationEvents = demonstrationEvents; + AscTest.ExecuteDemonstrationShortcut = ExecuteDemonstrationShortcut; + AscTest.ExecuteThumbnailShortcut = ExecuteThumbnailShortcut; + AscTest.ExecuteMainShortcut = ExecuteMainShortcut; + AscTest.ExecuteThumbnailHotkey = ExecuteThumbnailHotkey; + AscTest.ExecuteMainHotkey = ExecuteMainHotkey; })(window); diff --git a/tests/slide/shortcuts/helpers.js b/tests/slide/shortcuts/helpers.js deleted file mode 100644 index ee82bf20fe..0000000000 --- a/tests/slide/shortcuts/helpers.js +++ /dev/null @@ -1,502 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -'use strict'; - -(function (window) -{ - - AscCommon.CGraphics.prototype.SetFontSlot = function () {}; - AscCommon.CGraphics.prototype.SetFont = function () {}; - AscCommon.CGraphics.prototype.SetFontInternal = function () {}; - window.AscFonts = window.AscFonts || {}; - AscFonts.g_fontApplication = { - GetFontInfo : function (sFontName) - { - if (sFontName === 'Cambria Math') - { - return new AscFonts.CFontInfo('Cambria Math', 40, 1, 433, 1, -1, -1, -1, -1, -1, -1); - } - }, - Init : function () {}, - LoadFont : function () {}, - GetFontInfoName: function () {} - } - - window.g_fontApplication = AscFonts.g_fontApplication; - - AscCommon.CDocsCoApi.prototype.askSaveChanges = function (callback) - { - callback({'saveLock': false}); - }; - AscCommon.loadSmartArtBinary = function () - { - - }; - let oGlobalShape - const oGlobalLogicDocument = AscTest.CreateLogicDocument() - editor.WordControl.m_oLogicDocument.Document_UpdateInterfaceState = function () - { - }; - - function getController() - { - return oGlobalLogicDocument.GetCurrentController(); - } - - function createGroup(arrObjects) - { - const oController = getController(); - oController.resetSelection(); - for (let i = 0; i < arrObjects.length; i += 1) - { - arrObjects[i].select(oController, 0); - } - - return oController.createGroup(); - } - - function addToSelection(oObject) - { - const oController = getController(); - if (oObject.group) - { - const oMainGroup = oObject.group.getMainGroup(); - oMainGroup.select(oController, 0); - oController.selection.groupSelection = oMainGroup; - } - oObject.select(oController, 0); - } - - function remove() - { - oGlobalLogicDocument.Remove(); - } - - function selectOnlyObjects(arrObjects) - { - const oController = getController(); - oController.resetSelection(); - for (let i = 0; i < arrObjects.length; i += 1) - { - const oObject = arrObjects[i]; - if (oObject.group) - { - const oMainGroup = oObject.group.getMainGroup(); - oMainGroup.select(oController, 0); - oController.selection.groupSelection = oMainGroup; - } - oObject.select(oController, 0); - } - } - - function getFirstSlide() - { - return oGlobalLogicDocument.Slides[0]; - } - - function moveToParagraph(oParagraph, bIsStart) - { - oParagraph.SetThisElementCurrent(); - if (bIsStart) - { - oParagraph.MoveCursorToStartPos(); - } else - { - oParagraph.MoveCursorToEndPos(); - } - } - - function getShapeWithParagraphHelper(sTextIntoShape, bResetSelection) - { - const oController = oGlobalLogicDocument.GetCurrentController(); - if (bResetSelection) - { - oController.resetSelection(); - } - oGlobalShape = AscTest.createShape(oGlobalLogicDocument.Slides[0]); - - - oGlobalShape.setTxBody(AscFormat.CreateTextBodyFromString(sTextIntoShape, editor.WordControl.m_oDrawingDocument, oGlobalShape)); - const oContent = oGlobalShape.getDocContent(); - const oParagraph = oContent.Content[0]; - - return {oLogicDocument: oGlobalLogicDocument, oShape: oGlobalShape, oParagraph, oController, oContent}; - } - - function createEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsAltGr, bIsMacCmdKey) - { - const oKeyBoardEvent = new AscCommon.CKeyboardEvent(); - oKeyBoardEvent.KeyCode = nKeyCode; - oKeyBoardEvent.ShiftKey = bIsShift; - oKeyBoardEvent.AltKey = bIsAlt; - oKeyBoardEvent.CtrlKey = bIsCtrl; - oKeyBoardEvent.MacCmdKey = bIsMacCmdKey; - oKeyBoardEvent.AltGr = bIsAltGr; - return oKeyBoardEvent; - } - - function getDirectTextPrHelper(oParagraph, oEvent) - { - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - onKeyDown(oEvent); - return oGlobalLogicDocument.GetDirectTextPr(); - } - - function getDirectParaPrHelper(oParagraph, oEvent) - { - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - onKeyDown(oEvent); - return oGlobalLogicDocument.GetDirectParaPr(); - } - - function checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, sInitText) - { - const {oLogicDocument, oParagraph} = getShapeWithParagraphHelper(sInitText); - oParagraph.SetThisElementCurrent(); - oLogicDocument.MoveCursorToEndPos(); - onKeyDown(oEvent); - const sTextAfterKeyDown = AscTest.GetParagraphText(oParagraph); - oAssert.strictEqual(sTextAfterKeyDown, sCheckText, sPrompt); - } - - function checkTextAfterKeyDownHelperEmpty(sCheckText, oEvent, oAssert, sPrompt) - { - checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, ''); - } - - function checkTextAfterKeyDownHelperHelloWorld(sCheckText, oEvent, oAssert, sPrompt) - { - checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, 'Hello World'); - } - - function checkRemoveObject(oObject, arrSpTree) - { - let bCheckRemoveFromSpTree = true; - for (let nDrawingIndex = 0; nDrawingIndex < arrSpTree.length; nDrawingIndex += 1) - { - if (arrSpTree[nDrawingIndex] === oObject) - { - bCheckRemoveFromSpTree = false; - } - } - return bCheckRemoveFromSpTree && oObject.bDeleted; - } - - function createTable(nRows, nColumns) - { - const oGraphicFrame = oGlobalLogicDocument.Add_FlowTable(nColumns, nRows); - const oTable = oGraphicFrame.graphicObject; - //oTable.Resize(nColumns * 300, nRows * 200); - for (let nRow = 0; nRow < nRows; nRow += 1) - { - for (let nColumn = 0; nColumn < nColumns; nColumn += 1) - { - const oCell = oTable.Content[nRow].Get_Cell(nColumn); - const oContent = oCell.GetContent(); - AscFormat.AddToContentFromString(oContent, 'Cell' + nRow + 'x' + nColumn); - } - } - oGlobalLogicDocument.Recalculate(); - return oGraphicFrame; - } - - function createChart() - { - const oChart = editor.asc_getChartObject(Asc.c_oAscChartTypeSettings.lineNormal); - oChart.setParent(oGlobalLogicDocument.Slides[0]); - - oChart.addToDrawingObjects(); - oChart.spPr.setXfrm(new AscFormat.CXfrm()); - oChart.spPr.xfrm.setOffX(0); - oChart.spPr.xfrm.setOffY(0); - oChart.spPr.xfrm.setExtX(100); - oChart.spPr.xfrm.setExtY(100); - oGlobalLogicDocument.Recalculate(); - oGlobalLogicDocument.Document_UpdateInterfaceState(); - oGlobalLogicDocument.CheckEmptyPlaceholderNotes(); - - oGlobalLogicDocument.DrawingDocument.m_oWordControl.OnUpdateOverlay(); - return oChart; - } - - function createShapeWithTitlePlaceholder() - { - const oShape = AscTest.createShape(oGlobalLogicDocument.Slides[0]); - oShape.setNvSpPr(new AscFormat.UniNvPr()); - let oPh = new AscFormat.Ph(); - oPh.setType(AscFormat.phType_title); - oShape.nvSpPr.nvPr.setPh(oPh); - oShape.txBody = AscFormat.CreateTextBodyFromString('', oShape.getDrawingDocument(), oShape); - - oShape.recalculateContentWitCompiledPr(); - return oShape; - } - - function testMoveHelper(oEvent, bMoveToEndPosition, bGetPos, bGetSelectedText) - { - const { - oShape, - oParagraph, - oLogicDocument - } = getShapeWithParagraphHelper('HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHello', true); - oShape.setPaddings({Left: 0, Top: 0, Right: 0, Bottom: 0}); - oParagraph.SetThisElementCurrent(); - oParagraph.Pr.SetInd(0, 0, 0); - oParagraph.Set_Align(AscCommon.align_Left); - if (bMoveToEndPosition) - { - oLogicDocument.MoveCursorToEndPos(); - } else - { - oLogicDocument.MoveCursorToStartPos(); - } - oShape.recalculateContentWitCompiledPr(); - oLogicDocument.RecalculateCurPos(true, true); - - onKeyDown(oEvent); - - let oPos; - oLogicDocument.RecalculateCurPos(true, true); - if (bGetPos) - { - - oPos = oParagraph.GetCurPosXY(true, true); - } - let sSelectedText; - if (bGetSelectedText) - { - sSelectedText = oParagraph.GetSelectedText(); - } - return {oPos, sSelectedText}; - } - - function addPropertyToDocument(oPr) - { - oGlobalLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(oPr), true); - } - - function executeCheckMoveShape(oEvent) - { - const oController = oGlobalLogicDocument.GetCurrentController(); - oController.resetSelection(); - oGlobalShape.spPr.xfrm.setOffX(0); - oGlobalShape.spPr.xfrm.setOffY(0); - oGlobalShape.select(oController, 0); - oGlobalShape.recalculateTransform(); - editor.zoom100(); - onKeyDown(oEvent); - return oGlobalShape; - } - - function cleanPresentation() - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - editor.WordControl.Thumbnails.SelectAll(); - const arrSelectedArray = oGlobalLogicDocument.GetSelectedSlides(); - oGlobalLogicDocument.deleteSlides(arrSelectedArray); - } - - function checkSelectedSlides(arrSelectedSlides) - { - const arrPresentationSelectedSlides = oGlobalLogicDocument.GetSelectedSlides(); - return arrSelectedSlides.length === arrPresentationSelectedSlides.length && arrSelectedSlides.every((el, ind) => el === arrPresentationSelectedSlides[ind]); - } - - const arrCheckCodes = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 189, 187, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 219, 221, 186, 222, 220, 188, 190, 191, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 111, 106, - 109, 110, 107]; - - function createNativeEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) - { - const bIsMacOs = AscCommon.AscBrowser.isMacOs; - const oEvent = {}; - oEvent.isDefaultPrevented = false; - oEvent.isPropagationStopped = false; - oEvent.preventDefault = function () - { - if (bIsMacOs && oEvent.altKey && !(oEvent.ctrlKey || oEvent.metaKey) && (arrCheckCodes.indexOf(nKeyCode) !== -1)) - { - throw new Error('Alt key must not be disabled on macOS'); - } - oEvent.isDefaultPrevented = true; - }; - oEvent.stopPropagation = function () - { - oEvent.isPropagationStopped = true; - }; - - oEvent.keyCode = nKeyCode; - oEvent.ctrlKey = bIsCtrl; - oEvent.shiftKey = bIsShift; - oEvent.altKey = bIsAlt; - oEvent.metaKey = bIsMetaKey; - return oEvent; - } - - function executeTestWithCatchEvent(sSendEvent, fCustomCheck, customExpectedValue, oEvent, oAssert, fBeforeCallback) - { - fBeforeCallback && fBeforeCallback(); - - let bCheck = false; - - const fCheck = function (...args) - { - if (fCustomCheck) - { - bCheck = fCustomCheck(...args); - } else - { - bCheck = true; - } - } - editor.asc_registerCallback(sSendEvent, fCheck); - - onKeyDown(oEvent); - oAssert.strictEqual(bCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); - editor.asc_unregisterCallback(sSendEvent, fCheck); - } - - function onKeyDown(oEvent) - { - editor.WordControl.onKeyDown(oEvent); - } - - function addSlide() - { - oGlobalLogicDocument.addNextSlide(0); - } - - function createShape() - { - return AscTest.createShape(oGlobalLogicDocument.Slides[0]); - } - - function goToPage(nPage) - { - editor.WordControl.GoToPage(nPage); - } - - function goToPageWithFocus(nPage, eFocus) - { - goToPage(nPage); - oGlobalLogicDocument.SetThumbnailsFocusElement(eFocus); - } - - function onInput(arrCodes) - { - for (let i = 0; i < arrCodes.length; i += 1) - { - oGlobalLogicDocument.OnKeyPress(createEvent(arrCodes[i], false, false, false, false, false)); - } - } - - function moveCursorRight(bWord, bAddToSelect) - { - oGlobalLogicDocument.MoveCursorRight(!!bAddToSelect, !!bWord); - } - - function moveCursorLeft(bWord, bAddToSelect) - { - oGlobalLogicDocument.MoveCursorLeft(!!bAddToSelect, !!bWord); - } - - function moveCursorDown(bCtrlKey, bAddToSelect) - { - oGlobalLogicDocument.MoveCursorDown(!!bAddToSelect, !!bCtrlKey); - } - - function createMathInShape() - { - const {oShape, oParagraph} = getShapeWithParagraphHelper('', true); - selectOnlyObjects([oShape]); - moveToParagraph(oParagraph, true); - editor.asc_AddMath2(c_oAscMathType.FractionVertical); - return {oShape, oParagraph}; - } - - function checkDirectTextPrAfterKeyDown(fCallback, oEvent, oAssert, nExpectedValue, sPrompt) - { - const {oParagraph} = getShapeWithParagraphHelper('Hello World'); - const oTextPr = getDirectTextPrHelper(oParagraph, oEvent); - oAssert.strictEqual(fCallback(oTextPr), nExpectedValue, sPrompt); - } - - function checkDirectParaPrAfterKeyDown(fCallback, oEvent, oAssert, nExpectedValue, sPrompt) - { - const {oParagraph} = getShapeWithParagraphHelper('Hello World'); - const oParaPr = getDirectParaPrHelper(oParagraph, oEvent); - oAssert.strictEqual(fCallback(oParaPr), nExpectedValue, sPrompt); - } - - const AscTestShortcut = window.AscTestShortcut = {}; - AscTestShortcut.createMathInShape = createMathInShape; - AscTestShortcut.moveCursorDown = moveCursorDown; - AscTestShortcut.moveCursorLeft = moveCursorLeft; - AscTestShortcut.moveCursorRight = moveCursorRight; - AscTestShortcut.onInput = onInput; - AscTestShortcut.goToPageWithFocus = goToPageWithFocus; - AscTestShortcut.goToPage = goToPage; - AscTestShortcut.createShape = createShape; - AscTestShortcut.addSlide = addSlide; - AscTestShortcut.onKeyDown = onKeyDown; - AscTestShortcut.executeTestWithCatchEvent = executeTestWithCatchEvent; - AscTestShortcut.createNativeEvent = createNativeEvent; - AscTestShortcut.checkSelectedSlides = checkSelectedSlides; - AscTestShortcut.cleanPresentation = cleanPresentation; - AscTestShortcut.executeCheckMoveShape = executeCheckMoveShape; - AscTestShortcut.addPropertyToDocument = addPropertyToDocument; - AscTestShortcut.testMoveHelper = testMoveHelper; - AscTestShortcut.createShapeWithTitlePlaceholder = createShapeWithTitlePlaceholder; - AscTestShortcut.createChart = createChart; - AscTestShortcut.createTable = createTable; - AscTestShortcut.checkRemoveObject = checkRemoveObject; - AscTestShortcut.checkTextAfterKeyDownHelperHelloWorld = checkTextAfterKeyDownHelperHelloWorld; - AscTestShortcut.checkTextAfterKeyDownHelperEmpty = checkTextAfterKeyDownHelperEmpty; - AscTestShortcut.getDirectParaPrHelper = getDirectParaPrHelper; - AscTestShortcut.getDirectTextPrHelper = getDirectTextPrHelper; - AscTestShortcut.createEvent = createEvent; - AscTestShortcut.getShapeWithParagraphHelper = getShapeWithParagraphHelper; - AscTestShortcut.moveToParagraph = moveToParagraph; - AscTestShortcut.getFirstSlide = getFirstSlide; - AscTestShortcut.selectOnlyObjects = selectOnlyObjects; - AscTestShortcut.remove = remove; - AscTestShortcut.addToSelection = addToSelection; - AscTestShortcut.createGroup = createGroup; - AscTestShortcut.getController = getController; - AscTestShortcut.oGlobalLogicDocument = oGlobalLogicDocument; - AscTestShortcut.oGlobalShape = oGlobalShape; - AscTestShortcut.checkDirectTextPrAfterKeyDown = checkDirectTextPrAfterKeyDown; - AscTestShortcut.checkDirectParaPrAfterKeyDown = checkDirectParaPrAfterKeyDown; -})(window) diff --git a/tests/slide/shortcuts/shortcuts.html b/tests/slide/shortcuts/shortcuts.html index 9f260eb737..b795e91ef0 100644 --- a/tests/slide/shortcuts/shortcuts.html +++ b/tests/slide/shortcuts/shortcuts.html @@ -19,37 +19,26 @@

      test markup, will be hidden
      - - + + - diff --git a/tests/slide/shortcuts/shortcuts.js b/tests/slide/shortcuts/shortcuts.js index 335bd23157..64e7c2a6ed 100644 --- a/tests/slide/shortcuts/shortcuts.js +++ b/tests/slide/shortcuts/shortcuts.js @@ -31,1651 +31,1145 @@ */ 'use strict'; + (function (window) { const { - createMathInShape, - moveCursorDown, - moveCursorLeft, - moveCursorRight, - onInput, - goToPageWithFocus, - goToPage, - checkDirectTextPrAfterKeyDown, - checkDirectParaPrAfterKeyDown, - createShape, - addSlide, - onKeyDown, - executeTestWithCatchEvent, - createNativeEvent, - checkSelectedSlides, - cleanPresentation, - executeCheckMoveShape, - addPropertyToDocument, - testMoveHelper, - createShapeWithTitlePlaceholder, - createChart, - createTable, - checkRemoveObject, - checkTextAfterKeyDownHelperHelloWorld, - checkTextAfterKeyDownHelperEmpty, - createEvent, - getShapeWithParagraphHelper, - moveToParagraph, - getFirstSlide, - selectOnlyObjects, - addToSelection, - createGroup, - getController, - oGlobalLogicDocument, - oMainShortcutTypes, - oDemonstrationEvents, - oDemonstrationTypes, - oThumbnailsTypes, - oThumbnailsMainFocusTypes, - startThumbnailsFocusTest, - startThumbnailsMainFocusTest, - startMainTest - } = window.AscTestShortcut; - let oMockEvent = createNativeEvent(); - - function checkSave(oAssert) + mainShortcutTypes, + thumbnailsTypes, + demonstrationTypes, + demonstrationEvents, + ExecuteDemonstrationShortcut, + ExecuteThumbnailShortcut, + ExecuteMainShortcut, + ExecuteThumbnailHotkey, + ExecuteMainHotkey + } = AscTest; + + const logicDocument = AscTest.CreateLogicDocument(); + AscFormat.CHART_STYLE_MANAGER.init(); + + editor.sendEvent = Asc.asc_docs_api.prototype.sendEvent.bind(editor); + editor.asc_registerCallback = Asc.asc_docs_api.prototype.asc_registerCallback.bind(editor); + editor.asc_unregisterCallback = Asc.asc_docs_api.prototype.asc_unregisterCallback.bind(editor); + editor.sync_ContextMenuCallback = Asc.asc_docs_api.prototype.sync_ContextMenuCallback.bind(editor); + editor.sync_DemonstrationSlideChanged = Asc.asc_docs_api.prototype.sync_DemonstrationSlideChanged.bind(editor); + editor.sync_endDemonstration = Asc.asc_docs_api.prototype.sync_endDemonstration.bind(editor); + editor.sync_DialogAddHyperlink = Asc.asc_docs_api.prototype.sync_DialogAddHyperlink.bind(editor); + editor.getGraphicController = Asc.asc_docs_api.prototype.getGraphicController.bind(editor); + editor.FontSizeIn = Asc.asc_docs_api.prototype.FontSizeIn.bind(editor); + editor.FontSizeOut = Asc.asc_docs_api.prototype.FontSizeOut.bind(editor); + editor.asc_getChartObject = Asc.asc_docs_api.prototype.asc_getChartObject.bind(editor); + editor.asc_AddMath2 = Asc.asc_docs_api.prototype.asc_AddMath2.bind(editor); + editor.IncreaseIndent = Asc.asc_docs_api.prototype.IncreaseIndent.bind(editor); + editor.DecreaseIndent = Asc.asc_docs_api.prototype.DecreaseIndent.bind(editor); + editor.get_ShowParaMarks = Asc.asc_docs_api.prototype.get_ShowParaMarks.bind(editor); + editor.retrieveFormatPainterData = Asc.asc_docs_api.prototype.retrieveFormatPainterData.bind(editor); + editor.sync_EndAddShape = Asc.asc_docs_api.prototype.sync_EndAddShape.bind(editor); + editor.asc_getShowGuides = Asc.asc_docs_api.prototype.asc_getShowGuides.bind(editor); + editor.sync_HyperlinkClickCallback = Asc.asc_docs_api.prototype.sync_HyperlinkClickCallback.bind(editor); + AscCommon.CDocsCoApi.prototype.askSaveChanges = function (callback) { - const fOldSave = editor._onSaveCallbackInner; - let bCheck = false; - editor._onSaveCallbackInner = function () + window.setTimeout(function () { - bCheck = true; - editor.canSave = true; - }; - onKeyDown(oMockEvent); - oAssert.strictEqual(bCheck, true, 'Check save shortcut'); - editor._onSaveCallbackInner = fOldSave; + callback({"saveLock": false}); + }, 0); + }; + function CreateSlide() + { + logicDocument.addNextSlide(0); + editor.WordControl.Thumbnails.SlidesCount = logicDocument.Slides.length; + editor.WordControl.m_oDrawingDocument.SlidesCount = logicDocument.Slides.length; + editor.WordControl.Thumbnails.CalculatePlaces(); } - $(function () + function GoToSlide(slide) { - QUnit.module('Check shortcut focus', { - before: function () - { - addSlide(); - }, - after : function () - { - cleanPresentation(); - } - }); - QUnit.test('check shortcut focus', (oAssert) => - { - editor.StartDemonstration("presentation-preview", 0); - let bCheck = false; - let fOldKeyDown; - fOldKeyDown = editor.WordControl.DemonstrationManager.onKeyDown; - editor.WordControl.DemonstrationManager.onKeyDown = function () - { - bCheck = true; - } - editor.WordControl.onKeyDown(createNativeEvent()); - oAssert.true(bCheck, 'Check demonstration onKeyDown'); - editor.WordControl.DemonstrationManager.onKeyDown = fOldKeyDown; - editor.EndDemonstration(); - - bCheck = false; - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - fOldKeyDown = editor.WordControl.Thumbnails.onKeyDown; - editor.WordControl.Thumbnails.onKeyDown = function () - { - bCheck = true; - } - editor.WordControl.onKeyDown(createNativeEvent()); - oAssert.true(bCheck, 'Check thumbnails onKeyDown'); - editor.WordControl.Thumbnails.onKeyDown = fOldKeyDown; - - bCheck = false; - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - fOldKeyDown = editor.WordControl.m_oLogicDocument.OnKeyDown; - editor.WordControl.m_oLogicDocument.OnKeyDown = function () - { - bCheck = true; - } - editor.WordControl.onKeyDown(createNativeEvent()); - oAssert.true(bCheck, 'Check logic document onKeyDown'); - editor.WordControl.m_oLogicDocument.OnKeyDown = fOldKeyDown; - }); + editor.WordControl.GoToPage(slide); + } - QUnit.module("Test thumbnails main focus shortcuts", { - beforeEach: function () - { - cleanPresentation(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - }, - afterEach : function () - { - cleanPresentation(); - } - }); - QUnit.test('Test add next slide', (oAssert) => - { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - const arrOldSlides = oGlobalLogicDocument.Slides.slice(); - onKeyDown(oEvent); - const arrSelectedSlides = oGlobalLogicDocument.GetSelectedSlides(); - oAssert.true(checkSelectedSlides([1]) && (arrOldSlides.indexOf(oGlobalLogicDocument.Slides[arrSelectedSlides[0]]) === -1)); + function CleanPresentation() + { + editor.WordControl.Thumbnails.SelectAll(); + logicDocument.deleteSlides(logicDocument.GetSelectedSlides()); + } - }, oThumbnailsMainFocusTypes.addNextSlide); - }); + function AddShape(x, y, height, width) + { + AscCommon.History.Create_NewPoint(); + const shapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, AscFormat.GetDefaultTheme(), null, null, null, 0); + shapeTrack.track({}, x, y); + const shape = shapeTrack.getShape(false, AscTest.DrawingDocument, null); + shape.setBDeleted(false); + shape.spPr.xfrm.setExtX(width); + shape.spPr.xfrm.setExtY(height); + shape.setParent(logicDocument.Slides[0]); + shape.addToDrawingObjects(); + shape.select(GetDrawingObjects(), 0); + return shape; + } - QUnit.test('Test move to previous slide', (oAssert) => - { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(4, FOCUS_OBJECT_MAIN); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([3])); - }, oThumbnailsMainFocusTypes.moveToPreviousSlide); - }); + function SelectTitle(chart) + { + SelectDrawings([chart]); + const titles = chart.getAllTitles(); + const controller = GetDrawingObjects(); + controller.selection.chartSelection = chart; + chart.selectTitle(titles[0], 0); + } - QUnit.test('Test move to next slide', (oAssert) => - { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([1])); - }, oThumbnailsMainFocusTypes.moveToNextSlide); - }); + function AddChart() + { + const chart = editor.asc_getChartObject(Asc.c_oAscChartTypeSettings.lineNormal); + chart.setParent(logicDocument.Slides[0]); + + chart.addToDrawingObjects(); + chart.spPr.setXfrm(new AscFormat.CXfrm()); + chart.spPr.xfrm.setOffX(0); + chart.spPr.xfrm.setOffY(0); + chart.spPr.xfrm.setExtX(100); + chart.spPr.xfrm.setExtY(100); + logicDocument.Recalculate(); + return chart; + } - QUnit.test('Test move to first slide', (oAssert) => - { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(4, FOCUS_OBJECT_MAIN); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0])); - }, oThumbnailsMainFocusTypes.moveToFirstSlide); - }); + function AddPlaceholderShape() + { + const shape = AddShape(0, 0, 100, 100); + shape.setNvSpPr(new AscFormat.UniNvPr()); + let placeholder = new AscFormat.Ph(); + placeholder.setType(AscFormat.phType_title); + shape.nvSpPr.nvPr.setPh(placeholder); + shape.txBody = AscFormat.CreateTextBodyFromString('', shape.getDrawingDocument(), shape); + + shape.recalculateContentWitCompiledPr(); + return shape; + } - QUnit.test('Test select to first slide', (oAssert) => - { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(4, FOCUS_OBJECT_MAIN); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0, 1, 2, 3, 4])); - }, oThumbnailsMainFocusTypes.selectToFirstSlide); - }); + function AddTable(columns, rows) + { + return logicDocument.Add_FlowTable(columns, rows); + } - QUnit.test('Test move to last slide', (oAssert) => + function CreateGroup(arrObjects) + { + const controller = GetDrawingObjects(); + controller.resetSelection(); + for (let i = 0; i < arrObjects.length; i += 1) { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([4])); - }, oThumbnailsMainFocusTypes.moveToLastSlide); - }); + arrObjects[i].select(controller, 0); + } - QUnit.test('Test select to last slide', (oAssert) => - { - startThumbnailsMainFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0, 1, 2, 3, 4])); - }, oThumbnailsMainFocusTypes.selectToLastSlide); - }); + return controller.createGroup(); + } + + function ClearShapeAndAddParagraph(sText) + { + const textShape = AddShape(0, 0, 100, 100); + textShape.setPaddings({Left: 0, Top: 0, Right: 0, Bottom: 0}); + const txBody = AscFormat.CreateTextBodyFromString(sText, editor.WordControl.m_oDrawingDocument, textShape) + textShape.setTxBody(txBody); + const content = txBody.content; + content.SetThisElementCurrent(); + content.MoveCursorToStartPos(); + textShape.recalculate(); + return {shape: textShape, paragraph: content.Content[0]}; + } - QUnit.test('Test thumbnails shortcut actions', (oAssert) => + function GetDirectTextPr() + { + return logicDocument.GetDirectTextPr(); + } + + function GetDirectParaPr() + { + return logicDocument.GetDirectParaPr(); + } + + function Round(number, amount) + { + const power = Math.pow(10, amount); + return Math.round(number * power) / power; + } + + function SelectDrawings(arrDrawings) + { + const drawingController = GetDrawingObjects(); + drawingController.resetSelection() + for (let i = 0; i < arrDrawings.length; i += 1) { - cleanPresentation(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); - const fOldShortcut = editor.getShortcut; - goToPage(0); - - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.EditSelectAll;}; - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(createNativeEvent()); - oAssert.true(checkSelectedSlides([0, 1, 2, 3]), 'Check select all slides'); - - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Duplicate;}; - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - const arrOldSlides = oGlobalLogicDocument.Slides.slice(); - onKeyDown(createNativeEvent()); - oAssert.true(checkSelectedSlides([1]) && oGlobalLogicDocument.Slides.length === 5 && arrOldSlides.indexOf(oGlobalLogicDocument.Slides[1]) === -1, 'Check duplicate slides'); - - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Print;}; - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - executeTestWithCatchEvent('asc_onPrint', () => true, true, createNativeEvent(), oAssert); - - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Save;}; - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - checkSave(oAssert); - - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.ShowContextMenu;}; - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oMockEvent, oAssert); - - cleanPresentation(); - editor.getShortcut = fOldShortcut; - }); + arrDrawings[i].select(drawingController, 0); + } + } + + function GetDrawingObjects() + { + return editor.getGraphicController(); + } - QUnit.module('Test thumbnails hotkeys', { + QUnit.module("Test shortcuts", + { + afterEach : function () + { + CleanPresentation(); + }, + beforeEach: function () + { + CreateSlide(); + }, before: function () { - cleanPresentation(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); + AscTest.TurnOffRecalculate(); }, - after : function () + after: function () { - cleanPresentation(); + AscTest.TurnOnRecalculate(); } }); - let arrOldSlides; - let oOldSlide; - QUnit.test('Test thumbnails focus event', (oAssert) => + QUnit.test('Check actions with slides', (assert) => + { + AscTest.TurnOnRecalculate(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + + function CheckSelectedSlides(arrSelectedSlides) { - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - arrOldSlides = oGlobalLogicDocument.Slides.slice(); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([1]) && arrOldSlides.indexOf(oGlobalLogicDocument.Slides[1]) === -1, 'Check add next slide'); - }, oThumbnailsTypes.addNextSlide); + const presentationSelectedSlides = logicDocument.GetSelectedSlides(); + assert.deepEqual(presentationSelectedSlides, arrSelectedSlides, 'Check selected slides ' + arrSelectedSlides.join(', ')); + } - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - oOldSlide = getFirstSlide(); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0]) && oGlobalLogicDocument.Slides.indexOf(oOldSlide) === -1, 'Check remove selected slides'); - }, oThumbnailsTypes.removeSelectedSlides); + GoToSlide(0); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - const oFirstSlide = getFirstSlide(); - onKeyDown(oEvent); - oAssert.true(oGlobalLogicDocument.Slides[3] === oFirstSlide, 'Check move selected slides to end'); - }, oThumbnailsTypes.moveSelectedSlidesToEnd); + let oldSlides = logicDocument.Slides.slice(); + ExecuteThumbnailHotkey(thumbnailsTypes.addNextSlide, 0); + CheckSelectedSlides([1]); + assert.strictEqual(oldSlides.indexOf(logicDocument.Slides[1]), -1, 'Check add next slide'); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - const oFirstSlide = getFirstSlide(); - onKeyDown(oEvent); - oAssert.true(oGlobalLogicDocument.Slides[1] === oFirstSlide, 'Check move selected slides to next pos'); - }, oThumbnailsTypes.moveSelectedSlidesToNextPosition); + oldSlides = logicDocument.Slides.slice(); + ExecuteThumbnailHotkey(thumbnailsTypes.addNextSlide, 1); + CheckSelectedSlides([2]); + assert.strictEqual(oldSlides.indexOf(logicDocument.Slides[2]), -1, 'Check add next slide'); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0, 1]), 'Check select next slide'); - }, oThumbnailsTypes.selectNextSlide); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToNextSlide, 0); + CheckSelectedSlides([3]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([1]), 'Check move to next slide'); - }, oThumbnailsTypes.moveToNextSlide); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToNextSlide, 1); + CheckSelectedSlides([4]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(2, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0]), 'Check move to first slide'); - }, oThumbnailsTypes.moveToFirstSlide); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToPreviousSlide, 0); + CheckSelectedSlides([3]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(2, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0, 1, 2]), 'Check select from current position to first slide'); - }, oThumbnailsTypes.selectToFirstSlide); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToPreviousSlide, 1); + CheckSelectedSlides([2]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([3]), 'Check move to last slide'); - }, oThumbnailsTypes.moveToLastSlide); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToLastSlide); + CheckSelectedSlides([6]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(0, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([0, 1, 2, 3]), 'Check select from current position to last slide'); - }, oThumbnailsTypes.selectToLastSlide); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToFirstSlide); + CheckSelectedSlides([0]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(2, FOCUS_OBJECT_THUMBNAILS); - const oLastSlide = oGlobalLogicDocument.Slides[2]; - onKeyDown(oEvent); - oAssert.true(getFirstSlide() === oLastSlide, 'Check move selected slides to start'); - }, oThumbnailsTypes.moveSelectedSlidesToStart); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToLastSlide); + CheckSelectedSlides([6]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(2, FOCUS_OBJECT_THUMBNAILS); - const oLastSlide = oGlobalLogicDocument.Slides[2]; - onKeyDown(oEvent); - oAssert.true(oGlobalLogicDocument.Slides[1] === oLastSlide, 'Check move selected slides to previous pos'); - }, oThumbnailsTypes.moveSelectedSlidesToPreviousPosition); + ExecuteThumbnailHotkey(thumbnailsTypes.moveToFirstSlide); + CheckSelectedSlides([0]); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(2, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([1, 2]), 'Check select previous slide'); - }, oThumbnailsTypes.selectPreviousSlide); - startThumbnailsFocusTest((oEvent) => - { - goToPageWithFocus(2, FOCUS_OBJECT_THUMBNAILS); - onKeyDown(oEvent); - oAssert.true(checkSelectedSlides([1]), 'Check move to previous slide'); - }, oThumbnailsTypes.moveToPreviousSlide); - }); + ExecuteThumbnailHotkey(thumbnailsTypes.selectNextSlide, 0); + CheckSelectedSlides([0, 1]); - QUnit.module('Test demonstration mode shortcuts', { - beforeEach: function () - { - cleanPresentation(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); - addSlide(); - }, - afterEach : function () - { - cleanPresentation(); - } - }); + ExecuteThumbnailHotkey(thumbnailsTypes.selectNextSlide, 1); + CheckSelectedSlides([0, 1, 2]); - QUnit.test('Test demonstration mode shortcuts', (oAssert) => - { - editor.StartDemonstration("presentation-preview", 0); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 1, oDemonstrationEvents[oDemonstrationTypes.moveToNextSlide][0].event, oAssert); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 2, oDemonstrationEvents[oDemonstrationTypes.moveToNextSlide][1].event, oAssert); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 3, oDemonstrationEvents[oDemonstrationTypes.moveToNextSlide][2].event, oAssert); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 4, oDemonstrationEvents[oDemonstrationTypes.moveToNextSlide][3].event, oAssert); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 5, oDemonstrationEvents[oDemonstrationTypes.moveToNextSlide][4].event, oAssert); + GoToSlide(2); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 4, oDemonstrationEvents[oDemonstrationTypes.moveToPreviousSlide][0].event, oAssert); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 3, oDemonstrationEvents[oDemonstrationTypes.moveToPreviousSlide][1].event, oAssert); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 2, oDemonstrationEvents[oDemonstrationTypes.moveToPreviousSlide][2].event, oAssert); + ExecuteThumbnailHotkey(thumbnailsTypes.selectPreviousSlide, 0); + CheckSelectedSlides([1, 2]); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 0, oDemonstrationEvents[oDemonstrationTypes.moveToFirstSlide][0].event, oAssert); + ExecuteThumbnailHotkey(thumbnailsTypes.selectPreviousSlide, 0); + CheckSelectedSlides([0, 1, 2]); - executeTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 5, oDemonstrationEvents[oDemonstrationTypes.moveToLastSlide][0].event, oAssert); + ExecuteThumbnailHotkey(thumbnailsTypes.selectToLastSlide); + CheckSelectedSlides([2, 3, 4, 5, 6]); - executeTestWithCatchEvent('asc_onEndDemonstration', () => true, true, oDemonstrationEvents[oDemonstrationTypes.exitFromDemonstrationMode][0].event, oAssert); + ExecuteThumbnailHotkey(thumbnailsTypes.selectPreviousSlide, 1); + CheckSelectedSlides([2, 3, 4, 5]); - editor.EndDemonstration(); - }); + ExecuteThumbnailHotkey(thumbnailsTypes.selectPreviousSlide, 1); + CheckSelectedSlides([2, 3, 4]); - QUnit.module("Test main focus shortcuts", { - beforeEach: function () - { - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - }, - afterEach : function () - { - cleanPresentation(); - } - }); - QUnit.test('Test if the desired action is received by the keyboard shortcut.', (oAssert) => - { - let oEvent; - oEvent = createEvent(65, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.EditSelectAll, 'Check getting select all shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.selectToLastSlide); + CheckSelectedSlides([2, 3, 4, 5, 6]); - oEvent = createEvent(90, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.EditUndo, 'Check getting undo shortcut action'); + GoToSlide(3); - oEvent = createEvent(89, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.EditRedo, 'Check getting redo shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.selectToFirstSlide); + CheckSelectedSlides([0, 1, 2, 3]); - oEvent = createEvent(88, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Cut, 'Check getting cut shortcut action'); + GoToSlide(3); - oEvent = createEvent(67, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Copy, 'Check getting copy shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.selectToFirstSlide); + CheckSelectedSlides([0, 1, 2, 3]); - oEvent = createEvent(86, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Paste, 'Check getting paste shortcut action'); + let startPositionSlides = logicDocument.Slides.slice(); - oEvent = createEvent(68, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Duplicate, 'Check getting duplicate shortcut action'); + function CheckMoveSlides(oldPositions, newPositions) + { + for (let i = 0; i < oldPositions.length; i += 1) + { + assert.true(startPositionSlides[oldPositions[i]] === logicDocument.Slides[newPositions[i]], 'Check position ' + oldPositions[i] + '->' + newPositions[i]); + } + startPositionSlides = logicDocument.Slides.slice(); + } - oEvent = createEvent(80, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Print, 'Check getting print shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToNextPosition, 0); + CheckSelectedSlides([1, 2, 3, 4]); + CheckMoveSlides([0, 1, 2, 3], [1, 2, 3, 4]); - oEvent = createEvent(83, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Save, 'Check getting save shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToNextPosition, 1); + CheckSelectedSlides([2, 3, 4, 5]); + CheckMoveSlides([1, 2, 3, 4], [2, 3, 4, 5]); - oEvent = createEvent(93, false, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.ShowContextMenu, 'Check getting show context menu shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToStart, 0); + CheckSelectedSlides([0, 1, 2, 3]); + CheckMoveSlides([2, 3, 4, 5], [0, 1, 2, 3]); - oEvent = createEvent(121, false, true, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.ShowContextMenu, 'Check getting show context menu shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToEnd, 0); + CheckSelectedSlides([3, 4, 5, 6]); + CheckMoveSlides([0, 1, 2, 3], [3, 4, 5, 6]); - oEvent = createEvent(57351, false, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.ShowContextMenu, 'Check getting show context menu shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToStart, 1); + CheckSelectedSlides([0, 1, 2, 3]); + CheckMoveSlides([3, 4, 5, 6], [0, 1, 2, 3]); - oEvent = createEvent(56, true, true, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.ShowParaMarks, 'Check getting show paragraph marks shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToEnd, 1); + CheckSelectedSlides([3, 4, 5, 6]); + CheckMoveSlides([0, 1, 2, 3], [3, 4, 5, 6]); - oEvent = createEvent(66, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Bold, 'Check getting bold shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToPreviousPosition, 0); + CheckSelectedSlides([2, 3, 4, 5]); + CheckMoveSlides([3, 4, 5, 6], [2, 3, 4, 5]); - oEvent = createEvent(67, true, false, true, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.CopyFormat, 'Check getting copy format shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.moveSelectedSlidesToPreviousPosition, 1); + CheckSelectedSlides([1, 2, 3, 4]); + CheckMoveSlides([2, 3, 4, 5], [1, 2, 3, 4]); - oEvent = createEvent(69, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.CenterAlign, 'Check getting center align shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.removeSelectedSlides, 0); + assert.strictEqual(logicDocument.Slides.length, 3, 'Check slide amount'); + assert.true(logicDocument.Slides[0] === startPositionSlides[0], 'Check saved slides'); + assert.true(logicDocument.Slides[1] === startPositionSlides[5], 'Check saved slides'); + assert.true(logicDocument.Slides[2] === startPositionSlides[6], 'Check saved slides'); - oEvent = createEvent(69, true, false, true, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.EuroSign, 'Check getting euro sign shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.removeSelectedSlides, 1); + assert.strictEqual(logicDocument.Slides.length, 2, 'Check slide amount'); + assert.true(logicDocument.Slides[0] === startPositionSlides[0], 'Check saved slides'); + assert.true(logicDocument.Slides[1] === startPositionSlides[6], 'Check saved slides'); - oEvent = createEvent(71, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Group, 'Check getting group shortcut action'); + ExecuteThumbnailHotkey(thumbnailsTypes.removeSelectedSlides, 1); + assert.strictEqual(logicDocument.Slides.length, 1, 'Check slide amount'); + assert.true(logicDocument.Slides[0] === startPositionSlides[0], 'Check saved slides'); - oEvent = createEvent(71, true, true, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.UnGroup, 'Check getting ungroup shortcut action'); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); - oEvent = createEvent(73, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Italic, 'Check getting italic shortcut action'); + GoToSlide(0); - oEvent = createEvent(74, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.JustifyAlign, 'Check getting justify align shortcut action'); + oldSlides = logicDocument.Slides.slice(); + ExecuteMainHotkey(mainShortcutTypes.addNextSlide); + CheckSelectedSlides([1]); + assert.strictEqual(oldSlides.indexOf(logicDocument.Slides[1]), -1, 'Check add next slide'); - oEvent = createEvent(75, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.AddHyperlink, 'Check getting add hyperlink shortcut action'); + ExecuteThumbnailShortcut(Asc.c_oAscPresentationShortcutType.EditSelectAll); + CheckSelectedSlides([0, 1, 2, 3, 4, 5, 6]); - oEvent = createEvent(76, true, true, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.BulletList, 'Check getting bullet list shortcut action'); + GoToSlide(1); - oEvent = createEvent(76, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.LeftAlign, 'Check getting left align shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToNextSlide, 0); + CheckSelectedSlides([2]); - oEvent = createEvent(82, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.RightAlign, 'Check getting right align shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToPreviousSlide, 0); + CheckSelectedSlides([1]); - oEvent = createEvent(85, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Underline, 'Check getting underline shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToNextSlide, 1); + CheckSelectedSlides([2]); - oEvent = createEvent(53, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Strikethrough, 'Check getting strikethrough shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToPreviousSlide, 1); + CheckSelectedSlides([1]); - oEvent = createEvent(86, true, false, true, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.PasteFormat, 'Check getting paste format shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToNextSlide, 2); + CheckSelectedSlides([2]); - oEvent = createEvent(187, true, true, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Superscript, 'Check getting superscript shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToPreviousSlide, 2); + CheckSelectedSlides([1]); - oEvent = createEvent(188, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Superscript, 'Check getting superscript shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToLastSlide); + CheckSelectedSlides([6]); - oEvent = createEvent(187, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Subscript, 'Check getting subscript shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.moveToFirstSlide); + CheckSelectedSlides([0]); - oEvent = createEvent(190, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.Subscript, 'Check getting subscript shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.selectToLastSlide); + CheckSelectedSlides([0, 1, 2, 3, 4, 5, 6]); - oEvent = createEvent(189, true, true, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.EnDash, 'Check getting en dash shortcut action'); + GoToSlide(3); - oEvent = createEvent(219, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.DecreaseFont, 'Check getting decrease font size shortcut action'); + ExecuteMainHotkey(mainShortcutTypes.selectToFirstSlide); + CheckSelectedSlides([0, 1, 2, 3]); + AscTest.TurnOffRecalculate(); + }); - oEvent = createEvent(221, true, false, false, false, false); - oAssert.strictEqual(editor.getShortcut(oEvent), Asc.c_oAscPresentationShortcutType.IncreaseFont, 'Check getting increase font size shortcut action'); - }); + QUnit.test('Check actions with catch events', (oAssert) => + { + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); - let fOldGetShortcut; - QUnit.module('Test main shortcut actions', { - before: function () - { - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - fOldGetShortcut = editor.getShortcut; - }, - after : function () + let Execute; + + function ExecuteTestWithCatchEvent(sSendEvent, fCustomCheck, customExpectedValue, oEvent) + { + let check = false; + + const Check = function (...args) { - cleanPresentation(); - editor.getShortcut = fOldGetShortcut; + if (fCustomCheck) + { + check = fCustomCheck(...args); + } + else + { + check = true; + } } - }); + editor.asc_registerCallback(sSendEvent, Check); - QUnit.test('Test undo shortcut', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.EditUndo;}; - createShape(); - onKeyDown(oMockEvent); - oAssert.strictEqual(getFirstSlide().cSld.spTree.length, 0); - }); + Execute(oEvent); + oAssert.strictEqual(check, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); + editor.asc_unregisterCallback(sSendEvent, Check); + } - QUnit.test('Test redo shortcut', (oAssert) => - { - const oUndoShape = createShape(); - editor.Undo(); - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.EditRedo;}; - onKeyDown(oMockEvent); - oAssert.strictEqual(getFirstSlide().cSld.spTree.length === 1 && getFirstSlide().cSld.spTree[0] === oUndoShape, true); - }); + editor.WordControl.DemonstrationManager.Start(null, 0); + Execute = ExecuteDemonstrationShortcut; + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 1, demonstrationEvents[demonstrationTypes.moveToNextSlide][0]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 2, demonstrationEvents[demonstrationTypes.moveToNextSlide][1]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 3, demonstrationEvents[demonstrationTypes.moveToNextSlide][2]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 4, demonstrationEvents[demonstrationTypes.moveToNextSlide][3]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 5, demonstrationEvents[demonstrationTypes.moveToNextSlide][4]); - QUnit.test('Test select all shortcut', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.EditSelectAll;}; - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - const oFirstShape = createShape(); - const oSecondShape = createShape(); - onKeyDown(oMockEvent); - const oController = getController(); - oAssert.strictEqual(oController.selectedObjects.length === 2 && oController.selectedObjects.indexOf(oFirstShape) !== -1 && oController.selectedObjects.indexOf(oSecondShape) !== -1, true); - }); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 4, demonstrationEvents[demonstrationTypes.moveToPreviousSlide][0]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 3, demonstrationEvents[demonstrationTypes.moveToPreviousSlide][1]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 2, demonstrationEvents[demonstrationTypes.moveToPreviousSlide][2]); - QUnit.test('Test duplicate shape', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Duplicate;}; - const {oShape} = getShapeWithParagraphHelper('', true); - const arrOldSpTree = oGlobalLogicDocument.Slides[0].cSld.spTree.slice(); - selectOnlyObjects([oShape]); - onKeyDown(oMockEvent); - const arrUpdatedSpTree = oGlobalLogicDocument.Slides[0].cSld.spTree; - const oNewShape = arrUpdatedSpTree[arrUpdatedSpTree.length - 1]; - oAssert.true(arrOldSpTree.indexOf(oNewShape) === -1); - }); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 0, demonstrationEvents[demonstrationTypes.moveToFirstSlide][0]); - QUnit.test('Test print', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Print;}; - executeTestWithCatchEvent('asc_onPrint', () => true, true, oMockEvent, oAssert); - }); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 5, demonstrationEvents[demonstrationTypes.moveToLastSlide][0]); - QUnit.test('Test save', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Save;}; - checkSave(oAssert); - }); + ExecuteTestWithCatchEvent('asc_onEndDemonstration', () => true, true, demonstrationEvents[demonstrationTypes.exitFromDemonstrationMode][0]); - QUnit.test('Test context menu', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.ShowContextMenu;}; - executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oMockEvent, oAssert, () => - { - const {oParagraph} = getShapeWithParagraphHelper(''); - oParagraph.SetThisElementCurrent(); - }); - }); + Execute = ExecuteMainShortcut; + ExecuteTestWithCatchEvent('asc_onPrint', () => true, true, Asc.c_oAscPresentationShortcutType.Print); + ExecuteTestWithCatchEvent('asc_onContextMenu', () => true, true, Asc.c_oAscPresentationShortcutType.ShowContextMenu); - QUnit.test('Test show para marks', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.ShowParaMarks;}; - editor.put_ShowParaMarks(false); - onKeyDown(oMockEvent); - oAssert.true(!!editor.get_ShowParaMarks(), 'Check show para marks shortcut'); - }); + ClearShapeAndAddParagraph('') + ExecuteTestWithCatchEvent('asc_onDialogAddHyperlink', () => true, true, Asc.c_oAscPresentationShortcutType.AddHyperlink); - QUnit.test('Test bold shortcut', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Bold;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Bold(), oMockEvent, oAssert, true, 'Check bold shortcut'); - }); + Execute = ExecuteThumbnailShortcut; + GoToSlide(0, FOCUS_OBJECT_THUMBNAILS); + ExecuteTestWithCatchEvent('asc_onPrint', () => true, true, Asc.c_oAscPresentationShortcutType.Print); + ExecuteTestWithCatchEvent('asc_onContextMenu', () => true, true, Asc.c_oAscPresentationShortcutType.ShowContextMenu); - function getCopyParagraphPrTest() - { - const oCopyParagraphTextPr = new AscCommonWord.CTextPr(); - oCopyParagraphTextPr.SetUnderline(true); - oCopyParagraphTextPr.SetBold(true); - oCopyParagraphTextPr.BoldCS = true; - oCopyParagraphTextPr.SetItalic(true); - oCopyParagraphTextPr.ItalicCS = true; - return oCopyParagraphTextPr; - } + GoToSlide(0, FOCUS_OBJECT_MAIN); + }); - QUnit.test('Test copy format', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.CopyFormat;}; - const {oParagraph} = getShapeWithParagraphHelper('Hello World'); - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - addPropertyToDocument({Bold: true, Italic: true, Underline: true}); - - onKeyDown(oMockEvent); - const oTextPr = editor.getFormatPainterData().TextPr; - oAssert.strictEqual(oTextPr.Get_Bold(), true, 'Check copy format shortcut'); - oAssert.strictEqual(oTextPr.Get_Italic(), true, 'Check copy format shortcut'); - oAssert.strictEqual(oTextPr.Get_Underline(), true, 'Check copy format shortcut'); - }); + QUnit.test('Check add various characters', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph(''); + ExecuteMainHotkey(mainShortcutTypes.checkNonBreakingSpace); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0), 'Check add non breaking space'); - QUnit.test('Test paste format', (oAssert) => - { - let oParagraph; - oParagraph = getShapeWithParagraphHelper('Hello World').oParagraph; - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - addPropertyToDocument({Bold: true, Italic: true, Underline: true}); - oGlobalLogicDocument.Document_Format_Copy(); - - - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.PasteFormat;}; - oParagraph = getShapeWithParagraphHelper('Hello World').oParagraph; - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - - onKeyDown(oMockEvent); - const oDirectTextPr = oParagraph.GetDirectTextPr(); - oAssert.strictEqual(oDirectTextPr.Get_Bold(), true, 'Check copy format shortcut'); - oAssert.strictEqual(oDirectTextPr.Get_Italic(), true, 'Check copy format shortcut'); - oAssert.strictEqual(oDirectTextPr.Get_Underline(), true, 'Check copy format shortcut'); - }); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.EuroSign); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x20AC), 'Check add euro sign'); - QUnit.test('Test center align', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.CenterAlign;}; - checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.GetJc(), oMockEvent, oAssert, AscCommon.align_Center, 'Check center align shortcut'); - }); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.EnDash); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x20AC, 0x2013), 'Check add en dash'); - QUnit.test('Test insert euro sign', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.EuroSign;}; - checkTextAfterKeyDownHelperEmpty('€', oMockEvent, oAssert, 'Check euro sign shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkAddSpace); + assert.strictEqual(AscTest.GetParagraphText(paragraph), String.fromCharCode(0x00A0, 0x20AC, 0x2013, 0x0020), 'Check add space'); + }); - QUnit.test('Test group', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Group;}; - const oFirstShape = createShape(); - const oSecondShape = createShape(); - selectOnlyObjects([oFirstShape, oSecondShape]); - - onKeyDown(oMockEvent); - const oGroup = oFirstShape.group; - oAssert.true(oFirstShape.group && (oFirstShape.group === oSecondShape.group), 'Check group shortcut'); - }); + QUnit.test('Check actions with text movements', (assert) => + { + const {shape} = ClearShapeAndAddParagraph( + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'World Hello World'); + + function CheckCursorPosition(expected, description) + { + const position = shape.txBody.content.GetContentPosition(); + assert.strictEqual(position[position.length - 1].Position, expected, description); + } - QUnit.test('Test ungroup', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.UnGroup;}; - const oFirstShape = createShape(); - const oSecondShape = createShape(); - const oGroup = createGroup([oFirstShape, oSecondShape]); - selectOnlyObjects([oGroup]); - - onKeyDown(oMockEvent); - oAssert.true(!oFirstShape.group && !oSecondShape.group && oGroup.bDeleted, 'Check ungroup shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveToEndLineContent); + CheckCursorPosition(18, 'Check move to end line'); - QUnit.test('Test italic', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Italic;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Italic(), oMockEvent, oAssert, true, 'Check italic shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorRight); + CheckCursorPosition(19, 'Check move to right char'); - QUnit.test('Test justify align', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.JustifyAlign;}; - checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.GetJc(), oMockEvent, oAssert, AscCommon.align_Justify, 'check justify align shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorLeft); + CheckCursorPosition(18, 'Check move to left char'); - QUnit.test('Test open hyperlink dialog', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.AddHyperlink;}; - executeTestWithCatchEvent('asc_onDialogAddHyperlink', () => true, true, oMockEvent, oAssert, () => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello World'); - moveToParagraph(oParagraph); - oGlobalLogicDocument.SelectAll(); - }); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordLeft); + CheckCursorPosition(12, 'Check move to left word'); - QUnit.test('Test add bullet list to paragraphs', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.BulletList;}; - const {oParagraph} = getShapeWithParagraphHelper('Hello World'); - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - - onKeyDown(oMockEvent); - const oBullet = oParagraph.Get_PresentationNumbering(); - oAssert.true(oBullet.m_nType === AscFormat.numbering_presentationnumfrmt_Char, 'Check bullet list shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordRight); + CheckCursorPosition(18, 'Check move to right word'); - QUnit.test('Test left align', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.LeftAlign;}; - checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.GetJc(), oMockEvent, oAssert, AscCommon.align_Left, 'check right align shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordRight); + CheckCursorPosition(24, 'Check move to right word'); - QUnit.test('Test right align', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.RightAlign;}; - checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.GetJc(), oMockEvent, oAssert, AscCommon.align_Right, 'check right align shortcut'); - }); - QUnit.test('Test underline shortcut', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Underline;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Underline(), oMockEvent, oAssert, true, 'Check underline shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveToStartLineContent); + CheckCursorPosition(18, 'Check move to start line'); - QUnit.test('Test strikeout shortcut', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Strikethrough;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_Strikeout(), oMockEvent, oAssert, true, 'Check strikeout shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorBottom); + CheckCursorPosition(36, 'Check move down'); - QUnit.test('Test superscript vertalign', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Superscript;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetVertAlign(), oMockEvent, oAssert, AscCommon.vertalign_SuperScript, 'Check superscript shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorTop); + CheckCursorPosition(18, 'Check move up'); - QUnit.test('Test subscript vertalign', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.Subscript;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetVertAlign(), oMockEvent, oAssert, AscCommon.vertalign_SubScript, 'Check subscript shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveToEndPosContent); + CheckCursorPosition(161, 'Check move to end document'); - QUnit.test('Test en dash shortcut', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.EnDash;}; - checkTextAfterKeyDownHelperEmpty('–', oMockEvent, oAssert, 'Check en dash shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveToStartPosContent); + CheckCursorPosition(0, 'Check move to start document'); - QUnit.test('Test decrease font size', (oAssert) => + function CheckSelectedText(expectedText, description) { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.DecreaseFont;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_FontSize(), oMockEvent, oAssert, 9, 'Check decrease font size shortcut'); - }); + const selectedText = logicDocument.GetSelectedText(); + assert.strictEqual(selectedText, expectedText, description); + } - QUnit.test('Test increase font size', (oAssert) => - { - editor.getShortcut = function () {return Asc.c_oAscPresentationShortcutType.IncreaseFont;}; - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.Get_FontSize(), oMockEvent, oAssert, 11, 'Check increase font size shortcut'); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectToEndLineContent); + CheckSelectedText('Hello World Hello ', 'Select to end line'); - QUnit.module('Test hotkeys', { - before: function () - { - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - }, - after : function () - { - cleanPresentation(); - } - }); - QUnit.test('Test delete back char', (oAssert) => - { - startMainTest((oEvent) => - { - checkTextAfterKeyDownHelperHelloWorld('Hello Worl', oEvent, oAssert, 'Check delete with backspace') - }, oMainShortcutTypes.checkDeleteBack); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorRight); + CheckSelectedText('Hello World Hello W', 'Select to right char'); - QUnit.test('Test delete back word', (oAssert) => - { - startMainTest((oEvent) => - { - checkTextAfterKeyDownHelperHelloWorld('Hello ', oEvent, oAssert, 'Check delete word with backspace') - }, oMainShortcutTypes.checkDeleteWordBack); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorLeft); + CheckSelectedText('Hello World Hello ', 'Select to left char'); - QUnit.test('Test remove animation', (oAssert) => - { - startMainTest((oEvent) => - { - const {oShape} = getShapeWithParagraphHelper('', true); - selectOnlyObjects([oShape]); - oGlobalLogicDocument.AddAnimation(1, 1, 0, false, false); - - onKeyDown(oEvent); - const oTiming = oGlobalLogicDocument.GetCurTiming(); - const arrEffects = oTiming.getObjectEffects(oShape.GetId()); - oAssert.true(arrEffects.length === 0, 'Check remove animation'); - }, oMainShortcutTypes.checkRemoveAnimation); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorLeft); + CheckSelectedText('Hello World ', 'Select to left word'); - QUnit.test('Test remove chart', (oAssert) => - { - startMainTest((oEvent) => - { - const oChart1 = createChart(getFirstSlide()); - selectOnlyObjects([oChart1]); - onKeyDown(oEvent); - oAssert.true(checkRemoveObject(oChart1, getFirstSlide().cSld.spTree), "Check remove chart"); - }, oMainShortcutTypes.checkRemoveChart); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorRight); + CheckSelectedText('Hello World Hello ', 'Select to right word'); - QUnit.test('Test remove shape', (oAssert) => - { - startMainTest((oEvent) => - { - const {oShape} = getShapeWithParagraphHelper('', true); - selectOnlyObjects([oShape]); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorRight); + CheckSelectedText('Hello World Hello World ', 'Select to right word'); - onKeyDown(oEvent); - const arrSpTree = oGlobalLogicDocument.Slides[0].cSld.spTree; - oAssert.true(checkRemoveObject(oShape, arrSpTree), 'Check remove shape'); - }, oMainShortcutTypes.checkRemoveShape); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorRight); + CheckSelectedText('Hello World Hello World Hello ', 'Select to right word'); - QUnit.test('Test remove table', (oAssert) => - { - startMainTest((oEvent) => - { - const oGraphicFrame = createTable(3, 3); - selectOnlyObjects([oGraphicFrame]); - onKeyDown(oEvent); - const arrSpTree = getFirstSlide().cSld.spTree; - oAssert.true(checkRemoveObject(oGraphicFrame, arrSpTree), "Check remove table"); - }, oMainShortcutTypes.checkRemoveTable); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectToStartLineContent); + CheckSelectedText('Hello World Hello ', 'Select to start line'); - QUnit.test('Test remove group', (oAssert) => - { - startMainTest((oEvent) => - { - const oGroup1 = createGroup([createShape(), createShape()]); - selectOnlyObjects([oGroup1]); - onKeyDown(oEvent); - const arrSpTree = getFirstSlide().cSld.spTree; - oAssert.true(checkRemoveObject(oGroup1, arrSpTree), 'Check remove group'); - }, oMainShortcutTypes.checkRemoveGroup); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorBottom); + CheckSelectedText('Hello World Hello World Hello World ', 'Select down'); - QUnit.test('Test remove shape in group', (oAssert) => - { - startMainTest((oEvent) => - { - const oGroupedGroup = createGroup([createShape(), createShape()]); - const oRemovedShape = createShape(); - const oGroup1 = createGroup([oGroupedGroup, oRemovedShape]); - selectOnlyObjects([oRemovedShape]); - onKeyDown(oEvent); - oAssert.true(checkRemoveObject(oRemovedShape, oGroup1.spTree), 'Check remove shape in group'); - }, oMainShortcutTypes.checkRemoveShapeInGroup); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorTop); + CheckSelectedText('Hello World Hello ', 'Select up'); - //Tab - QUnit.test('Test go to next cell', (oAssert) => - { - startMainTest((oEvent) => - { - const oGraphicFrame = createTable(3, 3); - const oTable = oGraphicFrame.graphicObject; - onKeyDown(oEvent); - oAssert.strictEqual(oTable.CurCell.Index, 1, 'check go to next cell shortcut'); - }, oMainShortcutTypes.checkMoveToNextCell); - }); - QUnit.test('Test go to previous cell', (oAssert) => - { - startMainTest((oEvent) => - { - const oGraphicFrame = createTable(3, 3); - const oTable = oGraphicFrame.graphicObject; - moveCursorRight(); - onKeyDown(oEvent); - oAssert.strictEqual(oTable.CurCell.Index, 0, 'check go to previous cell shortcut'); - }, oMainShortcutTypes.checkMoveToPreviousCell); - }); + logicDocument.MoveCursorToEndPos(); + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorLeft); + CheckSelectedText('d', 'Select to left char'); - QUnit.test('Test bullet indent', (oAssert) => - { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello'); - const oBullet = AscFormat.fGetPresentationBulletByNumInfo({Type: 0, SubType: 1}); - oParagraph.Add_PresentationNumbering(oBullet); - moveToParagraph(oParagraph, true); - oParagraph.Set_Ind({Left: 0}); - onKeyDown(oEvent); - oAssert.strictEqual(oParagraph.Pr.Get_IndLeft(), 11.1125, 'Check bullet indent shortcut'); - }, oMainShortcutTypes.checkIncreaseBulletIndent); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorLeft); + CheckSelectedText('World', 'Select to left word'); + }); - QUnit.test('Test bullet unindent', (oAssert) => - { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello'); - const oBullet = AscFormat.fGetPresentationBulletByNumInfo({Type: 0, SubType: 1}); - oParagraph.Add_PresentationNumbering(oBullet); - oParagraph.Set_PresentationLevel(1); - moveToParagraph(oParagraph, true); - oParagraph.Set_Ind({Left: 11.1125}); - onKeyDown(oEvent); - oAssert.strictEqual(oParagraph.Pr.Get_IndLeft(), 0, 'Check bullet indent shortcut'); - }, oMainShortcutTypes.checkDecreaseBulletIndent); - }); + QUnit.test('Check remove parts of text', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph('Hello Hello Hello Hello'); + logicDocument.MoveCursorToEndPos(); - QUnit.test('Test add tab', (oAssert) => - { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper(''); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oGlobalLogicDocument.SelectAll(); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedText(false, {TabSymbol: '\t'}), '\t', 'Check add tab'); - }, oMainShortcutTypes.checkAddTab); - }); + ExecuteMainHotkey(mainShortcutTypes.checkDeleteBack); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hell', 'Check removing back symbol'); - QUnit.test('Test select next object', (oAssert) => - { - startMainTest((oEvent) => - { - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - const oFirstShape = createShape(); - const oSecondShape = createShape(); - const oThirdShape = createShape(); - selectOnlyObjects([oFirstShape]); - onKeyDown(oEvent); - oAssert.true(getController().getSelectedArray().length === 1 && getController().getSelectedArray()[0] === oSecondShape, 'Check select previous object'); - }, oMainShortcutTypes.checkSelectNextObject); - }); + ExecuteMainHotkey(mainShortcutTypes.checkDeleteWordBack); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing back word'); - QUnit.test('Test select previous object', (oAssert) => - { - startMainTest((oEvent) => - { - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - const oFirstShape = createShape(); - const oSecondShape = createShape(); - const oThirdShape = createShape(); - selectOnlyObjects([oFirstShape]); - onKeyDown(oEvent); - oAssert.true(getController().getSelectedArray().length === 1 && getController().getSelectedArray()[0] === oThirdShape, 'Check select previous object'); - }, oMainShortcutTypes.checkSelectPreviousObject); - }); - // Enter - QUnit.test('Test check visit hyperlink', (oAssert) => - { - startMainTest((oEvent) => - { - goToPage(1); - const {oParagraph} = getShapeWithParagraphHelper('Hello'); - moveToParagraph(oParagraph); - oGlobalLogicDocument.AddHyperlink({ - Text : 'abcd', - ToolTip: 'abcd', - Value : 'ppaction://hlinkshowjump?jump=firstslide' - }); - moveCursorLeft(); - moveCursorLeft(); - onKeyDown(oEvent); - const oSelectedInfo = oGlobalLogicDocument.IsCursorInHyperlink(); - oAssert.true(oSelectedInfo.Visited && oGlobalLogicDocument.GetSelectedSlides()[0] === 0, 'Check visit hyperlink'); - goToPage(0); - }, oMainShortcutTypes.checkVisitHyperlink); - }); + logicDocument.MoveCursorToStartPos(); + ExecuteMainHotkey(mainShortcutTypes.checkDeleteFront); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello ', 'Check removing front symbol'); + ExecuteMainHotkey(mainShortcutTypes.checkDeleteWordFront); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello ', 'Check removing front word'); + }); - QUnit.test('Test select shapes with placeholder', (oAssert) => - { - startMainTest((oEvent) => - { - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - const oFirstShapeWithPlaceholder = createShapeWithTitlePlaceholder(); - const oSecondShapeWithPlaceholder = createShapeWithTitlePlaceholder(); + QUnit.test('Check text property change', (assert) => + { + ClearShapeAndAddParagraph('Hello world'); + logicDocument.SelectAll(); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Bold); + assert.strictEqual(GetDirectTextPr().GetBold(), true, 'Check turn on bold'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Bold); + assert.strictEqual(GetDirectTextPr().GetBold(), false, 'Check turn off bold'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Italic); + assert.strictEqual(GetDirectTextPr().GetItalic(), true, 'Check turn on italic'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Italic); + assert.strictEqual(GetDirectTextPr().GetItalic(), false, 'Check turn off italic'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Strikethrough); + assert.strictEqual(GetDirectTextPr().GetStrikeout(), true, 'Check turn on strikeout'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Strikethrough); + assert.strictEqual(GetDirectTextPr().GetStrikeout(), false, 'Check turn off strikeout'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Underline); + assert.strictEqual(GetDirectTextPr().GetUnderline(), true, 'Check turn on underline'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Underline); + assert.strictEqual(GetDirectTextPr().GetUnderline(), false, 'Check turn off underline'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Superscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_SuperScript, 'Check turn on superscript'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Superscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off superscript'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Subscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_SubScript, 'Check turn on subscript'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Subscript); + assert.strictEqual(GetDirectTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off subscript'); + + // defaultSize = 10 + // 10 -> 11 -> 12 -> 14 -> 16 -> 14 -> 12 -> 11 -> 10 + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.IncreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 11, 'Check increase font size'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.IncreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 12, 'Check increase font size'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.IncreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 14, 'Check increase font size'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.IncreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 16, 'Check increase font size'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.DecreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 14, 'Check decrease font size'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.DecreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 12, 'Check decrease font size'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.DecreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 11, 'Check decrease font size'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.DecreaseFont); + assert.strictEqual(GetDirectTextPr().GetFontSize(), 10, 'Check decrease font size'); + }); - const oController = getController(); - oController.resetSelection(); - onKeyDown(oEvent); - oAssert.true(oController.selectedObjects.length === 1 && oController.selectedObjects[0] === oFirstShapeWithPlaceholder && oFirstShapeWithPlaceholder.selected, 'Check select first shape with placeholder'); + QUnit.test('Check paragraph property change', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph('Hello world'); - onKeyDown(oEvent); - oAssert.true(oController.selectedObjects.length === 1 && oController.selectedObjects[0] === oSecondShapeWithPlaceholder && oSecondShapeWithPlaceholder.selected, 'Check select second shape with placeholder'); - }, oMainShortcutTypes.checkSelectNextObjectWithPlaceholder); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check align left"); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.CenterAlign); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Center, "Check turn on center para"); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.JustifyAlign); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); - }); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.LeftAlign); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Left, "Check turn on left para"); - QUnit.test('Test add next slide after placeholder shape', (oAssert) => - { - startMainTest((oEvent) => - { - cleanPresentation(); - addSlide(); - goToPageWithFocus(0, FOCUS_OBJECT_MAIN); - - const oFirstShapeWithPlaceholder = createShapeWithTitlePlaceholder(); - selectOnlyObjects([oFirstShapeWithPlaceholder]); - const arrOldSlides = oGlobalLogicDocument.Slides.slice(); - onKeyDown(oEvent); - const arrSelectedSlides = oGlobalLogicDocument.GetSelectedSlides(); - oAssert.true(arrSelectedSlides.length === 1 && arrSelectedSlides[0] === 1 && arrOldSlides.indexOf(oGlobalLogicDocument.Slides[1]) === -1, 'Check add next slide after selecting last placeholder on current slide'); - goToPage(0); - }, oMainShortcutTypes.checkAddNextSlideAfterSelectLastPlaceholderObject); - }); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.RightAlign); + assert.strictEqual(GetDirectParaPr().GetJc(), AscCommon.align_Right, "Check turn on right para"); - QUnit.test('Test add break line', (oAssert) => - { - startMainTest((oEvent) => - { - const {oShape, oParagraph} = getShapeWithParagraphHelper(''); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - oAssert.true(oShape.getDocContent().Content.length === 1 && oParagraph.GetLinesCount() === 2, 'Check add break line'); - }, oMainShortcutTypes.checkAddBreakLine); - }); + paragraph.Set_PresentationLevel(0); + paragraph.Pr.SetInd(0, 0, 0); + ExecuteMainHotkey(mainShortcutTypes.checkIncreaseIndent); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 11.1125, "Check indent"); - QUnit.test('Test add break line in title', (oAssert) => - { - startMainTest((oEvent) => - { - const oShapeWithPlaceholder = createShapeWithTitlePlaceholder(); - const oContent = oShapeWithPlaceholder.getDocContent(); - const oParagraph = oContent.GetAllParagraphs()[0]; - oParagraph.SetThisElementCurrent(); - onKeyDown(oEvent); - oAssert.true(oContent.Content.length === 1 && oParagraph.GetLinesCount() === 2, 'Check add break line in title'); - }, oMainShortcutTypes.checkAddTitleBreakLine); - }); + ExecuteMainHotkey(mainShortcutTypes.checkDecreaseIndent); + assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0, "Check unindent"); - QUnit.test('Test add new line in math equation', (oAssert) => - { - startMainTest((oEvent) => - { - const {oParagraph} = createMathInShape(); - oGlobalLogicDocument.MoveCursorToStartPos(); - moveCursorRight(); - moveCursorRight(); - onInput([56, 56, 56, 56, 56, 56, 56]); - moveCursorLeft(); - moveCursorLeft(); - onKeyDown(oEvent); - const oParaMath = oParagraph.GetAllParaMaths()[0]; - const oFraction = oParaMath.Root.GetFirstElement(); - const oNumerator = oFraction.getNumerator(); - const oEqArray = oNumerator.GetFirstElement(); - oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); - }, oMainShortcutTypes.checkAddMathBreakLine); - }); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.BulletList); + const bullet = paragraph.Get_PresentationNumbering(); + assert.strictEqual(bullet.m_nType, AscFormat.numbering_presentationnumfrmt_Char, 'Check bullet list shortcut'); - QUnit.test('Test add new paragraph', (oAssert) => - { - startMainTest((oEvent) => - { - const {oShape, oParagraph} = getShapeWithParagraphHelper(''); - moveToParagraph(oParagraph); + paragraph.Pr.SetInd(0, 0, 0); + ExecuteMainHotkey(mainShortcutTypes.checkIncreaseBulletIndent); + assert.strictEqual(paragraph.Pr.Get_IndLeft(), 11.1125, 'Check bullet indent shortcut'); - onKeyDown(oEvent); - oAssert.true(oShape.getDocContent().Content.length === 2, 'Check add new paragraph'); - }, oMainShortcutTypes.checkAddParagraph); - }); + ExecuteMainHotkey(mainShortcutTypes.checkDecreaseBulletIndent); + assert.strictEqual(paragraph.Pr.Get_IndLeft(), 0, 'Check bullet unindent shortcut'); + }); - QUnit.test('Test creating txBody', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = createShape(); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.true(!!oShape.txBody, 'Check creating txBody'); - }, oMainShortcutTypes.checkAddTxBodyShape); - }); - QUnit.test('Test move cursor to start position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oShape, oParagraph} = getShapeWithParagraphHelper('', true); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.true(oParagraph.IsCursorAtBegin(), 'Check move cursor to start position in shape'); - }, oMainShortcutTypes.checkMoveCursorToStartPosShape); - }); - QUnit.test('Test select all content in shape', (oAssert) => - { - startMainTest((oEvent) => - { - const {oShape} = getShapeWithParagraphHelper('Hello Word', true); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedText(), 'Hello Word', 'Check select all content in shape'); - }, oMainShortcutTypes.checkSelectAllContentShape); - }); - QUnit.test('Test select all title', (oAssert) => - { - startMainTest((oEvent) => - { - const oChart = createChart(); - selectOnlyObjects([oChart]); - const oTitles = oChart.getAllTitles(); - const oController = getController(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); - - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedText(), 'Diagram Title', 'Check select all title'); - }, oMainShortcutTypes.checkSelectAllContentChartTitle); - }); - QUnit.test('Test move cursor to begin pos in title', (oAssert) => - { - startMainTest((oEvent) => - { - const oChart = createChart(); - const oTitles = oChart.getAllTitles(); - const oContent = AscFormat.CreateDocContentFromString('', editor.WordControl.m_oDrawingDocument, oTitles[0].txBody); - oTitles[0].txBody.content = oContent; - selectOnlyObjects([oChart]); - - const oController = getController(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); - - onKeyDown(oEvent); - oAssert.true(oContent.IsCursorAtBegin(), 'Check move cursor to begin pos in title'); - }, oMainShortcutTypes.checkMoveCursorToStartPosChartTitle); - }); - QUnit.test('Test remove and move to start position in table', (oAssert) => - { - startMainTest((oEvent) => - { - const arrSteps = []; - const oFrame = createTable(3, 3); - oFrame.Set_CurrentElement(); - const oTable1 = oFrame.graphicObject; - oTable1.MoveCursorToStartPos(); - // First cell - moveCursorRight(true, true); - moveCursorRight(true, true); - // Second cell - moveCursorRight(true, true); - // Third cell - moveCursorRight(true, true); - - onKeyDown(oEvent); - arrSteps.push(oTable1.IsCursorAtBegin()); - moveCursorRight(true, true); - moveCursorRight(true, true); - moveCursorRight(true, true); - arrSteps.push(oGlobalLogicDocument.GetSelectedText()); - oAssert.deepEqual(arrSteps, [true, ''], 'Check remove and move to start position in table'); - }, oMainShortcutTypes.checkRemoveAndMoveToStartPosTable); - }); - QUnit.test('Test select first cell content', (oAssert) => - { - startMainTest((oEvent) => - { - const oFrame = createTable(3, 3); - selectOnlyObjects([oFrame]); + QUnit.test('Check main actions with shapes', (assert) => + { + const drawing1 = AddShape(0, 0, 100, 200); - onKeyDown(oEvent); - oAssert.strictEqual(oGlobalLogicDocument.GetSelectedText(), 'Cell0x0', 'Check select first cell content'); - }, oMainShortcutTypes.checkSelectFirstCellContent); - }); - // Esc - QUnit.test('Test reset add new shape', (oAssert) => - { - startMainTest((oEvent) => - { - const oController = getController(); - oGlobalLogicDocument.StartAddShape('rect', true); - onKeyDown(oEvent); - oAssert.true(!oController.checkTrackDrawings(), 'Check reset add new shape'); - }, oMainShortcutTypes.checkResetAddShape); - }); + const dotsPerMM = logicDocument.DrawingDocument.GetDotsPerMM(); - QUnit.test('Test reset all selection', (oAssert) => + function CheckShapePosition(X, Y) { - startMainTest((oEvent) => - { - const oController = getController(); - oController.resetSelection(); - const oGroupedShape1 = createShape(); - const oGroupedShape2 = createShape(); - createGroup([oGroupedShape1, oGroupedShape2]); - addToSelection(oGroupedShape1); - const oTestGroup = oGroupedShape1.group; - onKeyDown(oEvent); - oAssert.true(oController.selectedObjects.length === 0, 'Check reset all selection'); - }, oMainShortcutTypes.checkResetAllDrawingSelection); - }); + assert.deepEqual([Round(drawing1.x * dotsPerMM, 10), Round(drawing1.y * dotsPerMM, 10), drawing1.extX, drawing1.extY], [X, Y, 200, 100], 'Check shape position after movement ' + X + ' ' + Y); + } - QUnit.test('Test reset step selection', (oAssert) => - { - startMainTest((oEvent) => - { - const oController = getController(); - const oGroupedShape1 = createShape(); - const oGroupedShape2 = createShape(); - createGroup([oGroupedShape1, oGroupedShape2]); - addToSelection(oGroupedShape1); - const oTestGroup = oGroupedShape1.group; - - selectOnlyObjects([oTestGroup, oGroupedShape1]); - onKeyDown(oEvent); - oAssert.true(oController.selectedObjects.length === 1 && oController.selectedObjects[0] === oTestGroup && oTestGroup.selectedObjects.length === 0, 'Check reset step selection'); - }, oMainShortcutTypes.checkResetStepDrawingSelection); - }); + SelectDrawings([drawing1]); - // Space - QUnit.test('Test add non breaking space', (oAssert) => - { - startMainTest((oEvent) => - { - checkTextAfterKeyDownHelperEmpty(String.fromCharCode(0x00A0), oEvent, oAssert, 'Check add non breaking space'); - }, oMainShortcutTypes.checkNonBreakingSpace); - }); + AscTest.TurnOnRecalculate(); + ExecuteMainHotkey(mainShortcutTypes.checkMoveShapeLeft); + CheckShapePosition(-5, 0); - QUnit.test('Test clear paragraph formatting', (oAssert) => - { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello World'); - oParagraph.SetThisElementCurrent(); - oGlobalLogicDocument.SelectAll(); - addPropertyToDocument({Bold: true, Italic: true, Underline: true}); - - onKeyDown(oEvent); - const oTextPr = oGlobalLogicDocument.GetDirectTextPr(); - oAssert.true(!(oTextPr.GetBold() || oTextPr.GetItalic() || oTextPr.GetUnderline()), 'Check clear paragraph formatting'); - }, oMainShortcutTypes.checkClearParagraphFormatting); - }); + ExecuteMainHotkey(mainShortcutTypes.checkLittleMoveShapeLeft); + CheckShapePosition(-6, 0); - QUnit.test('Test add space', (oAssert) => - { - startMainTest((oEvent) => - { - checkTextAfterKeyDownHelperEmpty(' ', oEvent, oAssert, 'Check add space') - }, oMainShortcutTypes.checkAddSpace); - }); - //pgUp + ExecuteMainHotkey(mainShortcutTypes.checkMoveShapeRight); + CheckShapePosition(-1, 0); - //End - QUnit.test('Test move cursor to end position shortcut', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, false, true, false); - oAssert.true(oPos.X === 25 && oPos.Y === 75, 'Check move cursor to end position shortcut'); - }, oMainShortcutTypes.checkMoveToEndPosContent); - }); + ExecuteMainHotkey(mainShortcutTypes.checkLittleMoveShapeRight); + CheckShapePosition(0, 0); - QUnit.test('Test move cursor to end line shortcut', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, false, true, false); - oAssert.true(oPos.X === 100 && oPos.Y === 15, 'Check move cursor to end line shortcut'); - }, oMainShortcutTypes.checkMoveToEndLineContent); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveShapeBottom); + CheckShapePosition(0, 5); - QUnit.test('Test select text to end line', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, false, false, true); - oAssert.strictEqual(sSelectedText, 'HelloworldHelloworld', 'Check select text to end line shortcut'); - }, oMainShortcutTypes.checkSelectToEndLineContent); - }); + ExecuteMainHotkey(mainShortcutTypes.checkLittleMoveShapeBottom); + CheckShapePosition(0, 6); - // Home - QUnit.test('Test move to start position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, true, true, false); - oAssert.true(oPos.X === 0 && oPos.Y === 15, 'Check move to start position shortcut'); - }, oMainShortcutTypes.checkMoveToStartPosContent); - }); + ExecuteMainHotkey(mainShortcutTypes.checkMoveShapeTop); + CheckShapePosition(0, 1); - QUnit.test('Test move to start line', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, true, true, false); - oAssert.true(oPos.X === 0 && oPos.Y === 75, 'Check move to start line shortcut'); - }, oMainShortcutTypes.checkMoveToStartLineContent); - }); + ExecuteMainHotkey(mainShortcutTypes.checkLittleMoveShapeTop); + CheckShapePosition(0, 0); + AscTest.TurnOffRecalculate(); - QUnit.test('Test select to start line', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, true, false, true); - oAssert.strictEqual(sSelectedText, 'Hello', 'Check select to start line shortcut'); - }, oMainShortcutTypes.checkSelectToStartLineContent); - }); - //Left arrow - QUnit.test('Test move cursor to end position', (oAssert) => + function CheckSelectedObjects(arrOfDrawings) { - startMainTest((oEvent) => + const length = Math.max(arrOfDrawings.length, GetDrawingObjects().selectedObjects.length); + for (let i = 0; i < length; i++) { - const {oPos} = testMoveHelper(oEvent, true, true, false); - oAssert.true(oPos.X === 20 && oPos.Y === 75, 'Check move cursor to end position shortcut'); - }, oMainShortcutTypes.checkMoveCursorLeft); - }); + assert.true(GetDrawingObjects().selectedObjects[i] === arrOfDrawings[i], 'Check selection movement between objects'); + } + } - QUnit.test('Test select text to left position', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, true, false, true); - oAssert.strictEqual(sSelectedText, 'o', 'Check select text to left position shortcut'); - }, oMainShortcutTypes.checkSelectCursorLeft); - }); + logicDocument.RemoveSelection(); + const drawing2 = AddShape(0, 0, 10, 10); + const drawing3 = AddShape(0, 0, 10, 10); + SelectDrawings([drawing3]); - QUnit.test('Test select word text to left position', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, true, false, true); - oAssert.strictEqual(sSelectedText, 'HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHello', 'Check select word text to left position shortcut'); - }, oMainShortcutTypes.checkSelectWordCursorLeft); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectNextObject); + CheckSelectedObjects([drawing1]); - QUnit.test('Test move cursor to left word position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, true, true, false); - oAssert.true(oPos.X === 0 && oPos.Y === 15, 'Check move cursor to left word position shortcut'); - }, oMainShortcutTypes.checkMoveCursorWordLeft); - }); - QUnit.test('Test move left in table', (oAssert) => - { - startMainTest((oEvent) => - { - const oFrame = createTable(3, 3); - oFrame.Set_CurrentElement(); - const oTable1 = oFrame.graphicObject; - oTable1.MoveCursorToStartPos(); - moveCursorRight(true); - moveCursorRight(true); - onKeyDown(oEvent); - oAssert.deepEqual([oTable1.CurCell.Row.Index, oTable1.CurCell.Index], [0, 0], 'Check move left in table'); - }, oMainShortcutTypes.checkMoveCursorLeftTable); - }); - //Right arrow - QUnit.test('Test move cursor to right position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, false, true, false); - oAssert.true(oPos.X === 5 && oPos.Y === 15, 'Check move cursor to right position shortcut'); - }, oMainShortcutTypes.checkMoveCursorRight); - }); - QUnit.test('Test move right in table', (oAssert) => - { - startMainTest((oEvent) => - { - const oFrame = createTable(3, 3); - oFrame.Set_CurrentElement(); - const oTable1 = oFrame.graphicObject; - oTable1.MoveCursorToStartPos(); - moveCursorRight(true); - onKeyDown(oEvent); - oAssert.deepEqual([oTable1.CurCell.Row.Index, oTable1.CurCell.Index], [0, 1], 'Check move right in table'); - }, oMainShortcutTypes.checkMoveCursorRightTable); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectNextObject); + CheckSelectedObjects([drawing2]); - QUnit.test('Test select text to right position', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, false, false, true); - oAssert.strictEqual(sSelectedText, 'H', 'Check select text to right position shortcut'); - }, oMainShortcutTypes.checkSelectCursorRight); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectNextObject); + CheckSelectedObjects([drawing3]); - QUnit.test('Test select word text to right position', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, false, false, true); - oAssert.strictEqual(sSelectedText, 'HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHello', 'Check select word text to right position shortcut'); - }, oMainShortcutTypes.checkSelectWordCursorRight); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectPreviousObject); + CheckSelectedObjects([drawing2]); - QUnit.test('Test move cursor to right word position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, true, true, false); - oAssert.true(oPos.X === 25 && oPos.Y === 75, 'Check move cursor to right word position shortcut'); - }, oMainShortcutTypes.checkMoveCursorWordRight); - }); - //Top arrow - QUnit.test('Test move cursor to top position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, true, true, false); - oAssert.true(oPos.X === 25 && oPos.Y === 55, 'Check move cursor to top position shortcut'); - }, oMainShortcutTypes.checkMoveCursorTop); - }); - QUnit.test('Test move top in table', (oAssert) => - { - startMainTest((oEvent) => - { - const oFrame = createTable(3, 3); - oFrame.Set_CurrentElement(); - const oTable1 = oFrame.graphicObject; - oTable1.MoveCursorToStartPos(); - moveCursorDown(); - onKeyDown(oEvent); - oAssert.deepEqual([oTable1.CurCell.Row.Index, oTable1.CurCell.Index], [0, 0], 'Check move top in table'); - }, oMainShortcutTypes.checkMoveCursorTopTable); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectPreviousObject); + CheckSelectedObjects([drawing1]); - QUnit.test('Test select text to top position', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, true, false, true); - oAssert.strictEqual(sSelectedText, 'worldHelloworldHello', 'Check select text to top position shortcut'); - }, oMainShortcutTypes.checkSelectCursorTop); - }); - // Bottom arrow - QUnit.test('Test move cursor to bottom position', (oAssert) => - { - startMainTest((oEvent) => - { - const {oPos} = testMoveHelper(oEvent, false, true, false); - oAssert.true(oPos.X === 0 && oPos.Y === 35, 'Check move cursor to bottom position shortcut'); - }, oMainShortcutTypes.checkMoveCursorBottom); - }); - QUnit.test('Test move bottom in table', (oAssert) => - { - startMainTest((oEvent) => - { - const oFrame = createTable(3, 3); - oFrame.Set_CurrentElement(); - const oTable1 = oFrame.graphicObject; - oTable1.MoveCursorToStartPos(); - onKeyDown(oEvent); - oAssert.deepEqual([oTable1.CurCell.Row.Index, oTable1.CurCell.Index], [1, 0], 'Check move bottom in table'); - }, oMainShortcutTypes.checkMoveCursorBottomTable); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectPreviousObject); + CheckSelectedObjects([drawing3]); - QUnit.test('Test select text to bottom position', (oAssert) => - { - startMainTest((oEvent) => - { - const {sSelectedText} = testMoveHelper(oEvent, false, false, true); - oAssert.strictEqual(sSelectedText, 'HelloworldHelloworld', 'Check select text to bottom position shortcut'); - }, oMainShortcutTypes.checkSelectCursorBottom); - }); + drawing2.setWordShape(false); + SelectDrawings([drawing2]); - // Check move shape - QUnit.test('Test big move shape bottom', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.y, 5 * AscCommon.g_dKoef_pix_to_mm, 'Check move shape bottom'); - }, oMainShortcutTypes.checkMoveShapeBottom); - }); + ExecuteMainHotkey(mainShortcutTypes.checkAddTxBodyShape); + assert.true(!!drawing2.txBody, 'Check create textBody after enter'); - QUnit.test('Test little move shape bottom', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.y, 1 * AscCommon.g_dKoef_pix_to_mm, 'Check little move shape bottom'); - }, oMainShortcutTypes.checkLittleMoveShapeBottom); - }); + SelectDrawings([drawing2]); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorToStartPosShape); + const paragraph = drawing2.getDocContent().Content[0]; + assert.true(paragraph.IsThisElementCurrent() && paragraph.IsCursorAtBegin(), 'Check movement to start position in empty content'); - QUnit.test('Test big move shape top', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.y, -5 * AscCommon.g_dKoef_pix_to_mm, 'Check move shape top'); - }, oMainShortcutTypes.checkMoveShapeTop); - }); + AscTest.EnterText([72, 101, 108, 108, 111]); + SelectDrawings([drawing2]); - QUnit.test('Test little move shape top', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.y, -1 * AscCommon.g_dKoef_pix_to_mm, 'Check move shape top'); - }, oMainShortcutTypes.checkLittleMoveShapeTop); - }); + ExecuteMainHotkey(mainShortcutTypes.checkSelectAllContentShape); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello', 'Check select non empty content'); - QUnit.test('Test big move shape right', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.x, 5 * AscCommon.g_dKoef_pix_to_mm, 'Check move shape right'); - }, oMainShortcutTypes.checkMoveShapeRight); - }); + SelectDrawings([drawing1, drawing2]); - QUnit.test('Test little move shape right', (oAssert) => - { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.x, 1 * AscCommon.g_dKoef_pix_to_mm, 'Check little move shape right'); - }, oMainShortcutTypes.checkLittleMoveShapeRight); - }); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Group); + assert.strictEqual(GetDrawingObjects().selectedObjects[0].getObjectType(), AscDFH.historyitem_type_GroupShape, 'Check group selected objects'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.UnGroup); + assert.strictEqual(GetDrawingObjects().selectedObjects[0].getObjectType(), AscDFH.historyitem_type_Shape, 'Check ungroup selected group'); + assert.strictEqual(GetDrawingObjects().selectedObjects[1].getObjectType(), AscDFH.historyitem_type_Shape, 'Check ungroup selected group'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Group); + let group = GetDrawingObjects().selectedObjects[0]; + group.selectObject(drawing1, 0); + GetDrawingObjects().selection.groupSelection = group; + + ExecuteMainHotkey(mainShortcutTypes.checkResetStepDrawingSelection); + assert.strictEqual(GetDrawingObjects().selectedObjects[0].getObjectType(), AscDFH.historyitem_type_GroupShape, 'Check reset step drawing selection'); + assert.strictEqual(group.selectedObjects.length, 0); - QUnit.test('Test big move shape left', (oAssert) => + group.selectObject(drawing1, 0); + GetDrawingObjects().selection.groupSelection = group; + + ExecuteMainHotkey(mainShortcutTypes.checkResetAllDrawingSelection); + assert.strictEqual(GetDrawingObjects().selectedObjects.length, 0, 'Check reset all drawing selection'); + + const graphicFrame = AddTable(4, 4); + + function CheckTablePosition(row, column) { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.x, -5 * AscCommon.g_dKoef_pix_to_mm, 'Check move shape left'); - }, oMainShortcutTypes.checkMoveShapeLeft); - }); + assert.strictEqual(graphicFrame.graphicObject.CurCell.Index, column, 'Check column active cell position'); + assert.strictEqual(graphicFrame.graphicObject.CurCell.Row.Index, row, 'Check row active cell position'); + } + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorRightTable); + CheckTablePosition(0, 1); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorRightTable); + CheckTablePosition(0, 2); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorRightTable); + CheckTablePosition(0, 3); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorLeftTable); + CheckTablePosition(0, 2); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorLeftTable); + CheckTablePosition(0, 1); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorBottomTable); + CheckTablePosition(1, 1); - QUnit.test('Test little move shape left', (oAssert) => + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorTopTable); + CheckTablePosition(0, 1); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToNextCell); + CheckTablePosition(0, 2); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToNextCell); + CheckTablePosition(0, 3); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToPreviousCell); + CheckTablePosition(0, 2); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToPreviousCell); + CheckTablePosition(0, 1); + + const cell = graphicFrame.graphicObject.Content[0].Get_Cell(0); + const content = cell.GetContent(); + AscFormat.AddToContentFromString(content, 'Hello Hello'); + SelectDrawings([graphicFrame]); + ExecuteMainHotkey(mainShortcutTypes.checkSelectFirstCellContent); + CheckTablePosition(0, 0); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello Hello', 'Check select first cell content'); + + graphicFrame.MoveCursorToStartPos(); + logicDocument.MoveCursorRight(true, true); + logicDocument.MoveCursorRight(true, true); + + logicDocument.MoveCursorRight(true, true); + + logicDocument.MoveCursorRight(true, true); + ExecuteMainHotkey(mainShortcutTypes.checkRemoveAndMoveToStartPosTable); + assert.true(graphicFrame.graphicObject.IsCursorAtBegin(), 'Check removing in table'); + assert.strictEqual(logicDocument.GetSelectedText(), '', 'Check removing in table'); + }); + + QUnit.test('Check prevent default', (assert) => + { + let res = ExecuteMainHotkey(mainShortcutTypes.checkNumLock); + assert.strictEqual(res & keydownresult_PreventDefault, keydownresult_PreventDefault, 'Check prevent default'); + res = ExecuteMainHotkey(mainShortcutTypes.checkScrollLock); + assert.strictEqual(res & keydownresult_PreventDefault, keydownresult_PreventDefault, 'Check prevent default'); + }); + + QUnit.test('Check remove graphic objects', (assert) => + { + + function CheckRemoveObject(spTree, shape) { - startMainTest((oEvent) => - { - const oShape = executeCheckMoveShape(oEvent); - oAssert.strictEqual(oShape.x, -1 * AscCommon.g_dKoef_pix_to_mm, 'Check little move shape left'); - }, oMainShortcutTypes.checkLittleMoveShapeLeft); - }); + assert.true(spTree.indexOf(shape) === -1, 'Check remove shape from spTree'); + } - //Delete - QUnit.test('Test delete front symbol', (oAssert) => + const checkActionsWithEvent = (eventIndex) => { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello world'); - moveToParagraph(oParagraph, true); + const shape = AddShape(0, 0, 100, 100); + SelectDrawings([shape]); + logicDocument.AddAnimation(1, 1, 0, false, false); + GetDrawingObjects().resetSelection(); + const timing = logicDocument.GetCurTiming(); + let effects = timing.getObjectEffects(shape.GetId()); + effects[0].select(); + ExecuteMainHotkey(mainShortcutTypes.checkRemoveAnimation, eventIndex) + effects = timing.getObjectEffects(shape.GetId()); + assert.strictEqual(effects.length, 0, 'Check remove animation'); - onKeyDown(oEvent); - oAssert.strictEqual(AscTest.GetParagraphText(oParagraph), 'ello world', 'Check delete front shortcut'); - }, oMainShortcutTypes.checkDeleteFront); - }); + SelectDrawings([shape]); + assert.true(logicDocument.GetCurrentSlide().cSld.spTree.indexOf(shape) !== -1, 'Check available shape in spTree'); + ExecuteMainHotkey(mainShortcutTypes.checkRemoveShape, eventIndex); + CheckRemoveObject(logicDocument.GetCurrentSlide().cSld.spTree, shape); - QUnit.test('Test delete front word', (oAssert) => - { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello world'); - moveToParagraph(oParagraph, true); + const chart = AddChart(); + SelectDrawings([chart]); + ExecuteMainHotkey(mainShortcutTypes.checkRemoveChart, eventIndex); + CheckRemoveObject(logicDocument.GetCurrentSlide().cSld.spTree, chart); - onKeyDown(oEvent); - oAssert.strictEqual(AscTest.GetParagraphText(oParagraph), 'world', 'Check delete front word shortcut'); - }, oMainShortcutTypes.checkDeleteWordFront); - }); - QUnit.test('Test increase indent', (oAssert) => + const shape1 = AddShape(0, 0, 100, 100); + const shape2 = AddShape(0, 0, 100, 100); + const shape3 = AddShape(0, 0, 100, 100); + + const group = CreateGroup([shape1, shape2, shape3]); + group.selectObject(shape1, 0); + GetDrawingObjects().selection.groupSelection = group; + + ExecuteMainHotkey(mainShortcutTypes.checkRemoveShapeInGroup, eventIndex); + CheckRemoveObject(group.spTree, shape1); + + SelectDrawings([group]); + ExecuteMainHotkey(mainShortcutTypes.checkRemoveGroup, eventIndex); + CheckRemoveObject(logicDocument.GetCurrentSlide().cSld.spTree, group); + }; + + checkActionsWithEvent(0); + checkActionsWithEvent(1); + }); + + QUnit.test('Check select all in chart title', (assert) => + { + AscTest.TurnOnRecalculate(); + const chart = AddChart(); + SelectTitle(chart); + ExecuteMainHotkey(mainShortcutTypes.checkSelectAllContentChartTitle); + assert.strictEqual(logicDocument.GetSelectedText(), 'Diagram Title', 'Check select all content in chart title'); + logicDocument.Remove(); + AscTest.TurnOffRecalculate(); + }); + + QUnit.test('Check actions for objects with placeholder', (assert) => + { + const shape1 = AddPlaceholderShape(); + const shape2 = AddPlaceholderShape(); + const shape3 = AddPlaceholderShape(); + + SelectDrawings([shape1]); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectNextObjectWithPlaceholder); + assert.true(GetDrawingObjects().selectedObjects[0] === shape2, 'Check select next object with placeholder'); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectNextObjectWithPlaceholder); + assert.true(GetDrawingObjects().selectedObjects[0] === shape3, 'Check select next object with placeholder'); + + ExecuteMainHotkey(mainShortcutTypes.checkAddNextSlideAfterSelectLastPlaceholderObject); + + assert.strictEqual(logicDocument.Slides.length, 2, 'Check creating new slide after selecting last shape with placeholder'); + assert.strictEqual(logicDocument.Get_CurPage(), 1, 'Check creating new slide after selecting last shape with placeholder'); + }); + + QUnit.test('Check add break line', (assert) => + { + function CheckAddBreakLine(shape) { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello'); - oParagraph.Pr.SetInd(0, 0, 0); - oParagraph.Set_PresentationLevel(0); - moveToParagraph(oParagraph, true); - - onKeyDown(oEvent); - const oParaPr = oGlobalLogicDocument.GetDirectParaPr(); - oAssert.strictEqual(oParaPr.GetIndLeft(), 11.1125, 'Check increase indent'); - }, oMainShortcutTypes.checkIncreaseIndent); - }); + assert.strictEqual(shape.txBody.content.Content.length, 1, 'Check amount paragraphs'); + assert.strictEqual(shape.txBody.content.Content[0].GetLinesCount(), 2, 'Check amount lines'); + } - QUnit.test('Test decrease indent', (oAssert) => { - startMainTest((oEvent) => - { - const {oParagraph} = getShapeWithParagraphHelper('Hello'); - oParagraph.Pr.SetInd(0, 12, 0); - oParagraph.Set_PresentationLevel(1); - moveToParagraph(oParagraph, true); - - onKeyDown(oEvent); - const oParaPr = oGlobalLogicDocument.GetDirectParaPr(); - oAssert.true(AscFormat.fApproxEqual(oParaPr.GetIndLeft(), 0.8875), 'Check decrease indent'); - }, oMainShortcutTypes.checkDecreaseIndent); - }); + AscTest.TurnOnRecalculate(); + const {shape} = ClearShapeAndAddParagraph('Hello Hello'); + logicDocument.MoveCursorRight(false, true); + + ExecuteMainHotkey(mainShortcutTypes.checkAddBreakLine); + CheckAddBreakLine(shape); + + const placeholderShape = AddPlaceholderShape(); + placeholderShape.setTxBody(AscFormat.CreateTextBodyFromString('Hello hello', AscTest.DrawingDocument, placeholderShape)); + placeholderShape.txBody.content.SetThisElementCurrent(); + placeholderShape.txBody.content.MoveCursorToStartPos(); + logicDocument.MoveCursorRight(false, true); + + ExecuteMainHotkey(mainShortcutTypes.checkAddTitleBreakLine); + CheckAddBreakLine(placeholderShape); + AscTest.TurnOffRecalculate(); + } + + const checkAddMathBreakLine = (eventIndex) => + { + const {shape} = ClearShapeAndAddParagraph(''); + editor.asc_AddMath2(c_oAscMathType.FractionVertical); + logicDocument.Recalculate(); + const paragraph = shape.txBody.content.Content[0]; + logicDocument.MoveCursorLeft(); + logicDocument.MoveCursorLeft(); + AscTest.EnterText([56, 56, 56, 56, 56, 56, 56]); + logicDocument.MoveCursorLeft(); + logicDocument.MoveCursorLeft(); + ExecuteMainHotkey(mainShortcutTypes.checkAddMathBreakLine, eventIndex); + const paraMath = paragraph.GetAllParaMaths()[0]; + const fraction = paraMath.Root.GetFirstElement(); + const numerator = fraction.getNumerator(); + const eqArray = numerator.GetFirstElement(); + assert.strictEqual(eqArray.getRowsCount(), 2, 'Check add new line in math'); + } + + checkAddMathBreakLine(0); + checkAddMathBreakLine(1); + }); + + QUnit.test('Check add new paragraph', (assert) => + { + const {shape} = ClearShapeAndAddParagraph(''); + ExecuteMainHotkey(mainShortcutTypes.checkAddParagraph); + assert.strictEqual(shape.txBody.content.Content.length, 2, 'Check add new paragraph'); + }); + + QUnit.test('Check add tab symbol', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph(''); + ExecuteMainHotkey(mainShortcutTypes.checkAddTab); + assert.true(paragraph.Content[0].Content[0].IsTab(), 'Check add tab symbol'); + }); + + QUnit.test('Check show paragraph marks', (assert) => + { + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.ShowParaMarks); + assert.true(editor.get_ShowParaMarks(), 'Check show para marks'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.ShowParaMarks); + assert.false(editor.get_ShowParaMarks(), 'Check hide para marks'); + }); + + QUnit.test('Check copy/paste format and clear formatting actions', (assert) => + { + ClearShapeAndAddParagraph('Hello'); + logicDocument.SelectAll(); - QUnit.test('Test prevent default on num lock', (oAssert) => + logicDocument.AddToParagraph(new AscCommonWord.ParaTextPr({Bold: true, Italic: true, Strikeout: true}), true); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.CopyFormat); + + let textPr = editor.getFormatPainterData().TextPr; + assert.true(textPr.GetBold(), 'Check copy paragraph property'); + assert.true(textPr.GetItalic(), 'Check copy paragraph property'); + assert.true(textPr.GetStrikeout(), 'Check copy paragraph property'); + + + ClearShapeAndAddParagraph('Hello'); + logicDocument.SelectAll(); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.PasteFormat); + + textPr = GetDirectTextPr(); + assert.true(textPr.GetBold(), 'Check paste paragraph property'); + assert.true(textPr.GetItalic(), 'Check paste paragraph property'); + assert.true(textPr.GetStrikeout(), 'Check paste paragraph property'); + + ExecuteMainHotkey(mainShortcutTypes.checkClearParagraphFormatting); + textPr = GetDirectTextPr(); + assert.false(textPr.GetBold(), 'Check clear paragraph property'); + assert.false(textPr.GetItalic(), 'Check clear paragraph property'); + assert.false(textPr.GetStrikeout(), 'Check clear paragraph property'); + }); + + QUnit.test('Check undo/redo', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph(''); + AscTest.EnterText([56, 56, 56, 56]); + assert.strictEqual(AscTest.GetParagraphText(paragraph), '8888', 'Check enter text'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.EditUndo); + assert.strictEqual(AscTest.GetParagraphText(paragraph), '', 'Check undo text'); + + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.EditRedo); + assert.strictEqual(AscTest.GetParagraphText(paragraph), '8888', 'Check redo text'); + }); + + QUnit.test('Check select all', (assert) => + { + const {paragraph, shape} = ClearShapeAndAddParagraph('Hello'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.EditSelectAll); + + assert.true(shape.txBody.content.IsSelectionUse(), 'Check content selection'); + assert.true(paragraph.IsSelectedAll(), 'Check paragraph selection'); + assert.strictEqual(logicDocument.GetSelectedText(), 'Hello', 'Check selected text'); + }); + + QUnit.test('Check reset action with adding new shape', (assert) => + { + logicDocument.StartAddShape('rect', true); + ExecuteMainHotkey(mainShortcutTypes.checkResetAddShape); + assert.true(!GetDrawingObjects().checkTrackDrawings(), 'Check reset add new shape'); + }); + + QUnit.test('Check visit hyperlink', (assert) => + { + CreateSlide(); + ClearShapeAndAddParagraph('Hello'); + logicDocument.AddHyperlink({ + Text : 'abcd', + ToolTip: 'abcd', + Value : "ppaction://hlinkshowjump?jump=lastslide" + }); + logicDocument.MoveCursorLeft(); + logicDocument.MoveCursorLeft(); + const selectedInfo = logicDocument.IsCursorInHyperlink(); + ExecuteMainHotkey(mainShortcutTypes.checkVisitHyperlink); + assert.true(selectedInfo.Visited && logicDocument.GetSelectedSlides()[0] === 1, 'Check visit hyperlink'); + }); + + QUnit.test('Check duplicate presentation objects', (assert) => + { + const shape = AddShape(0, 0, 100, 100); + SelectDrawings([shape]); + assert.strictEqual(logicDocument.Slides[0].cSld.spTree.length, 1, 'Check duplicate graphic object'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Duplicate); + assert.strictEqual(logicDocument.Slides[0].cSld.spTree.length, 2, 'Check duplicate graphic object'); + + GetDrawingObjects().resetSelection(); + assert.strictEqual(logicDocument.Slides.length, 1, 'Check duplicate slide'); + ExecuteMainShortcut(Asc.c_oAscPresentationShortcutType.Duplicate); + assert.strictEqual(logicDocument.Slides.length, 2, 'Check duplicate slide'); + }); + + QUnit.test('Check save action', (assert) => + { + assert.timeout(1000); + const done1 = assert.async(); + const done2 = assert.async(); + + function CheckSave(Execute, resolve) { - startMainTest((oEvent) => + const OldSave = editor._onSaveCallbackInner; + editor._onSaveCallbackInner = function () { - onKeyDown(oEvent); - oAssert.true(oEvent.isDefaultPrevented, 'Check prevent default on num lock'); - }, oMainShortcutTypes.checkNumLock); - }); + resolve(); + editor._onSaveCallbackInner = OldSave; + }; + editor._saveCheck = () => true; + editor.asc_isDocumentCanSave = () => true; + editor.canSave = true; + Execute(Asc.c_oAscPresentationShortcutType.Save); + } - QUnit.test('Test prevent default on scroll lock', (oAssert) => + new Promise((resolve) => CheckSave(ExecuteThumbnailShortcut, resolve)).then(function () { - startMainTest((oEvent) => - { - onKeyDown(oEvent); - oAssert.true(oEvent.isDefaultPrevented, 'Check prevent default on scroll lock'); - }, oMainShortcutTypes.checkScrollLock); + assert.true(true, 'Check save shortcut'); + done1(); + return new Promise((resolve) => CheckSave(ExecuteMainShortcut, resolve)) + }).then(function () + { + assert.true(true, 'Check save shortcut'); + done2(); }); }); })(window); From 85222208f4d75142e1cebd1c190dc389cc3b322e Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 21 Sep 2023 15:11:37 +0300 Subject: [PATCH 10/23] [pe]Fix passing tests --- slide/Editor/Format/Presentation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slide/Editor/Format/Presentation.js b/slide/Editor/Format/Presentation.js index 017def1bb3..edb5da0cd9 100644 --- a/slide/Editor/Format/Presentation.js +++ b/slide/Editor/Format/Presentation.js @@ -11110,7 +11110,7 @@ CPresentation.prototype.moveSlidesPrevPos = function () { if (can_move) { History.Create_NewPoint(AscDFH.historydescription_Presentation_MoveSlidesPrevPos); let aNewSelected = []; - for (i = first_index; i > -1; --i) { + for (i = first_index; i < _selected_array.length; ++i) { let nOldIdx = _selected_array[i]; let nNewIdx = nOldIdx - 1; this.moveSlides([nOldIdx], nNewIdx); From 0984ffecc71e5ffbecb67ba516857d7f0780f95f Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 2 Oct 2023 19:21:31 +0300 Subject: [PATCH 11/23] Return chart after adding on worksheet --- cell/view/DrawingObjectsController.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cell/view/DrawingObjectsController.js b/cell/view/DrawingObjectsController.js index 0fcbbf2c33..e010c19f04 100644 --- a/cell/view/DrawingObjectsController.js +++ b/cell/view/DrawingObjectsController.js @@ -482,6 +482,7 @@ DrawingObjectsController.prototype.addChartDrawingObject = function(options) this.startRecalculate(); this.drawingObjects.sendGraphicObjectProps(); } + return chart; }; DrawingObjectsController.prototype.isPointInDrawingObjects = function(x, y, e) From 6190e1644d0d42a16b055f2c615136bb4410eeb5 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 2 Oct 2023 19:22:34 +0300 Subject: [PATCH 12/23] [se]Remove unused shortcuts --- cell/view/EventsController.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cell/view/EventsController.js b/cell/view/EventsController.js index 9d8e2dd9c9..d6f89d0859 100644 --- a/cell/view/EventsController.js +++ b/cell/view/EventsController.js @@ -846,14 +846,10 @@ case 120: // F9 var type; - if (ctrlKey && event.altKey && shiftKey) { - type = Asc.c_oAscCalculateType.All; - } else if (ctrlKey && event.altKey) { - type = Asc.c_oAscCalculateType.Workbook; - } else if (shiftKey) { + if (shiftKey) { type = Asc.c_oAscCalculateType.ActiveSheet; } else { - type = Asc.c_oAscCalculateType.WorkbookOnlyChanged; + type = Asc.c_oAscCalculateType.All; } t.handlers.trigger("calculate", type); return result; From 381780f76de2680a75da70bdc65cda5540f9f06b Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 2 Oct 2023 19:24:11 +0300 Subject: [PATCH 13/23] [pe]Remove unused methods --- tests/slide/shortcuts/shortcuts.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/slide/shortcuts/shortcuts.js b/tests/slide/shortcuts/shortcuts.js index 64e7c2a6ed..a743d7b47c 100644 --- a/tests/slide/shortcuts/shortcuts.js +++ b/tests/slide/shortcuts/shortcuts.js @@ -97,27 +97,16 @@ function AddShape(x, y, height, width) { AscCommon.History.Create_NewPoint(); - const shapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, AscFormat.GetDefaultTheme(), null, null, null, 0); - shapeTrack.track({}, x, y); + const shapeTrack = new AscFormat.NewShapeTrack('rect', x, y, AscFormat.GetDefaultTheme(), null, null, null, 0); + shapeTrack.track({}, x+ width, y + height); const shape = shapeTrack.getShape(false, AscTest.DrawingDocument, null); shape.setBDeleted(false); - shape.spPr.xfrm.setExtX(width); - shape.spPr.xfrm.setExtY(height); shape.setParent(logicDocument.Slides[0]); shape.addToDrawingObjects(); shape.select(GetDrawingObjects(), 0); return shape; } - function SelectTitle(chart) - { - SelectDrawings([chart]); - const titles = chart.getAllTitles(); - const controller = GetDrawingObjects(); - controller.selection.chartSelection = chart; - chart.selectTitle(titles[0], 0); - } - function AddChart() { const chart = editor.asc_getChartObject(Asc.c_oAscChartTypeSettings.lineNormal); @@ -166,9 +155,9 @@ function ClearShapeAndAddParagraph(sText) { const textShape = AddShape(0, 0, 100, 100); - textShape.setPaddings({Left: 0, Top: 0, Right: 0, Bottom: 0}); const txBody = AscFormat.CreateTextBodyFromString(sText, editor.WordControl.m_oDrawingDocument, textShape) textShape.setTxBody(txBody); + textShape.setPaddings({Left: 0, Top: 0, Right: 0, Bottom: 0}); const content = txBody.content; content.SetThisElementCurrent(); content.MoveCursorToStartPos(); @@ -952,7 +941,11 @@ { AscTest.TurnOnRecalculate(); const chart = AddChart(); - SelectTitle(chart); + SelectDrawings([chart]); + const titles = chart.getAllTitles(); + const controller = GetDrawingObjects(); + controller.selection.chartSelection = chart; + chart.selectTitle(titles[0], 0); ExecuteMainHotkey(mainShortcutTypes.checkSelectAllContentChartTitle); assert.strictEqual(logicDocument.GetSelectedText(), 'Diagram Title', 'Check select all content in chart title'); logicDocument.Remove(); From 575ea579f8ff55f2f547cafabc20a8b57a3e9a8c Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 2 Oct 2023 19:25:09 +0300 Subject: [PATCH 14/23] [de]Remove unused code --- tests/word/shortcuts/shortcuts.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index a8b3e4ed6d..8c1cdae00c 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -231,13 +231,9 @@ function AddShape(x, y, h, w) { const drawing = new ParaDrawing(w, h, null, logicDocument.GetDrawingDocument(), logicDocument, null); - const shapeTrack = new AscFormat.NewShapeTrack('rect', 0, 0, logicDocument.theme, null, null, null, 0); - shapeTrack.track({}, x, y); + const shapeTrack = new AscFormat.NewShapeTrack('rect', x, y, logicDocument.theme, null, null, null, 0); + shapeTrack.track({}, x+ w, y + h); const shape = shapeTrack.getShape(true, logicDocument.GetDrawingDocument(), null); - shape.spPr.xfrm.setExtX(w); - shape.spPr.xfrm.setExtY(h); - shape.spPr.xfrm.setOffX(0); - shape.spPr.xfrm.setOffY(0); shape.setBDeleted(false); shape.setParent(drawing); From 352cd6b3c953824efb0ab59c1f7f09aa6fbdab09 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 2 Oct 2023 19:33:44 +0300 Subject: [PATCH 15/23] [se]Refactor shortcut tests --- tests/cell/shortcuts/TableId.js | 57 - tests/cell/shortcuts/events.js | 1055 ++++---- tests/cell/shortcuts/helpers.js | 927 ------- tests/cell/shortcuts/measurer.js | 233 +- tests/cell/shortcuts/shortcuts.html | 46 +- tests/cell/shortcuts/shortcuts.js | 3752 ++++++++++----------------- tests/cell/shortcuts/workbook.js | 182 ++ 7 files changed, 2278 insertions(+), 3974 deletions(-) delete mode 100644 tests/cell/shortcuts/TableId.js delete mode 100644 tests/cell/shortcuts/helpers.js create mode 100644 tests/cell/shortcuts/workbook.js diff --git a/tests/cell/shortcuts/TableId.js b/tests/cell/shortcuts/TableId.js deleted file mode 100644 index 2a0f560c8f..0000000000 --- a/tests/cell/shortcuts/TableId.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -(function (window) -{ - AscCommon.g_oTableId = { - map : {}, - Add : function(c, id) - { - this.map[id] = c; - }, - Get_ById : function(id) - { - if (!this.map[id]) - return null; - - return this.map[id]; - }, - TurnOff : function(){}, - TurnOn : function(){}, - init : function () {}, - }; - - AscCommon.g_oIdCounter.m_bLoad = false; - AscCommon.g_oIdCounter.m_bRead = false; -})(window); diff --git a/tests/cell/shortcuts/events.js b/tests/cell/shortcuts/events.js index a9e99ab012..a2065fd8c0 100644 --- a/tests/cell/shortcuts/events.js +++ b/tests/cell/shortcuts/events.js @@ -34,31 +34,82 @@ (function (window) { - const createEvent = AscTestShortcut.createEvent; - const cleanGraphic = AscTestShortcut.cleanGraphic; - const testAll = 0; - const testWindows = 1; - const testMacOs = 2; + const testFlags = { + nothing: 0x0000, + macOs : 0x1000, + opera : 0x0110, + }; - function CTestEvent(oEvent, nType) + function CNativeEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey, flags) { - this.type = nType || testAll; - this.event = oEvent; + this.keyCode = nKeyCode; + this.which = nKeyCode; + this.ctrlKey = !!bIsCtrl; + this.shiftKey = !!bIsShift; + this.altKey = !!bIsAlt; + this.metaKey = !!bIsMetaKey; + this.isDefaultPrevented = false; + this.isPropagationStopped = false; + + this.flags = flags || testFlags.nothing; } - const oKeyCode = + CNativeEvent.prototype.preventDefault = function () + { + this.isDefaultPrevented = true; + }; + CNativeEvent.prototype.stopPropagation = function () + { + this.isPropagationStopped = true; + }; + + CNativeEvent.prototype.enableFlags = function () + { + if (this.flags & testFlags.macOs) + { + AscCommon.AscBrowser.isMacOs = true; + } + + if (this.flags & testFlags.opera) + { + AscCommon.AscBrowser.isOpera = true; + } + } + CNativeEvent.prototype.disableFlags = function () + { + if (this.flags & testFlags.macOs) + { + AscCommon.AscBrowser.isMacOs = false; + } + + if (this.flags & testFlags.opera) + { + AscCommon.AscBrowser.isOpera = false; + } + } + const keyCodes = { BackSpace : 8, Tab : 9, Enter : 13, Esc : 27, + Space : 32, + PageUp : 33, + PageDown : 34, End : 35, Home : 36, ArrowLeft : 37, ArrowTop : 38, ArrowRight : 39, ArrowBottom : 40, + Digit1 : 49, + Digit2 : 50, + Digit3 : 51, + Digit4 : 52, + Digit5 : 53, + Digit6 : 54, Delete : 46, + EqualFirefox : 61, A : 65, B : 66, C : 67, @@ -76,399 +127,346 @@ X : 88, Y : 89, Z : 90, - OperaContextMenu: 57351, + ContextMenu : 93, + NumpadDecimal : 110, + F2 : 113, + F4 : 115, + F5 : 116, + F9 : 120, F10 : 121, NumLock : 144, ScrollLock : 145, + Semicolon : 186, Equal : 187, Comma : 188, Minus : 189, Period : 190, + Backquote : 192, BracketLeft : 219, BracketRight : 221, - F2 : 113 - } - - - function privateStartTest(fCallback, nShortcutType, oEvents) - { - cleanGraphic(); - const arrTestEvents = oEvents[nShortcutType]; - - for (let i = 0; i < arrTestEvents.length; i += 1) - { - cleanGraphic(); - const nTestType = arrTestEvents[i].type; - if (nTestType === testAll) - { - AscCommon.AscBrowser.isMacOs = true; - fCallback(arrTestEvents[i].event); - - cleanGraphic(); - AscCommon.AscBrowser.isMacOs = false; - fCallback(arrTestEvents[i].event); - } else if (nTestType === testMacOs) - { - AscCommon.AscBrowser.isMacOs = true; - fCallback(arrTestEvents[i].event); - AscCommon.AscBrowser.isMacOs = false; - } else if (nTestType === testWindows) - { - fCallback(arrTestEvents[i].event); - } + OperaContextMenu: 57351, } - } - const oGraphicTypes = { - removeBackChar : 1, - removeBackWord : 1.5, - removeChart : 2, - removeShape : 3, - removeGroup : 4, - removeShapeInGroup : 5, - addTab : 6, - selectNextObject : 7, - selectPreviousObject : 8, - visitHyperink : 9, - addLineInMath : 10, - addBreakLine : 11, - addParagraph : 12, - createTxBody : 13, - moveToStartInEmptyContent : 14, - selectAllAfterEnter : 15, - moveCursorToStartPositionInTitle: 16, - selectAllTitleAfterEnter : 17, - resetTextSelection : 18, - resetStepSelection : 18.5, - moveCursorToEndDocument : 19, - moveCursorToEndLine : 19.5, - selectToEndDocument : 20, - selectToEndLine : 20.5, - moveCursorToStartDocument : 21, - moveCursorToStartLine : 21.5, - selectToStartDocument : 22, - selectToStartLine : 22.5, - moveCursorLeftChar : 23, - selectCursorLeftChar : 24, - moveCursorLeftWord : 25, - selectCursorLeftWord : 26, - bigMoveGraphicObjectLeft : 27, - littleMoveGraphicObjectLeft : 28, - moveCursorRightChar : 29, - selectCursorRightChar : 30, - moveCursorRightWord : 31, - selectCursorRightWord : 32, - bigMoveGraphicObjectRight : 33, - littleMoveGraphicObjectRight : 34, - moveCursorUp : 35, - selectCursorUp : 36, - bigMoveGraphicObjectUp : 37, - littleMoveGraphicObjectUp : 38, - moveCursorDown : 39, - selectCursorDown : 40, - bigMoveGraphicObjectDown : 41, - littleMoveGraphicObjectDown : 42, - removeFrontWord : 43, - removeFrontChar : 44, - selectAllContent : 45, - selectAllDrawings : 46, - bold : 47, - cleanSlicer : 48, - centerAlign : 49, - italic : 50, - justifyAlign : 51, - leftAlign : 52, - rightAlign : 53, - invertMultiselectSlicer : 54, - underline : 55, - superscriptAndSubscript : 56, - superscript : 57, - enDash : 58, - hyphen : 59, - underscore : 60, - subscript : 61, - increaseFontSize : 62, - decreaseFontSize : 63 + const graphicHotkeyTypes = { + removeBackChar : 1, + removeChart : 2, + removeShape : 3, + removeGroup : 4, + removeShapeInGroup : 5, + addTab : 6, + selectNextObject : 7, + selectPreviousObject : 8, + visitHyperink : 9, + addLineInMath : 10, + addBreakLine : 11, + addParagraph : 12, + createTxBody : 13, + moveToStartInEmptyContent : 14, + selectAllAfterEnter : 15, + selectAllTitleAfterEnter : 17, + resetTextSelection : 18, + moveCursorToEndDocument : 19, + selectToEndDocument : 20, + moveCursorToStartDocument : 21, + selectToStartDocument : 22, + moveCursorLeftChar : 23, + selectCursorLeftChar : 24, + moveCursorLeftWord : 25, + selectCursorLeftWord : 26, + bigMoveGraphicObjectLeft : 27, + littleMoveGraphicObjectLeft : 28, + moveCursorRightChar : 29, + selectCursorRightChar : 30, + moveCursorRightWord : 31, + selectCursorRightWord : 32, + bigMoveGraphicObjectRight : 33, + littleMoveGraphicObjectRight: 34, + moveCursorUp : 35, + selectCursorUp : 36, + bigMoveGraphicObjectUp : 37, + littleMoveGraphicObjectUp : 38, + moveCursorDown : 39, + selectCursorDown : 40, + bigMoveGraphicObjectDown : 41, + littleMoveGraphicObjectDown : 42, + removeFrontWord : 43, + removeFrontChar : 44, + selectAllContent : 45, + selectAllDrawings : 46, + bold : 47, + cleanSlicer : 48, + centerAlign : 49, + italic : 50, + justifyAlign : 51, + leftAlign : 52, + rightAlign : 53, + invertMultiselectSlicer : 54, + underline : 55, + superscript : 57, + enDash : 58, + subscript : 61, + increaseFontSize : 62, + decreaseFontSize : 63, + removeBackWord : 64, + selectToStartLine : 65, + moveCursorToStartLine : 66, + selectToEndLine : 67, + moveCursorToEndLine : 68, + resetStepSelection : 69 }; - const oGraphicTestEvents = {}; - oGraphicTestEvents[oGraphicTypes.removeBackChar] = [ - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.BackSpace, false, true, false, false, false)), - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, true, false, false)), - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, true, false, false)) + const graphicEvents = {}; + graphicEvents[graphicHotkeyTypes.removeBackChar] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeBackWord] = [ - new CTestEvent(createEvent(oKeyCode.BackSpace, true, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.BackSpace, true, true, false, false, false)), - new CTestEvent(createEvent(oKeyCode.BackSpace, true, false, true, false, false)) + graphicEvents[graphicHotkeyTypes.removeBackWord] = [ + new CNativeEvent(keyCodes.BackSpace, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeChart] = [ - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.Delete, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.removeChart] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false), + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeShape] = [ - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.Delete, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.removeShape] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false), + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeGroup] = [ - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.Delete, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.removeGroup] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false), + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeShapeInGroup] = [ - new CTestEvent(createEvent(oKeyCode.BackSpace, false, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.Delete, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.removeShapeInGroup] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false), + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.addTab] = [ - new CTestEvent(createEvent(oKeyCode.Tab, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.addTab] = [ + new CNativeEvent(keyCodes.Tab, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectNextObject] = [ - new CTestEvent(createEvent(oKeyCode.Tab, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectNextObject] = [ + new CNativeEvent(keyCodes.Tab, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectPreviousObject] = [ - new CTestEvent(createEvent(oKeyCode.Tab, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectPreviousObject] = [ + new CNativeEvent(keyCodes.Tab, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.visitHyperink] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.visitHyperink] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.addLineInMath] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.addLineInMath] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.addBreakLine] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.addBreakLine] = [ + new CNativeEvent(keyCodes.Enter, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.addParagraph] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.addParagraph] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.createTxBody] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.createTxBody] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveToStartInEmptyContent] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveToStartInEmptyContent] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectAllAfterEnter] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectAllAfterEnter] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorToStartPositionInTitle] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectAllTitleAfterEnter] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectAllTitleAfterEnter] = [ - new CTestEvent(createEvent(oKeyCode.Enter, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.resetTextSelection] = [ + new CNativeEvent(keyCodes.Esc, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.resetTextSelection] = [ - new CTestEvent(createEvent(oKeyCode.Esc, false, false, false, false, false)) - - ]; - oGraphicTestEvents[oGraphicTypes.resetStepSelection] = [ - new CTestEvent(createEvent(oKeyCode.Esc, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.resetStepSelection] = [ + new CNativeEvent(keyCodes.Esc, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorToEndDocument] = [ - new CTestEvent(createEvent(oKeyCode.End, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorToEndDocument] = [ + new CNativeEvent(keyCodes.End, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorToEndLine] = [ - new CTestEvent(createEvent(oKeyCode.End, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorToEndLine] = [ + new CNativeEvent(keyCodes.End, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectToEndDocument] = [ - new CTestEvent(createEvent(oKeyCode.End, true, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectToEndDocument] = [ + new CNativeEvent(keyCodes.End, true, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectToEndLine] = [ - new CTestEvent(createEvent(oKeyCode.End, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectToEndLine] = [ + new CNativeEvent(keyCodes.End, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorToStartDocument] = [ - new CTestEvent(createEvent(oKeyCode.Home, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorToStartDocument] = [ + new CNativeEvent(keyCodes.Home, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorToStartLine] = [ - new CTestEvent(createEvent(oKeyCode.Home, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorToStartLine] = [ + new CNativeEvent(keyCodes.Home, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectToStartDocument] = [ - new CTestEvent(createEvent(oKeyCode.Home, true, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectToStartDocument] = [ + new CNativeEvent(keyCodes.Home, true, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectToStartLine] = [ - new CTestEvent(createEvent(oKeyCode.Home, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectToStartLine] = [ + new CNativeEvent(keyCodes.Home, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorLeftChar] = [ - new CTestEvent(createEvent(oKeyCode.ArrowLeft, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorLeftChar] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectCursorLeftChar] = [ - new CTestEvent(createEvent(oKeyCode.ArrowLeft, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectCursorLeftChar] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorLeftWord] = [ - new CTestEvent(createEvent(oKeyCode.ArrowLeft, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorLeftWord] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectCursorLeftWord] = [ - new CTestEvent(createEvent(oKeyCode.ArrowLeft, true, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectCursorLeftWord] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.bigMoveGraphicObjectLeft] = [ - new CTestEvent(createEvent(oKeyCode.ArrowLeft, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.bigMoveGraphicObjectLeft] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.littleMoveGraphicObjectLeft] = [ - new CTestEvent(createEvent(oKeyCode.ArrowLeft, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.littleMoveGraphicObjectLeft] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorRightChar] = [ - new CTestEvent(createEvent(oKeyCode.ArrowRight, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorRightChar] = [ + new CNativeEvent(keyCodes.ArrowRight, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectCursorRightChar] = [ - new CTestEvent(createEvent(oKeyCode.ArrowRight, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectCursorRightChar] = [ + new CNativeEvent(keyCodes.ArrowRight, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorRightWord] = [ - new CTestEvent(createEvent(oKeyCode.ArrowRight, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorRightWord] = [ + new CNativeEvent(keyCodes.ArrowRight, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectCursorRightWord] = [ - new CTestEvent(createEvent(oKeyCode.ArrowRight, true, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectCursorRightWord] = [ + new CNativeEvent(keyCodes.ArrowRight, true, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.bigMoveGraphicObjectRight] = [ - new CTestEvent(createEvent(oKeyCode.ArrowRight, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.bigMoveGraphicObjectRight] = [ + new CNativeEvent(keyCodes.ArrowRight, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.littleMoveGraphicObjectRight] = [ - new CTestEvent(createEvent(oKeyCode.ArrowRight, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.littleMoveGraphicObjectRight] = [ + new CNativeEvent(keyCodes.ArrowRight, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorUp] = [ - new CTestEvent(createEvent(oKeyCode.ArrowTop, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorUp] = [ + new CNativeEvent(keyCodes.ArrowTop, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectCursorUp] = [ - new CTestEvent(createEvent(oKeyCode.ArrowTop, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectCursorUp] = [ + new CNativeEvent(keyCodes.ArrowTop, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.bigMoveGraphicObjectUp] = [ - new CTestEvent(createEvent(oKeyCode.ArrowTop, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.bigMoveGraphicObjectUp] = [ + new CNativeEvent(keyCodes.ArrowTop, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.littleMoveGraphicObjectUp] = [ - new CTestEvent(createEvent(oKeyCode.ArrowTop, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.littleMoveGraphicObjectUp] = [ + new CNativeEvent(keyCodes.ArrowTop, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.moveCursorDown] = [ - new CTestEvent(createEvent(oKeyCode.ArrowBottom, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.moveCursorDown] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectCursorDown] = [ - new CTestEvent(createEvent(oKeyCode.ArrowBottom, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectCursorDown] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.bigMoveGraphicObjectDown] = [ - new CTestEvent(createEvent(oKeyCode.ArrowBottom, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.bigMoveGraphicObjectDown] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.littleMoveGraphicObjectDown] = [ - new CTestEvent(createEvent(oKeyCode.ArrowBottom, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.littleMoveGraphicObjectDown] = [ + new CNativeEvent(keyCodes.ArrowBottom, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeFrontWord] = [ - new CTestEvent(createEvent(oKeyCode.Delete, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.removeFrontWord] = [ + new CNativeEvent(keyCodes.Delete, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.removeFrontChar] = [ - new CTestEvent(createEvent(oKeyCode.Delete, false, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.removeFrontChar] = [ + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectAllContent] = [ - new CTestEvent(createEvent(oKeyCode.A, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectAllContent] = [ + new CNativeEvent(keyCodes.A, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.selectAllDrawings] = [ - new CTestEvent(createEvent(oKeyCode.A, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.selectAllDrawings] = [ + new CNativeEvent(keyCodes.A, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.bold] = [ - new CTestEvent(createEvent(oKeyCode.B, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.bold] = [ + new CNativeEvent(keyCodes.B, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.cleanSlicer] = [ - new CTestEvent(createEvent(oKeyCode.C, true, false, true, false, false), testMacOs), - new CTestEvent(createEvent(oKeyCode.C, false, false, true, false, false), testWindows) + graphicEvents[graphicHotkeyTypes.cleanSlicer] = [ + new CNativeEvent(keyCodes.C, true, false, true, false, testFlags.macOs), + new CNativeEvent(keyCodes.C, false, false, true, false) ]; - oGraphicTestEvents[oGraphicTypes.centerAlign] = [ - new CTestEvent(createEvent(oKeyCode.E, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.centerAlign] = [ + new CNativeEvent(keyCodes.E, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.italic] = [ - new CTestEvent(createEvent(oKeyCode.I, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.italic] = [ + new CNativeEvent(keyCodes.I, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.justifyAlign] = [ - new CTestEvent(createEvent(oKeyCode.J, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.justifyAlign] = [ + new CNativeEvent(keyCodes.J, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.leftAlign] = [ - new CTestEvent(createEvent(oKeyCode.L, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.leftAlign] = [ + new CNativeEvent(keyCodes.L, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.rightAlign] = [ - new CTestEvent(createEvent(oKeyCode.R, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.rightAlign] = [ + new CNativeEvent(keyCodes.R, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.invertMultiselectSlicer] = [ - new CTestEvent(createEvent(oKeyCode.S, true, false, true, false, false), testMacOs), - new CTestEvent(createEvent(oKeyCode.S, false, false, true, false, false), testWindows) + graphicEvents[graphicHotkeyTypes.invertMultiselectSlicer] = [ + new CNativeEvent(keyCodes.S, true, false, true, false, testFlags.macOs), + new CNativeEvent(keyCodes.S, false, false, true, false) ]; - oGraphicTestEvents[oGraphicTypes.underline] = [ - new CTestEvent(createEvent(oKeyCode.U, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.underline] = [ + new CNativeEvent(keyCodes.U, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.superscript] = [ - new CTestEvent(createEvent(oKeyCode.Equal, true, true, false, false, false)), - new CTestEvent(createEvent(oKeyCode.Comma, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.superscript] = [ + new CNativeEvent(keyCodes.Comma, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.enDash] = [ - new CTestEvent(createEvent(oKeyCode.Minus, true, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.enDash] = [ + new CNativeEvent(keyCodes.Minus, true, true, false, false) ]; - oGraphicTestEvents[oGraphicTypes.hyphen] = [ - new CTestEvent(createEvent(oKeyCode.Minus, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.subscript] = [ + new CNativeEvent(keyCodes.Period, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.underscore] = [ - new CTestEvent(createEvent(oKeyCode.Minus, false, true, false, false, false)) + graphicEvents[graphicHotkeyTypes.increaseFontSize] = [ + new CNativeEvent(keyCodes.BracketRight, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.subscript] = [ - new CTestEvent(createEvent(oKeyCode.Equal, true, false, false, false, false)), - new CTestEvent(createEvent(oKeyCode.Period, true, false, false, false, false)) + graphicEvents[graphicHotkeyTypes.decreaseFontSize] = [ + new CNativeEvent(keyCodes.BracketLeft, true, false, false, false) ]; - oGraphicTestEvents[oGraphicTypes.increaseFontSize] = [ - new CTestEvent(createEvent(oKeyCode.BracketRight, true, false, false, false, false)) - - ]; - oGraphicTestEvents[oGraphicTypes.decreaseFontSize] = [ - new CTestEvent(createEvent(oKeyCode.BracketLeft, true, false, false, false, false)) - - ]; - - function startGraphicTest(fCallback, nShortcutType) - { - privateStartTest(fCallback, nShortcutType, oGraphicTestEvents); - } - const oTableTypes = { + const tableHotkeyTypes = { refreshAllConnections : 0, refreshSelectedConnections: 1, changeFormatTableInfo : 2, calculateAll : 3, - calculateWorkbook : 4, calculateActiveSheet : 5, - calculateOnlyChanged : 6, focusOnCellEditor : 7, addDate : 8, addTime : 9, @@ -527,220 +525,218 @@ moveToUpperCell : 62, contextMenu : 63, moveToLowerCell : 64, - selectToLowerCell : 65 + selectToLowerCell : 65, + selectToUpperCell : 66 }; - const oTableEvents = {}; - oTableEvents[oTableTypes.refreshAllConnections] = [ - new CTestEvent(createEvent(116, true, false, true, false, false, false)) + const tableEvents = {}; + tableEvents[tableHotkeyTypes.refreshAllConnections] = [ + new CNativeEvent(keyCodes.F5, true, false, true, false) ]; - oTableEvents[oTableTypes.refreshSelectedConnections] = [ - new CTestEvent(createEvent(116, false, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.refreshSelectedConnections] = [ + new CNativeEvent(keyCodes.F5, false, false, true, false) ]; - oTableEvents[oTableTypes.changeFormatTableInfo] = [ - new CTestEvent(createEvent(82, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.changeFormatTableInfo] = [ + new CNativeEvent(keyCodes.R, true, true, false, false) ]; - oTableEvents[oTableTypes.calculateAll] = [ - new CTestEvent(createEvent(120, true, true, true, false, false)) + tableEvents[tableHotkeyTypes.calculateAll] = [ + new CNativeEvent(keyCodes.F9, false, false, false, false) ]; - oTableEvents[oTableTypes.calculateActiveSheet] = [ - new CTestEvent(createEvent(120, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.calculateActiveSheet] = [ + new CNativeEvent(keyCodes.F9, false, true, false, false) ]; - oTableEvents[oTableTypes.calculateOnlyChanged] = [ - new CTestEvent(createEvent(120, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.focusOnCellEditor] = [ + new CNativeEvent(keyCodes.F2, false, false, false, false) ]; - oTableEvents[oTableTypes.focusOnCellEditor] = [ - new CTestEvent(createEvent(113, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.addDate] = [ + new CNativeEvent(keyCodes.Semicolon, true, false, false, false) ]; - oTableEvents[oTableTypes.addDate] = [ - new CTestEvent(createEvent(186, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.addTime] = [ + new CNativeEvent(keyCodes.Semicolon, true, true, false, false) ]; - oTableEvents[oTableTypes.addTime] = [ - new CTestEvent(createEvent(186, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.removeActiveCell] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false) ]; - oTableEvents[oTableTypes.removeActiveCell] = [ - new CTestEvent(createEvent(8, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.emptyRange] = [ + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oTableEvents[oTableTypes.emptyRange] = [ - new CTestEvent(createEvent(46, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveActiveCellToLeft] = [ + new CNativeEvent(keyCodes.Tab, false, true, false, false) ]; - oTableEvents[oTableTypes.moveActiveCellToLeft] = [ - new CTestEvent(createEvent(9, false, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveActiveCellToRight] = [ + new CNativeEvent(keyCodes.Tab, false, false, false, false) ]; - oTableEvents[oTableTypes.moveActiveCellToRight] = [ - new CTestEvent(createEvent(9, false, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveActiveCellToDown] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oTableEvents[oTableTypes.moveActiveCellToDown] = [ - new CTestEvent(createEvent(13, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveActiveCellToUp] = [ + new CNativeEvent(keyCodes.Enter, false, true, false, false) ]; - oTableEvents[oTableTypes.moveActiveCellToUp] = [ - new CTestEvent(createEvent(13, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.reset] = [ + new CNativeEvent(keyCodes.Esc, false, false, false, false) ]; - oTableEvents[oTableTypes.reset] = [ - new CTestEvent(createEvent(27, false, false, false, false)) + tableEvents[tableHotkeyTypes.disableNumLock] = [ + new CNativeEvent(keyCodes.NumLock, false, false, false, false, testFlags.opera) ]; - oTableEvents[oTableTypes.disableNumLock] = [ - new CTestEvent(createEvent(144, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.disableScrollLock] = [ + new CNativeEvent(keyCodes.ScrollLock, false, false, false, false, testFlags.opera) ]; - oTableEvents[oTableTypes.disableScrollLock] = [ - new CTestEvent(createEvent(145, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.selectColumn] = [ + new CNativeEvent(keyCodes.Space, false, true, false, false) ]; - oTableEvents[oTableTypes.selectColumn] = [ - new CTestEvent(createEvent(32, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.selectRow] = [ + new CNativeEvent(keyCodes.Space, true, false, false, false) ]; - oTableEvents[oTableTypes.selectRow] = [ - new CTestEvent(createEvent(32, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectSheet] = [ + new CNativeEvent(keyCodes.Space, true, true, false, false), + new CNativeEvent(keyCodes.A, true, false, false, false) ]; - oTableEvents[oTableTypes.selectSheet] = [ - new CTestEvent(createEvent(32, true, true, false, false, false), testWindows), - new CTestEvent(createEvent(65, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.addSeparator] = [ + new CNativeEvent(keyCodes.NumpadDecimal, false, false, false, false) ]; - oTableEvents[oTableTypes.addSeparator] = [ - new CTestEvent(createEvent(110, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.goToPreviousSheet] = [ + new CNativeEvent(keyCodes.PageUp, false, false, true, false) ]; - oTableEvents[oTableTypes.goToPreviousSheet] = [ - new CTestEvent(createEvent(33, false, false, true, false, false)) + tableEvents[tableHotkeyTypes.moveToUpperCell] = [ + new CNativeEvent(keyCodes.PageUp, false, false, false, false) ]; - oTableEvents[oTableTypes.moveToUpperCell] = [ - new CTestEvent(createEvent(33, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.selectToUpperCell] = [ + new CNativeEvent(keyCodes.PageUp, false, true, false, false) ]; - oTableEvents[oTableTypes.moveToTopCell] = [ - new CTestEvent(createEvent(38, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToTopCell] = [ + new CNativeEvent(keyCodes.ArrowTop, true, false, false, false) ]; - oTableEvents[oTableTypes.moveToNextSheet] = [ - new CTestEvent(createEvent(33, false, false, true, false, false)) + tableEvents[tableHotkeyTypes.moveToNextSheet] = [ + new CNativeEvent(keyCodes.PageDown, false, false, true, false) ]; - oTableEvents[oTableTypes.moveToBottomCell] = [ - new CTestEvent(createEvent(40, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToBottomCell] = [ + new CNativeEvent(keyCodes.ArrowBottom, true, false, false, false) ]; - oTableEvents[oTableTypes.moveToLowerCell] = [ - new CTestEvent(createEvent(34, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToLowerCell] = [ + new CNativeEvent(keyCodes.PageDown, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToLowerCell] = [ - new CTestEvent(createEvent(34, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToLowerCell] = [ + new CNativeEvent(keyCodes.PageDown, false, true, false, false) ]; - oTableEvents[oTableTypes.moveToLeftEdgeCell] = [ - new CTestEvent(createEvent(37, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToLeftEdgeCell] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false) ]; - oTableEvents[oTableTypes.selectToLeftEdgeCell] = [ - new CTestEvent(createEvent(37, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.selectToLeftEdgeCell] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false) ]; - oTableEvents[oTableTypes.moveToLeftCell] = [ - new CTestEvent(createEvent(37, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToLeftCell] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToLeftCell] = [ - new CTestEvent(createEvent(37, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToLeftCell] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, true, false, false) ]; - oTableEvents[oTableTypes.moveToRightEdgeCell] = [ - new CTestEvent(createEvent(39, true, false, false, false, false)), - new CTestEvent(createEvent(35, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToRightEdgeCell] = [ + new CNativeEvent(keyCodes.ArrowRight, true, false, false, false), + new CNativeEvent(keyCodes.End, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToRightEdgeCell] = [ - new CTestEvent(createEvent(39, true, true, false, false, false)), - new CTestEvent(createEvent(35, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToRightEdgeCell] = [ + new CNativeEvent(keyCodes.ArrowRight, true, true, false, false), + new CNativeEvent(keyCodes.End, false, true, false, false) ]; - oTableEvents[oTableTypes.moveToRightCell] = [ - new CTestEvent(createEvent(39, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToRightCell] = [ + new CNativeEvent(keyCodes.ArrowRight, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToRightCell] = [ - new CTestEvent(createEvent(39, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToRightCell] = [ + new CNativeEvent(keyCodes.ArrowRight, false, true, false, false) ]; - oTableEvents[oTableTypes.selectToTopCell] = [ - new CTestEvent(createEvent(38, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToTopCell] = [ + new CNativeEvent(keyCodes.ArrowTop, true, true, false, false) ]; - oTableEvents[oTableTypes.moveToUpCell] = [ - new CTestEvent(createEvent(38, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToUpCell] = [ + new CNativeEvent(keyCodes.ArrowTop, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToUpCell] = [ - new CTestEvent(createEvent(38, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToUpCell] = [ + new CNativeEvent(keyCodes.ArrowTop, false, true, false, false) ]; - oTableEvents[oTableTypes.selectToBottomCell] = [ - new CTestEvent(createEvent(40, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToBottomCell] = [ + new CNativeEvent(keyCodes.ArrowBottom, true, true, false, false) ]; - oTableEvents[oTableTypes.moveToDownCell] = [ - new CTestEvent(createEvent(40, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToDownCell] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToDownCell] = [ - new CTestEvent(createEvent(40, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToDownCell] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, true, false, false) ]; - oTableEvents[oTableTypes.moveToFirstColumn] = [ - new CTestEvent(createEvent(36, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToFirstColumn] = [ + new CNativeEvent(keyCodes.Home, false, false, false, false) ]; - oTableEvents[oTableTypes.selectToFirstColumn] = [ - new CTestEvent(createEvent(36, false, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToFirstColumn] = [ + new CNativeEvent(keyCodes.Home, false, true, false, false) ]; - oTableEvents[oTableTypes.moveToLeftEdgeTop] = [ - new CTestEvent(createEvent(36, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToLeftEdgeTop] = [ + new CNativeEvent(keyCodes.Home, true, false, false, false) ]; - oTableEvents[oTableTypes.selectToLeftEdgeTop] = [ - new CTestEvent(createEvent(36, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToLeftEdgeTop] = [ + new CNativeEvent(keyCodes.Home, true, true, false, false) ]; - oTableEvents[oTableTypes.moveToRightBottomEdge] = [ - new CTestEvent(createEvent(35, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.moveToRightBottomEdge] = [ + new CNativeEvent(keyCodes.End, true, false, false, false) ]; - oTableEvents[oTableTypes.selectToRightBottomEdge] = [ - new CTestEvent(createEvent(35, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.selectToRightBottomEdge] = [ + new CNativeEvent(keyCodes.End, true, true, false, false) ]; - oTableEvents[oTableTypes.setNumberFormat] = [ - new CTestEvent(createEvent(49, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setNumberFormat] = [ + new CNativeEvent(keyCodes.Digit1, true, true, false, false) ]; - oTableEvents[oTableTypes.setTimeFormat] = [ - new CTestEvent(createEvent(50, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setTimeFormat] = [ + new CNativeEvent(keyCodes.Digit2, true, true, false, false) ]; - oTableEvents[oTableTypes.setDateFormat] = [ - new CTestEvent(createEvent(51, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setDateFormat] = [ + new CNativeEvent(keyCodes.Digit3, true, true, false, false) ]; - oTableEvents[oTableTypes.setCurrencyFormat] = [ - new CTestEvent(createEvent(52, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setCurrencyFormat] = [ + new CNativeEvent(keyCodes.Digit4, true, true, false, false) ]; - oTableEvents[oTableTypes.setPercentFormat] = [ - new CTestEvent(createEvent(53, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setPercentFormat] = [ + new CNativeEvent(keyCodes.Digit5, true, true, false, false) ]; - oTableEvents[oTableTypes.setStrikethrough] = [ - new CTestEvent(createEvent(53, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.setStrikethrough] = [ + new CNativeEvent(keyCodes.Digit5, true, false, false, false) ]; - oTableEvents[oTableTypes.setExponentialFormat] = [ - new CTestEvent(createEvent(54, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setExponentialFormat] = [ + new CNativeEvent(keyCodes.Digit6, true, true, false, false) ]; - oTableEvents[oTableTypes.setBold] = [ - new CTestEvent(createEvent(66, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.setBold] = [ + new CNativeEvent(keyCodes.B, true, false, false, false) ]; - oTableEvents[oTableTypes.setItalic] = [ - new CTestEvent(createEvent(73, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.setItalic] = [ + new CNativeEvent(keyCodes.I, true, false, false, false) ]; - oTableEvents[oTableTypes.setUnderline] = [ - new CTestEvent(createEvent(85, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.setUnderline] = [ + new CNativeEvent(keyCodes.U, true, false, false, false) ]; - oTableEvents[oTableTypes.setGeneralFormat] = [ - new CTestEvent(createEvent(192, true, true, false, false, false)) + tableEvents[tableHotkeyTypes.setGeneralFormat] = [ + new CNativeEvent(keyCodes.Backquote, true, true, false, false) ]; - oTableEvents[oTableTypes.redo] = [ - new CTestEvent(createEvent(89, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.redo] = [ + new CNativeEvent(keyCodes.Y, true, false, false, false) ]; - oTableEvents[oTableTypes.undo] = [ - new CTestEvent(createEvent(90, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.undo] = [ + new CNativeEvent(keyCodes.Z, true, false, false, false) ]; - oTableEvents[oTableTypes.print] = [ - new CTestEvent(createEvent(80, true, false, false, false, false)) + tableEvents[tableHotkeyTypes.print] = [ + new CNativeEvent(keyCodes.P, true, false, false, false) ]; - oTableEvents[oTableTypes.addSum] = [ - new CTestEvent(createEvent(61, false, false, true, false, false), testWindows), - new CTestEvent(createEvent(61, true, false, true, false, false), testMacOs) + tableEvents[tableHotkeyTypes.addSum] = [ + new CNativeEvent(keyCodes.EqualFirefox, false, false, true, false), + new CNativeEvent(keyCodes.EqualFirefox, true, false, true, false, testFlags.macOs), + new CNativeEvent(keyCodes.Equal, false, false, true, false), + new CNativeEvent(keyCodes.Equal, true, false, true, false, testFlags.macOs) ]; - oTableEvents[oTableTypes.contextMenu] = [ - new CTestEvent(createEvent(93, false, false, false, false, false)) + tableEvents[tableHotkeyTypes.contextMenu] = [ + new CNativeEvent(keyCodes.ContextMenu, false, false, false, false) ]; - function startTableTest(fCallback, nShortcutType) - { - privateStartTest(fCallback, nShortcutType, oTableEvents); - } - - const oCellEditorTypes = { + const cellEditorHotkeyTypes = { closeWithoutSave : 0, addNewLine : 1, saveAndMoveDown : 2, @@ -790,154 +786,179 @@ }; const oCellEditorEvents = {}; - oCellEditorEvents[oCellEditorTypes.closeWithoutSave] = [ - new CTestEvent(createEvent(27, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.closeWithoutSave] = [ + new CNativeEvent(keyCodes.Esc, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.addNewLine] = [ - new CTestEvent(createEvent(13, false, false, true, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.addNewLine] = [ + new CNativeEvent(keyCodes.Enter, false, false, true, false) ]; - oCellEditorEvents[oCellEditorTypes.saveAndMoveDown] = [ - new CTestEvent(createEvent(13, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.saveAndMoveDown] = [ + new CNativeEvent(keyCodes.Enter, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.saveAndMoveUp] = [ - new CTestEvent(createEvent(13, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.saveAndMoveUp] = [ + new CNativeEvent(keyCodes.Enter, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.saveAndMoveRight] = [ - new CTestEvent(createEvent(9, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.saveAndMoveRight] = [ + new CNativeEvent(keyCodes.Tab, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.saveAndMoveLeft] = [ - new CTestEvent(createEvent(9, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.saveAndMoveLeft] = [ + new CNativeEvent(keyCodes.Tab, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.removeCharBack] = [ - new CTestEvent(createEvent(8, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.removeCharBack] = [ + new CNativeEvent(keyCodes.BackSpace, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.removeWordBack] = [ - new CTestEvent(createEvent(8, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.removeWordBack] = [ + new CNativeEvent(keyCodes.BackSpace, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.addSpace] = [ - new CTestEvent(createEvent(32, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.addSpace] = [ + new CNativeEvent(keyCodes.Space, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToEndLine] = [ - new CTestEvent(createEvent(35, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToEndLine] = [ + new CNativeEvent(keyCodes.End, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToEndDocument] = [ - new CTestEvent(createEvent(35, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToEndDocument] = [ + new CNativeEvent(keyCodes.End, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectToEndLine] = [ - new CTestEvent(createEvent(35, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectToEndLine] = [ + new CNativeEvent(keyCodes.End, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectToEndDocument] = [ - new CTestEvent(createEvent(35, true, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectToEndDocument] = [ + new CNativeEvent(keyCodes.End, true, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToStartLine] = [ - new CTestEvent(createEvent(36, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToStartLine] = [ + new CNativeEvent(keyCodes.Home, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToStartDocument] = [ - new CTestEvent(createEvent(36, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToStartDocument] = [ + new CNativeEvent(keyCodes.Home, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectToStartLine] = [ - new CTestEvent(createEvent(36, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectToStartLine] = [ + new CNativeEvent(keyCodes.Home, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectToStartDocument] = [ - new CTestEvent(createEvent(36, true, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectToStartDocument] = [ + new CNativeEvent(keyCodes.Home, true, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveCursorLeftChar] = [ - new CTestEvent(createEvent(37, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveCursorLeftChar] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveCursorLeftWord] = [ - new CTestEvent(createEvent(37, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveCursorLeftWord] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectLeftChar] = [ - new CTestEvent(createEvent(37, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectLeftChar] = [ + new CNativeEvent(keyCodes.ArrowLeft, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectLeftWord] = [ - new CTestEvent(createEvent(37, true, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectLeftWord] = [ + new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToUpLine] = [ - new CTestEvent(createEvent(38, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToUpLine] = [ + new CNativeEvent(keyCodes.ArrowTop, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectToUpLine] = [ - new CTestEvent(createEvent(38, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectToUpLine] = [ + new CNativeEvent(keyCodes.ArrowTop, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToRightChar] = [ - new CTestEvent(createEvent(39, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToRightChar] = [ + new CNativeEvent(keyCodes.ArrowRight, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToRightWord] = [ - new CTestEvent(createEvent(39, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToRightWord] = [ + new CNativeEvent(keyCodes.ArrowRight, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectRightChar] = [ - new CTestEvent(createEvent(39, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectRightChar] = [ + new CNativeEvent(keyCodes.ArrowRight, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectRightWord] = [ - new CTestEvent(createEvent(39, true, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectRightWord] = [ + new CNativeEvent(keyCodes.ArrowRight, true, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.moveToDownLine] = [ - new CTestEvent(createEvent(40, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.moveToDownLine] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectToDownLine] = [ - new CTestEvent(createEvent(40, false, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectToDownLine] = [ + new CNativeEvent(keyCodes.ArrowBottom, false, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.deleteFrontChar] = [ - new CTestEvent(createEvent(46, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.deleteFrontChar] = [ + new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.deleteFrontWord] = [ - new CTestEvent(createEvent(46, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.deleteFrontWord] = [ + new CNativeEvent(keyCodes.Delete, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.setStrikethrough] = [ - new CTestEvent(createEvent(53, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.setStrikethrough] = [ + new CNativeEvent(keyCodes.Digit5, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.selectAll] = [ - new CTestEvent(createEvent(65, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.selectAll] = [ + new CNativeEvent(keyCodes.A, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.setBold] = [ - new CTestEvent(createEvent(66, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.setBold] = [ + new CNativeEvent(keyCodes.B, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.setItalic] = [ - new CTestEvent(createEvent(73, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.setItalic] = [ + new CNativeEvent(keyCodes.I, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.setUnderline] = [ - new CTestEvent(createEvent(85, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.setUnderline] = [ + new CNativeEvent(keyCodes.U, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.disableScrollLock] = [ - new CTestEvent(createEvent(145, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.disableScrollLock] = [ + new CNativeEvent(keyCodes.ScrollLock, false, false, false, false, testFlags.opera) ]; - oCellEditorEvents[oCellEditorTypes.disableNumLock] = [ - new CTestEvent(createEvent(144, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.disableNumLock] = [ + new CNativeEvent(keyCodes.NumLock, false, false, false, false, testFlags.opera) ]; - oCellEditorEvents[oCellEditorTypes.disablePrint] = [ - new CTestEvent(createEvent(80, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.disablePrint] = [ + new CNativeEvent(keyCodes.P, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.undo] = [ - new CTestEvent(createEvent(90, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.undo] = [ + new CNativeEvent(keyCodes.Z, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.redo] = [ - new CTestEvent(createEvent(89, true, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.redo] = [ + new CNativeEvent(keyCodes.Y, true, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.addSeparator] = [ - new CTestEvent(createEvent(110, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.addSeparator] = [ + new CNativeEvent(keyCodes.NumpadDecimal, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.disableF2] = [ - new CTestEvent(createEvent(113, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.disableF2] = [ + new CNativeEvent(keyCodes.F2, false, false, false, false, testFlags.opera) ]; - oCellEditorEvents[oCellEditorTypes.switchReference] = [ - new CTestEvent(createEvent(115, false, false, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.switchReference] = [ + new CNativeEvent(keyCodes.F4, false, false, false, false) ]; - oCellEditorEvents[oCellEditorTypes.addTime] = [ - new CTestEvent(createEvent(186, true, true, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.addTime] = [ + new CNativeEvent(keyCodes.Semicolon, true, true, false, false) ]; - oCellEditorEvents[oCellEditorTypes.addDate] = [ - new CTestEvent(createEvent(186, true, false, false, false)) + oCellEditorEvents[cellEditorHotkeyTypes.addDate] = [ + new CNativeEvent(keyCodes.Semicolon, true, false, false, false) ]; - function startCellEditorTest(fCallback, nShortcutType) + function ExecuteGraphicHotkey(type, eventIndex) + { + const event = graphicEvents[type][eventIndex || 0]; + return ExecuteShortcut(event); + } + + function ExecuteTableHotkey(type, eventIndex) + { + const event = tableEvents[type][eventIndex || 0]; + return ExecuteShortcut(event); + } + + function ExecuteCellEditorHotkey(type, eventIndex) + { + const event = oCellEditorEvents[type][eventIndex || 0]; + return ExecuteShortcut(event); + } + + function ExecuteShortcut(e) { - privateStartTest(fCallback, nShortcutType, oCellEditorEvents); + e.enableFlags(); + Asc.editor.onKeyDown(e); + e.disableFlags(); + return e.isDefaultPrevented; } - AscTestShortcut.startCellEditorTest = startCellEditorTest; - AscTestShortcut.startTableTest = startTableTest; - AscTestShortcut.startGraphicTest = startGraphicTest; - AscTestShortcut.oTableTypes = oTableTypes; - AscTestShortcut.oCellEditorTypes = oCellEditorTypes; - AscTestShortcut.oGraphicTypes = oGraphicTypes; + window.AscTestShortcut = {}; + AscTestShortcut.tableHotkeyTypes = tableHotkeyTypes; + AscTestShortcut.cellEditorHotkeyTypes = cellEditorHotkeyTypes; + AscTestShortcut.graphicHotkeyTypes = graphicHotkeyTypes; + AscTestShortcut.graphicEvents = graphicEvents; + AscTestShortcut.tableEvents = tableEvents; + AscTestShortcut.ExecuteCellEditorHotkey = ExecuteCellEditorHotkey; + AscTestShortcut.ExecuteTableHotkey = ExecuteTableHotkey; + AscTestShortcut.ExecuteGraphicHotkey = ExecuteGraphicHotkey; + AscTestShortcut.ExecuteShortcut = ExecuteShortcut; })(window); diff --git a/tests/cell/shortcuts/helpers.js b/tests/cell/shortcuts/helpers.js deleted file mode 100644 index a3b3cf0697..0000000000 --- a/tests/cell/shortcuts/helpers.js +++ /dev/null @@ -1,927 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -"use strict"; - -var AscTestShortcut = AscTestShortcut || {}; -(function (window) -{ - window.AscFonts = AscFonts || {}; - window.setTimeout = function (callback) - { - callback(); - } - Asc.spreadsheet_api.prototype._loadFonts = function (fonts, callback) - { - callback(); - }; - Asc.spreadsheet_api.prototype._loadModules = function () {}; - AscCommon.baseEditorsApi.prototype._onEndLoadSdk = function() { - this.ImageLoader = AscCommon.g_image_loader; - this.chartPreviewManager = new AscCommon.ChartPreviewManager(); - this.textArtPreviewManager = new AscCommon.TextArtPreviewManager(); - - AscFormat.initStyleManager(); - }; - Asc.spreadsheet_api.prototype._loadFonts = function(fonts, callback) { - callback(); - }; - AscCommonExcel.WorksheetView.prototype._calcVisibleRows = function () - { - - }; - AscCommonExcel.WorksheetView.prototype._calcVisibleColumns = function () - { - - }; - AscCommonExcel.WorksheetView.prototype.scrollVertical = function () - { - - }; - AscCommonExcel.WorksheetView.prototype.scrollHorizontal = function () - { - - }; - AscCommonExcel.WorksheetView.prototype._normalizeViewRange = function () - { - - }; - AscCommonExcel.WorksheetView.prototype._fixVisibleRange = function () - { - - }; - - AscCommonExcel.WorkbookView.prototype.sendCursor = function () - { - - } - - const fOldCellEditor = AscCommonExcel.CellEditor.prototype.open; - AscCommonExcel.CellEditor.prototype.open = function (options) - { - options.getSides = function () - { - return {l: [0], r: [100], b: [10], cellX: 0, cellY: 0, ri: 0, bi: 0}; - } - fOldCellEditor.call(this, options); - }; - Asc.DrawingContext.prototype.measureChar = function () - { - return Asc.TextMetrics(5, 9, 10, 1, 1, 10, 5); - } - AscFonts.CFontManager.prototype.MeasureChar = function () - { - return {fAdvanceX: 5, oBBox: {fMaxX: 0, fMinX: 0}}; - }; - AscCommon.ZLib = function () - { - this.open = function () - { - return false; - } - }; - - Asc.DrawingContext.prototype.setFont = function () - { - }; - Asc.DrawingContext.prototype.fillText = function () - { - }; - Asc.DrawingContext.prototype.getFontMetrics = function () - { - return {ascender: 15, descender: 4, lineGap: 1, nat_scale: 1000, nat_y1: 1000, nat_y2: -1000}; - }; - - AscCommon.loadSmartArtBinary = function () - { - - }; - - function initEditor() - { - const editor = new Asc.spreadsheet_api({'id-view': 'editor_sdk', 'id-input': 'ce-cell-content'}); - editor.FontLoader = { - LoadDocumentFonts: function () - { - editor.ServerIdWaitComplete = true; - editor._coAuthoringInitEnd(); - editor.asyncFontsDocumentEndLoaded(); - } - } - - - const sStream = AscCommon.getEmpty(); - const oFile = new AscCommon.OpenFileResult(); - oFile.bSerFormat = AscCommon.checkStreamSignature(sStream, AscCommon.c_oSerFormat.Signature); - oFile.data = sStream; - - editor.openDocument(oFile); - - - editor.asc_setZoom(1); - return editor; - } - - const editor = initEditor(); - - function createEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsAltGr, bIsMacCmdKey) - { - const oKeyBoardEvent = { - preventDefault : function () - { - this.isDefaultPrevented = true; - }, - stopPropagation: function () - { - this.isPropagationStopped = true; - } - }; - oKeyBoardEvent.isDefaultPrevented = false; - oKeyBoardEvent.isPropagationStopped = false; - oKeyBoardEvent.which = nKeyCode; - oKeyBoardEvent.keyCode = nKeyCode; - oKeyBoardEvent.shiftKey = bIsShift; - oKeyBoardEvent.altKey = bIsAlt; - oKeyBoardEvent.ctrlKey = bIsCtrl; - oKeyBoardEvent.metaKey = bIsMacCmdKey; - oKeyBoardEvent.altGr = bIsAltGr; - return oKeyBoardEvent; - } - - function wbModel() - { - return editor.wbModel; - } - - function wbView() - { - return editor.wb; - } - - function executeTestWithCatchEvent(sSendEvent, fCustomCheck, customExpectedValue, oEvent, oAssert, fBeforeCallback) - { - fBeforeCallback && fBeforeCallback(); - - let bCheck = false; - - const fCheck = function (...args) - { - if (fCustomCheck) - { - bCheck = fCustomCheck(...args); - } else - { - bCheck = true; - } - } - editor.asc_registerCallback(sSendEvent, fCheck); - - onKeyDown(oEvent); - oAssert.strictEqual(bCheck, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); - editor.asc_unregisterCallback(sSendEvent, fCheck); - } - - function getFragments(start, length) - { - return cellEditor()._getFragments(start, length); - } - - function getSelectionCellEditor() - { - return cellEditor().copySelection().map((e) => e.getFragmentText()).join(''); - } - - function moveToStartCellEditor() - { - cellEditor()._moveCursor(-2); - } - - function moveToEndCellEditor() - { - cellEditor()._moveCursor(-4); - } - - function moveRight() - { - wbView()._onChangeSelection(true, 1, 0, false, false); - } - - function moveToCell(nRow, nCol) - { - const nCurrentCell = activeCell(); - wbView()._onChangeSelection(true, nCol - nCurrentCell.c1, nRow - nCurrentCell.r1, false, false); - } - - function selectToCell(nRow, nCol) - { - const nCurrentCell = activeCell(); - wbView()._onChangeSelection(false, nCol - nCurrentCell.c1, nRow - nCurrentCell.r1, false, false); - } - - function onKeyDown(oEvent) - { - if (oEvent instanceof Object) - { - editor.onKeyDown(oEvent); - } else - { - const oRetEvent = createEvent.apply(null, arguments); - editor.onKeyDown(oRetEvent); - return oRetEvent; - } - } - - - function checkTextAfterKeyDownHelperEmpty(sCheckText, oEvent, oAssert, sPrompt) - { - checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, ''); - } - - function remove() - { - editor.asc_Remove(); - } - - function closeCellEditor(bSkip) - { - wbView().closeCellEditor(); - } - - function enterTextWithoutClose(sString) - { - wbView().EnterText(sString.split('').map((e) => e.charCodeAt(0))); - setCheckOpenCellEditor(true); - } - - function enterText(sString) - { - enterTextWithoutClose(sString); - closeCellEditor(); - } - - function cellEditor() - { - return wbView().cellEditor; - } - - function getCellText() - { - closeCellEditor(true); - return activeCellRange().getValueWithFormat(); - } - - function getCellTextWithoutFormat() - { - closeCellEditor(); - return activeCellRange().getValueWithoutFormat(); - } - - function moveDown() - { - wbView()._onChangeSelection(true, 0, 1, false, false); - } - - function wsView() - { - return wbView().getWorksheet(); - } - - function ws() - { - return wsView().model; - } - - function moveAndEnterText(sText, nRow, nCol) - { - moveToCell(nRow, nCol); - enterText(sText); - } - - function createTest(oAssert) - { - const deep = (result, expected, sPrompt) => oAssert.deepEqual(result, expected, sPrompt); - const equal = (result, expected, sPrompt) => oAssert.strictEqual(result, expected, sPrompt); - return {deep, equal}; - } - - function moveAndGetCellText(nRow, nCol) - { - - moveToCell(nRow, nCol); - return getCellText(); - } - - function goToSheet(i) - { - wbView().showWorksheet(i); - } - - let id = 0; - - function createWorksheet() - { - const sName = 'name' + id; - editor.asc_addWorksheet(sName); - id += 1; - return sName; - } - - function removeCurrentWorksheet() - { - editor.asc_deleteWorksheet(); - } - - function cleanCell(oRange) - { - return {r: oRange.r1, c: oRange.c1}; - } - - function cleanRange(oRange) - { - return {r1: oRange.r1, r2: oRange.r2, c1: oRange.c1, c2: oRange.c2}; - } - - function cleanSelection() - { - return cleanRange(selectionRange()); - } - - function cleanActiveCell() - { - return cleanCell(activeCell()); - } - - function checkRange(nRow1, nRow2, nCol1, nCol2) - { - return cleanRange(Asc.Range(nCol1, nRow1, nCol2, nRow2, true)); - } - - function openCellEditor() - { - var enterOptions = new AscCommonExcel.CEditorEnterOptions(); - enterOptions.newText = ''; - enterOptions.quickInput = true; - enterOptions.focus = true; - handlers().trigger('editCell', enterOptions); - setCheckOpenCellEditor(true); - } - - function checkActiveCell(nRow, nCol) - { - return cleanCell(new Asc.Range(nCol, nRow, nCol, nRow, true)); - } - - function cleanCache() - { - wsView()._cleanCache(); - } - - function selectAll() - { - wbView().selectAll(); - } - - function cleanAll() - { - selectAll(); - handlers().trigger("empty"); - cleanCache(); - wsView().changeZoomResize(); - wsView().visibleRange = new Asc.Range(0, 0, 23, 37); - moveToCell(0, 0); - } - - function setCellFormat(nFormat) - { - handlers().trigger('setCellFormat', nFormat); - - - } - - function selectionInfo() - { - return wbView().getSelectionInfo(); - } - - function xfs() - { - return selectionInfo().asc_getXfs(); - } - - function undo() - { - handlers().trigger('undo'); - } - - function selectAllCell() - { - cellEditor()._moveCursor(-2); - cellEditor()._selectChars(-4); - } - - function cellPosition() - { - return cellEditor().cursorPos; - } - - function getCellEditMode() - { - return wsView().getCellEditMode(); - } - - function testPreventDefaultAndStopPropagation(oEvent, oAssert, bInvert) - { - onKeyDown(oEvent); - oAssert.true(!!bInvert ? !oEvent.isDefaultPrevented : oEvent.isDefaultPrevented); - oAssert.true(!!bInvert ? !oEvent.isPropagationStopped : oEvent.isPropagationStopped); - } - - function controller() - { - return editor.wb.controller; - } - - function handlers() - { - return controller().handlers; - } - - function activeCell() - { - return wsView().getActiveCell(); - } - - function selectionRange() - { - return wsView().getSelectedRange().bbox; - } - - function activeCellRange() - { - return ws().getRange3(activeCell().r1, activeCell().c1, activeCell().r2, activeCell().c2); - } - - function addHyperlink(sLink, sText) - { - const oHyperlink = new AscCommonExcel.Hyperlink(); - oHyperlink.Hyperlink = sLink; - - const oAscHyperlink = new Asc.asc_CHyperlink(oHyperlink); - oAscHyperlink.text = sText; - editor.asc_insertHyperlink(oAscHyperlink); - } - - function createMathInShape() - { - const {oShape, oParagraph} = createShapeWithContent('', true); - selectOnlyObjects([oShape]); - moveToParagraph(oParagraph, true); - editor.asc_AddMath2(c_oAscMathType.FractionVertical); - return {oShape, oParagraph}; - } - - function moveCursorRight(bAddToSelect, bWord) - { - graphicController().cursorMoveRight(bAddToSelect, bWord); - } - - function moveCursorLeft(bAddToSelect, bWord) - { - graphicController().cursorMoveLeft(bAddToSelect, bWord); - } - - function moveCursorUp(bAddToSelect, bWord) - { - graphicController().cursorMoveUp(bAddToSelect, bWord); - } - - function moveCursorDown(bAddToSelect, bWord) - { - graphicController().cursorMoveDown(bAddToSelect, bWord); - - } - - function checkMoveContentShapeHelper(arrExpected, oEvent, oAssert) - { - const {deep, equal} = createTest(oAssert); - const {oShape} = createShapeWithContent('Hello World Hello World Hello World Hello World Hello World'); - moveToShapeParagraph(oShape, 0); - onKeyDown(oEvent); - equal(contentPosition(), arrExpected[0]); - - moveToShapeParagraph(oShape, 0, true); - onKeyDown(oEvent); - equal(contentPosition(), arrExpected[1]); - } - - function contentPosition() - { - const arrContentPosition = graphicController().getTargetDocContent().GetContentPosition(); - return arrContentPosition[arrContentPosition.length - 1].Position; - } - - function selectedContent() - { - return graphicController().GetSelectedText(false, {TabSymbol: '\t'}); - } - - function checkSelectContentShapeHelper(arrExpected, oEvent, oAssert) - { - const {deep, equal} = createTest(oAssert); - const {oShape} = createShapeWithContent('Hello World Hello World Hello World Hello World Hello World'); - moveToShapeParagraph(oShape, 0, true); - onKeyDown(oEvent); - equal(selectedContent(), arrExpected[0]); - - moveToShapeParagraph(oShape, 0); - onKeyDown(oEvent); - equal(selectedContent(), arrExpected[1]); - } - - function round(nNumber, nAmount) - { - const nPower = Math.pow(10, nAmount); - return Math.round(nNumber * nPower) / nPower; - } - - function moveShapeHelper(oExpected, oEvent, oAssert) - { - const oShape = createShape(); - const {deep, equal} = createTest(oAssert); - selectOnlyObjects([oShape]); - - onKeyDown(oEvent); - oShape.recalculateTransform(); - deep({x: round(oShape.x, 12), y: round(oShape.y, 12)}, {x: round(oExpected.x, 12), y: round(oExpected.y, 12)}); - } - - function createTable() - { - moveToCell(0, 0); - enterText('Hello'); - - moveToCell(1, 0); - enterText('1'); - moveToCell(2, 0); - enterText('2'); - moveToCell(3, 0); - enterText('3'); - moveToCell(4, 0); - enterText('4'); - moveToCell(0, 0); - selectToCell(4, 0); - - editor.asc_addAutoFilter('TableStyleMedium2', editor.asc_getAddFormatTableOptions()); - } - - function createSlicer() - { - createTable(); - editor.asc_insertSlicer(['Hello']); - return graphicController().getSelectedArray()[0]; - } - - function moveToShapeParagraph(oShape, nParagraph, bIsMoveToStart) - { - const oParagraph = oShape.getDocContent().Content[nParagraph]; - moveToParagraph(oParagraph, bIsMoveToStart); - - return oParagraph; - } - - - function addProperty(oPr) - { - graphicController().paragraphAdd(new AscCommonWord.ParaTextPr(oPr), true); - } - - function targetContent() - { - return graphicController().getTargetDocContent(); - } - - function textPr() - { - return graphicController().getParagraphTextPr(); - } - - function paraPr() - { - return graphicController().getParagraphParaPr(); - } - - function moveToParagraph(oParagraph, bToStart) - { - oParagraph.SetThisElementCurrent(); - if (bToStart) - { - oParagraph.MoveCursorToStartPos(); - } else - { - oParagraph.MoveCursorToEndPos(); - } - - graphicController().recalculateCurPos(true, true); - } - - function selectedObjects() - { - return graphicController().getSelectedArray(); - } - - function cleanGraphic() - { - graphicController().resetSelection(); - graphicController().selectAll(); - graphicController().remove(); - } - - function graphicController() - { - return editor.getGraphicController(); - } - - function createShape() - { - const oGraphicController = graphicController(); - const oTrack = new AscFormat.NewShapeTrack('rect', 0, 0, wbModel().theme, null, null, null, 0, oGraphicController); - const oShape = oTrack.getShape(false, drawingDocument(), oGraphicController.drawingObjects); - oShape.setWorksheet(wbView().getWorksheet().model); - oShape.spPr.xfrm.setOffX(100); - oShape.spPr.xfrm.setOffY(100); - oShape.spPr.xfrm.setExtX(100); - oShape.spPr.xfrm.setExtY(100); - oShape.setPaddings({Left: 0, Right: 0, Top: 0, Bottom: 0}); - oShape.setParent(oGraphicController.drawingObjects); - oShape.setRecalculateInfo(); - - oShape.addToDrawingObjects(undefined, AscCommon.c_oAscCellAnchorType.cellanchorTwoCell); - oShape.checkDrawingBaseCoords(); - oGraphicController.checkChartTextSelection(); - oGraphicController.resetSelection(); - oShape.select(oGraphicController, 0); - oGraphicController.startRecalculate(); - oGraphicController.drawingObjects.sendGraphicObjectProps(); - oGraphicController.recalculate(); - oShape.recalculateTransform(); - - return oShape; - } - - function drawingDocument() - { - return wbModel().DrawingDocument; - } - - function selectOnlyObjects(arrShapes) - { - const oController = graphicController(); - oController.resetSelection(); - for (let i = 0; i < arrShapes.length; i += 1) - { - const oObject = arrShapes[i]; - if (oObject.group) - { - const oMainGroup = oObject.group.getMainGroup(); - oMainGroup.select(oController, 0); - oController.selection.groupSelection = oMainGroup; - } - oObject.select(oController, 0); - } - } - - function createShapeWithContent(sText) - { - const oShape = createShape(); - selectOnlyObjects([oShape]) - oShape.setTxBody(AscFormat.CreateTextBodyFromString(sText, drawingDocument(), oShape)); - const oParagraph = oShape.txBody.content.Content[0]; - oShape.recalculateContentWitCompiledPr(); - return {oShape, oParagraph}; - } - - function checkTextAfterKeyDownHelperHelloWorld(sCheckText, oEvent, oAssert, sPrompt) - { - checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, 'Hello World'); - } - - function getParagraphText(oParagraph) - { - return oParagraph.GetText({ParaEndToSpace: false}); - } - - function checkTextAfterKeyDownHelper(sCheckText, oEvent, oAssert, sPrompt, sInitText) - { - const {oParagraph} = createShapeWithContent(sInitText); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - const sTextAfterKeyDown = getParagraphText(oParagraph); - oAssert.strictEqual(sTextAfterKeyDown, sCheckText, sPrompt); - } - - function checkDirectTextPrAfterKeyDown(fCallback, oEvent, oAssert, nExpectedValue, sPrompt) - { - const {oParagraph} = createShapeWithContent('Hello World'); - let oTextPr = getDirectTextPrHelper(oParagraph, oEvent); - oAssert.strictEqual(fCallback(oTextPr), nExpectedValue, sPrompt); - return function continueCheck(fCallback2, oEvent2, oAssert2, nExpectedValue2, sPrompt2) - { - oTextPr = getDirectTextPrHelper(oParagraph, oEvent2); - oAssert2.strictEqual(fCallback2(oTextPr), nExpectedValue2, sPrompt2); - return continueCheck; - } - } - - function checkDirectParaPrAfterKeyDown(fCallback, oEvent, oAssert, nExpectedValue, sPrompt) - { - const {oParagraph} = createShapeWithContent('Hello World'); - let oParaPr = getDirectParaPrHelper(oParagraph, oEvent); - oAssert.strictEqual(fCallback(oParaPr), nExpectedValue, sPrompt); - - return function continueCheck(fCallback2, oEvent2, oAssert2, nExpectedValue2, sPrompt2) - { - oParaPr = getDirectParaPrHelper(oParagraph, oEvent2); - oAssert2.strictEqual(fCallback2(oParaPr), nExpectedValue2, sPrompt2); - return continueCheck; - } - } - - function getDirectTextPrHelper(oParagraph, oEvent) - { - oParagraph.SetThisElementCurrent(); - graphicController().selectAll(); - onKeyDown(oEvent); - return textPr(); - } - - function getDirectParaPrHelper(oParagraph, oEvent) - { - oParagraph.SetThisElementCurrent(); - graphicController().selectAll(); - onKeyDown(oEvent); - return paraPr(); - } - - function checkRemoveObject(oShape, arrShapes) - { - return !!(arrShapes.indexOf(oShape) === -1 && oShape.bDeleted); - } - - function createGroup(arrShapes) - { - graphicController().resetSelection(); - selectOnlyObjects(arrShapes); - return graphicController().createGroup(); - } - - function createChart() - { - moveAndEnterText('1', 0, 0); - moveAndEnterText('2', 1, 0); - moveAndEnterText('3', 2, 0); - - moveAndEnterText('1', 0, 1); - moveAndEnterText('2', 1, 1); - moveAndEnterText('3', 2, 1); - - selectToCell(0, 0); - - const oProps = editor.asc_getChartObject(true); - oProps.changeType(0); - editor.asc_addChartDrawingObject(oProps); - return selectedObjects()[0]; - } - - let bIsCellEditorOpened = false; - - function setCheckOpenCellEditor(oPr) - { - bIsCellEditorOpened = oPr; - } - - function checkOpenCellEditor() - { - return bIsCellEditorOpened; - } - - AscTestShortcut.wbModel = wbModel; - AscTestShortcut.wbView = wbView; - AscTestShortcut.executeTestWithCatchEvent = executeTestWithCatchEvent; - AscTestShortcut.getFragments = getFragments; - AscTestShortcut.getSelectionCellEditor = getSelectionCellEditor; - AscTestShortcut.moveToStartCellEditor = moveToStartCellEditor; - AscTestShortcut.moveToEndCellEditor = moveToEndCellEditor; - AscTestShortcut.moveRight = moveRight; - AscTestShortcut.moveToCell = moveToCell; - AscTestShortcut.selectToCell = selectToCell; - AscTestShortcut.onKeyDown = onKeyDown; - AscTestShortcut.remove = remove; - AscTestShortcut.closeCellEditor = closeCellEditor; - AscTestShortcut.enterTextWithoutClose = enterTextWithoutClose; - AscTestShortcut.enterText = enterText; - AscTestShortcut.cellEditor = cellEditor; - AscTestShortcut.getCellText = getCellText; - AscTestShortcut.getCellTextWithoutFormat = getCellTextWithoutFormat; - AscTestShortcut.moveDown = moveDown; - AscTestShortcut.wsView = wsView; - AscTestShortcut.ws = ws; - AscTestShortcut.moveAndEnterText = moveAndEnterText; - AscTestShortcut.createTest = createTest; - AscTestShortcut.moveAndGetCellText = moveAndGetCellText; - AscTestShortcut.goToSheet = goToSheet; - AscTestShortcut.createWorksheet = createWorksheet; - AscTestShortcut.removeCurrentWorksheet = removeCurrentWorksheet; - AscTestShortcut.cleanCell = cleanCell; - AscTestShortcut.cleanRange = cleanRange; - AscTestShortcut.cleanSelection = cleanSelection; - AscTestShortcut.cleanActiveCell = cleanActiveCell; - AscTestShortcut.checkRange = checkRange; - AscTestShortcut.openCellEditor = openCellEditor; - AscTestShortcut.checkActiveCell = checkActiveCell; - AscTestShortcut.cleanCache = cleanCache; - AscTestShortcut.selectAll = selectAll; - AscTestShortcut.cleanAll = cleanAll; - AscTestShortcut.setCellFormat = setCellFormat; - AscTestShortcut.selectionInfo = selectionInfo; - AscTestShortcut.xfs = xfs; - AscTestShortcut.undo = undo; - AscTestShortcut.createEvent = createEvent; - AscTestShortcut.selectAllCell = selectAllCell; - AscTestShortcut.cellPosition = cellPosition; - AscTestShortcut.getCellEditMode = getCellEditMode; - AscTestShortcut.testPreventDefaultAndStopPropagation = testPreventDefaultAndStopPropagation; - AscTestShortcut.controller = controller; - AscTestShortcut.handlers = handlers; - AscTestShortcut.activeCell = activeCell; - AscTestShortcut.selectionRange = selectionRange; - AscTestShortcut.checkOpenCellEditor = checkOpenCellEditor; - AscTestShortcut.setCheckOpenCellEditor = setCheckOpenCellEditor; - AscTestShortcut.activeCellRange = activeCellRange; - AscTestShortcut.addHyperlink = addHyperlink; - AscTestShortcut.createMathInShape = createMathInShape; - AscTestShortcut.moveCursorRight = moveCursorRight; - AscTestShortcut.moveCursorLeft = moveCursorLeft; - AscTestShortcut.moveCursorUp = moveCursorUp; - AscTestShortcut.moveCursorDown = moveCursorDown; - AscTestShortcut.checkMoveContentShapeHelper = checkMoveContentShapeHelper; - AscTestShortcut.contentPosition = contentPosition; - AscTestShortcut.selectedContent = selectedContent; - AscTestShortcut.checkSelectContentShapeHelper = checkSelectContentShapeHelper; - AscTestShortcut.round = round; - AscTestShortcut.moveShapeHelper = moveShapeHelper; - AscTestShortcut.createTable = createTable; - AscTestShortcut.createSlicer = createSlicer; - AscTestShortcut.moveToShapeParagraph = moveToShapeParagraph; - AscTestShortcut.addProperty = addProperty; - AscTestShortcut.targetContent = targetContent; - AscTestShortcut.textPr = textPr; - AscTestShortcut.paraPr = paraPr; - AscTestShortcut.moveToParagraph = moveToParagraph; - AscTestShortcut.selectedObjects = selectedObjects; - AscTestShortcut.cleanGraphic = cleanGraphic; - AscTestShortcut.graphicController = graphicController; - AscTestShortcut.createShape = createShape; - AscTestShortcut.drawingDocument = drawingDocument; - AscTestShortcut.selectOnlyObjects = selectOnlyObjects; - AscTestShortcut.createShapeWithContent = createShapeWithContent; - AscTestShortcut.checkTextAfterKeyDownHelperHelloWorld = checkTextAfterKeyDownHelperHelloWorld; - AscTestShortcut.checkTextAfterKeyDownHelperEmpty = checkTextAfterKeyDownHelperEmpty; - AscTestShortcut.getParagraphText = getParagraphText; - AscTestShortcut.checkTextAfterKeyDownHelper = checkTextAfterKeyDownHelper; - AscTestShortcut.checkDirectTextPrAfterKeyDown = checkDirectTextPrAfterKeyDown; - AscTestShortcut.checkDirectParaPrAfterKeyDown = checkDirectParaPrAfterKeyDown; - AscTestShortcut.getDirectTextPrHelper = getDirectTextPrHelper; - AscTestShortcut.getDirectParaPrHelper = getDirectParaPrHelper; - AscTestShortcut.checkRemoveObject = checkRemoveObject; - AscTestShortcut.createGroup = createGroup; - AscTestShortcut.createChart = createChart; -})(window); diff --git a/tests/cell/shortcuts/measurer.js b/tests/cell/shortcuts/measurer.js index 6fc8801c7b..5ea7389908 100644 --- a/tests/cell/shortcuts/measurer.js +++ b/tests/cell/shortcuts/measurer.js @@ -34,134 +34,133 @@ (function(window) { + const OnOldLoadFontModule = onLoadFontsModule; + onLoadFontsModule = function (window, undefined) { + OnOldLoadFontModule(window, undefined); + const CharWidth = 0.5; + const FontSize = 10; + const FontHeight = 20; + const FontAscent = 15; + const FontDescent = 5; - const CharWidth = 0.5; - const FontSize = 10; - const FontHeight = 20; - const FontAscent = 15; - const FontDescent = 5; + const GraphemeNormal = 20; + const GraphemeLigature_ffi = 25; + const GraphemeLigature_ff = 30; + const GraphemeLigature_fi = 35; - const GraphemeNormal = 20; - const GraphemeLigature_ffi = 25; - const GraphemeLigature_ff = 30; - const GraphemeLigature_fi = 35; + const GraphemeCombining_xyz = 40; + const GraphemeCombining_xy = 45; - const GraphemeCombining_xyz = 40; - const GraphemeCombining_xy = 45; + const Letter = { + f : 102, + i : 105, - const Letter = { - f : 102, - i : 105, + x : 120, + y : 121, + z : 122 + }; - x : 120, - y : 121, - z : 122 - }; - - let HB_String = []; - AscFonts.HB_StartString = function() - { - HB_String.length = 0; - }; - AscFonts.HB_EndString = function() - { - - }; - AscFonts.HB_AppendToString = function(u) - { - HB_String.push(u); - }; - AscFonts.onLoadModule = function () { - - } - AscFonts.CTextShaper.prototype.FlushWord = function() - { - AscFonts.HB_EndString(); + let HB_String = []; + AscFonts.HB_StartString = function() + { + HB_String.length = 0; + }; + AscFonts.HB_EndString = function() + { - for (let nIndex = 0, nCount = HB_String.length; nIndex < nCount; ++nIndex) + }; + AscFonts.HB_AppendToString = function(u) { - if (nCount - nIndex >= 3 - && Letter.f === HB_String[nIndex] - && Letter.f === HB_String[nIndex + 1] - && Letter.i === HB_String[nIndex + 2]) - { - this.FlushGrapheme(GraphemeLigature_ffi, CharWidth * 3, 3, true); - nIndex += 2; - } - else if (nCount - nIndex >= 2 - && Letter.f === HB_String[nIndex] - && Letter.f === HB_String[nIndex + 1]) - { - this.FlushGrapheme(GraphemeLigature_ff, CharWidth * 2, 2, true); - nIndex += 1; - } - else if (nCount - nIndex >= 2 - && Letter.f === HB_String[nIndex] - && Letter.i === HB_String[nIndex + 1]) - { - this.FlushGrapheme(GraphemeLigature_fi, CharWidth * 2, 2, true); - nIndex += 1; - } - else if (nCount - nIndex >= 3 - && Letter.x === HB_String[nIndex] - && Letter.y === HB_String[nIndex + 1] - && Letter.z === HB_String[nIndex + 2]) - { - this.FlushGrapheme(GraphemeCombining_xyz, CharWidth * 3, 3, false); - nIndex += 2; - } - else if (nCount - nIndex >= 2 - && Letter.x === HB_String[nIndex] - && Letter.y === HB_String[nIndex + 1]) - { - this.FlushGrapheme(GraphemeCombining_xy, CharWidth * 2, 2, false); - nIndex += 1; - } - else + HB_String.push(u); + }; + AscFonts.CTextShaper.prototype.FlushWord = function() + { + AscFonts.HB_EndString(); + + for (let nIndex = 0, nCount = HB_String.length; nIndex < nCount; ++nIndex) { - this.FlushGrapheme(GraphemeNormal, CharWidth, 1, false); + if (nCount - nIndex >= 3 + && Letter.f === HB_String[nIndex] + && Letter.f === HB_String[nIndex + 1] + && Letter.i === HB_String[nIndex + 2]) + { + this.FlushGrapheme(GraphemeLigature_ffi, CharWidth * 3, 3, true); + nIndex += 2; + } + else if (nCount - nIndex >= 2 + && Letter.f === HB_String[nIndex] + && Letter.f === HB_String[nIndex + 1]) + { + this.FlushGrapheme(GraphemeLigature_ff, CharWidth * 2, 2, true); + nIndex += 1; + } + else if (nCount - nIndex >= 2 + && Letter.f === HB_String[nIndex] + && Letter.i === HB_String[nIndex + 1]) + { + this.FlushGrapheme(GraphemeLigature_fi, CharWidth * 2, 2, true); + nIndex += 1; + } + else if (nCount - nIndex >= 3 + && Letter.x === HB_String[nIndex] + && Letter.y === HB_String[nIndex + 1] + && Letter.z === HB_String[nIndex + 2]) + { + this.FlushGrapheme(GraphemeCombining_xyz, CharWidth * 3, 3, false); + nIndex += 2; + } + else if (nCount - nIndex >= 2 + && Letter.x === HB_String[nIndex] + && Letter.y === HB_String[nIndex + 1]) + { + this.FlushGrapheme(GraphemeCombining_xy, CharWidth * 2, 2, false); + nIndex += 1; + } + else + { + this.FlushGrapheme(GraphemeNormal, CharWidth, 1, false); + } } - } - AscFonts.HB_StartString(); - }; - g_oTextMeasurer.SetFontInternal = function() - { - }; - g_oTextMeasurer.SetTextPr = function() - { - }; - g_oTextMeasurer.SetFontSlot = function() - { - }; - g_oTextMeasurer.SetFont = function() - { - }; - g_oTextMeasurer.GetHeight = function() - { - return FontHeight; - }; - g_oTextMeasurer.GetAscender = function() - { - return FontAscent; - }; - g_oTextMeasurer.GetDescender = function() - { - return FontDescent; - }; - g_oTextMeasurer.MeasureCode = function() - { - return {Width : CharWidth * FontSize}; - }; - g_oTextMeasurer.Measure2Code = function() - { - return {Width : CharWidth * FontSize}; - }; - g_oTextMeasurer.Measure = function() - { - return {Width : CharWidth * FontSize}; + AscFonts.HB_StartString(); + }; + g_oTextMeasurer.SetFontInternal = function() + { + }; + g_oTextMeasurer.SetTextPr = function() + { + }; + g_oTextMeasurer.SetFontSlot = function() + { + }; + g_oTextMeasurer.SetFont = function() + { + }; + g_oTextMeasurer.GetHeight = function() + { + return FontHeight; + }; + g_oTextMeasurer.GetAscender = function() + { + return FontAscent; + }; + g_oTextMeasurer.GetDescender = function() + { + return FontDescent; + }; + g_oTextMeasurer.MeasureCode = function() + { + return {Width : CharWidth * FontSize}; + }; + g_oTextMeasurer.Measure2Code = function() + { + return {Width : CharWidth * FontSize}; + }; + g_oTextMeasurer.Measure = function() + { + return {Width : CharWidth * FontSize}; + }; }; - })(window); diff --git a/tests/cell/shortcuts/shortcuts.html b/tests/cell/shortcuts/shortcuts.html index 38c7385ec7..150390e1b9 100644 --- a/tests/cell/shortcuts/shortcuts.html +++ b/tests/cell/shortcuts/shortcuts.html @@ -3,43 +3,35 @@ - Shortcuts tests - + Shortcut tests - + + + + + + + + + -

      Test shortcuts

      +

      Cell shortcut tests

        test markup, will be hidden
        - - - - - - - - +
        - \ No newline at end of file + diff --git a/tests/cell/shortcuts/shortcuts.js b/tests/cell/shortcuts/shortcuts.js index 5ca3d3a5b4..cae73714e5 100644 --- a/tests/cell/shortcuts/shortcuts.js +++ b/tests/cell/shortcuts/shortcuts.js @@ -32,2459 +32,1553 @@ "use strict"; +QUnit.config.autostart = false; (function (window) { - const editor = Asc.editor; const { - wbView, - executeTestWithCatchEvent, - getFragments, - getSelectionCellEditor, - moveToStartCellEditor, - moveToEndCellEditor, - moveToCell, - selectToCell, - checkOpenCellEditor, - onKeyDown, - closeCellEditor, - enterTextWithoutClose, - setCheckOpenCellEditor, - enterText, - cellEditor, - getCellText, - wsView, - ws, - moveAndEnterText, - createTest, - moveAndGetCellText, - goToSheet, - createWorksheet, - removeCurrentWorksheet, - cleanSelection, - cleanActiveCell, - checkRange, - openCellEditor, - checkActiveCell, - selectAll, - cleanAll, - setCellFormat, - xfs, - undo, - createEvent, - selectAllCell, - cellPosition, - getCellEditMode, - testPreventDefaultAndStopPropagation, - addHyperlink, - createMathInShape, - moveCursorRight, - moveCursorLeft, - moveCursorUp, - moveCursorDown, - checkMoveContentShapeHelper, - contentPosition, - selectedContent, - checkSelectContentShapeHelper, - round, - moveShapeHelper, - createTable, - createSlicer, - moveToShapeParagraph, - addProperty, - textPr, - moveToParagraph, - selectedObjects, - graphicController, - createShape, - selectOnlyObjects, - createShapeWithContent, - checkTextAfterKeyDownHelperHelloWorld, - getParagraphText, - checkDirectTextPrAfterKeyDown, - checkDirectParaPrAfterKeyDown, - startCellEditorTest, - startTableTest, - startGraphicTest, - oTableTypes, - oCellEditorTypes, - oGraphicTypes, - checkRemoveObject, - checkTextAfterKeyDownHelperEmpty, - createGroup, - createChart - } = window.AscTestShortcut; - const pxToMm = AscCommon.g_dKoef_pix_to_mm; - - $( - function () + tableHotkeyTypes, + cellEditorHotkeyTypes, + graphicHotkeyTypes, + tableEvents, + graphicEvents, + ExecuteCellEditorHotkey, + ExecuteTableHotkey, + ExecuteGraphicHotkey, + ExecuteShortcut, + InitEditor + } = AscTestShortcut; + + let editor, wb, wbView, ws, wsView, cellEditor; + InitEditor(function () + { + editor = window["Asc"]["editor"]; + wb = editor.wbModel; + wbView = editor.wb; + ws = wb.aWorksheets[0]; + wsView = wbView.getWorksheet(); + cellEditor = wbView.cellEditor; + QUnit.start(); + }); + + function GetParagraphText(paragraph) + { + return paragraph.GetText({ParaEndToSpace: false}); + } + + function ClearShapeAndAddParagraph(sText) + { + const textShape = AddShape(0, 0, 100, 100); + const txBody = AscFormat.CreateTextBodyFromString(sText, wb.DrawingDocument, textShape); + textShape.setTxBody(txBody); + textShape.setPaddings({Left: 0, Top: 0, Right: 0, Bottom: 0}); + const paragraph = txBody.content.Content[0]; + paragraph.SetThisElementCurrent(); + paragraph.MoveCursorToStartPos(); + textShape.recalculate(); + return {shape: textShape, paragraph: paragraph}; + } + + function AddShape(x, y, height, width) + { + const shapeTrack = new AscFormat.NewShapeTrack('rect', x, y, wb.theme, null, null, null, 0); + shapeTrack.track({}, x + width, y + height); + const shape = shapeTrack.getShape(false, wb.DrawingDocument, null); + shape.setBDeleted(false); + shape.setWorksheet(ws); + shape.setParent(GetDrawingObjects().drawingObjects); + shape.addToDrawingObjects(undefined, AscCommon.c_oAscCellAnchorType.cellanchorTwoCell); + shape.checkDrawingBaseCoords(); + + shape.select(GetDrawingObjects(), 0); + return shape; + } + + function EnterText(text) + { + const codePoints = text.split('').map((e) => e.charCodeAt()); + wbView.EnterText(codePoints); + } + + function AddChart() + { + ws.getRange4(0, 0).fillData([['1']]); + const props = editor.asc_getChartObject(Asc.c_oAscChartTypeSettings.lineNormal); + props.left = 0; + props.top = 0; + props.width = 100; + props.height = 100; + return GetDrawingObjects().addChartDrawingObject(props); + } + + function CreateGroup(arrObjects) + { + const controller = GetDrawingObjects(); + controller.resetSelection(); + for (let i = 0; i < arrObjects.length; i += 1) { - QUnit.module('test worksheet shortcuts'); - function createTwoPivotTables() - { - cleanAll(); - moveAndEnterText('ad', 0, 0); - moveAndEnterText('1', 1, 0); - moveAndEnterText('2', 2, 0); - editor.asc_insertPivotExistingWorksheet("Sheet1!$A$1:$A$3", "Sheet1!$C$1"); - const oPivotTable1 = ws().getPivotTable(2, 1); - oPivotTable1.asc_addField(editor, 0); - - moveAndEnterText('ap', 0, 1); - moveAndEnterText('2', 1, 1); - moveAndEnterText('3', 2, 1); - editor.asc_insertPivotExistingWorksheet("Sheet1!$B$1:$B$3", "Sheet1!$D$1"); - const oPivotTable2 = ws().getPivotTable(3, 1); - oPivotTable2.asc_addField(editor, 0); - } - QUnit.test('Test refresh all connections', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - createTwoPivotTables(); - - moveAndEnterText('4', 2, 0); - moveAndEnterText('4', 2, 1); - - moveToCell(1, 2); - onKeyDown(oEvent); - equal(getCellText(), '5'); - - moveToCell(1, 3); - equal(getCellText(), '6'); - }, oTableTypes.refreshAllConnections); - - }); - - QUnit.test('Test refresh selected connections', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - createTwoPivotTables(); - - moveAndEnterText('4', 2, 0); - moveAndEnterText('4', 2, 1); - - moveToCell(1, 2); - onKeyDown(oEvent); - equal(getCellText(), '5'); - - moveToCell(1, 3); - equal(getCellText(), '5'); - }, oTableTypes.refreshSelectedConnections); - }); - - - QUnit.test('Test change format table info', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - createTable(); - moveToCell(4, 0); - onKeyDown(oEvent); - moveToCell(5, 0); - equal(getCellText(), '10'); - }, oTableTypes.changeFormatTableInfo); - }); - // todo - // QUnit.test.todo('Test calculate all', (oAssert) => - // { - // const {deep, equal} = createTest(oAssert); - // startTableTest((oEvent) => - // { - // - // }, oTableTypes.calculateAll); - // - // }); - // - // - // QUnit.test.todo('Test calculate active sheet', (oAssert) => - // { - // const {deep, equal} = createTest(oAssert); - // startTableTest((oEvent) => - // { - // - // }, oTableTypes.calculateActiveSheet); - // - // }); - // - // QUnit.test.todo('Test calculate only changed', (oAssert) => - // { - // const {deep, equal} = createTest(oAssert); - // startTableTest((oEvent) => - // { - // - // }, oTableTypes.calculateOnlyChanged); - // - // }); - - QUnit.test('Test focus on cell editor', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - equal(getCellEditMode(), true); - }, oTableTypes.focusOnCellEditor); - }); - - QUnit.test('Test add date', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - const oDate = new Asc.cDate(); - equal(getCellText(), oDate.getDateString(editor), 'Check insert current date'); - }, oTableTypes.addDate); - - - }); - QUnit.test('Test add time', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - const oDate = new Asc.cDate(); - onKeyDown(oEvent); - equal(getCellText(), oDate.getTimeString(editor).split(' ').join(':00 '), 'Check insert current time'); - }, oTableTypes.addTime); - - - }); - - - QUnit.test('Test remove active cell text', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(0, 0); - enterText('hello World'); - onKeyDown(oEvent); - equal(getCellText(), '', 'Check remove active cell'); - }, oTableTypes.removeActiveCell); - }); - - - QUnit.test('Test empty range', (oAssert) => - { - - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveAndEnterText('Hello World', 0, 0); - moveAndEnterText('Hello World', 1, 1); - moveAndEnterText('Hello World', 2, 2); - moveToCell(0, 0); - selectToCell(5, 5); - onKeyDown(oEvent); - const arrSteps = []; - closeCellEditor(); - arrSteps.push(moveAndGetCellText(0, 0)); - arrSteps.push(moveAndGetCellText(1, 1)); - arrSteps.push(moveAndGetCellText(2, 2)); - deep(arrSteps, ['', '', ''], 'Check empty shortcut'); - }, oTableTypes.emptyRange); - - }); - - - QUnit.test('Test move active cell to left', (oAssert) => - { - - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 1); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0), 'Check move left active cell'); - }, oTableTypes.moveActiveCellToLeft); - - }); - - QUnit.test('Test move active cell to right', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 1), 'Check move right active cell'); - }, oTableTypes.moveActiveCellToRight); - - }); - - QUnit.test('Test move active cell to down', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(1, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(2, 0), 'Check move down active cell'); - }, oTableTypes.moveActiveCellToDown); - }); - - QUnit.test('Test move active cell to up', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(1, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0), 'Check move up active cell'); - }, oTableTypes.moveActiveCellToUp); + arrObjects[i].select(controller, 0); + } - }); + return controller.createGroup(); + } + + function GetDirectGraphicTextPr() + { + return GetDrawingObjects().getParagraphTextPr(); + } + + function GetDirectGraphicParaPr() + { + return GetDrawingObjects().getParagraphParaPr(); + } + + function Round(number, amount) + { + const power = Math.pow(10, amount); + return Math.round(number * power) / power; + } + + function SelectDrawings(arrDrawings) + { + const drawingController = GetDrawingObjects(); + drawingController.resetSelection() + for (let i = 0; i < arrDrawings.length; i += 1) + { + arrDrawings[i].select(drawingController, 0); + } + } + + function GetDrawingObjects() + { + return editor.getGraphicController(); + } + + function FillActiveCell(text) + { + const activeCell = ws.selectionRange.activeCell; + ws.getRange4(activeCell.row, activeCell.col).fillData([[text]]); + + } + + function SetVisibleRange(r1, c1, r2, c2) + { + wsView.visibleRange = new Asc.Range(r1, c1, r2, c2); + wsView.nRowsCount = 49; + wsView.nColsCount = 49; + } + + function FillExampleData() + { + ws.getRange3(0, 0, 2, 2).fillData([ + ['test11', 'test12', 'test13'], + ['1', '2', '3'], + ['1', '2', '3'] + ]); + + Select(0, 0, 0, 0, 2, 2); + } + + function GetRange(c1, r1, c2, r2) + { + return new Asc.Range(c1, r1, c2, r2); + } + + function Select(activeR, activeC, r1, c1, r2, c2) + { + CloseCellEditor(true); + ws.selectionRange.ranges = [GetRange(c1, r1, c2, r2)]; + ws.selectionRange.activeCell = new AscCommon.CellBase(activeR, activeC); + wbView._updateSelectionInfo(); + } + + function ResetData(r1, c1, r2, c2) + { + ws.autoFilters.deleteAutoFilter(GetRange(0, 0, 0, 0)); + while (ws.TableParts.length) + { + ws.deleteTablePart(0); + } + ws.removeRows(r1, r2, false); + ws.removeCols(c1, c2); + } + + function GetCellText(row, column) + { + return ws.getRange4(row, column).getValueWithFormat(); + } + + function CloseCellEditor(save) + { + wbView.closeCellEditor(!save); + } + + function CreateTable() + { + FillExampleData(); + ws.autoFilters.addAutoFilter('TableStyleMedium2', GetRange(0, 0, 2, 2)); + } + + function CreateSlicer() + { + CreateTable(); + editor.asc_insertSlicer(['test11']); + return GetDrawingObjects().selectedObjects[0]; + } + + function RemoveGraphicObjects() + { + GetDrawingObjects().resetSelection(); + GetDrawingObjects().selectAll(); + GetDrawingObjects().remove(); + } + + function GetCellEditorText() + { + return AscCommonExcel.getFragmentsText(cellEditor.options.fragments); + } + + function OpenCellEditor() + { + const enterOptions = new AscCommonExcel.CEditorEnterOptions(); + enterOptions.newText = ''; + enterOptions.quickInput = true; + enterOptions.focus = true; + wbView._onEditCell(enterOptions); + } + + function GetSelectedCellEditorText() + { + const fragments = cellEditor.copySelection() || []; + return AscCommonExcel.getFragmentsText(fragments) + } + + function CreateWorksheets(names) + { + editor.asc_insertWorksheet(names); + } + + function RemoveWorksheets(indexes) + { + editor.asc_deleteWorksheet(indexes); + } + + QUnit.module('Test cell editor shortcut', { + afterEach: function () + { + CloseCellEditor(); + } + }); + QUnit.test('Check actions with text movements', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + OpenCellEditor(); + EnterText('Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'World Hello World'); + + cellEditor._moveCursor(-2); + + function CheckCursorPosition(expected, description) + { + assert.strictEqual(cellEditor.cursorPos, expected, description); + } - QUnit.test('Test reset', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - editor.asc_startAddShape('rect'); - onKeyDown(oEvent); - equal(graphicController().checkEndAddShape(), false); - moveToCell(0, 0); - editor.asc_SelectionCut(); - onKeyDown(oEvent); - equal(wsView().copyCutRange, null); - - moveToCell(0, 0); - editor.asc_Copy(); - onKeyDown(oEvent); - equal(wsView().copyCutRange, null); - }, oTableTypes.reset); - - }); - - QUnit.test('Test disable num lock', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - // run test for macOS and Windows - moveToCell(0, 0); - AscCommon.AscBrowser.isOpera = true; - testPreventDefaultAndStopPropagation(createEvent(144, false, false, false, false, false), oAssert); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToEndLine); + CheckCursorPosition(18, 'Check move to end line'); - AscCommon.AscBrowser.isOpera = false; - testPreventDefaultAndStopPropagation(createEvent(144, false, false, false, false, false), oAssert, true); - }, oTableTypes.disableNumLock); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightChar); + CheckCursorPosition(19, 'Check move to right char'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveCursorLeftChar); + CheckCursorPosition(18, 'Check move to left char'); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveCursorLeftWord); + CheckCursorPosition(12, 'Check move to left word'); - QUnit.test('Test disable scroll lock', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - // run test for macOS and Windows - moveToCell(0, 0); - AscCommon.AscBrowser.isOpera = true; - testPreventDefaultAndStopPropagation(createEvent(145, false, false, false, false, false), oAssert); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightWord); + CheckCursorPosition(18, 'Check move to right word'); - AscCommon.AscBrowser.isOpera = false; - testPreventDefaultAndStopPropagation(createEvent(145, false, false, false, false, false), oAssert, true); - }, oTableTypes.disableScrollLock); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightWord); + CheckCursorPosition(24, 'Check move to right word'); - }); - QUnit.test('Test select column', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 1048575, 0, 0), 'Check move up'); - }, oTableTypes.selectColumn); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); + CheckCursorPosition(18, 'Check move to start line'); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToDownLine); + CheckCursorPosition(36, 'Check move down'); - QUnit.test('Test select row', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 0, 0, 16383), 'Check move up'); - }, oTableTypes.selectRow); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToUpLine); + CheckCursorPosition(18, 'Check move up'); - QUnit.test('Test select sheet', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 1048575, 0, 16383), 'Check move up'); - }, oTableTypes.selectSheet); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToEndDocument); + CheckCursorPosition(161, 'Check move to end document'); - QUnit.test('Test add separator', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - equal(getCellText(), '.'); - }, oTableTypes.addSeparator); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartDocument); + CheckCursorPosition(0, 'Check move to start document'); + function CheckSelectedText(expectedText, description) + { + assert.strictEqual(GetSelectedCellEditorText(), expectedText, description); + } - QUnit.test('Test go to previous sheet', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - createWorksheet(); - onKeyDown(oEvent); - equal(wbView().wsActive, 0, 'Check got to previous worksheet'); - goToSheet(1); - removeCurrentWorksheet(); - }, oTableTypes.goToPreviousSheet); - }); - - QUnit.test('Test move to next sheet', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - createWorksheet(); - goToSheet(0); - onKeyDown(oEvent); - equal(wbView().wsActive, 1, 'Check got to next worksheet'); - removeCurrentWorksheet(); - }, oTableTypes.moveToNextSheet); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToEndLine); + CheckSelectedText('Hello World Hello ', 'Select to end line'); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightChar); + CheckSelectedText('Hello World Hello W', 'Select to right char'); - QUnit.test('Test move to left edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 39); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0), 'check move left'); - }, oTableTypes.moveToLeftEdgeCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectLeftChar); + CheckSelectedText('Hello World Hello ', 'Select to left char'); - QUnit.test('Test select to left edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 39); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 0, 0, 0), 'check move left'); - }, oTableTypes.selectToLeftEdgeCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectLeftWord); + CheckSelectedText('Hello World ', 'Select to left word'); - QUnit.test('Test move to left cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 1); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0), 'check move left'); - }, oTableTypes.moveToLeftCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightWord); + CheckSelectedText('Hello World Hello ', 'Select to right word'); - QUnit.test('Test select to left cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 1); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 0, 0, 1), 'check move left'); - }, oTableTypes.selectToLeftCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightWord); + CheckSelectedText('Hello World Hello World ', 'Select to right word'); - QUnit.test('Test move to right cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 1), 'check move left'); - }, oTableTypes.moveToRightCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightWord); + CheckSelectedText('Hello World Hello World Hello ', 'Select to right word'); - QUnit.test('Test select to right cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 0, 0, 1), 'check move left'); - }, oTableTypes.selectToRightCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToStartLine); + CheckSelectedText('Hello World Hello ', 'Select to start line'); - QUnit.test('Test move to top cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToDownLine); + CheckSelectedText('Hello World Hello World Hello World ', 'Select down'); - moveToCell(25, 0); - enterText('Hello'); - moveToCell(27, 0); - enterText('Hello'); - moveToCell(35, 0); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToUpLine); + CheckSelectedText('Hello World Hello ', 'Select up'); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(27, 0)); + cellEditor._moveCursor(-4); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectLeftChar); + CheckSelectedText('d', 'Select to left char'); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(25, 0)); - }, oTableTypes.moveToTopCell); - }); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectLeftWord); + CheckSelectedText('World', 'Select to left word'); - QUnit.test('Test move to upper cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToStartDocument); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World', 'Select to start content'); - moveAndEnterText('Hello', 22, 0); - moveToCell(33, 0); - wsView().visibleRange = new Asc.Range(0, 0, 23, 35); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0)); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToEndDocument); + CheckSelectedText('', 'Select to end content'); - }, oTableTypes.moveToUpperCell); - }); + cellEditor._moveCursor(-2); - QUnit.test('Test select to top cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToEndDocument); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World', 'Select to end content'); + // todo unlock + // cellEditor._moveCursor(-4); + // + // ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); + // CheckCursorPosition(144, 'Check move to start line'); + // ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); + // CheckCursorPosition(144, 'Check move to start line'); + }); - moveToCell(25, 0); - enterText('Hello'); - moveToCell(27, 0); - enterText('Hello'); - moveToCell(35, 0); + QUnit.test('Check remove parts of text', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + OpenCellEditor(); + EnterText('Hello Hello Hello Hello'); + cellEditor._moveCursor(-4); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(27, 35, 0, 0)); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.removeCharBack); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello Hell', 'Check removing back symbol'); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(25, 35, 0, 0)); - }, oTableTypes.selectToTopCell); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.removeWordBack); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello ', 'Check removing back word'); - }); + cellEditor._moveCursor(-2); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.deleteFrontChar); + assert.strictEqual(GetCellEditorText(), 'ello Hello Hello ', 'Check removing front symbol'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.deleteFrontWord); + assert.strictEqual(GetCellEditorText(), 'Hello Hello ', 'Check removing front word'); + }); - QUnit.test('Test move to up cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(5, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(4, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(3, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(2, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(1, 0)); - }, oTableTypes.moveToUpCell); - - }); - - QUnit.test('Test select to up cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(5, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(5, 4, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(5, 3, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(5, 2, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(5, 1, 0, 0)); - }, oTableTypes.selectToUpCell); - - }); - - QUnit.test('Test move to bottom cell', (oAssert) => - { - - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(45, 0); - enterText('Hello'); - moveToCell(47, 0); - enterText('Hello'); - moveToCell(42, 0); - - wsView().visibleRange = new Asc.Range(0, 0, 49, 49); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(45, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(47, 0)); - }, oTableTypes.moveToBottomCell); - - startTableTest((oEvent) => - { - moveToCell(45, 0); - enterText('Hello'); - moveToCell(47, 0); - enterText('Hello'); - moveToCell(42, 0); - - wsView().visibleRange = new Asc.Range(0, 0, 49, 49); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(92, 0)); - }, oTableTypes.moveToLowerCell); - }); - - QUnit.test('Test select to bottom cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(45, 0); - enterText('Hello'); - moveToCell(47, 0); - enterText('Hello'); - moveToCell(42, 0); - wsView().visibleRange = new Asc.Range(0, 0, 100, 100); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(42, 45, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(42, 47, 0, 0)); - }, oTableTypes.selectToBottomCell); - }); - - QUnit.test('Test select to lower cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(45, 0); - enterText('Hello'); - moveToCell(47, 0); - enterText('Hello'); - moveToCell(42, 0); - - wsView().visibleRange = new Asc.Range(0, 0, 100, 100); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(42, 143, 0, 0)); - }, oTableTypes.selectToLowerCell); - }); - - QUnit.test('Test move to down cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(1, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(2, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(3, 0)); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(4, 0)); - }, oTableTypes.moveToDownCell); - }); - - QUnit.test('Test select to down cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 1, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 2, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 3, 0, 0)); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 4, 0, 0)); - }, oTableTypes.selectToDownCell); - }); - - - QUnit.test('Test move to left edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(5, 25); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(5, 0)); - }, oTableTypes.moveToFirstColumn); - }); - - QUnit.test('Test select to left edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(5, 25); - - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(5, 5, 0, 25)); - }, oTableTypes.selectToFirstColumn); - - }); - - QUnit.test('Test move to left edge top', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(5, 25); - - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0)); - }, oTableTypes.moveToLeftEdgeTop); - }); - - QUnit.test('Test select to left edge top', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(5, 25); - - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 5, 0, 25)); - }, oTableTypes.selectToLeftEdgeTop); - }); + QUnit.test('Check save and moving from cell', (assert) => + { + function CheckSaveAndMoving(row, column, text) + { + assert.false(wbView.getCellEditMode(), 'Check closing cell editor'); + assert.deepEqual([ws.selectionRange.activeCell.row, ws.selectionRange.activeCell.col], [row, column], 'Check active cell'); + assert.strictEqual(GetCellText(5, 5), text, 'Check initial text'); + } - QUnit.test('Test select to right edge cell', (oAssert) => + Select(5, 5, 5, 5, 5, 5); + EnterText('Hello1'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.saveAndMoveDown); + CheckSaveAndMoving(6, 5, 'Hello1'); + + Select(5, 5, 5, 5, 5, 5); + EnterText('Hello2'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.saveAndMoveUp); + CheckSaveAndMoving(4, 5, 'Hello2'); + + Select(5, 5, 5, 5, 5, 5); + EnterText('Hello3'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.saveAndMoveRight); + CheckSaveAndMoving(5, 6, 'Hello3'); + + Select(5, 5, 5, 5, 5, 5); + EnterText('Hello4'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.saveAndMoveLeft); + CheckSaveAndMoving(5, 4, 'Hello4'); + + Select(5, 5, 5, 5, 5, 5); + EnterText('Hello5'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.closeWithoutSave); + CheckSaveAndMoving(5, 5, 'Hello4'); + }); + + QUnit.test('Check change text formatting', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('Hello Hello'); + cellEditor.selectAll(); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setStrikethrough); + assert.true(cellEditor._getFragments(0, 11).every((e) => e.format.getStrikeout()), 'Check cell editor strikeout format'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setStrikethrough); + assert.false(cellEditor._getFragments(0, 11).every((e) => e.format.getStrikeout()), 'Check cell editor strikeout format'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setBold); + assert.true(cellEditor._getFragments(0, 11).every((e) => e.format.getBold()), 'Check cell editor bold format'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setBold); + assert.false(cellEditor._getFragments(0, 11).every((e) => e.format.getBold()), 'Check cell editor bold format'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setItalic); + assert.true(cellEditor._getFragments(0, 11).every((e) => e.format.getItalic()), 'Check cell editor italic format'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setItalic); + assert.false(cellEditor._getFragments(0, 11).every((e) => e.format.getItalic()), 'Check cell editor italic format'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setUnderline); + assert.true(cellEditor._getFragments(0, 11).every((e) => e.format.getUnderline() === Asc.EUnderline.underlineSingle), 'Check cell editor underline format'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.setUnderline); + assert.true(cellEditor._getFragments(0, 11).every((e) => e.format.getUnderline() === Asc.EUnderline.underlineNone), 'Check cell editor underline format'); + }); + + QUnit.test('Check enter text in cell editor', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + OpenCellEditor(); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addTime); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getTimeString(editor).split(' ').join(':00 '), 'Check add time'); + EnterText(''); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addDate); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getDateString(editor), 'Check add date'); + + EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addSeparator); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), '.', 'Check add separator'); + + EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addSpace); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), ' ', 'Check add space'); + + EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); + assert.strictEqual(cellEditor.textRender.getLinesCount(), 2, 'Check add new line'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); + assert.strictEqual(cellEditor.textRender.getLinesCount(), 3, 'Check add new line'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); + assert.strictEqual(cellEditor.textRender.getLinesCount(), 4, 'Check add new line'); + }); + + QUnit.test('Check disabling shortcuts', (assert) => + { + OpenCellEditor(); + assert.true(ExecuteCellEditorHotkey(cellEditorHotkeyTypes.disableScrollLock)); + assert.true(ExecuteCellEditorHotkey(cellEditorHotkeyTypes.disableNumLock)); + assert.true(ExecuteCellEditorHotkey(cellEditorHotkeyTypes.disableF2)); + assert.true(ExecuteCellEditorHotkey(cellEditorHotkeyTypes.disablePrint)); + }); + + QUnit.test('Check select all', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('Hello'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectAll) + assert.strictEqual(GetSelectedCellEditorText(), 'Hello', 'Check select all'); + }); + + QUnit.test('Check undo/redo in cell editor', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('H'); + EnterText('e'); + EnterText('l'); + EnterText('l'); + EnterText('o'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.undo); + assert.strictEqual(GetCellEditorText(), 'Hell', 'Check undo'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.undo); + assert.strictEqual(GetCellEditorText(), 'Hel', 'Check undo'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.redo); + assert.strictEqual(GetCellEditorText(), 'Hell', 'Check redo'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.redo); + assert.strictEqual(GetCellEditorText(), 'Hello', 'Check redo'); + }); + QUnit.test('Check switch reference of formula', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('=F4'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.switchReference); + assert.strictEqual(GetCellEditorText(), '=$F$4', 'Check switch to absolute reference'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.switchReference); + assert.strictEqual(GetCellEditorText(), '=F$4', 'Check switch to absolute row'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.switchReference); + assert.strictEqual(GetCellEditorText(), '=$F4', 'Check switch to absolute column'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.switchReference); + assert.strictEqual(GetCellEditorText(), '=F4', 'Check switch to relative reference'); + }); + + QUnit.test('Test catch events', (assert) => + { + function ExecuteTestWithCatchEvent(sSendEvent, fCustomCheck, customExpectedValue, oEvent) + { + let check = false; + const Check = function (...args) { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => + if (fCustomCheck) { - cleanAll() - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(0, 0); - - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 0, 0, 23)); - - moveToCell(4, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(4, 4, 0, 8)); - - moveToCell(5, 0); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(5, 5, 0, 5)); - }, oTableTypes.selectToRightEdgeCell); - }); - - QUnit.test('Test move to right edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => + check = fCustomCheck(...args); + } + else { - cleanAll(); - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(0, 0); - - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 23)); - - moveToCell(4, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(4, 8)); + check = true; + } + } + editor.asc_registerCallback(sSendEvent, Check); + ExecuteShortcut(oEvent); + assert.strictEqual(check, customExpectedValue === undefined ? true : customExpectedValue, 'Check catch ' + sSendEvent + ' event'); + editor.asc_unregisterCallback(sSendEvent, Check); + } - moveToCell(5, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(5, 5)); - }, oTableTypes.moveToRightEdgeCell); - }); + ExecuteTestWithCatchEvent('asc_onPrint', () => true, true, tableEvents[tableHotkeyTypes.print][0]); + ExecuteTestWithCatchEvent('asc_onContextMenu', () => true, true, tableEvents[tableHotkeyTypes.contextMenu][0]); - QUnit.test('Test move to right bottom edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll() - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(0, 0); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(5, 8)); - }, oTableTypes.moveToRightBottomEdge); - }); + ClearShapeAndAddParagraph(''); + const hyperlink = new AscCommonExcel.Hyperlink(); + hyperlink.Hyperlink = "https://www.onlyoffice.com/"; + const ascHyperlink = new Asc.asc_CHyperlink(hyperlink); + ascHyperlink.text = "Hello"; + editor.asc_insertHyperlink(ascHyperlink); + GetDrawingObjects().cursorMoveLeft(); + GetDrawingObjects().cursorMoveLeft(); - QUnit.test('Test select to right bottom edge cell', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveAndEnterText('Hello', 5, 5); - moveAndEnterText('Hello', 4, 8); - moveToCell(0, 0); + ExecuteTestWithCatchEvent('asc_onHyperlinkClick', (sValue) => sValue, 'https://www.onlyoffice.com/', graphicEvents[graphicHotkeyTypes.visitHyperink][0]); + const selectedInfo = new CSelectedElementsInfo(); + GetDrawingObjects().getTargetDocContent().GetSelectedElementsInfo(selectedInfo); + assert.true(selectedInfo.m_oHyperlink.Visited, 'Check hyperlink visited'); + RemoveGraphicObjects(); - onKeyDown(oEvent); - deep(cleanSelection(), checkRange(0, 5, 0, 8)); - }, oTableTypes.selectToRightBottomEdge); - }); + }); + QUnit.module('Test graphic shortcuts', { + afterEach: function () + { + RemoveGraphicObjects(); + } + }); + QUnit.test('Check remove parts of text', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph('Hello Hello Hello Hello'); + GetDrawingObjects().cursorMoveToEndPos(); - QUnit.test('Test set number format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveAndEnterText('49990', 5, 5); - onKeyDown(oEvent); - equal(getCellText(), '49990.00', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setNumberFormat); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeBackChar); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello Hell', 'Check removing back symbol'); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeBackWord); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing back word'); - QUnit.test('Test set time format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(5, 5); - enterText('49990'); - onKeyDown(oEvent); - equal(getCellText(), '12:00:00 AM', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setTimeFormat); - }); - - QUnit.test('Test set date format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(5, 5); - enterText('49990'); - onKeyDown(oEvent); - equal(getCellText(), '11/11/2036', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setDateFormat); - }); - - QUnit.test('Test set currency format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(5, 5); - enterText('49990'); - onKeyDown(oEvent); - equal(getCellText(), '$49,990.00', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setCurrencyFormat); - }); - - QUnit.test('Test set percent format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(5, 5); - enterText('0.1'); - onKeyDown(oEvent); - equal(getCellText(), '10.00%', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setPercentFormat); - }); + GetDrawingObjects().cursorMoveToStartPos(); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeFrontChar); + assert.strictEqual(GetParagraphText(paragraph), 'ello Hello Hello ', 'Check removing front symbol'); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeFrontWord); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello ', 'Check removing front word'); + }); + QUnit.test('Check remove graphic objects', (assert) => + { - QUnit.test('Test strikethrough', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(6, 6); - enterText('0.1'); - onKeyDown(oEvent); - equal(xfs().asc_getFontStrikeout(), true); - onKeyDown(oEvent); - equal(xfs().asc_getFontStrikeout(), false); - }, oTableTypes.setStrikethrough); - }); - - QUnit.test('Test set exponential format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(5, 5); - enterText('0.1'); - onKeyDown(oEvent); - equal(getCellText(), '1.00E-01', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setExponentialFormat); - }); - - QUnit.test('Test bold', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(6, 6); - enterText('0.1'); - onKeyDown(oEvent); - equal(xfs().asc_getFontBold(), true); - onKeyDown(oEvent); - equal(xfs().asc_getFontBold(), false); - }, oTableTypes.setBold); - }); - - QUnit.test('Test italic', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(6, 6); - enterText('0.1'); - onKeyDown(oEvent); - equal(xfs().asc_getFontItalic(), true); - onKeyDown(oEvent); - equal(xfs().asc_getFontItalic(), false); - }, oTableTypes.setItalic); - }); - - QUnit.test('Test underline', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(6, 6); - enterText('0.1'); - onKeyDown(oEvent); - equal(xfs().asc_getFontUnderline(), true); - onKeyDown(oEvent); - equal(xfs().asc_getFontUnderline(), false); - }, oTableTypes.setUnderline); - }); - - - QUnit.test('Test set general format', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(5, 5); - enterText('0.1'); - setCellFormat(Asc.c_oAscNumFormatType.Time); + function CheckRemoveObject(spTree, shape) + { + assert.true(spTree.indexOf(shape) === -1, 'Check remove shape from spTree'); + } - onKeyDown(oEvent); - equal(getCellText(), '0.1', 'set number format'); - setCellFormat(Asc.c_oAscNumFormatType.General); - }, oTableTypes.setGeneralFormat); - }); + function CheckRemoveDrawingObject(shape) + { + assert.false(ws.Drawings.some((e) => e.graphicObject === shape), 'Check remove shape from spTree'); + } + const CheckActionsWithEvent = (eventIndex) => + { + const shape = AddShape(0, 0, 100, 100); + SelectDrawings([shape]); + assert.true(ws.Drawings.some((e) => e.graphicObject === shape), 'Check available shape in spTree'); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeShape, eventIndex); + CheckRemoveDrawingObject(shape); - QUnit.test('Test redo', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(6, 6); - enterText('0.1'); - undo(); - onKeyDown(oEvent); - equal(getCellText(), '0.1'); - }, oTableTypes.redo); - }); - - QUnit.test('Test undo', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - moveToCell(6, 6); - enterText('0.1'); - onKeyDown(oEvent); - equal(getCellText(), ''); - }, oTableTypes.undo); - }); - - QUnit.test('Test print', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - executeTestWithCatchEvent('asc_onPrint', () => true, true, oEvent, oAssert); - }, oTableTypes.print); - }); + const chart = AddChart(); + SelectDrawings([chart]); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeChart, eventIndex); + CheckRemoveDrawingObject(chart); - QUnit.test('Test add sum function', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - cleanAll(); - goToSheet(0); - moveToCell(0, 0); - enterText('1'); - moveToCell(0, 1); - enterText('2'); - moveToCell(7, 7); - setCellFormat(Asc.c_oAscNumFormatType.General); - onKeyDown(oEvent); - enterTextWithoutClose('A1,B1'); - equal(getCellText(), "3"); - }, oTableTypes.addSum); - }); - - QUnit.test('Test context menu', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startTableTest((oEvent) => - { - executeTestWithCatchEvent('asc_onContextMenu', () => true, true, oEvent, oAssert); - }, oTableTypes.contextMenu); - }); - QUnit.module("test cell editor shortcuts", { - before : function () - { - goToSheet(0); - }, - beforeEach: function () - { - setCheckOpenCellEditor(false); - goToSheet(0); - cleanAll(); - }, - afterEach : function () - { - if (!checkOpenCellEditor()) - { - throw new Error('cell editor must be opened in cell editor module'); - } - } - }); - QUnit.test('Test close cell editor', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - equal(getCellText(), ''); - }, oCellEditorTypes.closeWithoutSave); - - }); - QUnit.test('Test add new line', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - equal(cellEditor().textRender.getLinesCount(), 2); + const shape1 = AddShape(0, 0, 100, 100); + const shape2 = AddShape(0, 0, 100, 100); + const shape3 = AddShape(0, 0, 100, 100); - onKeyDown(oEvent); - equal(cellEditor().textRender.getLinesCount(), 3); + const group = CreateGroup([shape1, shape2, shape3]); + group.selectObject(shape1, 0); + GetDrawingObjects().selection.groupSelection = group; - onKeyDown(oEvent); - equal(cellEditor().textRender.getLinesCount(), 4); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeShapeInGroup, eventIndex); + CheckRemoveObject(group.spTree, shape1); - onKeyDown(oEvent); - equal(cellEditor().textRender.getLinesCount(), 5); - }, oCellEditorTypes.addNewLine); - }); + SelectDrawings([group]); + ExecuteGraphicHotkey(graphicHotkeyTypes.removeGroup, eventIndex); + CheckRemoveDrawingObject(group); + }; - QUnit.test('Try close editor', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(1, 0)); - - moveToCell(0, 0); - equal(getCellText(), 'Hello'); - }, oCellEditorTypes.saveAndMoveDown); - cleanAll(); - startCellEditorTest((oEvent) => - { - moveToCell(1, 0); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0)); - - moveToCell(1, 0); - equal(getCellText(), 'Hello'); - }, oCellEditorTypes.saveAndMoveUp); - }); - - QUnit.test('Test sync and close editor', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 1)); - moveToCell(0, 0); - equal(getCellText(), 'Hello'); - }, oCellEditorTypes.saveAndMoveRight); - startCellEditorTest((oEvent) => - { - moveToCell(0, 1); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - deep(cleanActiveCell(), checkActiveCell(0, 0)); - moveToCell(0, 1); - equal(getCellText(), 'Hello'); - }, oCellEditorTypes.saveAndMoveLeft); - }); - QUnit.test('Test remove char back', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello'); - onKeyDown(oEvent); - equal(getCellText(), 'Hell'); - }, oCellEditorTypes.removeCharBack); - - }); - QUnit.test('Test remove word back', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World'); - onKeyDown(oEvent); - equal(getCellText(), 'Hello '); - }, oCellEditorTypes.removeWordBack); - - }); + CheckActionsWithEvent(0); + CheckActionsWithEvent(1); + }); - QUnit.test('Test add space in cell editor', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - onKeyDown(oEvent); - equal(getCellText(), ' '); - }, oCellEditorTypes.addSpace); + QUnit.test('Check main actions with shapes', (assert) => + { + const drawing1 = AddShape(100, 100, 100, 200); - }); - - QUnit.test('Test move cursor to end', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 18); - }, oCellEditorTypes.moveToEndLine); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 47); - }, oCellEditorTypes.moveToEndDocument); - }); - - QUnit.test('Test select to end', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'Hello World Hello '); - }, oCellEditorTypes.selectToEndLine); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'Hello World Hello World Hello World Hello World'); - }, oCellEditorTypes.selectToEndDocument); - }); - - QUnit.test('Test move cursor to start', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 36); - }, oCellEditorTypes.moveToStartLine); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 0); - }, oCellEditorTypes.moveToStartDocument); - }); - QUnit.test('Test select to start', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'Hello World'); - }, oCellEditorTypes.selectToStartLine); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'Hello World Hello World Hello World Hello World'); - }, oCellEditorTypes.selectToStartDocument); - }); - QUnit.test('Test move cursor to left', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 46); - }, oCellEditorTypes.moveCursorLeftChar); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 42); - }, oCellEditorTypes.moveCursorLeftWord); - }); - QUnit.test('Test select to left', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'd'); - }, oCellEditorTypes.selectLeftChar); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToEndCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'World'); - }, oCellEditorTypes.selectLeftWord); - }); - QUnit.test('Test move cursor to up', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - onKeyDown(oEvent); - equal(cellPosition(), 29); - }, oCellEditorTypes.moveToUpLine); - - }); - QUnit.test('Test select to up', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), ' World Hello World'); - }, oCellEditorTypes.selectToUpLine); - }); - QUnit.test('Test move cursor to right', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 1); - }, oCellEditorTypes.moveToRightChar); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 6); - }, oCellEditorTypes.moveToRightWord); - }); - QUnit.test('Test select to right', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'H'); - }, oCellEditorTypes.selectRightChar); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'Hello '); - }, oCellEditorTypes.selectRightWord); - }); - - QUnit.test('Test move cursor to down', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(cellPosition(), 18); - }, oCellEditorTypes.moveToDownLine); - }); - QUnit.test('Test select to down', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getSelectionCellEditor(), 'Hello World Hello '); - }, oCellEditorTypes.selectToDownLine); - }); - - QUnit.test('Test delete front', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getCellText(), 'ello World Hello World Hello World Hello World'); - }, oCellEditorTypes.deleteFrontChar); - - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - equal(getCellText(), 'World Hello World Hello World Hello World'); - }, oCellEditorTypes.deleteFrontWord); - }); - - QUnit.test('Test strikethrough', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - enterTextWithoutClose('hihih'); - const arrFragments = getFragments(0, 5); - equal(arrFragments.length, 1); - equal(arrFragments[0].format.getStrikeout(), true); - }, oCellEditorTypes.setStrikethrough); - }); - - QUnit.test('Test select all text', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); + function CheckShapePosition(X, Y) + { + assert.deepEqual([Round(drawing1.x, 12), Round(drawing1.y, 12), Round(drawing1.extX, 12), Round(drawing1.extY, 12)], [Round(X, 12), Round(Y, 12), 200, 100], 'Check shape position after movement ' + X + ' ' + Y); + } - equal(getSelectionCellEditor(), 'Hello World Hello World Hello World Hello World'); - }, oCellEditorTypes.selectAll); - }); + SelectDrawings([drawing1]); - QUnit.test('Test bold', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - enterTextWithoutClose('hihih'); - const arrFragments = getFragments(0, 5); - equal(arrFragments.length, 1); - equal(arrFragments[0].format.getBold(), true); - }, oCellEditorTypes.setBold); - }); - - QUnit.test('Test italic', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - enterTextWithoutClose('hihih'); - const arrFragments = getFragments(0, 5); - equal(arrFragments.length, 1); - equal(arrFragments[0].format.getItalic(), true); - }, oCellEditorTypes.setItalic); - }); - - QUnit.test('Test underline', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('Hello World Hello World Hello World Hello World'); - moveToStartCellEditor(); - onKeyDown(oEvent); - enterTextWithoutClose('hihih'); - const arrFragments = getFragments(0, 5); - equal(arrFragments.length, 1); - equal(arrFragments[0].format.getUnderline(), Asc.EUnderline.underlineSingle); - }, oCellEditorTypes.setUnderline); - }); - - QUnit.test('Test disable scroll lock', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - AscCommon.AscBrowser.isOpera = true; - testPreventDefaultAndStopPropagation(createEvent(145, false, false, false, false, false), oAssert); - - AscCommon.AscBrowser.isOpera = false; - testPreventDefaultAndStopPropagation(createEvent(145, false, false, false, false, false), oAssert, true); - }, oCellEditorTypes.disableScrollLock); - }); - QUnit.test('Test disable num lock', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - AscCommon.AscBrowser.isOpera = true; - testPreventDefaultAndStopPropagation(createEvent(144, false, false, false, false, false), oAssert); - AscCommon.AscBrowser.isOpera = false; - testPreventDefaultAndStopPropagation(createEvent(144, false, false, false, false, false), oAssert, true); - }, oCellEditorTypes.disableNumLock); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.bigMoveGraphicObjectLeft); + CheckShapePosition(100 - 5 * AscCommon.g_dKoef_pix_to_mm, 100); - QUnit.test('Test print', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - testPreventDefaultAndStopPropagation(createEvent(80, true, false, false, false, false), oAssert); - }, oCellEditorTypes.disablePrint); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.littleMoveGraphicObjectLeft); + CheckShapePosition(100 - 6 * AscCommon.g_dKoef_pix_to_mm, 100); - QUnit.test('Test undo', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('H'); - enterTextWithoutClose('e'); - enterTextWithoutClose('l'); - enterTextWithoutClose('l'); - enterTextWithoutClose('o'); - onKeyDown(oEvent); - equal(getCellText(), 'Hell'); - }, oCellEditorTypes.undo); - }); - - QUnit.test('Test redo', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - enterTextWithoutClose('H'); - enterTextWithoutClose('e'); - enterTextWithoutClose('l'); - enterTextWithoutClose('l'); - enterTextWithoutClose('o'); - cellEditor().undo(); - onKeyDown(oEvent); - equal(getCellText(), 'Hello'); - }, oCellEditorTypes.redo); - }); - - QUnit.test('Test add separator', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - onKeyDown(oEvent); - equal(getCellText(), '.'); - }, oCellEditorTypes.addSeparator); - }); - QUnit.test('Test disable F2', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); + ExecuteGraphicHotkey(graphicHotkeyTypes.bigMoveGraphicObjectRight); + CheckShapePosition(100 - AscCommon.g_dKoef_pix_to_mm, 100); - AscCommon.AscBrowser.isOpera = true; - testPreventDefaultAndStopPropagation(createEvent(113, false, false, false, false, false), oAssert); + ExecuteGraphicHotkey(graphicHotkeyTypes.littleMoveGraphicObjectRight); + CheckShapePosition(100, 100); - AscCommon.AscBrowser.isOpera = false; - testPreventDefaultAndStopPropagation(createEvent(113, false, false, false, false, false), oAssert, true); - }, oCellEditorTypes.disableF2); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.bigMoveGraphicObjectDown); + CheckShapePosition(100, 100 + 5 * AscCommon.g_dKoef_pix_to_mm); - QUnit.test('Test switch reference', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - enterTextWithoutClose('=F4'); + ExecuteGraphicHotkey(graphicHotkeyTypes.littleMoveGraphicObjectDown); + CheckShapePosition(100, 100 + 6 * AscCommon.g_dKoef_pix_to_mm); - onKeyDown(oEvent); - selectAllCell(); - equal(getSelectionCellEditor(), '=$F$4'); - closeCellEditor(); - }, oCellEditorTypes.switchReference); + ExecuteGraphicHotkey(graphicHotkeyTypes.bigMoveGraphicObjectUp); + CheckShapePosition(100, 100 + AscCommon.g_dKoef_pix_to_mm); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.littleMoveGraphicObjectUp); + CheckShapePosition(100, 100); - QUnit.test('Test add time', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - onKeyDown(oEvent); - const oDate = new Asc.cDate(); - equal(getCellText(), oDate.getTimeString(editor).split(' ').join(':00 '), 'Check insert current time'); - }, oCellEditorTypes.addTime); - }); - - QUnit.test('Test add date', (oAssert) => - { - const {equal, deep} = createTest(oAssert); - startCellEditorTest((oEvent) => - { - moveToCell(0, 0); - openCellEditor(); - onKeyDown(oEvent); - const oDate = new Asc.cDate(); - equal(getCellText(), oDate.getDateString(editor), 'Check insert current date'); - }, oCellEditorTypes.addDate); - }); - - QUnit.module('Test graphic objects shortcuts'); - QUnit.test('Test remove back text graphic object', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkTextAfterKeyDownHelperHelloWorld('Hello Worl', oEvent, oAssert, 'Check delete with backspace'); - }, oGraphicTypes.removeBackChar); - }); - QUnit.test('Test remove back text graphic object', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkTextAfterKeyDownHelperHelloWorld('Hello ', oEvent, oAssert, 'Check delete word with backspace') - }, oGraphicTypes.removeBackWord); - }); - - QUnit.test('Test remove chart', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oChart = createChart(); - selectOnlyObjects([oChart]); - onKeyDown(oEvent); - oAssert.true(checkRemoveObject(oChart, ws().Drawings.map((el) => el.graphicObject)), "Check remove group"); - }, oGraphicTypes.removeChart); - }); - - QUnit.test('Test remove shape', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape} = createShapeWithContent('', true); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.true(checkRemoveObject(oShape, ws().Drawings.map((el) => el.graphicObject)), 'Check remove shape'); - }, oGraphicTypes.removeShape); - }); - - QUnit.test('Test remove group', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oGroup = createGroup([createShape(), createShape()]); - selectOnlyObjects([oGroup]); - onKeyDown(oEvent); - oAssert.true(checkRemoveObject(oGroup, ws().Drawings.map((el) => el.graphicObject)), 'Check remove group'); - }, oGraphicTypes.removeGroup); - }); - QUnit.test('Test remove shape in group', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oGroupedGroup = createGroup([createShape(), createShape()]); - const oRemovedShape = createShape(); - const oGroup = createGroup([oGroupedGroup, oRemovedShape]); - selectOnlyObjects([oRemovedShape]); - onKeyDown(oEvent); - oAssert.true(checkRemoveObject(oRemovedShape, oGroup.spTree), 'Check remove shape in group'); - }, oGraphicTypes.removeShapeInGroup); - }); - - QUnit.test('Test add tab', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oParagraph} = createShapeWithContent(''); - moveToParagraph(oParagraph); - onKeyDown(oEvent); - selectAll(); - equal(selectedContent(), '\t'); - }, oGraphicTypes.addTab); - }); - QUnit.test('Test select next object', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oShape1 = createShape(); - const oShape2 = createShape(); - const oShape3 = createShape(); - selectOnlyObjects([oShape1]); - onKeyDown(oEvent); - equal(selectedObjects().length === 1 && selectedObjects()[0] === oShape2, true); - onKeyDown(oEvent); - equal(selectedObjects().length === 1 && selectedObjects()[0] === oShape3, true); - onKeyDown(oEvent); - equal(selectedObjects().length === 1 && selectedObjects()[0] === oShape1, true); - }, oGraphicTypes.selectNextObject); - }); - - QUnit.test('Test select previous object', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oShape1 = createShape(); - const oShape2 = createShape(); - const oShape3 = createShape(); - selectOnlyObjects([oShape1]); - onKeyDown(oEvent); - equal(selectedObjects().length === 1 && selectedObjects()[0] === oShape3, true); - onKeyDown(oEvent); - equal(selectedObjects().length === 1 && selectedObjects()[0] === oShape2, true); - onKeyDown(oEvent); - equal(selectedObjects().length === 1 && selectedObjects()[0] === oShape1, true); - }, oGraphicTypes.selectPreviousObject); - }); - - QUnit.test('Test visit hyperlink', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape, oParagraph} = createShapeWithContent('', 0, false); - moveToParagraph(oParagraph); - addHyperlink("https://www.onlyoffice.com/", "Hello"); - moveCursorLeft(); - moveCursorLeft(); - executeTestWithCatchEvent('asc_onHyperlinkClick', (sValue) => sValue, 'https://www.onlyoffice.com/', oEvent, oAssert); - moveToParagraph(oParagraph); - moveCursorLeft(); - const oSelectedInfo = new CSelectedElementsInfo(); - graphicController().getTargetDocContent().GetSelectedElementsInfo(oSelectedInfo); - equal(oSelectedInfo.m_oHyperlink.Visited, true); - }, oGraphicTypes.visitHyperink); - }); - - QUnit.test('Test add line in math', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oParagraph} = createMathInShape(); - moveToParagraph(oParagraph, true); - moveCursorRight(); - moveCursorRight(); - enterText('fffffff'); - moveCursorLeft(); - moveCursorLeft(); - onKeyDown(oEvent); - const oParaMath = oParagraph.GetAllParaMaths()[0]; - const oFraction = oParaMath.Root.GetFirstElement(); - const oNumerator = oFraction.getNumerator(); - const oEqArray = oNumerator.GetFirstElement(); - oAssert.strictEqual(oEqArray.getRowsCount(), 2, 'Check add new line math'); - }, oGraphicTypes.addLineInMath); - }); - QUnit.test('Test add break line', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape, oParagraph} = createShapeWithContent(''); - moveToParagraph(oParagraph); - - onKeyDown(oEvent); - oAssert.true(oShape.getDocContent().Content.length === 1 && oParagraph.GetLinesCount() === 2, 'Check add break line'); - }, oGraphicTypes.addBreakLine); - }); - - QUnit.test('Test add paragraph', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape, oParagraph} = createShapeWithContent(''); - moveToParagraph(oParagraph); - - onKeyDown(oEvent); - oAssert.true(oShape.getDocContent().Content.length === 2, 'Check add new paragraph'); - }, oGraphicTypes.addParagraph); - }); - - QUnit.test('Test create text body', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oShape = createShape(); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.true(!!oShape.txBody, 'Check creating txBody'); - }, oGraphicTypes.createTxBody); - }); - - QUnit.test('Test move cursor to start position in empty content', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape, oParagraph} = createShapeWithContent('', true); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.true(oParagraph.IsCursorAtBegin(), 'Check move cursor to start position in shape'); - }, oGraphicTypes.moveToStartInEmptyContent); - }); - QUnit.test('Test select all after enter', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape} = createShapeWithContent('Hello Word', true); - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - oAssert.strictEqual(selectedContent(), 'Hello Word', 'Check select all content in shape'); - }, oGraphicTypes.selectAllAfterEnter); - }); - QUnit.test('Test select all after enter in title', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oChart = createChart(); - selectOnlyObjects([oChart]); - const oTitles = oChart.getAllTitles(); - const oController = graphicController(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); - - onKeyDown(oEvent); - oAssert.strictEqual(selectedContent(), 'Diagram Title', 'Check select all title'); - }, oGraphicTypes.selectAllTitleAfterEnter); - }); - QUnit.test('Test move cursor to start position in empty title', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oChart = createChart(); - const oTitles = oChart.getAllTitles(); - const oContent = AscFormat.CreateDocContentFromString('', graphicController().drawingObjects.getDrawingDocument(), oTitles[0].txBody); - oTitles[0].txBody.content = oContent; - selectOnlyObjects([oChart]); - - const oController = graphicController(); - oController.selection.chartSelection = oChart; - oChart.selectTitle(oTitles[0], 0); - - onKeyDown(oEvent); - oAssert.true(oContent.IsCursorAtBegin(), 'Check move cursor to begin pos in title'); - }, oGraphicTypes.moveCursorToStartPositionInTitle); - }); - QUnit.test('Test reset text selection', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape} = createShapeWithContent("Hello world"); - const oParagraph = moveToShapeParagraph(oShape, 0); - onKeyDown(oEvent); - equal(!graphicController().selection.textSelection, true); - }, oGraphicTypes.resetTextSelection); - }); - - QUnit.test('Test reset step selection', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - let oGroupedShape1 = createShape(); - let oGroupedShape2 = createShape(); - createGroup([oGroupedShape1, oGroupedShape2]); - let oTestGroup = oGroupedShape1.group; - const oController = graphicController(); - selectOnlyObjects([oTestGroup, oGroupedShape1]); - onKeyDown(oEvent); - oAssert.true(oController.selectedObjects.length === 1 && oController.selectedObjects[0] === oTestGroup && oTestGroup.selectedObjects.length === 0, 'Check reset step selection'); - - }, oGraphicTypes.resetStepSelection); - }); - QUnit.test('Test move cursor to end', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([59, 18], oEvent, oAssert); - }, oGraphicTypes.moveCursorToEndLine); - }); - - QUnit.test('Test move cursor to end', (oAssert) => + function CheckSelectedObjects(arrOfDrawings) + { + const length = Math.max(arrOfDrawings.length, GetDrawingObjects().selectedObjects.length); + for (let i = 0; i < length; i++) { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([59, 59], oEvent, oAssert); - }, oGraphicTypes.moveCursorToEndDocument); - }); + assert.true(GetDrawingObjects().selectedObjects[i] === arrOfDrawings[i], 'Check selection movement between objects'); + } + } + GetDrawingObjects().resetSelection(); + const drawing2 = AddShape(0, 0, 10, 10); + const drawing3 = AddShape(0, 0, 10, 10); + SelectDrawings([drawing3]); - QUnit.test('Test select to end', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['Hello World Hello ', ''], oEvent, oAssert); - }, oGraphicTypes.selectToEndLine); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectNextObject); + CheckSelectedObjects([drawing1]); - QUnit.test('Test select to end', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['Hello World Hello World Hello World Hello World Hello World', ''], oEvent, oAssert); - }, oGraphicTypes.selectToEndDocument); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectNextObject); + CheckSelectedObjects([drawing2]); - QUnit.test('Test move cursor to start', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([54, 0], oEvent, oAssert); - }, oGraphicTypes.moveCursorToStartLine); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectNextObject); + CheckSelectedObjects([drawing3]); - QUnit.test('Test move cursor to start', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([0, 0], oEvent, oAssert); - }, oGraphicTypes.moveCursorToStartDocument); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectPreviousObject); + CheckSelectedObjects([drawing2]); - QUnit.test('Test select to start', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['', 'World'], oEvent, oAssert); - }, oGraphicTypes.selectToStartLine); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectPreviousObject); + CheckSelectedObjects([drawing1]); - QUnit.test('Test select to start', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['', 'Hello World Hello World Hello World Hello World Hello World'], oEvent, oAssert); - }, oGraphicTypes.selectToStartDocument); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectPreviousObject); + CheckSelectedObjects([drawing3]); - QUnit.test('Test move cursor to left char', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([58, 0], oEvent, oAssert); + drawing2.setWordShape(false); + SelectDrawings([drawing2]); - }, oGraphicTypes.moveCursorLeftChar); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.createTxBody); + assert.true(!!drawing2.txBody, 'Check create textBody after enter'); - QUnit.test('Test select to left char', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['', 'd'], oEvent, oAssert); - }, oGraphicTypes.selectCursorLeftChar); - }); + SelectDrawings([drawing2]); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveToStartInEmptyContent); + const paragraph = drawing2.getDocContent().Content[0]; + assert.true(drawing2.parent.controller.selection.textSelection === drawing2, 'Check text selection'); + assert.true(paragraph.IsCursorAtBegin(), 'Check movement to start position in empty content'); - QUnit.test('Test move cursor to left word', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([54, 0], oEvent, oAssert); - }, oGraphicTypes.moveCursorLeftWord); - }); + EnterText('Hello'); + SelectDrawings([drawing2]); - QUnit.test('Test select to left word', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['', 'World'], oEvent, oAssert); - }, oGraphicTypes.selectCursorLeftWord); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectAllAfterEnter); + assert.strictEqual(GetDrawingObjects().GetSelectedText(), 'Hello', 'Check select non empty content'); - QUnit.test('Test move object to left', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100 - pxToMm, y: 100}, oEvent, oAssert); - }, oGraphicTypes.littleMoveGraphicObjectLeft); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.resetTextSelection); + assert.true(GetDrawingObjects().selectedObjects[0] === drawing2, 'Check reset text selection'); + assert.true(!GetDrawingObjects().selection.textSelection, 'Check reset text selection'); - QUnit.test('Test move object to left', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100 - 5 * pxToMm, y: 100}, oEvent, oAssert); - }, oGraphicTypes.bigMoveGraphicObjectLeft); - }); + let group = CreateGroup([drawing1, drawing2]); + group.selectObject(drawing1, 0); + GetDrawingObjects().selection.groupSelection = group; - QUnit.test('Test move cursor to up', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([41, 0], oEvent, oAssert); + ExecuteGraphicHotkey(graphicHotkeyTypes.resetStepSelection); + assert.strictEqual(GetDrawingObjects().selectedObjects[0].getObjectType(), AscDFH.historyitem_type_GroupShape, 'Check reset step drawing selection'); + assert.strictEqual(group.selectedObjects.length, 0, 'Check reset step selection'); - }, oGraphicTypes.moveCursorUp); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.resetStepSelection); + assert.strictEqual(GetDrawingObjects().selectedObjects.length, 0, 'Check reset all drawing selection'); + }); - QUnit.test('Test select to up', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['', ' World Hello World'], oEvent, oAssert); - }, oGraphicTypes.selectCursorUp); - }); + QUnit.test('Check actions with text movements', (assert) => + { + const {shape} = ClearShapeAndAddParagraph( + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'World Hello World ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'Hello World Hello ' + + 'World Hello World'); - QUnit.test('Test move object to up', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100, y: 100 - pxToMm}, oEvent, oAssert); - }, oGraphicTypes.littleMoveGraphicObjectUp); - }); + function CheckCursorPosition(expected, description) + { + const position = shape.txBody.content.GetContentPosition(); + assert.strictEqual(position[position.length - 1].Position, expected, description); + } - QUnit.test('Test move object to up', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100, y: 100 - 5 * pxToMm}, oEvent, oAssert); - }, oGraphicTypes.bigMoveGraphicObjectUp); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToEndLine); + CheckCursorPosition(18, 'Check move to end line'); - QUnit.test('Test move cursor to right char', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([59, 1], oEvent, oAssert); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightChar); + CheckCursorPosition(19, 'Check move to right char'); - }, oGraphicTypes.moveCursorRightChar); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorLeftChar); + CheckCursorPosition(18, 'Check move to left char'); - QUnit.test('Test select to right char', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['H', ''], oEvent, oAssert); - }, oGraphicTypes.selectCursorRightChar); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorLeftWord); + CheckCursorPosition(12, 'Check move to left word'); - QUnit.test('Test move cursor to right word', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([59, 6], oEvent, oAssert); - }, oGraphicTypes.moveCursorRightWord); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightWord); + CheckCursorPosition(18, 'Check move to right word'); - QUnit.test('Test select to right word', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['Hello ', ''], oEvent, oAssert); - }, oGraphicTypes.selectCursorRightWord); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightWord); + CheckCursorPosition(24, 'Check move to right word'); - QUnit.test('Test move object to right', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100 + pxToMm, y: 100}, oEvent, oAssert); - }, oGraphicTypes.littleMoveGraphicObjectRight); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToStartLine); + CheckCursorPosition(18, 'Check move to start line'); - QUnit.test('Test move object to right', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100 + 5 * pxToMm, y: 100}, oEvent, oAssert); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorDown); + CheckCursorPosition(36, 'Check move down'); - }, oGraphicTypes.bigMoveGraphicObjectRight); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorUp); + CheckCursorPosition(18, 'Check move up'); - QUnit.test('Test move cursor to down', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkMoveContentShapeHelper([59, 18], oEvent, oAssert); - }, oGraphicTypes.moveCursorDown); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToEndDocument); + CheckCursorPosition(161, 'Check move to end document'); - QUnit.test('Test select to down', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkSelectContentShapeHelper(['Hello World Hello ', ''], oEvent, oAssert); - }, oGraphicTypes.selectCursorDown); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToStartDocument); + CheckCursorPosition(0, 'Check move to start document'); - QUnit.test('Test move object to down', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100, y: 100 + pxToMm}, oEvent, oAssert); + function CheckSelectedText(expectedText, description) + { + const selectedText = GetDrawingObjects().GetSelectedText(); + assert.strictEqual(selectedText, expectedText, description); + } - }, oGraphicTypes.littleMoveGraphicObjectDown); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToEndLine); + CheckSelectedText('Hello World Hello ', 'Select to end line'); - QUnit.test('Test move object to down', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - moveShapeHelper({x: 100, y: 100 + 5 * pxToMm}, oEvent, oAssert); - }, oGraphicTypes.bigMoveGraphicObjectDown); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightChar); + CheckSelectedText('Hello World Hello W', 'Select to right char'); - QUnit.test('Test remove front text graphic object', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oParagraph} = createShapeWithContent('Hello World'); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - equal(getParagraphText(oParagraph), 'ello World'); - }, oGraphicTypes.removeFrontChar); - }); - - QUnit.test('Test remove front text graphic object', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oParagraph} = createShapeWithContent('Hello World'); - moveToParagraph(oParagraph, true); - onKeyDown(oEvent); - equal(getParagraphText(oParagraph), 'World'); - }, oGraphicTypes.removeFrontWord); - }); - QUnit.test('Test select all content in shape', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape} = createShapeWithContent('Hello World'); - const oParagraph = moveToShapeParagraph(oShape, 0); - onKeyDown(oEvent); - equal(selectedContent(), 'Hello World'); - }, oGraphicTypes.selectAllContent); - }); - QUnit.test('Test select all graphic objects', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oShape1 = createShape(); - const oShape2 = createShape(); - const oShape3 = createShape(); - selectOnlyObjects([oShape1]); - onKeyDown(oEvent); - equal(selectedObjects().length === 3 && (oShape1.selected && selectedObjects().indexOf(oShape1) !== -1) && (oShape2.selected && selectedObjects().indexOf(oShape2) !== -1) && (oShape3.selected && selectedObjects().indexOf(oShape3) !== -1), true); - }, oGraphicTypes.selectAllDrawings); - }); - - QUnit.test('Test bold', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetBold(), oEvent, oAssert, true); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorLeftChar); + CheckSelectedText('Hello World Hello ', 'Select to left char'); - }, oGraphicTypes.bold); - }); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorLeftWord); + CheckSelectedText('Hello World ', 'Select to left word'); - QUnit.test('Test clear slicer', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oSlicer = createSlicer(); - oSlicer.buttonsContainer.buttons[0].setInvertSelectTmpState(); - oSlicer.onViewUpdate(); - onKeyDown(oEvent); - equal(oSlicer.buttonsContainer.buttons[0].isSelected(), true); - }, oGraphicTypes.cleanSlicer); - }); - - QUnit.test('Test center align', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectParaPrAfterKeyDown((oPara) => oPara.GetJc(), oEvent, oAssert, align_Center); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightWord); + CheckSelectedText('Hello World Hello ', 'Select to right word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightWord); + CheckSelectedText('Hello World Hello World ', 'Select to right word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightWord); + CheckSelectedText('Hello World Hello World Hello ', 'Select to right word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToStartLine); + CheckSelectedText('Hello World Hello ', 'Select to start line'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorDown); + CheckSelectedText('Hello World Hello World Hello World ', 'Select down'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorUp); + CheckSelectedText('Hello World Hello ', 'Select up'); + + GetDrawingObjects().cursorMoveToEndPos(); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorLeftChar); + CheckSelectedText('d', 'Select to left char'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorLeftWord); + CheckSelectedText('World', 'Select to left word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToStartDocument); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World', 'Select to start content'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToEndDocument); + CheckSelectedText('', 'Select to end content'); + + GetDrawingObjects().cursorMoveToStartPos(); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToEndDocument); + CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World', 'Select to end content'); + }); + + QUnit.test('Check paragraph property change', (assert) => + { + ClearShapeAndAddParagraph('Hello world'); + + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Left, "Check align left"); + ExecuteGraphicHotkey(graphicHotkeyTypes.centerAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Center, "Check turn on center para"); + ExecuteGraphicHotkey(graphicHotkeyTypes.centerAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Left, "Check turn on center para"); + + ExecuteGraphicHotkey(graphicHotkeyTypes.justifyAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); + ExecuteGraphicHotkey(graphicHotkeyTypes.justifyAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Left, "Check turn on justify para"); + ExecuteGraphicHotkey(graphicHotkeyTypes.justifyAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Justify, "Check turn on justify para"); + + ExecuteGraphicHotkey(graphicHotkeyTypes.leftAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Left, "Check turn on left para"); + ExecuteGraphicHotkey(graphicHotkeyTypes.leftAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Justify, "Check turn on left para"); + ExecuteGraphicHotkey(graphicHotkeyTypes.leftAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Left, "Check turn on left para"); + + ExecuteGraphicHotkey(graphicHotkeyTypes.rightAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Right, "Check turn on right para"); + ExecuteGraphicHotkey(graphicHotkeyTypes.rightAlign); + assert.strictEqual(GetDirectGraphicParaPr().GetJc(), AscCommon.align_Left, "Check turn on right para"); + }); + + QUnit.test('Check text property change', (assert) => + { + ClearShapeAndAddParagraph('Hello world'); + GetDrawingObjects().selectAll(); + + ExecuteGraphicHotkey(graphicHotkeyTypes.bold); + assert.strictEqual(GetDirectGraphicTextPr().GetBold(), true, 'Check turn on bold'); + ExecuteGraphicHotkey(graphicHotkeyTypes.bold); + assert.strictEqual(GetDirectGraphicTextPr().GetBold(), false, 'Check turn off bold'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.italic); + assert.strictEqual(GetDirectGraphicTextPr().GetItalic(), true, 'Check turn on italic'); + ExecuteGraphicHotkey(graphicHotkeyTypes.italic); + assert.strictEqual(GetDirectGraphicTextPr().GetItalic(), false, 'Check turn off italic'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.underline); + assert.strictEqual(GetDirectGraphicTextPr().GetUnderline(), true, 'Check turn on underline'); + ExecuteGraphicHotkey(graphicHotkeyTypes.underline); + assert.strictEqual(GetDirectGraphicTextPr().GetUnderline(), false, 'Check turn off underline'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.superscript); + assert.strictEqual(GetDirectGraphicTextPr().GetVertAlign(), AscCommon.vertalign_SuperScript, 'Check turn on superscript'); + ExecuteGraphicHotkey(graphicHotkeyTypes.superscript); + assert.strictEqual(GetDirectGraphicTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off superscript'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.subscript); + assert.strictEqual(GetDirectGraphicTextPr().GetVertAlign(), AscCommon.vertalign_SubScript, 'Check turn on subscript'); + ExecuteGraphicHotkey(graphicHotkeyTypes.subscript); + assert.strictEqual(GetDirectGraphicTextPr().GetVertAlign(), AscCommon.vertalign_Baseline, 'Check turn off subscript'); + + // defaultSize = 10 + // 10 -> 11 -> 12 -> 14 -> 16 -> 14 -> 12 -> 11 -> 10 + ExecuteGraphicHotkey(graphicHotkeyTypes.increaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 11, 'Check increase font size'); + ExecuteGraphicHotkey(graphicHotkeyTypes.increaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 12, 'Check increase font size'); + ExecuteGraphicHotkey(graphicHotkeyTypes.increaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 14, 'Check increase font size'); + ExecuteGraphicHotkey(graphicHotkeyTypes.increaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 16, 'Check increase font size'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.decreaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 14, 'Check decrease font size'); + ExecuteGraphicHotkey(graphicHotkeyTypes.decreaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 12, 'Check decrease font size'); + ExecuteGraphicHotkey(graphicHotkeyTypes.decreaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 11, 'Check decrease font size'); + ExecuteGraphicHotkey(graphicHotkeyTypes.decreaseFontSize); + assert.strictEqual(GetDirectGraphicTextPr().GetFontSize(), 10, 'Check decrease font size'); + }); + + QUnit.test('Check add various characters', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph(''); + ExecuteGraphicHotkey(graphicHotkeyTypes.enDash); + assert.strictEqual(GetParagraphText(paragraph), String.fromCharCode(0x2013), 'Check add en dash'); + }); + + QUnit.test('Check select all', (assert) => + { + const {paragraph, shape} = ClearShapeAndAddParagraph('Hello'); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectAllContent); + + assert.true(shape.txBody.content.IsSelectionUse(), 'Check content selection'); + assert.true(paragraph.IsSelectedAll(), 'Check paragraph selection'); + assert.strictEqual(GetDrawingObjects().GetSelectedText(), 'Hello', 'Check selected text'); + + const drawing2 = AddShape(); + + SelectDrawings([shape]); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectAllDrawings); + assert.strictEqual(GetDrawingObjects().selectedObjects.length, 2, 'Check amount of selected shapes'); + assert.true(GetDrawingObjects().selectedObjects[0] === drawing2, 'Check selected shape'); + assert.true(GetDrawingObjects().selectedObjects[1] === shape, 'Check selected shape'); + }); + + QUnit.test('Check select all in chart title', (assert) => + { + const chart = AddChart(); + SelectDrawings([chart]); + const titles = chart.getAllTitles(); + const controller = GetDrawingObjects(); + controller.selection.chartSelection = chart; + chart.selectTitle(titles[0], 0); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectAllTitleAfterEnter); + assert.strictEqual(GetDrawingObjects().GetSelectedText(), 'Diagram Title', 'Check select all content in chart title'); + }); + + QUnit.test('Check add tab symbol', (assert) => + { + const {paragraph} = ClearShapeAndAddParagraph(''); + ExecuteGraphicHotkey(graphicHotkeyTypes.addTab); + assert.true(paragraph.Content[0].Content[0].IsTab(), 'Check add tab symbol'); + }); + + QUnit.test('Check add new paragraph', (assert) => + { + const {shape} = ClearShapeAndAddParagraph(''); + ExecuteGraphicHotkey(graphicHotkeyTypes.addParagraph); + assert.strictEqual(shape.txBody.content.Content.length, 2, 'Check add new paragraph'); + }); + + QUnit.test('Check add break line', (assert) => + { + function CheckAddBreakLine(shape) + { + assert.strictEqual(shape.txBody.content.Content.length, 1, 'Check amount paragraphs'); + assert.strictEqual(shape.txBody.content.Content[0].GetLinesCount(), 2, 'Check amount lines'); + } - }, oGraphicTypes.centerAlign); - }); - QUnit.test('Test italic', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetItalic(), oEvent, oAssert, true); + { - }, oGraphicTypes.italic); - }); - QUnit.test('Test justify align', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectParaPrAfterKeyDown((oPara) => oPara.GetJc(), oEvent, oAssert, align_Justify); + const {shape} = ClearShapeAndAddParagraph('Hello Hello'); + GetDrawingObjects().cursorMoveRight(false, true); + ExecuteGraphicHotkey(graphicHotkeyTypes.addBreakLine); + CheckAddBreakLine(shape); - }, oGraphicTypes.justifyAlign); - }); - QUnit.test('Test left align', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const continueCheck = checkDirectParaPrAfterKeyDown((oPara) => oPara.GetJc(), oEvent, oAssert, align_Justify); - continueCheck((oPara) => oPara.GetJc(), oEvent, oAssert, align_Left); + } - }, oGraphicTypes.leftAlign); - }); - QUnit.test('Test right align', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectParaPrAfterKeyDown((oParaPr) => oParaPr.GetJc(), oEvent, oAssert, align_Right); - }, oGraphicTypes.rightAlign); - }); + { + const {shape} = ClearShapeAndAddParagraph(''); + editor.asc_AddMath2(c_oAscMathType.FractionVertical); + GetDrawingObjects().recalculate(); + const paragraph = shape.txBody.content.Content[0]; + GetDrawingObjects().cursorMoveLeft(); + GetDrawingObjects().cursorMoveLeft(); + EnterText('8888888'); + GetDrawingObjects().cursorMoveLeft(); + GetDrawingObjects().cursorMoveLeft(); + ExecuteGraphicHotkey(graphicHotkeyTypes.addLineInMath); + const paraMath = paragraph.GetAllParaMaths()[0]; + const fraction = paraMath.Root.GetFirstElement(); + const numerator = fraction.getNumerator(); + const eqArray = numerator.GetFirstElement(); + assert.strictEqual(eqArray.getRowsCount(), 2, 'Check add new line in math'); + } + }); - QUnit.test('Test invert multiselect slicer', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const oSlicer = createSlicer(); - onKeyDown(oEvent); - equal(oSlicer.isMultiSelect(), true); - }, oGraphicTypes.invertMultiselectSlicer); - }); - QUnit.test('Test underline', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetUnderline(), oEvent, oAssert, true); - }, oGraphicTypes.underline); - }); + QUnit.test('Check slicer shortcuts', (assert) => + { + const ExecuteHotkeyWithEvent = (index) => + { + const slicer = CreateSlicer(); + ExecuteGraphicHotkey(graphicHotkeyTypes.invertMultiselectSlicer, index); + assert.true(slicer.isMultiSelect(), 'Check multiselect slicer'); + + slicer.buttonsContainer.buttons[0].setUnselectTmpState(); + ExecuteGraphicHotkey(graphicHotkeyTypes.cleanSlicer, index); + assert.true(slicer.buttonsContainer.buttons[0].isSelected(), 'Check clean slicer'); + RemoveGraphicObjects(); + ResetData(0, 0, 49, 49); + }; + ExecuteHotkeyWithEvent(0); + ExecuteHotkeyWithEvent(1); + }); + + + QUnit.module('Test table hotkeys', { + before : function f() + { + SetVisibleRange(0, 0, 49, 49); + }, + afterEach: function () + { + CloseCellEditor(true); + ResetData(0, 0, 49, 49); + } + }); + QUnit.test('Check cell movement', (assert) => + { + function CheckActiveCell(expectedRow, expectedColumn, description) + { + assert.deepEqual([ws.selectionRange.activeCell.row, ws.selectionRange.activeCell.col], [expectedRow, expectedColumn], description); + } - QUnit.test('Test superscript vertical align', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetVertAlign(), oEvent, oAssert, AscCommon.vertalign_SuperScript); + function CheckActiveRange(r1, c1, r2, c2, description) + { + const lastRange = ws.selectionRange.getLast(); + assert.deepEqual([lastRange.r1, lastRange.c1, lastRange.r2, lastRange.c2], [r1, c1, r2, c2], description); + } - }, oGraphicTypes.superscript); - }); - QUnit.test('Test add en dash', (oAssert) => - { - startGraphicTest((oEvent) => - { - checkTextAfterKeyDownHelperEmpty('–', oEvent, oAssert); - }, oGraphicTypes.enDash); - }); + Select(0, 15, 0, 15, 0, 15); + FillActiveCell('Hello'); + Select(25, 0, 25, 0, 25, 0); + FillActiveCell('Hello'); + Select(27, 0, 27, 0, 27, 0); + FillActiveCell('Hello'); + + Select(5, 5, 5, 5, 5, 5); + FillActiveCell('Hello'); + Select(4, 8, 4, 8, 4, 8); + FillActiveCell('Hello'); + + Select(35, 0, 35, 0, 35, 0); + ExecuteTableHotkey(tableHotkeyTypes.moveToTopCell); + CheckActiveCell(27, 0, 'Check move to top cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToTopCell); + CheckActiveCell(25, 0, 'Check move to top cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToTopCell); + CheckActiveCell(0, 0, 'Check move to top cell'); + + + Select(0, 39, 0, 39, 0, 39); + ExecuteTableHotkey(tableHotkeyTypes.moveToLeftEdgeCell); + CheckActiveCell(0, 15, 'Check move to left edge cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToLeftEdgeCell); + CheckActiveCell(0, 0, 'Check move to left edge cell'); + + Select(0, 2, 0, 2, 0, 2); + ExecuteTableHotkey(tableHotkeyTypes.moveToLeftCell); + CheckActiveCell(0, 1, 'Check move to left cell'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.moveToRightEdgeCell); + CheckActiveCell(0, 15, 'Check move to right edge cell'); + + Select(4, 0, 4, 0, 4, 0); + ExecuteTableHotkey(tableHotkeyTypes.moveToRightEdgeCell, 1); + CheckActiveCell(4, 8, 'Check move to right edge cell'); + + Select(5, 0, 5, 0, 5, 0); + ExecuteTableHotkey(tableHotkeyTypes.moveToRightEdgeCell); + CheckActiveCell(5, 5, 'Check move to right edge cell'); + + ExecuteTableHotkey(tableHotkeyTypes.moveToRightCell); + CheckActiveCell(5, 6, 'Check move to right cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToRightCell); + CheckActiveCell(5, 7, 'Check move to right cell'); + + ExecuteTableHotkey(tableHotkeyTypes.moveToDownCell); + CheckActiveCell(6, 7, 'Check move to down cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToDownCell); + CheckActiveCell(7, 7, 'Check move to down cell'); + + ExecuteTableHotkey(tableHotkeyTypes.moveToUpCell); + CheckActiveCell(6, 7, 'Check move to up cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToUpCell); + CheckActiveCell(5, 7, 'Check move to up cell'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.moveToBottomCell); + CheckActiveCell(25, 0, 'Check move to bottom cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToBottomCell); + CheckActiveCell(27, 0, 'Check move to bottom cell'); + + Select(5, 25, 5, 25, 5, 25); + ExecuteTableHotkey(tableHotkeyTypes.moveToFirstColumn); + CheckActiveCell(5, 0, 'Check move to first column'); + + Select(5, 25, 5, 25, 5, 25); + ExecuteTableHotkey(tableHotkeyTypes.moveToLeftEdgeTop); + CheckActiveCell(0, 0, 'Check move to left-top edge cell'); + + ExecuteTableHotkey(tableHotkeyTypes.moveToRightBottomEdge); + CheckActiveCell(27, 15, 'Check move to right-bottom edge cell'); + ExecuteTableHotkey(tableHotkeyTypes.moveToLowerCell); + CheckActiveCell(77, 15, 'Check move to lower cell'); + + ExecuteTableHotkey(tableHotkeyTypes.moveToUpperCell); + CheckActiveCell(27, 15, 'Check move to upper cell'); + + Select(35, 0, 35, 0, 35, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectToTopCell); + CheckActiveRange(27, 0, 35, 0, 'Check select to top cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToTopCell); + CheckActiveRange(25, 0, 35, 0, 'Check select to top cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToTopCell); + CheckActiveRange(0, 0, 35, 0, 'Check select to top cell'); + + Select(0, 39, 0, 39, 0, 39); + ExecuteTableHotkey(tableHotkeyTypes.selectToLeftEdgeCell); + CheckActiveRange(0, 15, 0, 39, 'Check select to left edge cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToLeftEdgeCell); + CheckActiveRange(0, 0, 0, 39, 'Check select to left edge cell'); + + Select(0, 2, 0, 2, 0, 2); + ExecuteTableHotkey(tableHotkeyTypes.selectToLeftCell); + CheckActiveRange(0, 1, 0, 2, 'Check select to left cell'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectToRightEdgeCell); + CheckActiveRange(0, 0, 0, 15, 'Check select to right edge cell'); + + Select(4, 0, 4, 0, 4, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectToRightEdgeCell, 1); + CheckActiveRange(4, 0, 4, 8, 'Check select to right edge cell'); + + Select(5, 0, 5, 0, 5, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectToRightEdgeCell); + CheckActiveRange(5, 0, 5, 5, 'Check select to right edge cell'); + + ExecuteTableHotkey(tableHotkeyTypes.selectToRightCell); + CheckActiveRange(5, 0, 5, 6, 'Check select to right cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToRightCell); + CheckActiveRange(5, 0, 5, 7, 'Check select to right cell'); + + ExecuteTableHotkey(tableHotkeyTypes.selectToDownCell); + CheckActiveRange(5, 0, 6, 7, 'Check select to down cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToDownCell); + CheckActiveRange(5, 0, 7, 7, 'Check select to down cell'); + + ExecuteTableHotkey(tableHotkeyTypes.selectToUpCell); + CheckActiveRange(5, 0, 6, 7, 'Check select to up cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToUpCell); + CheckActiveRange(5, 0, 5, 7, 'Check select to up cell'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectToBottomCell); + CheckActiveRange(0, 0, 25, 0, 'Check select to bottom cell'); + ExecuteTableHotkey(tableHotkeyTypes.selectToBottomCell); + CheckActiveRange(0, 0, 27, 0, 'Check select to bottom cell'); + + Select(5, 25, 5, 25, 5, 25); + ExecuteTableHotkey(tableHotkeyTypes.selectToFirstColumn); + CheckActiveRange(5, 0, 5, 25, 'Check select to first column'); + + Select(5, 25, 5, 25, 5, 25); + ExecuteTableHotkey(tableHotkeyTypes.selectToLeftEdgeTop); + CheckActiveRange(0, 0, 5, 25, 'Check select to left-top edge cell'); + + ExecuteTableHotkey(tableHotkeyTypes.selectToRightBottomEdge); + CheckActiveRange(5, 15, 27, 25, 'Check select to right-bottom edge cell'); + + ExecuteTableHotkey(tableHotkeyTypes.selectToLowerCell); + CheckActiveRange(5, 15, 77, 25, 'Check select to lower cell'); + + ExecuteTableHotkey(tableHotkeyTypes.selectToUpperCell); + CheckActiveRange(5, 15, 27, 25, 'Check select to upper cell'); + + Select(0, 0, 0, 0, 3, 3); + + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToRight); + CheckActiveCell(0, 1, 'Check move active cell to right'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToRight); + CheckActiveCell(0, 2, 'Check move active cell to right'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToRight); + CheckActiveCell(0, 3, 'Check move active cell to right'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToRight); + CheckActiveCell(1, 0, 'Check move active cell to right'); + + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToLeft); + CheckActiveCell(0, 3, 'Check move active cell to left'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToLeft); + CheckActiveCell(0, 2, 'Check move active cell to left'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToLeft); + CheckActiveCell(0, 1, 'Check move active cell to left'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToLeft); + CheckActiveCell(0, 0, 'Check move active cell to left'); + + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToDown); + CheckActiveCell(1, 0, 'Check move active cell to down'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToDown); + CheckActiveCell(2, 0, 'Check move active cell to down'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToDown); + CheckActiveCell(3, 0, 'Check move active cell to down'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToDown); + CheckActiveCell(0, 1, 'Check move active cell to down'); + + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToUp); + CheckActiveCell(3, 0, 'Check move active cell to up'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToUp); + CheckActiveCell(2, 0, 'Check move active cell to up'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToUp); + CheckActiveCell(1, 0, 'Check move active cell to up'); + ExecuteTableHotkey(tableHotkeyTypes.moveActiveCellToUp); + CheckActiveCell(0, 0, 'Check move active cell to up'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectRow); + CheckActiveRange(0, 0, AscCommon.gc_nMaxRow0, 0, 'Check select row'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectColumn); + CheckActiveRange(0, 0, 0, AscCommon.gc_nMaxCol0, 'Check select column'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectSheet); + CheckActiveRange(0, 0, AscCommon.gc_nMaxRow0, AscCommon.gc_nMaxCol0, 'Check select sheet'); + + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.selectSheet, 1); + CheckActiveRange(0, 0, AscCommon.gc_nMaxRow0, AscCommon.gc_nMaxCol0, 'Check select sheet'); + }); + + QUnit.test('Check reset actions', (assert) => + { + editor.asc_startAddShape('rect'); + ExecuteTableHotkey(tableHotkeyTypes.reset); + assert.strictEqual(GetDrawingObjects().checkEndAddShape(), false, 'Check resetting add shape'); + Select(0, 0, 0, 0, 0, 0); + editor.asc_SelectionCut(); + ExecuteTableHotkey(tableHotkeyTypes.reset); + assert.strictEqual(wsView.copyCutRange, null, 'Check resetting cut range'); + + Select(0, 0, 0, 0, 0, 0); + editor.asc_Copy(); + ExecuteTableHotkey(tableHotkeyTypes.reset); + assert.strictEqual(wsView.copyCutRange, null, 'Check resetting copy range'); + }); + + + QUnit.test('Check actions with removing', (assert) => + { + Select(0, 15, 0, 15, 0, 15); + FillActiveCell('Hello'); + Select(25, 0, 25, 0, 25, 0); + FillActiveCell('Hello'); + Select(27, 0, 27, 0, 27, 0); + FillActiveCell('Hello'); + + Select(0, 15, 0, 0, 30, 30); + ExecuteTableHotkey(tableHotkeyTypes.removeActiveCell); + CloseCellEditor(true); + + assert.strictEqual(GetCellText(0, 15), '', 'Check remove active cell'); + assert.strictEqual(GetCellText(25, 0), 'Hello', 'Check remove active cell'); + assert.strictEqual(GetCellText(27, 0), 'Hello', 'Check remove active cell'); + + ExecuteTableHotkey(tableHotkeyTypes.emptyRange); + assert.strictEqual(GetCellText(0, 15), '', 'Check remove range'); + assert.strictEqual(GetCellText(25, 0), '', 'Check remove range'); + assert.strictEqual(GetCellText(27, 0), '', 'Check remove range'); + }); + + QUnit.test('Check actions with filling cell', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.addDate); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getDateString(editor), 'Check add date'); + + ExecuteTableHotkey(tableHotkeyTypes.addTime); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getTimeString(editor).split(' ').join(':00 '), 'Check add time'); + + ExecuteTableHotkey(tableHotkeyTypes.addSeparator); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), '.', 'Check add separator'); + }); + + QUnit.test('Check actions with formatting cell', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + FillActiveCell('0.1'); + ExecuteTableHotkey(tableHotkeyTypes.setExponentialFormat); + assert.strictEqual(GetCellText(0, 0), '1.00E-01', 'set exponential format'); + ExecuteTableHotkey(tableHotkeyTypes.setPercentFormat); + assert.strictEqual(GetCellText(0, 0), '10.00%', 'set percent format'); + + FillActiveCell('49990'); + ExecuteTableHotkey(tableHotkeyTypes.setCurrencyFormat); + assert.strictEqual(GetCellText(0, 0), '$49,990.00', 'set currency format'); + ExecuteTableHotkey(tableHotkeyTypes.setTimeFormat); + assert.strictEqual(GetCellText(0, 0), '12:00:00 AM', 'set time format'); + ExecuteTableHotkey(tableHotkeyTypes.setDateFormat); + assert.strictEqual(GetCellText(0, 0), '11/11/2036', 'set date format'); + ExecuteTableHotkey(tableHotkeyTypes.setNumberFormat); + assert.strictEqual(GetCellText(0, 0), '49990.00', 'set number format'); + ExecuteTableHotkey(tableHotkeyTypes.setGeneralFormat); + assert.strictEqual(GetCellText(0, 0), '49990', 'set general format'); + + function GetCellFormatting(row, column) + { + return ws.getRange4(row, column).getXfs(); + } - QUnit.test('Test add hyphen', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkTextAfterKeyDownHelperEmpty('-', oEvent, oAssert); - }, oGraphicTypes.hyphen); - }); + ExecuteTableHotkey(tableHotkeyTypes.setStrikethrough); + assert.true(GetCellFormatting(0, 0).asc_getFontStrikeout(), 'Check turn on strikeout format'); + ExecuteTableHotkey(tableHotkeyTypes.setStrikethrough); + assert.false(GetCellFormatting(0, 0).asc_getFontStrikeout(), 'Check turn of strikeout format'); + + ExecuteTableHotkey(tableHotkeyTypes.setBold); + assert.true(GetCellFormatting(0, 0).asc_getFontBold(), 'Check turn on bold format'); + ExecuteTableHotkey(tableHotkeyTypes.setBold); + assert.false(GetCellFormatting(0, 0).asc_getFontBold(), 'Check turn off bold format'); + + ExecuteTableHotkey(tableHotkeyTypes.setItalic); + assert.true(GetCellFormatting(0, 0).asc_getFontItalic(), 'Check turn on italic format'); + ExecuteTableHotkey(tableHotkeyTypes.setItalic); + assert.false(GetCellFormatting(0, 0).asc_getFontItalic(), 'Check turn off italic format'); + + ExecuteTableHotkey(tableHotkeyTypes.setUnderline); + assert.true(GetCellFormatting(0, 0).asc_getFontUnderline(), 'Check turn on underline format'); + ExecuteTableHotkey(tableHotkeyTypes.setUnderline); + assert.false(GetCellFormatting(0, 0).asc_getFontUnderline(), 'Check turn off underline format'); + }); + + QUnit.test('Check undo/redo', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('0.1'); + CloseCellEditor(true); + + assert.strictEqual(GetCellText(0, 0), '0.1', 'Check cell value'); + ExecuteTableHotkey(tableHotkeyTypes.undo); + assert.strictEqual(GetCellText(0, 0), '', 'Check undo'); + ExecuteTableHotkey(tableHotkeyTypes.redo); + assert.strictEqual(GetCellText(0, 0), '0.1', 'Check redo'); + }); + + QUnit.test('Check focus on cell editor', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.focusOnCellEditor); + assert.true(wsView.getCellEditMode(), 'Check open cell editor'); + }); + + QUnit.test('Check prevent default in Opera', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + let isPreventDefaulted = ExecuteTableHotkey(tableHotkeyTypes.disableNumLock); + assert.true(isPreventDefaulted); + + isPreventDefaulted = ExecuteTableHotkey(tableHotkeyTypes.disableScrollLock); + assert.true(isPreventDefaulted); + }); + + QUnit.test('Check add sum formula', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('1'); + Select(0, 1, 0, 1, 0, 1); + EnterText('2'); + + Select(7, 7, 7, 7, 7, 7); + ExecuteTableHotkey(tableHotkeyTypes.addSum); + EnterText('A1,B1'); + CloseCellEditor(true); + assert.strictEqual(GetCellText(7, 7), "3", 'Check sum result'); + + Select(8, 8, 8, 8, 8, 8); + ExecuteTableHotkey(tableHotkeyTypes.addSum, 1); + EnterText('A1,B1'); + CloseCellEditor(true); + assert.strictEqual(GetCellText(8, 8), "3", 'Check sum result'); + + Select(9, 9, 9, 9, 9, 9); + ExecuteTableHotkey(tableHotkeyTypes.addSum, 2); + EnterText('A1,B1'); + CloseCellEditor(true); + assert.strictEqual(GetCellText(9, 9), "3", 'Check sum result'); + + Select(10, 10, 10, 10, 10, 10); + ExecuteTableHotkey(tableHotkeyTypes.addSum, 3); + EnterText('A1,B1'); + CloseCellEditor(true); + assert.strictEqual(GetCellText(10, 10), "3", 'Check sum result'); + }); + + QUnit.test('Check move on worksheets', (assert) => + { + CreateWorksheets(['name1', 'name2']); + const ws1 = wb.getWorksheetByName(['name1'], 0); + const ws2 = wb.getWorksheetByName(['name2'], 0); + assert.strictEqual(wb.getActive(), 0, 'Check select first sheet'); + assert.true(wb.getWorksheet(0) === ws1, 'Check select first sheet'); + + ExecuteTableHotkey(tableHotkeyTypes.moveToNextSheet); + assert.strictEqual(wb.getActive(), 1, 'Check select second sheet'); + assert.true(wb.getWorksheet(1) === ws2, 'Check select second sheet'); + ExecuteTableHotkey(tableHotkeyTypes.moveToNextSheet); + assert.strictEqual(wb.getActive(), 2, 'Check select third sheet'); + assert.true(wb.getWorksheet(2) === ws, 'Check select third sheet'); + + ExecuteTableHotkey(tableHotkeyTypes.goToPreviousSheet); + assert.strictEqual(wb.getActive(), 1, 'Check select second sheet'); + assert.true(wb.getWorksheet(1) === ws2, 'Check select second sheet'); + ExecuteTableHotkey(tableHotkeyTypes.goToPreviousSheet); + assert.strictEqual(wb.getActive(), 0, 'Check select first sheet'); + assert.true(wb.getWorksheet(0) === ws1, 'Check select first sheet'); + + RemoveWorksheets([0, 1]); + }); + + QUnit.test('Check refresh connections', (assert) => + { + Select(0, 0, 0, 0, 0, 0); + EnterText('ad'); + Select(1, 0, 1, 0, 1, 0); + EnterText('1'); + Select(2, 0, 2, 0, 2, 0); + EnterText('2'); + CloseCellEditor(true); + editor.asc_insertPivotExistingWorksheet("Sheet1!$A$1:$A$3", "Sheet1!$C$1"); + const pivotTable1 = ws.getPivotTable(2, 1); + pivotTable1.asc_addField(editor, 0); + + Select(0, 1, 0, 1, 0, 1); + EnterText('ap'); + Select(1, 1, 1, 1, 1, 1); + EnterText('2'); + Select(2, 1, 2, 1, 2, 1); + EnterText('3'); + CloseCellEditor(true); + editor.asc_insertPivotExistingWorksheet("Sheet1!$B$1:$B$3", "Sheet1!$D$1"); + const pivotTable2 = ws.getPivotTable(3, 1); + pivotTable2.asc_addField(editor, 0); + + Select(2, 0, 2, 0, 2, 0); + EnterText('4'); + Select(2, 1, 2, 1, 2, 1); + EnterText('4'); + + Select(1, 2, 1, 2, 1, 2); + ExecuteTableHotkey(tableHotkeyTypes.refreshSelectedConnections); + assert.strictEqual(GetCellText(1, 2), '5', 'Check refresh selected connections'); + + Select(1, 3, 1, 3, 1, 3); + assert.strictEqual(GetCellText(1, 3), '5', 'Check refresh selected connections'); + + Select(2, 0, 2, 0, 2, 0); + EnterText('5'); + + Select(1, 2, 1, 2, 1, 2); + ExecuteTableHotkey(tableHotkeyTypes.refreshAllConnections); + assert.strictEqual(GetCellText(1, 2), '6', 'Check refresh all connections'); + + Select(1, 3, 1, 3, 1, 3); + assert.strictEqual(GetCellText(1, 3), '6', 'Check refresh all connections'); + + }); + QUnit.test('Change format table info', (assert) => + { + CreateTable(); + Select(1, 0, 1, 0, 1, 0); + ExecuteTableHotkey(tableHotkeyTypes.changeFormatTableInfo); + assert.strictEqual(GetCellText(3, 2), '6', 'Check change format table info'); + ExecuteTableHotkey(tableHotkeyTypes.changeFormatTableInfo); + }); + + QUnit.test('Check recalculating data', (assert) => + { + CreateWorksheets(['name1']); + const wsName = wb.getWorksheetByName(['name1'], 0); + + ws.getRange4(0, 2).fillData([['=sum(a1+b1)']]); + ws.getRange4(0, 0)._foreach(function (cell) + { + cell.setValueNumberInternal(1); + }); + ws.getRange4(0, 1)._foreach(function (cell) + { + cell.setValueNumberInternal(2); + }); - QUnit.test('Test add underscore', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkTextAfterKeyDownHelperEmpty('_', oEvent, oAssert); - }, oGraphicTypes.underscore); - }); + wsName.getRange4(0, 2).fillData([['=sum(a1+b1)']]); + wsName.getRange4(0, 0)._foreach(function (cell) + { + cell.setValueNumberInternal(1); + }); + wsName.getRange4(0, 1)._foreach(function (cell) + { + cell.setValueNumberInternal(2); + }); - QUnit.test('Test add subscript', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - checkDirectTextPrAfterKeyDown((oTextPr) => oTextPr.GetVertAlign(), oEvent, oAssert, AscCommon.vertalign_SubScript, 'Check subscript shortcut'); - }, oGraphicTypes.subscript); - }); + assert.strictEqual(ws.getRange4(0, 2).getValueWithFormat(), '0', 'Check non calculating values'); + assert.strictEqual(wsName.getRange4(0, 2).getValueWithFormat(), '0', 'Check non calculating values'); + ExecuteTableHotkey(tableHotkeyTypes.calculateActiveSheet); + assert.strictEqual(ws.getRange4(0, 2).getValueWithFormat(), '0', 'Check non calculating value'); + assert.strictEqual(wsName.getRange4(0, 2).getValueWithFormat(), '3', 'Check calculating value'); - QUnit.test('Test decrease font size', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape} = createShapeWithContent('Hello'); - selectAll(); - addProperty({FontSize: 16}); - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 14); - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 12); - - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 11); - - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 10); - }, oGraphicTypes.decreaseFontSize); - }); - - QUnit.test('Test increase font size', (oAssert) => - { - const {deep, equal} = createTest(oAssert); - startGraphicTest((oEvent) => - { - const {oShape} = createShapeWithContent('Hello'); - moveToShapeParagraph(oShape, 0); - selectAll(); - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 11); - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 12); - - selectOnlyObjects([oShape]); - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 14); - - onKeyDown(oEvent); - equal(textPr().GetFontSize(), 16); - }, oGraphicTypes.increaseFontSize); - }); - } - ) + wsName.getRange4(0, 0)._foreach(function (cell) + { + cell.setValueNumberInternal(0); + }); + + ExecuteTableHotkey(tableHotkeyTypes.calculateAll); + assert.strictEqual(ws.getRange4(0, 2).getValueWithFormat(), '3', 'Check calculating value'); + assert.strictEqual(wsName.getRange4(0, 2).getValueWithFormat(), '2', 'Check calculating value'); + RemoveWorksheets([0]); + }); })(window); diff --git a/tests/cell/shortcuts/workbook.js b/tests/cell/shortcuts/workbook.js new file mode 100644 index 0000000000..1117ae861b --- /dev/null +++ b/tests/cell/shortcuts/workbook.js @@ -0,0 +1,182 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +"use strict"; + +(function (window) +{ +const charCellEditorWidth = 5; +const cellEditorWidth = 100; + + AscCommonExcel.WorkbookView.prototype._onUpdateCursor = function () {}; + AscCommonExcel.WorkbookView.prototype._canResize = function () {}; + AscCommonExcel.WorkbookView.prototype._onWSSelectionChanged = function () {}; + AscCommonExcel.WorkbookView.prototype.sendCursor = function () {}; + AscCommonExcel.WorkbookView.prototype.showWorksheet = function (index, bLockDraw) + { + index = AscFormat.isRealNumber(index) ? index : this.model.getActive(); + this.model.setActive(index); + this.wsActive = index; + }; + + AscCommonExcel.WorksheetView.prototype._init = function () {this._initWorksheetDefaultWidth();}; + AscCommonExcel.WorksheetView.prototype.updateRanges = function () {}; + AscCommonExcel.WorksheetView.prototype._autoFitColumnsWidth = function () {}; + AscCommonExcel.WorksheetView.prototype.setSelection = function () {}; + AscCommonExcel.WorksheetView.prototype.cleanSelection = function () {}; + AscCommonExcel.WorksheetView.prototype.draw = function () {editor.wb._updateSelectionInfo()}; + AscCommonExcel.WorksheetView.prototype._onUpdateFormatTable = function () {}; + AscCommonExcel.WorksheetView.prototype._drawSelection = function () {}; + AscCommonExcel.WorksheetView.prototype._calcRangeOffset = function () {return {};}; + AscCommonExcel.WorksheetView.prototype._calcVisibleRows = function () {}; + AscCommonExcel.WorksheetView.prototype._calcVisibleColumns = function () {}; + AscCommonExcel.WorksheetView.prototype._normalizeViewRange = function () {}; + AscCommonExcel.WorksheetView.prototype._fixVisibleRange = function () {}; + AscCommonExcel.WorksheetView.prototype.getCursorTypeFromXY = function () {return {};}; + AscCommonExcel.WorksheetView.prototype._calcActiveCellOffset = function () {return {};}; + AscCommonExcel.WorksheetView.prototype._prepareDrawingObjects = function () + { + this.objectRender = new AscFormat.DrawingObjects(); + this.objectRender.init(this); + this.objectRender.showDrawingObjects = function () {}; + this.objectRender.getContextWidth = function () {return 100}; + this.objectRender.getContextHeight = function () {return 100}; + this.objectRender.controller.updateOverlay = function () {}; + this.objectRender.controller.updateSelectionState = function () {}; + }; + + AscCommonExcel.asc_CEventsController.prototype._createScrollBars = function () {}; + const OldEventControllerInit = AscCommonExcel.asc_CEventsController.prototype.init; + AscCommonExcel.asc_CEventsController.prototype.init = function (view, widgetElem, canvasElem, handlers) + { + return OldEventControllerInit.call(this, view, document.createElement('div'), document.createElement('canvas'), handlers); + }; + + AscCommon.InitBrowserInputContext = function () {}; + + Asc.DrawingContext.prototype.setFont = function () {}; + Asc.DrawingContext.prototype.setFont = function () {}; + Asc.DrawingContext.prototype.fillText = function () {}; + Asc.DrawingContext.prototype.getFontMetrics = function () + { + return {ascender: 15, descender: 4, lineGap: 1, nat_scale: 1000, nat_y1: 1000, nat_y2: -1000}; + }; + Asc.DrawingContext.prototype.measureChar = function () + { + return Asc.TextMetrics(charCellEditorWidth, 9, 10, 1, 1, 10, charCellEditorWidth); + } + + AscFonts.CFontManager.prototype.MeasureChar = function () + { + return {fAdvanceX: charCellEditorWidth, oBBox: {fMaxX: 0, fMinX: 0}}; + }; + + AscCommonExcel.CellEditor.prototype._init = function () + { + this.drawingCtx = new Asc.DrawingContext({ + canvas: document.createElement('canvas'), units: 0/*px*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont + }); + this.overlayCtx = new Asc.DrawingContext({ + canvas: document.createElement('canvas'), units: 0/*px*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont + }); + this.textRender = new AscCommonExcel.CellTextRender(this.drawingCtx); + } + AscCommonExcel.CellEditor.prototype.updateWizardMode = function () {}; + AscCommonExcel.CellEditor.prototype._cleanText = function () {}; + AscCommonExcel.CellEditor.prototype._cleanSelection = function () {}; + AscCommonExcel.CellEditor.prototype._adjustCanvas = function () {}; + AscCommonExcel.CellEditor.prototype._showCanvas = function () {}; + AscCommonExcel.CellEditor.prototype._calculateCanvasSize = function () {}; + AscCommonExcel.CellEditor.prototype._renderText = function () {}; + AscCommonExcel.CellEditor.prototype._updateCursorPosition = function () {}; + AscCommonExcel.CellEditor.prototype._updateCursor = function () {}; + AscCommonExcel.CellEditor.prototype._hideCanvas = function () {}; + const OldCellEditorOpen = AscCommonExcel.CellEditor.prototype.open; + AscCommonExcel.CellEditor.prototype.open = function (options) + { + options.getSides = function () + { + return {l: [0], r: [cellEditorWidth], b: [10], cellX: 0, cellY: 0, ri: 0, bi: 0}; + } + OldCellEditorOpen.call(this, options); + }; + + Asc.spreadsheet_api.prototype._init = function () {this._loadModules();}; + Asc.spreadsheet_api.prototype._loadFonts = function (fonts, callback) {callback();}; + Asc.spreadsheet_api.prototype.onEndLoadFile = function (fonts, callback) {OpenDocument();}; + AscCommon.baseEditorsApi.prototype._onEndLoadSdk = function () {this.ImageLoader = AscCommon.g_image_loader;}; + + let editor; + function InitEditor(Callback) + { + editor = new Asc.spreadsheet_api({ + 'id-view': 'editor_sdk' + }); + editor.HtmlElement = document.createElement('div'); + editor.topLineEditorElement = document.createElement('input'); + editor.FontLoader = { + LoadDocumentFonts: function () + { + setTimeout(Callback, 0) + } + }; + + window["Asc"]["editor"] = editor; + } + + function OpenDocument() + { + AscCommon.g_oTableId.init(); + AscCommon.g_clipboardBase.Init(editor); + editor._onEndLoadSdk(); + AscFormat.initStyleManager(); + editor.isOpenOOXInBrowser = false; + editor._openDocument(AscCommon.getEmpty()); + editor._openOnClient(); + editor.collaborativeEditing = new AscCommonExcel.CCollaborativeEditing({}); + editor.wb = new AscCommonExcel.WorkbookView(editor.wbModel, editor.controller, editor.handlers, editor.HtmlElement, + editor.topLineEditorElement, editor, editor.collaborativeEditing, editor.fontRenderingMode); + const wb = editor.wbModel; + + const wsView = editor.wb.getWorksheet(0); + wsView.handlers = editor.handlers; + wb.DrawingDocument.SelectEnabled = function () {}; + wb.DrawingDocument.UpdateTarget = function () {}; + wb.DrawingDocument.CheckTargetShow = function () {}; + wb.DrawingDocument.TargetStart = function () {}; + + wb.setActive(0); + editor.wb.wsActive = 0; + } + + AscTestShortcut.InitEditor = InitEditor; +})(window); From dcf09124d84997809a264fa19801e95e92944d51 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 3 Oct 2023 14:16:22 +0300 Subject: [PATCH 16/23] [pe] Add moving to specific slide tests --- tests/slide/common/editor.js | 1 + tests/slide/shortcuts/events.js | 7 ++++++- tests/slide/shortcuts/shortcuts.js | 21 +++++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/slide/common/editor.js b/tests/slide/common/editor.js index 3bd3099fa6..dc2856a0fa 100644 --- a/tests/slide/common/editor.js +++ b/tests/slide/common/editor.js @@ -122,5 +122,6 @@ AscTest.Editor = editor; window.editor = editor; + Asc.editor = editor; })(window); diff --git a/tests/slide/shortcuts/events.js b/tests/slide/shortcuts/events.js index 7c1584bae7..539d6a1e5d 100644 --- a/tests/slide/shortcuts/events.js +++ b/tests/slide/shortcuts/events.js @@ -228,7 +228,8 @@ moveToPreviousSlide : 1, moveToFirstSlide : 2, moveToLastSlide : 3, - exitFromDemonstrationMode: 4 + exitFromDemonstrationMode: 4, + moveToNumberSlide : 5 }; const demonstrationEvents = {}; demonstrationEvents[demonstrationTypes.moveToNextSlide] = [ @@ -238,6 +239,9 @@ new CNativeEvent(39, false, false, false, false), new CNativeEvent(40, false, false, false, false) ]; + demonstrationEvents[demonstrationTypes.moveToNumberSlide] = [ + new CNativeEvent(13, false, false, false, false), + ]; demonstrationEvents[demonstrationTypes.moveToPreviousSlide] = [ new CNativeEvent(33, false, false, false, false), new CNativeEvent(37, false, false, false, false), @@ -421,4 +425,5 @@ AscTest.ExecuteMainShortcut = ExecuteMainShortcut; AscTest.ExecuteThumbnailHotkey = ExecuteThumbnailHotkey; AscTest.ExecuteMainHotkey = ExecuteMainHotkey; + AscTest.CNativeEvent = CNativeEvent; })(window); diff --git a/tests/slide/shortcuts/shortcuts.js b/tests/slide/shortcuts/shortcuts.js index a743d7b47c..98fdba3a3b 100644 --- a/tests/slide/shortcuts/shortcuts.js +++ b/tests/slide/shortcuts/shortcuts.js @@ -43,7 +43,8 @@ ExecuteThumbnailShortcut, ExecuteMainShortcut, ExecuteThumbnailHotkey, - ExecuteMainHotkey + ExecuteMainHotkey, + CNativeEvent } = AscTest; const logicDocument = AscTest.CreateLogicDocument(); @@ -419,6 +420,12 @@ CreateSlide(); CreateSlide(); CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); + CreateSlide(); let Execute; @@ -458,8 +465,18 @@ ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 0, demonstrationEvents[demonstrationTypes.moveToFirstSlide][0]); - ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 5, demonstrationEvents[demonstrationTypes.moveToLastSlide][0]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 11, demonstrationEvents[demonstrationTypes.moveToLastSlide][0]); + + ExecuteDemonstrationShortcut(new CNativeEvent(53)); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 4, demonstrationEvents[demonstrationTypes.moveToNumberSlide][0]); + ExecuteDemonstrationShortcut(new CNativeEvent(56)); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 7, demonstrationEvents[demonstrationTypes.moveToNumberSlide][0]); + ExecuteDemonstrationShortcut(new CNativeEvent(49)); + ExecuteDemonstrationShortcut(new CNativeEvent(48)); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 9, demonstrationEvents[demonstrationTypes.moveToNumberSlide][0]); + ExecuteTestWithCatchEvent('asc_onDemonstrationSlideChanged', (nSlideNum) => nSlideNum, 10, demonstrationEvents[demonstrationTypes.moveToNumberSlide][0]); + ExecuteTestWithCatchEvent('asc_onEndDemonstration', () => true, true, demonstrationEvents[demonstrationTypes.exitFromDemonstrationMode][0]); Execute = ExecuteMainShortcut; From 9e8aa66d67d15de3b107d8235a2a402d10f6b520 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 3 Oct 2023 14:17:11 +0300 Subject: [PATCH 17/23] Add macOs text movement tests --- tests/cell/shortcuts/events.js | 61 +++++--- tests/cell/shortcuts/shortcuts.js | 129 +++++++++++++--- tests/slide/shortcuts/events.js | 229 ++++++++++++++++++----------- tests/slide/shortcuts/shortcuts.js | 58 +++++++- tests/word/shortcuts/events.js | 87 +++++++++-- tests/word/shortcuts/shortcuts.js | 75 +++++++--- 6 files changed, 476 insertions(+), 163 deletions(-) diff --git a/tests/cell/shortcuts/events.js b/tests/cell/shortcuts/events.js index a2065fd8c0..cfcc666f27 100644 --- a/tests/cell/shortcuts/events.js +++ b/tests/cell/shortcuts/events.js @@ -220,7 +220,8 @@ new CNativeEvent(keyCodes.BackSpace, false, false, false, false) ]; graphicEvents[graphicHotkeyTypes.removeBackWord] = [ - new CNativeEvent(keyCodes.BackSpace, true, false, false, false) + new CNativeEvent(keyCodes.BackSpace, true, false, false, false), + new CNativeEvent(keyCodes.BackSpace, false, false, true, false, testFlags.macOs) ]; graphicEvents[graphicHotkeyTypes.removeChart] = [ new CNativeEvent(keyCodes.BackSpace, false, false, false, false), @@ -284,7 +285,8 @@ ]; graphicEvents[graphicHotkeyTypes.moveCursorToEndLine] = [ - new CNativeEvent(keyCodes.End, false, false, false, false) + new CNativeEvent(keyCodes.End, false, false, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, false, false, true, testFlags.macOs) ]; graphicEvents[graphicHotkeyTypes.selectToEndDocument] = [ @@ -292,7 +294,8 @@ ]; graphicEvents[graphicHotkeyTypes.selectToEndLine] = [ - new CNativeEvent(keyCodes.End, false, true, false, false) + new CNativeEvent(keyCodes.End, false, true, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, true, false, true, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.moveCursorToStartDocument] = [ @@ -300,7 +303,8 @@ ]; graphicEvents[graphicHotkeyTypes.moveCursorToStartLine] = [ - new CNativeEvent(keyCodes.Home, false, false, false, false) + new CNativeEvent(keyCodes.Home, false, false, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, false, false, true, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.selectToStartDocument] = [ @@ -308,7 +312,8 @@ ]; graphicEvents[graphicHotkeyTypes.selectToStartLine] = [ - new CNativeEvent(keyCodes.Home, false, true, false, false) + new CNativeEvent(keyCodes.Home, false, true, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, true, false, true, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.moveCursorLeftChar] = [ @@ -319,11 +324,13 @@ ]; graphicEvents[graphicHotkeyTypes.moveCursorLeftWord] = [ - new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false) + new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, false, true, false, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.selectCursorLeftWord] = [ - new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false) + new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, true, true, false, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.bigMoveGraphicObjectLeft] = [ @@ -343,11 +350,12 @@ ]; graphicEvents[graphicHotkeyTypes.moveCursorRightWord] = [ - new CNativeEvent(keyCodes.ArrowRight, true, false, false, false) - + new CNativeEvent(keyCodes.ArrowRight, true, false, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, false, true, false, testFlags.macOs) ]; graphicEvents[graphicHotkeyTypes.selectCursorRightWord] = [ - new CNativeEvent(keyCodes.ArrowRight, true, true, false, false) + new CNativeEvent(keyCodes.ArrowRight, true, true, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, true, true, false, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.bigMoveGraphicObjectRight] = [ @@ -390,7 +398,8 @@ ]; graphicEvents[graphicHotkeyTypes.removeFrontWord] = [ - new CNativeEvent(keyCodes.Delete, true, false, false, false) + new CNativeEvent(keyCodes.Delete, true, false, false, false), + new CNativeEvent(keyCodes.Delete, false, false, true, false, testFlags.macOs), ]; graphicEvents[graphicHotkeyTypes.removeFrontChar] = [ @@ -808,31 +817,36 @@ new CNativeEvent(keyCodes.BackSpace, false, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.removeWordBack] = [ - new CNativeEvent(keyCodes.BackSpace, true, false, false, false) + new CNativeEvent(keyCodes.BackSpace, true, false, false, false), + new CNativeEvent(keyCodes.BackSpace, false, false, true, false, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.addSpace] = [ new CNativeEvent(keyCodes.Space, true, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToEndLine] = [ - new CNativeEvent(keyCodes.End, false, false, false, false) + new CNativeEvent(keyCodes.End, false, false, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, false, false, true, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToEndDocument] = [ new CNativeEvent(keyCodes.End, true, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.selectToEndLine] = [ - new CNativeEvent(keyCodes.End, false, true, false, false) + new CNativeEvent(keyCodes.End, false, true, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, true, false, true, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.selectToEndDocument] = [ new CNativeEvent(keyCodes.End, true, true, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToStartLine] = [ - new CNativeEvent(keyCodes.Home, false, false, false, false) + new CNativeEvent(keyCodes.Home, false, false, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, false, false, true, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToStartDocument] = [ new CNativeEvent(keyCodes.Home, true, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.selectToStartLine] = [ - new CNativeEvent(keyCodes.Home, false, true, false, false) + new CNativeEvent(keyCodes.Home, false, true, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, true, false, true, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.selectToStartDocument] = [ new CNativeEvent(keyCodes.Home, true, true, false, false) @@ -841,13 +855,15 @@ new CNativeEvent(keyCodes.ArrowLeft, false, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.moveCursorLeftWord] = [ - new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false) + new CNativeEvent(keyCodes.ArrowLeft, true, false, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, false, true, false, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.selectLeftChar] = [ new CNativeEvent(keyCodes.ArrowLeft, false, true, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.selectLeftWord] = [ - new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false) + new CNativeEvent(keyCodes.ArrowLeft, true, true, false, false), + new CNativeEvent(keyCodes.ArrowLeft, false, true, true, false, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToUpLine] = [ new CNativeEvent(keyCodes.ArrowTop, false, false, false, false) @@ -859,13 +875,15 @@ new CNativeEvent(keyCodes.ArrowRight, false, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToRightWord] = [ - new CNativeEvent(keyCodes.ArrowRight, true, false, false, false) + new CNativeEvent(keyCodes.ArrowRight, true, false, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, false, true, false, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.selectRightChar] = [ new CNativeEvent(keyCodes.ArrowRight, false, true, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.selectRightWord] = [ - new CNativeEvent(keyCodes.ArrowRight, true, true, false, false) + new CNativeEvent(keyCodes.ArrowRight, true, true, false, false), + new CNativeEvent(keyCodes.ArrowRight, false, true, true, false, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToDownLine] = [ new CNativeEvent(keyCodes.ArrowBottom, false, false, false, false) @@ -877,7 +895,8 @@ new CNativeEvent(keyCodes.Delete, false, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.deleteFrontWord] = [ - new CNativeEvent(keyCodes.Delete, true, false, false, false) + new CNativeEvent(keyCodes.Delete, true, false, false, false), + new CNativeEvent(keyCodes.Delete, false, false, true, false, testFlags.macOs), ]; oCellEditorEvents[cellEditorHotkeyTypes.setStrikethrough] = [ new CNativeEvent(keyCodes.Digit5, true, false, false, false) diff --git a/tests/cell/shortcuts/shortcuts.js b/tests/cell/shortcuts/shortcuts.js index cae73714e5..740531faf3 100644 --- a/tests/cell/shortcuts/shortcuts.js +++ b/tests/cell/shortcuts/shortcuts.js @@ -295,12 +295,33 @@ QUnit.config.autostart = false; ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightChar); CheckCursorPosition(19, 'Check move to right char'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToEndLine, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToEndLine, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightChar); + CheckCursorPosition(19, 'Check move to right char'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveCursorLeftChar); CheckCursorPosition(18, 'Check move to left char'); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveCursorLeftWord); CheckCursorPosition(12, 'Check move to left word'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveCursorLeftWord, 1); + CheckCursorPosition(6, 'Check move to left word'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightWord, 1); + CheckCursorPosition(12, 'Check move to right word'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToRightWord); CheckCursorPosition(18, 'Check move to right word'); @@ -334,6 +355,21 @@ QUnit.config.autostart = false; ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightChar); CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToEndLine, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToEndLine, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToStartLine, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToStartLine, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightChar); + CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectLeftChar); CheckSelectedText('Hello World Hello ', 'Select to left char'); @@ -343,6 +379,12 @@ QUnit.config.autostart = false; ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightWord); CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectLeftWord, 1); + CheckSelectedText('Hello World ', 'Select to left word'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightWord, 1); + CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectRightWord); CheckSelectedText('Hello World Hello World ', 'Select to right word'); @@ -375,33 +417,38 @@ QUnit.config.autostart = false; ExecuteCellEditorHotkey(cellEditorHotkeyTypes.selectToEndDocument); CheckSelectedText('Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello Hello World Hello Hello World Hello Hello World Hello World Hello World', 'Select to end content'); - // todo unlock - // cellEditor._moveCursor(-4); - // - // ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); - // CheckCursorPosition(144, 'Check move to start line'); - // ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); - // CheckCursorPosition(144, 'Check move to start line'); + cellEditor._moveCursor(-4); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); + CheckCursorPosition(144, 'Check move to start line'); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.moveToStartLine); + CheckCursorPosition(144, 'Check move to start line'); }); QUnit.test('Check remove parts of text', (assert) => { Select(0, 0, 0, 0, 0, 0); OpenCellEditor(); - EnterText('Hello Hello Hello Hello'); + EnterText('Hello Hello Hello Hello Hello Hello Hello'); cellEditor._moveCursor(-4); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.removeCharBack); - assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello Hell', 'Check removing back symbol'); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello Hello Hello Hello Hell', 'Check removing back symbol'); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.removeWordBack); - assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello ', 'Check removing back word'); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello Hello Hello Hello ', 'Check removing back word'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.removeWordBack, 1); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello Hello Hello ', 'Check removing back word'); cellEditor._moveCursor(-2); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.deleteFrontChar); - assert.strictEqual(GetCellEditorText(), 'ello Hello Hello ', 'Check removing front symbol'); + assert.strictEqual(GetCellEditorText(), 'ello Hello Hello Hello Hello ', 'Check removing front symbol'); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.deleteFrontWord); - assert.strictEqual(GetCellEditorText(), 'Hello Hello ', 'Check removing front word'); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello Hello ', 'Check removing front word'); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.deleteFrontWord, 1); + assert.strictEqual(GetCellEditorText(), 'Hello Hello Hello ', 'Check removing front word'); }); QUnit.test('Check save and moving from cell', (assert) => @@ -605,20 +652,26 @@ QUnit.config.autostart = false; }); QUnit.test('Check remove parts of text', (assert) => { - const {paragraph} = ClearShapeAndAddParagraph('Hello Hello Hello Hello'); + const {paragraph} = ClearShapeAndAddParagraph('Hello Hello Hello Hello Hello Hello Hello'); GetDrawingObjects().cursorMoveToEndPos(); ExecuteGraphicHotkey(graphicHotkeyTypes.removeBackChar); - assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello Hell', 'Check removing back symbol'); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello Hello Hell', 'Check removing back symbol'); ExecuteGraphicHotkey(graphicHotkeyTypes.removeBackWord); - assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing back word'); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello Hello ', 'Check removing back word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.removeBackWord, 1); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello ', 'Check removing back word'); GetDrawingObjects().cursorMoveToStartPos(); ExecuteGraphicHotkey(graphicHotkeyTypes.removeFrontChar); - assert.strictEqual(GetParagraphText(paragraph), 'ello Hello Hello ', 'Check removing front symbol'); + assert.strictEqual(GetParagraphText(paragraph), 'ello Hello Hello Hello Hello ', 'Check removing front symbol'); ExecuteGraphicHotkey(graphicHotkeyTypes.removeFrontWord); - assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello ', 'Check removing front word'); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello Hello ', 'Check removing front word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.removeFrontWord, 1); + assert.strictEqual(GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing front word'); }); QUnit.test('Check remove graphic objects', (assert) => @@ -796,12 +849,33 @@ QUnit.config.autostart = false; ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightChar); CheckCursorPosition(19, 'Check move to right char'); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToEndLine, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToEndLine, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToStartLine, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorToStartLine, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightChar); + CheckCursorPosition(19, 'Check move to right char'); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorLeftChar); CheckCursorPosition(18, 'Check move to left char'); ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorLeftWord); CheckCursorPosition(12, 'Check move to left word'); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorLeftWord, 1); + CheckCursorPosition(6, 'Check move to left word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightWord, 1); + CheckCursorPosition(12, 'Check move to right word'); + ExecuteGraphicHotkey(graphicHotkeyTypes.moveCursorRightWord); CheckCursorPosition(18, 'Check move to right word'); @@ -836,6 +910,21 @@ QUnit.config.autostart = false; ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightChar); CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToEndLine, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToEndLine, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToStartLine, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectToStartLine, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightChar); + CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorLeftChar); CheckSelectedText('Hello World Hello ', 'Select to left char'); @@ -845,6 +934,12 @@ QUnit.config.autostart = false; ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightWord); CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorLeftWord, 1); + CheckSelectedText('Hello World ', 'Select to left word'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightWord, 1); + CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteGraphicHotkey(graphicHotkeyTypes.selectCursorRightWord); CheckSelectedText('Hello World Hello World ', 'Select to right word'); diff --git a/tests/slide/shortcuts/events.js b/tests/slide/shortcuts/events.js index 539d6a1e5d..6941fb3e24 100644 --- a/tests/slide/shortcuts/events.js +++ b/tests/slide/shortcuts/events.js @@ -33,6 +33,11 @@ (function (window) { + const testFlags = { + nothing: 0x0000, + macOs: 0x0001 + }; + const mainShortcutTypes = { checkDeleteBack : 0, checkDeleteWordBack : 1, @@ -113,114 +118,144 @@ selectToLastSlide : 77 }; const mainEvents = {}; - mainEvents[mainShortcutTypes.checkDeleteBack] = [CreateKeyboardEvent(8, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkDeleteWordBack] = [CreateKeyboardEvent(8, true, false, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteBack] = [CreateKeyboardEvent(8, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteWordBack] = [ + CreateKeyboardEvent(8, true, false, false, false), + CreateKeyboardEvent(8, false, false, true, false, testFlags.macOs), + ]; mainEvents[mainShortcutTypes.checkRemoveAnimation] = [ - CreateKeyboardEvent(8, false, false, false, false, false), - CreateKeyboardEvent(46, false, false, false, false, false, false)]; + CreateKeyboardEvent(8, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false)]; mainEvents[mainShortcutTypes.checkRemoveChart] = [ - CreateKeyboardEvent(8, false, false, false, false, false), - CreateKeyboardEvent(46, false, false, false, false, false, false)]; + CreateKeyboardEvent(8, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false)]; mainEvents[mainShortcutTypes.checkRemoveShape] = [ - CreateKeyboardEvent(8, false, false, false, false, false), - CreateKeyboardEvent(46, false, false, false, false, false, false)]; + CreateKeyboardEvent(8, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false)]; mainEvents[mainShortcutTypes.checkRemoveTable] = [ CreateKeyboardEvent(8, false, false, false, false, false), - CreateKeyboardEvent(46, false, false, false, false, false, false)]; + CreateKeyboardEvent(46, false, false, false, false)]; mainEvents[mainShortcutTypes.checkRemoveGroup] = [ CreateKeyboardEvent(8, false, false, false, false, false), - CreateKeyboardEvent(46, false, false, false, false, false, false)]; + CreateKeyboardEvent(46, false, false, false, false)]; mainEvents[mainShortcutTypes.checkRemoveShapeInGroup] = [ - CreateKeyboardEvent(8, false, false, false, false, false), - CreateKeyboardEvent(46, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveToNextCell] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveToPreviousCell] = [CreateKeyboardEvent(9, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkIncreaseBulletIndent] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkDecreaseBulletIndent] = [CreateKeyboardEvent(9, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddTab] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectNextObject] = [CreateKeyboardEvent(9, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectPreviousObject] = [CreateKeyboardEvent(9, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkVisitHyperlink] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectNextObjectWithPlaceholder] = [CreateKeyboardEvent(13, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddNextSlideAfterSelectLastPlaceholderObject] = [CreateKeyboardEvent(13, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddBreakLine] = [CreateKeyboardEvent(13, false, true, false, false, false, false)]; + CreateKeyboardEvent(8, false, false, false, false), + CreateKeyboardEvent(46, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToNextCell] = [CreateKeyboardEvent(9, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToPreviousCell] = [CreateKeyboardEvent(9, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkIncreaseBulletIndent] = [CreateKeyboardEvent(9, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDecreaseBulletIndent] = [CreateKeyboardEvent(9, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkAddTab] = [CreateKeyboardEvent(9, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectNextObject] = [CreateKeyboardEvent(9, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectPreviousObject] = [CreateKeyboardEvent(9, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkVisitHyperlink] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectNextObjectWithPlaceholder] = [CreateKeyboardEvent(13, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddNextSlideAfterSelectLastPlaceholderObject] = [CreateKeyboardEvent(13, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddBreakLine] = [CreateKeyboardEvent(13, false, true, false, false)]; mainEvents[mainShortcutTypes.checkAddMathBreakLine] = [ - CreateKeyboardEvent(13, false, true, false, false, false, false), - CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddTitleBreakLine] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddParagraph] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddTxBodyShape] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorToStartPosShape] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectAllContentShape] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectAllContentChartTitle] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkRemoveAndMoveToStartPosTable] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectFirstCellContent] = [CreateKeyboardEvent(13, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkResetAddShape] = [CreateKeyboardEvent(27, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkResetAllDrawingSelection] = [CreateKeyboardEvent(27, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkResetStepDrawingSelection] = [CreateKeyboardEvent(27, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkNonBreakingSpace] = [CreateKeyboardEvent(32, true, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkClearParagraphFormatting] = [CreateKeyboardEvent(32, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkAddSpace] = [CreateKeyboardEvent(32, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveToEndPosContent] = [CreateKeyboardEvent(35, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveToEndLineContent] = [CreateKeyboardEvent(35, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectToEndLineContent] = [CreateKeyboardEvent(35, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveToStartPosContent] = [CreateKeyboardEvent(36, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveToStartLineContent] = [CreateKeyboardEvent(36, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectToStartLineContent] = [CreateKeyboardEvent(36, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorLeft] = [CreateKeyboardEvent(37, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectCursorLeft] = [CreateKeyboardEvent(37, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectWordCursorLeft] = [CreateKeyboardEvent(37, true, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorWordLeft] = [CreateKeyboardEvent(37, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorLeftTable] = [CreateKeyboardEvent(37, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorRight] = [CreateKeyboardEvent(39, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorRightTable] = [CreateKeyboardEvent(39, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectCursorRight] = [CreateKeyboardEvent(39, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectWordCursorRight] = [CreateKeyboardEvent(39, true, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorWordRight] = [CreateKeyboardEvent(39, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorTop] = [CreateKeyboardEvent(38, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorTopTable] = [CreateKeyboardEvent(38, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectCursorTop] = [CreateKeyboardEvent(38, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorBottom] = [CreateKeyboardEvent(40, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveCursorBottomTable] = [CreateKeyboardEvent(40, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkSelectCursorBottom] = [CreateKeyboardEvent(40, false, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveShapeBottom] = [CreateKeyboardEvent(40, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkLittleMoveShapeBottom] = [CreateKeyboardEvent(40, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveShapeTop] = [CreateKeyboardEvent(38, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkLittleMoveShapeTop] = [CreateKeyboardEvent(38, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveShapeRight] = [CreateKeyboardEvent(39, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkLittleMoveShapeRight] = [CreateKeyboardEvent(39, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkMoveShapeLeft] = [CreateKeyboardEvent(37, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkLittleMoveShapeLeft] = [CreateKeyboardEvent(37, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkDeleteFront] = [CreateKeyboardEvent(46, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkDeleteWordFront] = [CreateKeyboardEvent(46, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkIncreaseIndent] = [CreateKeyboardEvent(77, true, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkDecreaseIndent] = [CreateKeyboardEvent(77, true, true, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkNumLock] = [CreateKeyboardEvent(144, false, false, false, false, false, false)]; - mainEvents[mainShortcutTypes.checkScrollLock] = [CreateKeyboardEvent(145, false, false, false, false, false, false)]; + CreateKeyboardEvent(13, false, true, false, false), + CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddTitleBreakLine] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddParagraph] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddTxBodyShape] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorToStartPosShape] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectAllContentShape] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectAllContentChartTitle] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkRemoveAndMoveToStartPosTable] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectFirstCellContent] = [CreateKeyboardEvent(13, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkResetAddShape] = [CreateKeyboardEvent(27, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkResetAllDrawingSelection] = [CreateKeyboardEvent(27, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkResetStepDrawingSelection] = [CreateKeyboardEvent(27, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkNonBreakingSpace] = [CreateKeyboardEvent(32, true, true, false, false)]; + mainEvents[mainShortcutTypes.checkClearParagraphFormatting] = [CreateKeyboardEvent(32, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkAddSpace] = [CreateKeyboardEvent(32, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToEndPosContent] = [CreateKeyboardEvent(35, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToEndLineContent] = [ + CreateKeyboardEvent(35, false, false, false, false), + CreateKeyboardEvent(39, true, false, false, false, testFlags.macOs), + ]; + mainEvents[mainShortcutTypes.checkSelectToEndLineContent] = [ + CreateKeyboardEvent(35, false, true, false, false), + CreateKeyboardEvent(39, true, true, false, false, testFlags.macOs), + ]; + mainEvents[mainShortcutTypes.checkMoveToStartPosContent] = [CreateKeyboardEvent(36, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveToStartLineContent] = [ + CreateKeyboardEvent(36, false, false, false, false), + CreateKeyboardEvent(37, true, false, false, false, testFlags.macOs) + ]; + mainEvents[mainShortcutTypes.checkSelectToStartLineContent] = [ + CreateKeyboardEvent(36, false, true, false, false), + CreateKeyboardEvent(37, true, true, false, false, testFlags.macOs) + ]; + mainEvents[mainShortcutTypes.checkMoveCursorLeft] = [CreateKeyboardEvent(37, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorLeft] = [CreateKeyboardEvent(37, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkSelectWordCursorLeft] = [ + CreateKeyboardEvent(37, true, true, false, false), + CreateKeyboardEvent(37, false, true, true, false, testFlags.macOs) + ]; + mainEvents[mainShortcutTypes.checkMoveCursorWordLeft] = [ + CreateKeyboardEvent(37, true, false, false, false), + CreateKeyboardEvent(37, false, false, true, false, testFlags.macOs) + ]; + mainEvents[mainShortcutTypes.checkMoveCursorLeftTable] = [CreateKeyboardEvent(37, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorRight] = [CreateKeyboardEvent(39, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorRightTable] = [CreateKeyboardEvent(39, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorRight] = [CreateKeyboardEvent(39, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkSelectWordCursorRight] = [ + CreateKeyboardEvent(39, true, true, false, false), + CreateKeyboardEvent(39, false, true, true, false, testFlags.macOs), + ]; + mainEvents[mainShortcutTypes.checkMoveCursorWordRight] = [ + CreateKeyboardEvent(39, true, false, false, false), + CreateKeyboardEvent(39, false, false, true, false, testFlags.macOs), + ]; + mainEvents[mainShortcutTypes.checkMoveCursorTop] = [CreateKeyboardEvent(38, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorTopTable] = [CreateKeyboardEvent(38, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorTop] = [CreateKeyboardEvent(38, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorBottom] = [CreateKeyboardEvent(40, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveCursorBottomTable] = [CreateKeyboardEvent(40, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkSelectCursorBottom] = [CreateKeyboardEvent(40, false, true, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeBottom] = [CreateKeyboardEvent(40, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeBottom] = [CreateKeyboardEvent(40, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeTop] = [CreateKeyboardEvent(38, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeTop] = [CreateKeyboardEvent(38, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeRight] = [CreateKeyboardEvent(39, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeRight] = [CreateKeyboardEvent(39, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkMoveShapeLeft] = [CreateKeyboardEvent(37, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkLittleMoveShapeLeft] = [CreateKeyboardEvent(37, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteFront] = [CreateKeyboardEvent(46, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkDeleteWordFront] = [ + CreateKeyboardEvent(46, true, false, false, false), + CreateKeyboardEvent(46, false, false, true, false, testFlags.macOs), + ]; + mainEvents[mainShortcutTypes.checkIncreaseIndent] = [CreateKeyboardEvent(77, true, false, false, false)]; + mainEvents[mainShortcutTypes.checkDecreaseIndent] = [CreateKeyboardEvent(77, true, true, false, false)]; + mainEvents[mainShortcutTypes.checkNumLock] = [CreateKeyboardEvent(144, false, false, false, false)]; + mainEvents[mainShortcutTypes.checkScrollLock] = [CreateKeyboardEvent(145, false, false, false, false)]; mainEvents[mainShortcutTypes.addNextSlide] = [ - CreateKeyboardEvent(77, true, false, false, false, false, false) + CreateKeyboardEvent(77, true, false, false, false) ]; mainEvents[mainShortcutTypes.moveToPreviousSlide] = [ - CreateKeyboardEvent(38, false, false, false, false, false, false), - CreateKeyboardEvent(37, false, false, false, false, false, false), - CreateKeyboardEvent(33, false, false, false, false, false, false) + CreateKeyboardEvent(38, false, false, false, false), + CreateKeyboardEvent(37, false, false, false, false), + CreateKeyboardEvent(33, false, false, false, false) ]; mainEvents[mainShortcutTypes.moveToNextSlide] = [ - CreateKeyboardEvent(39, false, false, false, false, false, false), - CreateKeyboardEvent(40, false, false, false, false, false, false), - CreateKeyboardEvent(34, false, false, false, false, false, false) + CreateKeyboardEvent(39, false, false, false, false), + CreateKeyboardEvent(40, false, false, false, false), + CreateKeyboardEvent(34, false, false, false, false) ]; mainEvents[mainShortcutTypes.moveToFirstSlide] = [ - CreateKeyboardEvent(36, false, false, false, false, false, false) + CreateKeyboardEvent(36, false, false, false, false) ]; mainEvents[mainShortcutTypes.selectToFirstSlide] = [ - CreateKeyboardEvent(36, false, true, false, false, false, false) + CreateKeyboardEvent(36, false, true, false, false) ]; mainEvents[mainShortcutTypes.moveToLastSlide] = [ - CreateKeyboardEvent(35, false, false, false, false, false, false) + CreateKeyboardEvent(35, false, false, false, false) ]; mainEvents[mainShortcutTypes.selectToLastSlide] = [ - CreateKeyboardEvent(35, false, true, false, false, false, false) + CreateKeyboardEvent(35, false, true, false, false) ]; const demonstrationTypes = { @@ -328,8 +363,9 @@ ]; - function CreateKeyboardEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) + function CreateKeyboardEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey, flags) { + flags = flags || testFlags.nothing; const event = new AscCommon.CKeyboardEvent(); event.KeyCode = nKeyCode; event.CtrlKey = !!bIsCtrl; @@ -346,6 +382,20 @@ { event.isPropagationStopped = true; } + event.enableFlags = function () + { + if (flags & testFlags.macOs) + { + AscCommon.AscBrowser.isMacOs = true; + } + } + event.disableFlags = function () + { + if (flags & testFlags.macOs) + { + AscCommon.AscBrowser.isMacOs = false; + } + } return event; } @@ -391,7 +441,10 @@ function ExecuteMainShortcut(e) { - return editor.WordControl.m_oLogicDocument.OnKeyDown(e); + e.enableFlags && e.enableFlags(); + const res = editor.WordControl.m_oLogicDocument.OnKeyDown(e); + e.disableFlags && e.disableFlags(); + return res; } function ExecuteThumbnailShortcut(e) diff --git a/tests/slide/shortcuts/shortcuts.js b/tests/slide/shortcuts/shortcuts.js index 98fdba3a3b..f920d4d733 100644 --- a/tests/slide/shortcuts/shortcuts.js +++ b/tests/slide/shortcuts/shortcuts.js @@ -535,12 +535,33 @@ ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorRight); CheckCursorPosition(19, 'Check move to right char'); + ExecuteMainHotkey(mainShortcutTypes.checkMoveToEndLineContent, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToEndLineContent, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToStartLineContent, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveToStartLineContent, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorRight); + CheckCursorPosition(19, 'Check move to right char'); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorLeft); CheckCursorPosition(18, 'Check move to left char'); ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordLeft); CheckCursorPosition(12, 'Check move to left word'); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordLeft, 1); + CheckCursorPosition(6, 'Check move to left word'); + + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordRight, 1); + CheckCursorPosition(12, 'Check move to right word'); + ExecuteMainHotkey(mainShortcutTypes.checkMoveCursorWordRight); CheckCursorPosition(18, 'Check move to right word'); @@ -575,6 +596,21 @@ ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorRight); CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteMainHotkey(mainShortcutTypes.checkSelectToEndLineContent, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectToEndLineContent, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectToStartLineContent, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectToStartLineContent, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorRight); + CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteMainHotkey(mainShortcutTypes.checkSelectCursorLeft); CheckSelectedText('Hello World Hello ', 'Select to left char'); @@ -584,6 +620,12 @@ ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorRight); CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorLeft, 1); + CheckSelectedText('Hello World ', 'Select to left word'); + + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorRight, 1); + CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteMainHotkey(mainShortcutTypes.checkSelectWordCursorRight); CheckSelectedText('Hello World Hello World ', 'Select to right word'); @@ -610,20 +652,26 @@ QUnit.test('Check remove parts of text', (assert) => { - const {paragraph} = ClearShapeAndAddParagraph('Hello Hello Hello Hello'); + const {paragraph} = ClearShapeAndAddParagraph('Hello Hello Hello Hello Hello Hello Hello'); logicDocument.MoveCursorToEndPos(); ExecuteMainHotkey(mainShortcutTypes.checkDeleteBack); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hell', 'Check removing back symbol'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello Hello Hell', 'Check removing back symbol'); ExecuteMainHotkey(mainShortcutTypes.checkDeleteWordBack); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing back word'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello Hello ', 'Check removing back word'); + + ExecuteMainHotkey(mainShortcutTypes.checkDeleteWordBack, 1); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello ', 'Check removing back word'); logicDocument.MoveCursorToStartPos(); ExecuteMainHotkey(mainShortcutTypes.checkDeleteFront); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello ', 'Check removing front symbol'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello Hello Hello ', 'Check removing front symbol'); ExecuteMainHotkey(mainShortcutTypes.checkDeleteWordFront); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello ', 'Check removing front word'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello ', 'Check removing front word'); + + ExecuteMainHotkey(mainShortcutTypes.checkDeleteWordFront, 1); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing front word'); }); QUnit.test('Check text property change', (assert) => diff --git a/tests/word/shortcuts/events.js b/tests/word/shortcuts/events.js index 062f30b67f..c6724c6b40 100644 --- a/tests/word/shortcuts/events.js +++ b/tests/word/shortcuts/events.js @@ -33,6 +33,10 @@ (function (window) { window.AscTestShortcut = {}; + const testFlags = { + nothing: 0x0000, + macOs: 0x0001 + }; const testHotkeyActions = { removeBackSymbol : 0, removeBackWord : 1, @@ -129,7 +133,10 @@ testHotkeyEvents[testHotkeyActions.bigMoveGraphicObjectUp] = [CreateTestEvent(38, false, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.littleMoveGraphicObjectUp] = [CreateTestEvent(38, true, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.removeBackSymbol] = [CreateTestEvent(8, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.removeBackWord] = [CreateTestEvent(8, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeBackWord] = [ + CreateTestEvent(8, true, false, false, false), + CreateTestEvent(8, false, false, true, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.removeShape] = [ CreateTestEvent(8, false, false, false, false, false), CreateTestEvent(46, false, false, false, false, false) @@ -167,21 +174,45 @@ testHotkeyEvents[testHotkeyActions.endEditing] = [CreateTestEvent(27, false, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.toggleCheckBox] = [CreateTestEvent(32, false, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.moveToEndDocument] = [CreateTestEvent(35, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToEndLine] = [CreateTestEvent(35, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToEndLine] = [ + CreateTestEvent(35, false, false, false, false), + CreateTestEvent(39, true, false, false, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.selectToEndDocument] = [CreateTestEvent(35, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToEndLine] = [CreateTestEvent(35, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectToStartLine] = [CreateTestEvent(36, false, true, false, false)]; + testHotkeyEvents[testHotkeyActions.selectToEndLine] = [ + CreateTestEvent(35, false, true, false, false), + CreateTestEvent(39, true, true, false, false, testFlags.macOs), + ]; + testHotkeyEvents[testHotkeyActions.selectToStartLine] = [ + CreateTestEvent(36, false, true, false, false), + CreateTestEvent(37, true, true, false, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.selectToStartDocument] = [CreateTestEvent(36, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToStartLine] = [CreateTestEvent(36, false, false, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToStartLine] = [ + CreateTestEvent(36, false, false, false, false), + CreateTestEvent(37, true, false, false, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.moveToStartDocument] = [CreateTestEvent(36, true, false, false)]; - testHotkeyEvents[testHotkeyActions.selectLeftWord] = [CreateTestEvent(37, true, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToLeftWord] = [CreateTestEvent(37, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.selectLeftWord] = [ + CreateTestEvent(37, true, true, false, false), + CreateTestEvent(37, false, true, true, false, testFlags.macOs), + ]; + testHotkeyEvents[testHotkeyActions.moveToLeftWord] = [ + CreateTestEvent(37, true, false, false, false), + CreateTestEvent(37, false, false, true, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.selectLeftChar] = [CreateTestEvent(37, false, true, false, false)]; testHotkeyEvents[testHotkeyActions.moveToLeftChar] = [CreateTestEvent(37, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.moveToRightChar] = [CreateTestEvent(39, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.selectRightChar] = [CreateTestEvent(39, false, true, false, false)]; - testHotkeyEvents[testHotkeyActions.moveToRightWord] = [CreateTestEvent(39, true, false, false, false)]; - testHotkeyEvents[testHotkeyActions.selectRightWord] = [CreateTestEvent(39, true, true, false, false)]; + testHotkeyEvents[testHotkeyActions.moveToRightWord] = [ + CreateTestEvent(39, true, false, false, false), + CreateTestEvent(39, false, false, true, false, testFlags.macOs) + ]; + testHotkeyEvents[testHotkeyActions.selectRightWord] = [ + CreateTestEvent(39, true, true, false, false), + CreateTestEvent(39, false, true, true, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.moveUp] = [CreateTestEvent(38, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.selectUp] = [CreateTestEvent(38, false, true, false, false)]; testHotkeyEvents[testHotkeyActions.previousOptionComboBox] = [CreateTestEvent(38, false, false, false, false, false)]; @@ -189,10 +220,13 @@ testHotkeyEvents[testHotkeyActions.selectDown] = [CreateTestEvent(40, false, true, false, false)]; testHotkeyEvents[testHotkeyActions.nextOptionComboBox] = [CreateTestEvent(40, false, false, false, false, false)]; testHotkeyEvents[testHotkeyActions.removeFrontSymbol] = [CreateTestEvent(46, false, false, false, false)]; - testHotkeyEvents[testHotkeyActions.removeFrontWord] = [CreateTestEvent(46, true, false, false, false)]; + testHotkeyEvents[testHotkeyActions.removeFrontWord] = [ + CreateTestEvent(46, true, false, false, false), + CreateTestEvent(46, false, false, true, false, testFlags.macOs), + ]; testHotkeyEvents[testHotkeyActions.unicodeToChar] = [ CreateTestEvent(88, false, false, true, false), - CreateTestEvent(88, true, false, true, false) + CreateTestEvent(88, true, false, true, false, testFlags.macOs) ]; testHotkeyEvents[testHotkeyActions.showContextMenu] = [ CreateTestEvent(93, false, false, false, false), @@ -221,19 +255,48 @@ testHotkeyEvents[testHotkeyActions.selectToStartNextPage] = [CreateTestEvent(34, true, true, false, false)]; testHotkeyEvents[testHotkeyActions.selectToNextPage] = [CreateTestEvent(34, false, true, false, false)]; -function CreateTestEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey) +function CreateTestEvent(nKeyCode, bIsCtrl, bIsShift, bIsAlt, bIsMetaKey, flags) { + flags = flags || testFlags.nothing; const event = new AscCommon.CKeyboardEvent(); event.KeyCode = nKeyCode; event.CtrlKey = !!bIsCtrl; event.ShiftKey = !!bIsShift; event.AltKey = !!bIsAlt; event.MacCmdKey = !!bIsMetaKey; + event.enableFlags = function () + { + if (flags & testFlags.macOs) + { + AscCommon.AscBrowser.isMacOs = true; + } + } + event.disableFlags = function () + { + if (flags & testFlags.macOs) + { + AscCommon.AscBrowser.isMacOs = false; + } + } return event; } + function ExecuteShortcut(e) + { + e.enableFlags && e.enableFlags(); + const res = editor.WordControl.m_oLogicDocument.OnKeyDown(e); + e.disableFlags && e.disableFlags(); + return res; + } + function ExecuteHotkey(type, eventIndex) + { + const event = testHotkeyEvents[type][eventIndex || 0]; + return ExecuteShortcut(event); + } AscTestShortcut.testHotkeyActions = testHotkeyActions; AscTestShortcut.testHotkeyEvents = testHotkeyEvents; + AscTestShortcut.ExecuteShortcut = ExecuteShortcut; + AscTestShortcut.ExecuteHotkey = ExecuteHotkey; })(window); diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 8c1cdae00c..f41525c038 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -37,7 +37,8 @@ { const testHotkeyEvents = AscTestShortcut.testHotkeyEvents; const testHotkeyActions = AscTestShortcut.testHotkeyActions; - + const ExecuteShortcut = AscTestShortcut.ExecuteShortcut; + const ExecuteHotkey = AscTestShortcut.ExecuteHotkey; let logicDocument = AscTest.CreateLogicDocument(); const pageWidth = 100; @@ -157,17 +158,6 @@ logicDocument.RemoveHdrFtr(page, false); } - function ExecuteShortcut(type) - { - return logicDocument.OnKeyDown(type); - } - - function ExecuteHotkey(type, eventIndex) - { - const event = testHotkeyEvents[type][eventIndex || 0]; - return ExecuteShortcut(event); - } - function ClearDocumentAndAddParagraph(text) { logicDocument.RemoveSelection(); @@ -707,19 +697,25 @@ QUnit.test('Check remove symbols', (assert) => { - const paragraph = ClearDocumentAndAddParagraph('Hello Hello Hello Hello'); + const paragraph = ClearDocumentAndAddParagraph('Hello Hello Hello Hello Hello Hello Hello'); ExecuteHotkey(testHotkeyActions.removeBackSymbol); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hell', 'Check removing back symbol'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello Hello Hell', 'Check removing back symbol'); ExecuteHotkey(testHotkeyActions.removeBackWord); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing back word'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello Hello ', 'Check removing back word'); + + ExecuteHotkey(testHotkeyActions.removeBackWord, 1); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello Hello ', 'Check removing back word'); logicDocument.MoveCursorToStartPos(); ExecuteHotkey(testHotkeyActions.removeFrontSymbol); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello ', 'Check removing front symbol'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'ello Hello Hello Hello Hello ', 'Check removing front symbol'); ExecuteHotkey(testHotkeyActions.removeFrontWord); - assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello ', 'Check removing front word'); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello Hello ', 'Check removing front word'); + + ExecuteHotkey(testHotkeyActions.removeFrontWord, 1); + assert.strictEqual(AscTest.GetParagraphText(paragraph), 'Hello Hello Hello ', 'Check removing front word'); }); QUnit.test('Check move/select in text', (assert) => { @@ -753,12 +749,33 @@ ExecuteHotkey(testHotkeyActions.moveToRightChar); CheckCursorPosition(19, 'Check move to right char'); + ExecuteHotkey(testHotkeyActions.moveToEndLine, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteHotkey(testHotkeyActions.moveToEndLine, 1); + CheckCursorPosition(36, 'Check move to end line'); + + ExecuteHotkey(testHotkeyActions.moveToStartLine, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteHotkey(testHotkeyActions.moveToStartLine, 1); + CheckCursorPosition(18, 'Check move to start line'); + + ExecuteHotkey(testHotkeyActions.moveToRightChar); + CheckCursorPosition(19, 'Check move to right char'); + ExecuteHotkey(testHotkeyActions.moveToLeftChar); CheckCursorPosition(18, 'Check move to left char'); ExecuteHotkey(testHotkeyActions.moveToLeftWord); CheckCursorPosition(12, 'Check move to left word'); + ExecuteHotkey(testHotkeyActions.moveToLeftWord, 1); + CheckCursorPosition(6, 'Check move to left word'); + + ExecuteHotkey(testHotkeyActions.moveToRightWord, 1); + CheckCursorPosition(12, 'Check move to right word'); + ExecuteHotkey(testHotkeyActions.moveToRightWord); CheckCursorPosition(18, 'Check move to right word'); @@ -804,10 +821,24 @@ ExecuteHotkey(testHotkeyActions.selectToEndLine); CheckSelectedText('Hello World Hello ', 'Select to end line'); - ExecuteHotkey(testHotkeyActions.selectRightChar); CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteHotkey(testHotkeyActions.selectToEndLine, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteHotkey(testHotkeyActions.selectToEndLine, 1); + CheckSelectedText('Hello World Hello World Hello World ', 'Select to end line content'); + + ExecuteHotkey(testHotkeyActions.selectToStartLine, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteHotkey(testHotkeyActions.selectToStartLine, 1); + CheckSelectedText('Hello World Hello ', 'Select to start line content'); + + ExecuteHotkey(testHotkeyActions.checkSelectCursorRight); + CheckSelectedText('Hello World Hello W', 'Select to right char'); + ExecuteHotkey(testHotkeyActions.selectLeftChar); CheckSelectedText('Hello World Hello ', 'Select to left char'); @@ -817,6 +848,12 @@ ExecuteHotkey(testHotkeyActions.selectRightWord); CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteHotkey(testHotkeyActions.selectLeftWord, 1); + CheckSelectedText('Hello World ', 'Select to left word'); + + ExecuteHotkey(testHotkeyActions.selectRightWord, 1); + CheckSelectedText('Hello World Hello ', 'Select to right word'); + ExecuteHotkey(testHotkeyActions.selectRightWord); CheckSelectedText('Hello World Hello World ', 'Select to right word'); @@ -1279,10 +1316,8 @@ AscTest.MoveCursorLeft(true, true); - AscCommon.AscBrowser.isMacOs = true; ExecuteHotkey(testHotkeyActions.unicodeToChar, 1); assert.strictEqual(logicDocument.GetSelectedText(), '☝', 'Check replace unicode code to symbol'); - AscCommon.AscBrowser.isMacOs = false; }); QUnit.test("Check reset drag'n'drop", (oAssert) => From bb00ab4f5f04eb332a5734f4e888f964c118512c Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 3 Oct 2023 14:17:42 +0300 Subject: [PATCH 18/23] [de] Remove unusual code --- tests/word/shortcuts/shortcuts.js | 56 +++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index f41525c038..9ade2eacfe 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -44,7 +44,7 @@ const pageWidth = 100; const pageHeight = 100; logicDocument.Set_DocumentPageSize(pageWidth, pageHeight); - var props = new Asc.CDocumentSectionProps(); + const props = new Asc.CDocumentSectionProps(); props.put_TopMargin(0); props.put_LeftMargin(0); props.put_BottomMargin(0); @@ -148,16 +148,6 @@ logicDocument.Create_SectionHdrFtr( AscCommon.hdrftr_Footer, page ); } - function RemoveHeader(page) - { - logicDocument.RemoveHdrFtr(page, true); - } - - function RemoveFooter(page) - { - logicDocument.RemoveHdrFtr(page, false); - } - function ClearDocumentAndAddParagraph(text) { logicDocument.RemoveSelection(); @@ -248,7 +238,7 @@ function AddCheckBox() { const checkBox = logicDocument.AddContentControlCheckBox(); - var specProps = new AscCommon.CSdtCheckBoxPr(); + const specProps = new AscCommon.CSdtCheckBoxPr(); checkBox.ApplyCheckBoxPr(specProps); checkBox.SetFormPr(new AscCommon.CSdtFormPr()); return checkBox; @@ -257,7 +247,7 @@ function AddComboBox(items) { const comboBox = logicDocument.AddContentControlComboBox(); - var specProps = new AscCommon.CSdtComboBoxPr(); + const specProps = new AscCommon.CSdtComboBoxPr(); specProps.clear(); for (let i = 0; i < items.length; i++) { @@ -303,7 +293,7 @@ { let complexForm = logicDocument.AddComplexForm(); const formPr = new AscWord.CSdtFormPr(); - var formTextPr = new AscCommon.CSdtTextFormPr(); + const formTextPr = new AscCommon.CSdtTextFormPr(); formTextPr.put_MultiLine(true); complexForm.SetFormPr(formPr); complexForm.SetTextFormPr(formTextPr); @@ -527,7 +517,7 @@ ExecuteShortcut(c_oAscDocumentShortcutType.UnIndent); assert.strictEqual(GetDirectParaPr().GetIndLeft(), 0, "Check indent"); - const paragraph2 = CreateParagraphWithText('Hello'); + CreateParagraphWithText('Hello'); logicDocument.SelectAll(); @@ -610,7 +600,7 @@ QUnit.test('Check copy/paste format', (assert) => { - let paragraph = ClearDocumentAndAddParagraph('Hello'); + ClearDocumentAndAddParagraph('Hello'); ApplyTextPrToDocument({Bold: true, Italic: true, Underline: true}); GetDirectTextPr(); ExecuteShortcut(c_oAscDocumentShortcutType.CopyFormat); @@ -619,7 +609,7 @@ assert.true(textPr.Get_Italic(), 'Check copy italic format from paragraph'); assert.true(textPr.Get_Underline(), 'Check copy underline format from paragraph'); - paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); ExecuteShortcut(c_oAscDocumentShortcutType.PasteFormat); textPr = GetDirectTextPr(); assert.true(textPr.Get_Bold(), 'Check paste bold format from paragraph'); @@ -667,7 +657,7 @@ QUnit.test('Check update fields', (assert) => { - const paragraph = ClearDocumentAndAddParagraph('Hello'); + ClearDocumentAndAddParagraph('Hello'); const paragraph2 = CreateParagraphWithText('Hello'); const paragraph3 = CreateParagraphWithText('Hello'); @@ -725,7 +715,7 @@ assert.strictEqual(position[position.length - 1].Position, expected, description); } - const paragraph = ClearDocumentAndAddParagraph( + ClearDocumentAndAddParagraph( 'Hello World Hello ' + 'World Hello World ' + 'Hello World Hello ' + @@ -1018,7 +1008,7 @@ { TurnOnRecalculate(); TurnOnRecalculateCurPos(); - const paragraph = ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); + ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); AscTest.Recalculate(); GoToFooter(2); @@ -1059,7 +1049,7 @@ QUnit.test('Check reset actions shortcut', (assert) => { TurnOnRecalculate(); - const paragraph = ClearDocumentAndAddParagraph(""); + ClearDocumentAndAddParagraph(""); AscTest.Recalculate() editor.StartAddShape('rect'); ExecuteHotkey(testHotkeyActions.resetStartAddShape); @@ -1082,7 +1072,7 @@ QUnit.test('Check filling forms', (assert) => { - let paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); const checkBox = AddCheckBox(); AscTest.SetFillingFormMode(true); @@ -1094,7 +1084,7 @@ AscTest.SetEditingMode(); ClearDocumentAndAddParagraph(''); - const comboBox = AddComboBox(['Hello', 'World', 'yo']); + AddComboBox(['Hello', 'World', 'yo']); AscTest.SetFillingFormMode(true); ExecuteHotkey(testHotkeyActions.nextOptionComboBox); assert.strictEqual(logicDocument.GetSelectedText(), 'Hello', 'Check select next option in combobox'); @@ -1120,7 +1110,7 @@ QUnit.test('Check movement selecting forms', (assert) => { - const paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); let checkBox1 = AddCheckBox(); AscTest.MoveCursorRight(); let checkBox2 = AddCheckBox(); @@ -1172,7 +1162,7 @@ QUnit.test('Check select all in chart title', (assert) => { TurnOnRecalculate(); - const paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); AscTest.Recalculate(); TurnOffRecalculate(); const paraDrawing = AddChart(); @@ -1190,14 +1180,14 @@ QUnit.test('Check add new paragraph in content', (assert) => { - const paragraph = ClearDocumentAndAddParagraph('Hello text'); + ClearDocumentAndAddParagraph('Hello text'); ExecuteHotkey(testHotkeyActions.addNewParagraphContent); assert.strictEqual(logicDocument.Content.length, 2, 'Check add new paragraph'); }); QUnit.test('Check add new paragraph math', (assert) => { - const paragraph = ClearDocumentAndAddParagraph('Hello text'); + ClearDocumentAndAddParagraph('Hello text'); logicDocument.AddParaMath(); AscTest.EnterText('abcd'); AscTest.MoveCursorLeft(); @@ -1246,7 +1236,7 @@ QUnit.test("Check add break line to inlinelvlsdt", (assert) => { TurnOnRecalculate(); - const paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); const complexForm = AddComplexForm(); ExecuteHotkey(testHotkeyActions.addBreakLineInlineLvlSdt); assert.strictEqual(complexForm.Lines[0], 2, "Check add break line"); @@ -1256,7 +1246,7 @@ QUnit.test("Check visit hyperlink", (assert) => { TurnOnRecalculate() - const paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); AscTest.Recalculate() TurnOffRecalculate(); logicDocument.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Page)) @@ -1270,7 +1260,7 @@ QUnit.test("Check handle tab in math", (assert) => { - const paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); logicDocument.AddParaMath(); AscTest.EnterText('abcd+abcd+abcd'); logicDocument.MoveCursorToEndPos(); @@ -1294,7 +1284,7 @@ QUnit.test("Check end editing form", (assert) => { logicDocument.End_SilentMode(); - const paragraph = ClearDocumentAndAddParagraph(''); + ClearDocumentAndAddParagraph(''); const checkBox = AddCheckBox(); AscTest.SetFillingFormMode(true); checkBox.MoveCursorToContentControl(true); @@ -1307,7 +1297,7 @@ QUnit.test("Check replace unicode to char hotkeys", (assert) => { - const paragraph = ClearDocumentAndAddParagraph('2601'); + ClearDocumentAndAddParagraph('2601'); AscTest.MoveCursorLeft(true, true); ExecuteHotkey(testHotkeyActions.unicodeToChar, 0); assert.strictEqual(logicDocument.GetSelectedText(), '☁', 'Check replace unicode code to symbol'); @@ -1323,7 +1313,7 @@ QUnit.test("Check reset drag'n'drop", (oAssert) => { TurnOnRecalculate(); - const paragraph = ClearDocumentAndAddParagraph('Hello Hello'); + ClearDocumentAndAddParagraph('Hello Hello'); AscTest.Recalculate(); logicDocument.MoveCursorToStartPos(); AscTest.MoveCursorRight(true, true); From adea8e312faab32a5f7975bb26d6b938247f151a Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 3 Oct 2023 14:18:55 +0300 Subject: [PATCH 19/23] [se] Add show drop down tests --- tests/cell/shortcuts/events.js | 12 ++++++++---- tests/cell/shortcuts/shortcuts.js | 32 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tests/cell/shortcuts/events.js b/tests/cell/shortcuts/events.js index cfcc666f27..148788b353 100644 --- a/tests/cell/shortcuts/events.js +++ b/tests/cell/shortcuts/events.js @@ -535,7 +535,10 @@ contextMenu : 63, moveToLowerCell : 64, selectToLowerCell : 65, - selectToUpperCell : 66 + selectToUpperCell : 66, + showFilterOptions : 67, + showAutoComplete : 68, + showDataValidation : 69 }; const tableEvents = {}; @@ -741,9 +744,10 @@ new CNativeEvent(keyCodes.Equal, false, false, true, false), new CNativeEvent(keyCodes.Equal, true, false, true, false, testFlags.macOs) ]; - tableEvents[tableHotkeyTypes.contextMenu] = [ - new CNativeEvent(keyCodes.ContextMenu, false, false, false, false) - ]; + tableEvents[tableHotkeyTypes.contextMenu] = [new CNativeEvent(keyCodes.ContextMenu, false, false, false, false)]; + tableEvents[tableHotkeyTypes.showFilterOptions] = [new CNativeEvent(keyCodes.ArrowBottom, false, false, true, false)]; + tableEvents[tableHotkeyTypes.showAutoComplete] = [new CNativeEvent(keyCodes.ArrowBottom, false, false, true, false)]; + tableEvents[tableHotkeyTypes.showDataValidation] = [new CNativeEvent(keyCodes.ArrowBottom, false, false, true, false)]; const cellEditorHotkeyTypes = { closeWithoutSave : 0, diff --git a/tests/cell/shortcuts/shortcuts.js b/tests/cell/shortcuts/shortcuts.js index 740531faf3..b44af2e15e 100644 --- a/tests/cell/shortcuts/shortcuts.js +++ b/tests/cell/shortcuts/shortcuts.js @@ -1172,6 +1172,38 @@ QUnit.config.autostart = false; ResetData(0, 0, 49, 49); } }); + QUnit.test('Check drop down menu', (assert) => + { + let check = false; + const ShowAutoComplete = function () {check = true;}; + wbView.handlers.add("asc_onEntriesListMenu", ShowAutoComplete); + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.showAutoComplete); + assert.true(check); + wbView.handlers.remove("asc_onEntriesListMenu", ShowAutoComplete); + check = false; + + const props = ws.getDataValidationProps(); + props.setType(Asc.EDataValidationType.List); + props.setFormula1(new Asc.CDataFormula('"1"')); + ws.setDataValidationProps(props); + const ShowDataValidations = function () {check = true;}; + wbView.handlers.add("asc_onValidationListMenu", ShowDataValidations); + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.showDataValidation); + assert.true(check); + ws.deleteDataValidationById(props.Get_Id()); + wbView.handlers.remove("asc_onValidationListMenu", ShowDataValidations); + check = false; + + const SetAutoFiltersDialog = function () {check = true;}; + wbView.handlers.add("setAutoFiltersDialog", SetAutoFiltersDialog); + CreateTable(); + Select(0, 0, 0, 0, 0, 0); + ExecuteTableHotkey(tableHotkeyTypes.showFilterOptions); + assert.true(check); + wbView.handlers.remove("setAutoFiltersDialog", SetAutoFiltersDialog); + }); QUnit.test('Check cell movement', (assert) => { function CheckActiveCell(expectedRow, expectedColumn, description) From 296044c70f1f7667d3ea8439c8496daa56517350 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 3 Oct 2023 14:19:52 +0300 Subject: [PATCH 20/23] [se] Add tests for firefox keys --- tests/cell/shortcuts/events.js | 17 ++++++++++++----- tests/cell/shortcuts/shortcuts.js | 25 +++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/tests/cell/shortcuts/events.js b/tests/cell/shortcuts/events.js index 148788b353..df3c6a498e 100644 --- a/tests/cell/shortcuts/events.js +++ b/tests/cell/shortcuts/events.js @@ -108,6 +108,7 @@ Digit4 : 52, Digit5 : 53, Digit6 : 54, + SemicolonFirefox: 59, Delete : 46, EqualFirefox : 61, A : 65, @@ -136,6 +137,7 @@ F10 : 121, NumLock : 144, ScrollLock : 145, + MinusFirefox : 173, Semicolon : 186, Equal : 187, Comma : 188, @@ -454,7 +456,8 @@ ]; graphicEvents[graphicHotkeyTypes.enDash] = [ - new CNativeEvent(keyCodes.Minus, true, true, false, false) + new CNativeEvent(keyCodes.Minus, true, true, false, false), + new CNativeEvent(keyCodes.MinusFirefox, true, true, false, false), ]; graphicEvents[graphicHotkeyTypes.subscript] = [ @@ -564,10 +567,12 @@ new CNativeEvent(keyCodes.F2, false, false, false, false) ]; tableEvents[tableHotkeyTypes.addDate] = [ - new CNativeEvent(keyCodes.Semicolon, true, false, false, false) + new CNativeEvent(keyCodes.Semicolon, true, false, false, false), + new CNativeEvent(keyCodes.SemicolonFirefox, true, false, false, false), ]; tableEvents[tableHotkeyTypes.addTime] = [ - new CNativeEvent(keyCodes.Semicolon, true, true, false, false) + new CNativeEvent(keyCodes.Semicolon, true, true, false, false), + new CNativeEvent(keyCodes.SemicolonFirefox, true, true, false, false), ]; tableEvents[tableHotkeyTypes.removeActiveCell] = [ new CNativeEvent(keyCodes.BackSpace, false, false, false, false) @@ -942,10 +947,12 @@ new CNativeEvent(keyCodes.F4, false, false, false, false) ]; oCellEditorEvents[cellEditorHotkeyTypes.addTime] = [ - new CNativeEvent(keyCodes.Semicolon, true, true, false, false) + new CNativeEvent(keyCodes.Semicolon, true, true, false, false), + new CNativeEvent(keyCodes.SemicolonFirefox, true, true, false, false), ]; oCellEditorEvents[cellEditorHotkeyTypes.addDate] = [ - new CNativeEvent(keyCodes.Semicolon, true, false, false, false) + new CNativeEvent(keyCodes.Semicolon, true, false, false, false), + new CNativeEvent(keyCodes.SemicolonFirefox, true, false, false, false), ]; function ExecuteGraphicHotkey(type, eventIndex) diff --git a/tests/cell/shortcuts/shortcuts.js b/tests/cell/shortcuts/shortcuts.js index b44af2e15e..f03eda39e5 100644 --- a/tests/cell/shortcuts/shortcuts.js +++ b/tests/cell/shortcuts/shortcuts.js @@ -527,18 +527,28 @@ QUnit.config.autostart = false; ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addDate); CloseCellEditor(true); assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getDateString(editor), 'Check add date'); + EnterText(''); + + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addTime, 1); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getTimeString(editor).split(' ').join(':00 '), 'Check add time'); + EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addDate, 1); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getDateString(editor), 'Check add date'); EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addSeparator); CloseCellEditor(true); assert.strictEqual(GetCellText(0, 0), '.', 'Check add separator'); - EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addSpace); CloseCellEditor(true); assert.strictEqual(GetCellText(0, 0), ' ', 'Check add space'); - EnterText(''); + ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); assert.strictEqual(cellEditor.textRender.getLinesCount(), 2, 'Check add new line'); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); @@ -1060,6 +1070,9 @@ QUnit.config.autostart = false; const {paragraph} = ClearShapeAndAddParagraph(''); ExecuteGraphicHotkey(graphicHotkeyTypes.enDash); assert.strictEqual(GetParagraphText(paragraph), String.fromCharCode(0x2013), 'Check add en dash'); + + ExecuteGraphicHotkey(graphicHotkeyTypes.enDash, 1); + assert.strictEqual(GetParagraphText(paragraph), String.fromCharCode(0x2013, 0x2013), 'Check add en dash'); }); QUnit.test('Check select all', (assert) => @@ -1471,6 +1484,14 @@ QUnit.config.autostart = false; ExecuteTableHotkey(tableHotkeyTypes.addTime); CloseCellEditor(true); assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getTimeString(editor).split(' ').join(':00 '), 'Check add time'); + + ExecuteTableHotkey(tableHotkeyTypes.addDate, 1); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getDateString(editor), 'Check add date'); + + ExecuteTableHotkey(tableHotkeyTypes.addTime, 1); + CloseCellEditor(true); + assert.strictEqual(GetCellText(0, 0), (new Asc.cDate()).getTimeString(editor).split(' ').join(':00 '), 'Check add time'); ExecuteTableHotkey(tableHotkeyTypes.addSeparator); CloseCellEditor(true); From 90ca2ce76dc5761eb0d216cd991330d3332bcc83 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Tue, 3 Oct 2023 16:07:28 +0300 Subject: [PATCH 21/23] [de] Add more tests for movement between headers/footer --- tests/word/shortcuts/shortcuts.js | 43 ++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 9ade2eacfe..89f490a6fd 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -82,6 +82,7 @@ drawingDocument.OnRePaintAttack = function() {}; drawingDocument.ConvertCoordsToCursorWR = function(X, Y) {return {X: X, Y: Y}}; drawingDocument.OnUpdateOverlay = function() {}; + drawingDocument.Set_RulerState_HdrFtr = function() {}; editor.retrieveFormatPainterData = Asc.asc_docs_api.prototype.retrieveFormatPainterData.bind(editor); editor.get_ShowParaMarks = Asc.asc_docs_api.prototype.get_ShowParaMarks.bind(editor); @@ -136,16 +137,27 @@ }, 0); }; - function GoToHeader(page) + function GoToHeaderFooter(page, isHeader) { logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); - logicDocument.Create_SectionHdrFtr( AscCommon.hdrftr_Header, page ); + const mouseEvent = new AscCommon.CMouseEventHandler(); + mouseEvent.Button = 0; + mouseEvent.ClickCount = 1; + + logicDocument.OnMouseDown(mouseEvent, 0, isHeader ? 0 : pageHeight, page); + logicDocument.OnMouseUp(mouseEvent, 0, isHeader ? 0 : pageHeight, page); + logicDocument.OnMouseMove(mouseEvent, 0, 0, page); + logicDocument.MoveCursorLeft(); } - function GoToFooter(page) + function RemoveHeader(page) { - logicDocument.SetDocPosType(AscCommonWord.docpostype_HdrFtr); - logicDocument.Create_SectionHdrFtr( AscCommon.hdrftr_Footer, page ); + logicDocument.RemoveHdrFtr(page, true); + } + + function RemoveFooter(page) + { + logicDocument.RemoveHdrFtr(page, false); } function ClearDocumentAndAddParagraph(text) @@ -1011,37 +1023,50 @@ ClearDocumentAndAddParagraph("Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"); AscTest.Recalculate(); - GoToFooter(2); - GoToHeader(2); - + GoToHeaderFooter(2); + GoToHeaderFooter(2, true); ExecuteHotkey(testHotkeyActions.moveToPreviousHeaderFooter); + assert.strictEqual(logicDocument.Get_CurPage(), 1, 'Check current page'); + assert.true(!!logicDocument.Controller.HdrFtr.Pages[1].Footer, 'Footer exists'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer, 'Check move to previous footer'); ExecuteHotkey(testHotkeyActions.moveToPreviousHeaderFooter); + assert.strictEqual(logicDocument.Get_CurPage(), 1, 'Check current page'); + assert.true(!!logicDocument.Controller.HdrFtr.Pages[1].Header, 'Header exists'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header, 'Check move to previous header'); ExecuteHotkey(testHotkeyActions.moveToNextHeaderFooter); + assert.strictEqual(logicDocument.Get_CurPage(), 1, 'Check current page'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Footer, 'Check move to next footer'); ExecuteHotkey(testHotkeyActions.moveToNextHeaderFooter); + assert.strictEqual(logicDocument.Get_CurPage(), 2, 'Check current page'); + assert.true(!!logicDocument.Controller.HdrFtr.Pages[2].Header, 'Header exists'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header, 'Check move to next header'); ExecuteHotkey(testHotkeyActions.moveToPreviousHeader, 0); + assert.strictEqual(logicDocument.Get_CurPage(), 1, 'Check current page'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header, 'Check move to previous header'); ExecuteHotkey(testHotkeyActions.moveToPreviousHeader, 1); + assert.strictEqual(logicDocument.Get_CurPage(), 0, 'Check current page'); + assert.true(!!logicDocument.Controller.HdrFtr.Pages[0].Header, 'Header exists'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[0].Header, 'Check move to previous header'); ExecuteHotkey(testHotkeyActions.moveToNextHeader, 0); + assert.strictEqual(logicDocument.Get_CurPage(), 1, 'Check current page'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[1].Header, 'Check move to next header'); ExecuteHotkey(testHotkeyActions.moveToNextHeader, 1); + assert.strictEqual(logicDocument.Get_CurPage(), 2, 'Check current page'); assert.true(logicDocument.Controller.HdrFtr.CurHdrFtr === logicDocument.Controller.HdrFtr.Pages[2].Header, 'Check move to next header'); ExecuteHotkey(testHotkeyActions.endEditing); assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Check end editing footer"); - GoToFooter(0); + GoToHeaderFooter(0); ExecuteHotkey(testHotkeyActions.endEditing); assert.strictEqual(logicDocument.GetDocPosType(), AscCommonWord.docpostype_Content, "Check end editing footer"); + RemoveHeader(0); + RemoveFooter(0); TurnOffRecalculateCurPos(); TurnOffRecalculate(); }); From 8ca76137567239c4e5053a50e0491e74832945d9 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Fri, 13 Oct 2023 15:07:03 +0300 Subject: [PATCH 22/23] [se] Remove "add space" test --- tests/cell/shortcuts/events.js | 4 ---- tests/cell/shortcuts/shortcuts.js | 5 ----- 2 files changed, 9 deletions(-) diff --git a/tests/cell/shortcuts/events.js b/tests/cell/shortcuts/events.js index df3c6a498e..0a84238d6a 100644 --- a/tests/cell/shortcuts/events.js +++ b/tests/cell/shortcuts/events.js @@ -763,7 +763,6 @@ saveAndMoveLeft : 5, removeCharBack : 6, removeWordBack : 7, - addSpace : 8, moveToEndLine : 9, moveToEndDocument : 10, selectToEndLine : 11, @@ -829,9 +828,6 @@ new CNativeEvent(keyCodes.BackSpace, true, false, false, false), new CNativeEvent(keyCodes.BackSpace, false, false, true, false, testFlags.macOs), ]; - oCellEditorEvents[cellEditorHotkeyTypes.addSpace] = [ - new CNativeEvent(keyCodes.Space, true, false, false, false) - ]; oCellEditorEvents[cellEditorHotkeyTypes.moveToEndLine] = [ new CNativeEvent(keyCodes.End, false, false, false, false), new CNativeEvent(keyCodes.ArrowRight, false, false, false, true, testFlags.macOs), diff --git a/tests/cell/shortcuts/shortcuts.js b/tests/cell/shortcuts/shortcuts.js index f03eda39e5..fa5e945ea2 100644 --- a/tests/cell/shortcuts/shortcuts.js +++ b/tests/cell/shortcuts/shortcuts.js @@ -544,11 +544,6 @@ QUnit.config.autostart = false; assert.strictEqual(GetCellText(0, 0), '.', 'Check add separator'); EnterText(''); - ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addSpace); - CloseCellEditor(true); - assert.strictEqual(GetCellText(0, 0), ' ', 'Check add space'); - EnterText(''); - ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); assert.strictEqual(cellEditor.textRender.getLinesCount(), 2, 'Check add new line'); ExecuteCellEditorHotkey(cellEditorHotkeyTypes.addNewLine); From 1b46beb46f1f8d1d1a5f59cf819094ad5ce848df Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Thu, 19 Oct 2023 13:35:43 +0300 Subject: [PATCH 23/23] Fix typo --- tests/word/shortcuts/shortcuts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/word/shortcuts/shortcuts.js b/tests/word/shortcuts/shortcuts.js index 89f490a6fd..88b60479ca 100644 --- a/tests/word/shortcuts/shortcuts.js +++ b/tests/word/shortcuts/shortcuts.js @@ -838,7 +838,7 @@ ExecuteHotkey(testHotkeyActions.selectToStartLine, 1); CheckSelectedText('Hello World Hello ', 'Select to start line content'); - ExecuteHotkey(testHotkeyActions.checkSelectCursorRight); + ExecuteHotkey(testHotkeyActions.selectRightChar); CheckSelectedText('Hello World Hello W', 'Select to right char'); ExecuteHotkey(testHotkeyActions.selectLeftChar);