// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. /** * A pipeline task to create a HTML/CSS wrapper for a test so it can run in DRT. */ class HtmlWrapTask extends PipelineTask { final String _testFileTemplate; final String _htmlSourceFileTemplate; final String _htmlDestFileTemplate; final String _cssSourceFileTemplate; final String _cssDestFileTemplate; HtmlWrapTask(this._testFileTemplate, this._htmlSourceFileTemplate, this._htmlDestFileTemplate, this._cssSourceFileTemplate, this._cssDestFileTemplate); execute(Path testfile, List stdout, List stderr, bool logging, Function exitHandler) { var testname = expandMacros(_testFileTemplate, testfile); // If the test already has a corresponding HTML file we copy that, // else we create a new wrapper. var htmlSourceName = expandMacros(_htmlSourceFileTemplate, testfile); var htmlDestName = expandMacros(_htmlDestFileTemplate, testfile); var cssSourceName = expandMacros(_cssSourceFileTemplate, testfile); var cssDestName = expandMacros(_cssDestFileTemplate, testfile); var htmlMaster = new File(htmlSourceName); if (htmlMaster.existsSync()) { if (logging) { stdout.add('Copying $htmlSourceName to $htmlDestName'); } copyFile(htmlSourceName, htmlDestName); } else { if (logging) { stdout.add('Creating wrapper $htmlDestName'); } var p = new Path(testname); var runtime = config.runtime; var startDart = ''; if (runtime == 'drt-dart') { startDart = "if (navigator.webkitStartDart) navigator.webkitStartDart();"; } var prefix = flattenPath(p.directoryPath.toString()); var suffix = (config.layoutPixel || config.layoutText) ? '-child': ''; var scriptElement; if (runtime == 'drt-dart') { scriptElement = "
$bodyElements $scriptElement