pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/DelphiCodeCoverage/DelphiCodeCoverage/pull/51/files

ithub.githubassets.com/assets/code-34e10031edc15af1.css" /> Fix compilation for Delphi XE6 by GuilhermeAlecrim7K · Pull Request #51 · DelphiCodeCoverage/DelphiCodeCoverage · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 42 additions & 26 deletions Source/HTMLCoverageReport.pas
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ THTMLCoverageReport = class(TInterfacedObject, IReport)

function PrettyPercentage(nbItems, nbTotal : Integer) : String;

function HtmlEncode(const AStr: string) : String;
public
constructor Create(const ACoverageConfiguration: ICoverageConfiguration);

Expand All @@ -90,9 +91,24 @@ implementation

uses
System.SysUtils,
{$IF CompilerVersion >= 28.0}
System.NetEncoding,
{$ENDIF}
JclFileUtils;

function THTMLCoverageReport.HtmlEncode(const AStr: string) : String;
begin
{$IF CompilerVersion >= 28.0}
Result := TNetEncoding.HTML.Encode(AStr);
{$ELSE}
Result := StringReplace(AStr, '&', '&', [rfReplaceAll]);
Result := StringReplace(Result, '<', '&lt;', [rfReplaceAll]);
Result := StringReplace(Result, '>', '&gt;', [rfReplaceAll]);
Result := StringReplace(Result, '"', '&quot;', [rfReplaceAll]);
Result := StringReplace(Result, '''', '&#39;', [rfReplaceAll]);
{$ENDIF}
end;

procedure THTMLCoverageReport.Generate(
const ACoverage: ICoverageStats;
const AModuleInfoList: TModuleList;
Expand Down Expand Up @@ -472,7 +488,7 @@ procedure THTMLCoverageReport.AddTableFooter(
AOutputFile.WriteLine(
'<tfoot>'
+ '<tr>'
+ '<th>' + TNetEncoding.HTML.Encode(AHeading)
+ '<th>' + HtmlEncode(AHeading)
+ '<th>' + IntToStr(coveredLineCount)
+ '<th>' + IntToStr(lineCount - coveredLineCount)
+ '<th>' + IntToStr(lineCount)
Expand All @@ -487,11 +503,11 @@ procedure THTMLCoverageReport.AddTableHeader(
const AOutputFile: TTextWriter);
begin
AOutputFile.WriteLine(
'<p>' + TNetEncoding.HTML.Encode(ATableHeading) + '</p>'
'<p>' + HtmlEncode(ATableHeading) + '</p>'
+ '<table class="' + SummaryClass + '">'
+ '<thead>'
+ '<tr>'
+ '<th rowspan=2 idx=0>' + TNetEncoding.HTML.Encode(AColumnHeading)
+ '<th rowspan=2 idx=0>' + HtmlEncode(AColumnHeading)
+ '<th colspan=3 idx=3>Number of lines'
+ '<th rowspan=2 idx=4>Percent(s) covered'
+ '<tr>'
Expand Down Expand Up @@ -607,7 +623,7 @@ procedure THTMLCoverageReport.GenerateCoverageTable(
while AInputFile.Peek <> -1 do
begin
InputLine := AInputFile.ReadLine;
InputLine := TNetEncoding.HTML.Encode(TrimRight(InputLine));
InputLine := HtmlEncode(TrimRight(InputLine));
LineCoverage := ACoverageModule.CoverageLine[LineCoverageIter];
if (LineCount = LineCoverage.LineNumber) then
begin
Expand All @@ -628,7 +644,7 @@ procedure THTMLCoverageReport.GenerateCoverageTable(
AOutputFile.WriteLine(
'<script>(function () {'#10 +
'var starts = [],' +
'prev = document.getElementById("nav-prev"),' +
'prev = document.getElementById("nav-prev"),' +
'next = document.getElementById("nav-next");'#10 +
'(function () {'#10 +
'var p;'#10 +
Expand All @@ -639,31 +655,31 @@ procedure THTMLCoverageReport.GenerateCoverageTable(
'} else { p = null }'#10 +
'})'#10 +
'})();'#10 +
'function findPrev() {'#10 +
'var y = prev.getBoundingClientRect().top - 4;'#10 +
'for (var i=starts.length-1; i>=0; i--) {'#10 +
'if (starts[i].getBoundingClientRect().top < y) return starts[i]'#10 +
'}'#10 +
'}'#10 +
'function findNext() {'#10 +
'var y = next.getBoundingClientRect().top + 4;'#10 +
'for (var i=0; i<starts.length; i++) {'#10 +
'function findPrev() {'#10 +
'var y = prev.getBoundingClientRect().top - 4;'#10 +
'for (var i=starts.length-1; i>=0; i--) {'#10 +
'if (starts[i].getBoundingClientRect().top < y) return starts[i]'#10 +
'}'#10 +
'}'#10 +
'function findNext() {'#10 +
'var y = next.getBoundingClientRect().top + 4;'#10 +
'for (var i=0; i<starts.length; i++) {'#10 +
'if (starts[i].getBoundingClientRect().top > y) return starts[i];'#10 +
'}'#10 +
'}'#10 +
'function onScroll() {'#10 +
'prev.setAttribute("class", findPrev() ? "active" : "");'#10 +
'next.setAttribute("class", findNext() ? "active" : "");'#10 +
'onScroll.pending = 0;'#10 +
'}'#10 +
'document.addEventListener("scroll", function() {'#10 +
'if (!onScroll.pending) { onScroll.pending = requestAnimationFrame(onScroll) }'#10 +
'});'#10 +
'}'#10 +
'}'#10 +
'function onScroll() {'#10 +
'prev.setAttribute("class", findPrev() ? "active" : "");'#10 +
'next.setAttribute("class", findNext() ? "active" : "");'#10 +
'onScroll.pending = 0;'#10 +
'}'#10 +
'document.addEventListener("scroll", function() {'#10 +
'if (!onScroll.pending) { onScroll.pending = requestAnimationFrame(onScroll) }'#10 +
'});'#10 +
'onScroll();'#10 +
'function scrollTo(row) {'#10 +
'if (row) window.scrollTo({ behavior: "smooth", top: window.scrollY+row.getBoundingClientRect().top-prev.getBoundingClientRect().top });'#10 +
'}'#10 +
'next.addEventListener("click", () => scrollTo(findNext()) );'#10 +
'}'#10 +
'next.addEventListener("click", () => scrollTo(findNext()) );'#10 +
'prev.addEventListener("click", () => scrollTo(findPrev()) );'#10 +
'})();</script>'
);
Expand Down
8 changes: 4 additions & 4 deletions Test/CoverageConfigurationTest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1518,13 +1518,13 @@ procedure TCoverageConfigurationTest.TestMixIncludeExcludeSourceMask;
LCmdParams : array of string;
LCoverageConfiguration : ICoverageConfiguration;
I : Integer;
LINCLUDE_EXCLUDE_FILES_PREFIX: string;
begin
const cINCLUDE_EXCLUDE_FILES_PREFIX = cINCLUDE_FILES_PREFIX + cEXCLUDE_FILES_PREFIX;

LINCLUDE_EXCLUDE_FILES_PREFIX := cINCLUDE_FILES_PREFIX + cEXCLUDE_FILES_PREFIX;
LNumOfFiles := Random(20) + 10;
SetLength(LCmdParams, LNumOfFiles + 5);
LCmdParams[0] := '-esm';
LCmdParams[1] := cINCLUDE_EXCLUDE_FILES_PREFIX + '*';
LCmdParams[1] := LINCLUDE_EXCLUDE_FILES_PREFIX + '*';
LCmdParams[2] := '-ism';
LCmdParams[3] := cINCLUDE_FILES_PREFIX + '*';
LCmdParams[4] := '-u';
Expand All @@ -1549,7 +1549,7 @@ procedure TCoverageConfigurationTest.TestMixIncludeExcludeSourceMask;
LCoverageConfiguration.ParseCommandLine;
for I := 0 to Pred(LTotalUnitList.Count) do
if ((LeftStr(LTotalUnitList[I], Length(cINCLUDE_FILES_PREFIX)) = cINCLUDE_FILES_PREFIX)
and not (LeftStr(LTotalUnitList[I], Length(cINCLUDE_EXCLUDE_FILES_PREFIX)) = cINCLUDE_EXCLUDE_FILES_PREFIX)) then
and not (LeftStr(LTotalUnitList[I], Length(LINCLUDE_EXCLUDE_FILES_PREFIX)) = LINCLUDE_EXCLUDE_FILES_PREFIX)) then
CheckNotEquals(-1, LCoverageConfiguration.Units.IndexOf(LTotalUnitList[I]), 'Missing included unit')
else
CheckEquals(-1, LCoverageConfiguration.Units.IndexOf(LTotalUnitList[I]), 'Unit should have been excluded');
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy