[de] Add color tests for ApiRun/ApiParagraph/ApiInlineLevelSdt

This commit is contained in:
Ilya Kirillov
2025-09-23 15:31:06 +03:00
parent 4412d3a17d
commit 6bae7d957a
10 changed files with 277 additions and 15 deletions

View File

@ -81,7 +81,7 @@ const allTests = [
'word/merge-documents/mergeDocuments.html',
'word/math-autocorrection/math-autocorrection.html',
'word/change-case/change-case.html',
'word/builder/api/replace-text-smart.html',
'word/js-api/js-api.html',
'cell/shortcuts/shortcuts.html',
'slide/shortcuts/shortcuts.html',

View File

@ -109,16 +109,41 @@ var AscTest = AscTest || {};
if (QUnit && !QUnit.assert.close)
{
QUnit.assert.close = function(number, expected, maxDifference, message)
if (!QUnit.assert.close)
{
if (undefined === maxDifference || null === maxDifference || 0 === maxDifference)
maxDifference = 0.00001;
QUnit.assert.pushResult({
result : Math.abs(number - expected) < maxDifference,
actual : number,
expected : expected,
message : message
});
QUnit.assert.close = function(number, expected, maxDifference, message)
{
if (undefined === maxDifference || null === maxDifference || 0 === maxDifference)
maxDifference = 0.00001;
QUnit.assert.pushResult({
result : Math.abs(number - expected) < maxDifference,
actual : number,
expected : expected,
message : message
});
}
}
if (!QUnit.assert.equalRgb)
{
QUnit.assert.equalRgb = function(actualRgb, expectedRgb, message)
{
QUnit.assert.strictEqual(actualRgb.r, expectedRgb.r, (message ? message : "") + " check r component");
QUnit.assert.strictEqual(actualRgb.g, expectedRgb.g, (message ? message : "") + " check g component");
QUnit.assert.strictEqual(actualRgb.b, expectedRgb.b, (message ? message : "") + " check b component");
};
}
if (!QUnit.assert.equalRgba)
{
QUnit.assert.equalRgba = function(actualRgba, expectedRgba, message)
{
QUnit.assert.strictEqual(actualRgba.r, expectedRgba.r, (message ? message : "") + " check r component");
QUnit.assert.strictEqual(actualRgba.g, expectedRgba.g, (message ? message : "") + " check g component");
QUnit.assert.strictEqual(actualRgba.b, expectedRgba.b, (message ? message : "") + " check b component");
QUnit.assert.strictEqual(actualRgba.a, expectedRgba.a, (message ? message : "") + " check a component");
};
}
}

View File

@ -0,0 +1,51 @@
/*
* (c) Copyright Ascensio System SIA 2010-2025
*
* 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-6 Ernesta Birznieka-Upish
* 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 ()
{
QUnit.module("Test the ApiInlineLevelSdt methods");
function createApiInlineCC()
{
return AscTest.Editor.CreateInlineLvlSdt();
}
QUnit.test("Color", function (assert)
{
let apiInlineCC = createApiInlineCC();
assert.strictEqual(apiInlineCC.GetBorderColor(), null, "Color border color for a newly created paragraph");
apiInlineCC.SetBorderColor(255, 122, 100, 255);
assert.equalRgba(apiInlineCC.GetBorderColor(), {r : 255, g : 122, b : 100, a : 255}, "Check border color");
});
});

View File

@ -0,0 +1,51 @@
/*
* (c) Copyright Ascensio System SIA 2010-2025
*
* 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-6 Ernesta Birznieka-Upish
* 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 ()
{
QUnit.module("Test the ApiParagraph methods");
function createApiParagraph()
{
return AscTest.Editor.CreateParagraph();
}
QUnit.test("Color", function (assert)
{
let apiParagraph = createApiParagraph();
assert.strictEqual(apiParagraph.GetShd(), null, "Color check for a newly created paragraph");
apiParagraph.SetShd("clear", 255, 122, 100);
//assert.equalRgb(apiParagraph.GetShd(), {r : 255, g : 122, b : 100}, "Check shd color");
});
});

View File

@ -0,0 +1,51 @@
/*
* (c) Copyright Ascensio System SIA 2010-2025
*
* 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-6 Ernesta Birznieka-Upish
* 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 ()
{
QUnit.module("Test the ApiRun methods");
function createApiRun()
{
return AscTest.Editor.CreateRun();
}
QUnit.test("Color", function (assert)
{
let apiRun = createApiRun();
assert.strictEqual(apiRun.GetColor(), null, "Color check for a newly created run");
apiRun.SetColor(255, 0, 0);
//assert.equalRgb(apiRun.GetColor(), {r : 255, g : 0, b : 0}, "Color check for a newly created run");
});
});

View File

@ -32,9 +32,6 @@
$(function ()
{
AscTest.Editor.GetDocument = AscCommon.DocumentEditorApi.prototype.GetDocument.bind(AscTest.Editor);
AscTest.Editor.ReplaceTextSmart = AscCommon.DocumentEditorApi.prototype.ReplaceTextSmart.bind(AscTest.Editor);
function GetParagraphRunsInfo(paragraph)
{
let result = [];

View File

@ -0,0 +1,46 @@
/*
* (c) Copyright Ascensio System SIA 2010-2025
*
* 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-6 Ernesta Birznieka-Upish
* 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()
{
AscTest.Editor.GetDocument = AscCommon.DocumentEditorApi.prototype.GetDocument.bind(AscTest.Editor);
AscTest.Editor.ReplaceTextSmart = AscCommon.DocumentEditorApi.prototype.ReplaceTextSmart.bind(AscTest.Editor);
AscTest.Editor.CreateRun = AscCommon.DocumentEditorApi.prototype.CreateRun.bind(AscTest.Editor);
AscTest.Editor.CreateParagraph = AscCommon.DocumentEditorApi.prototype.CreateParagraph.bind(AscTest.Editor);
AscTest.Editor.CreateInlineLvlSdt = AscCommon.DocumentEditorApi.prototype.CreateInlineLvlSdt.bind(AscTest.Editor);
QUnit.testStart(function()
{
AscCommon.History.Clear();
AscTest.ClearDocument();
});
});

View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Test the paragraph review</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/qunit/2.16.0/qunit.css" rel="stylesheet" media="screen"/>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/qunit/2.16.0/qunit.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xregexp/3.2.0/xregexp-all.min.js"></script>
<script type="text/javascript" src="../../../develop/sdkjs/word/scripts.js"></script>
<script type="text/javascript">
window.sdk_scripts.forEach(function(item)
{
document.write('<script type="text/javascript" src="' + item + '"><\/script>');
});
</script>
<script type="text/javascript" src="../common/common.js"></script>
<script type="text/javascript" src="../common/editor.js"></script>
<script type="text/javascript" src="../common/document.js"></script>
<script type="text/javascript" src="../common/measurer.js"></script>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="api/replace-text-smart.js"></script>
<script type="text/javascript" src="api-inline-level-sdt.js"></script>
<script type="text/javascript" src="api-paragraph.js"></script>
<script type="text/javascript" src="api-run.js"></script>
</head>
<body>
<h1 id="qunit-header">Test document js-api</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>