![JAR search and dependency download from the Maven repository](/logo.png)
gwen.report.HtmlSlideshowFormatter.scala Maven / Gradle / Ivy
/*
* Copyright 2014-2015 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gwen.report
import java.io.File
import gwen.GwenInfo
import gwen.GwenSettings
import gwen.eval.FeatureResult
import gwen.eval.FeatureSummary
import gwen.eval.GwenOptions
import gwen.report.ReportFormat.value2ReportFormat
import gwen.eval.FeatureUnit
/** Formats the slideshow. */
trait HtmlSlideshowFormatter extends ReportFormatter {
/**
* Formats the feature detail report as HTML.
*
* @param options gwen command line options
* @param info the gwen implementation info
* @param unit the feature input
* @param result the feature result to report
* @param breadcrumbs names and references for linking back to parent reports
* @param reportFiles the target report files (head = detail, tail = metas)
*/
override def formatDetail(options: GwenOptions, info: GwenInfo, unit: FeatureUnit, result: FeatureResult, breadcrumbs: List[(String, File)], reportFiles: List[File]): Option[String] = {
val screenshots = result.screenshots
if (screenshots.isEmpty || result.isMeta) None
else {
val reportDir = ReportFormat.slideshow.reportDir(options)
val featureName = result.spec.featureFile.map(_.getPath()).getOrElse(result.spec.feature.name)
val rootPath = relativePath(reportFiles.head, reportDir).filter(_ == File.separatorChar).flatMap(_ => "../")
val summaryCrumb = ("Summary", new File(s"$rootPath/html", "feature-summary.html"))
val featureCrumb = ("Feature", ReportFormat.html.createReportFile(ReportFormat.html.createReportDir(options, result.spec, unit.dataRecord), "", result.spec, unit.dataRecord))
Some(s"""
${formatHtmlHead(s"Slideshow - ${featureName}", rootPath)}
${formatJsHeader(rootPath)}
${HtmlReportFormatter.formatReportHeader(info, "Feature Slideshow", featureName, rootPath)}
${HtmlReportFormatter.formatStatusHeader(unit, result, rootPath, List(summaryCrumb, featureCrumb), Nil)}
${HtmlSlideshowFormatter.formatSlideshow(screenshots, rootPath)}
""")
}
}
/**
* Not used by this implementation.
*
* @param options gwen command line options
* @param info the gwen implementation info
* @param summary the accumulated feature results summary
*/
override def formatSummary(options: GwenOptions, info: GwenInfo, summary: FeatureSummary): Option[String] = None
private def formatJsHeader(rootPath: String) = s"""
"""
private def formatHtmlHead(title: String, rootPath: String) = s"""
${title}
"""
}
object HtmlSlideshowFormatter {
private def maxFramesPerSec(screenshots: List[File]) = if (screenshots.length < 10) screenshots.length else 10
private[report] def formatSlideshow(screenshots: List[File], rootPath: String) = s"""
"""
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy