17460160b801b4230f20722efbafcac347312e702Mathias Agopian# Copyright (C) 2013 Google Inc. All rights reserved. 27460160b801b4230f20722efbafcac347312e702Mathias Agopian# 37460160b801b4230f20722efbafcac347312e702Mathias Agopian# Redistribution and use in source and binary forms, with or without 47460160b801b4230f20722efbafcac347312e702Mathias Agopian# modification, are permitted provided that the following conditions are 57460160b801b4230f20722efbafcac347312e702Mathias Agopian# met: 67460160b801b4230f20722efbafcac347312e702Mathias Agopian# 77460160b801b4230f20722efbafcac347312e702Mathias Agopian# * Redistributions of source code must retain the above copyright 87460160b801b4230f20722efbafcac347312e702Mathias Agopian# notice, this list of conditions and the following disclaimer. 97460160b801b4230f20722efbafcac347312e702Mathias Agopian# * Redistributions in binary form must reproduce the above 107460160b801b4230f20722efbafcac347312e702Mathias Agopian# copyright notice, this list of conditions and the following disclaimer 117460160b801b4230f20722efbafcac347312e702Mathias Agopian# in the documentation and/or other materials provided with the 127460160b801b4230f20722efbafcac347312e702Mathias Agopian# distribution. 137460160b801b4230f20722efbafcac347312e702Mathias Agopian# * Neither the name of Google Inc. nor the names of its 147460160b801b4230f20722efbafcac347312e702Mathias Agopian# contributors may be used to endorse or promote products derived from 157460160b801b4230f20722efbafcac347312e702Mathias Agopian# this software without specific prior written permission. 167460160b801b4230f20722efbafcac347312e702Mathias Agopian# 177460160b801b4230f20722efbafcac347312e702Mathias Agopian# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 187460160b801b4230f20722efbafcac347312e702Mathias Agopian# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 197460160b801b4230f20722efbafcac347312e702Mathias Agopian# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 207460160b801b4230f20722efbafcac347312e702Mathias Agopian# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 217460160b801b4230f20722efbafcac347312e702Mathias Agopian# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 227460160b801b4230f20722efbafcac347312e702Mathias Agopian# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 237460160b801b4230f20722efbafcac347312e702Mathias Agopian# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 247460160b801b4230f20722efbafcac347312e702Mathias Agopian# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 253330b203039dea366d4981db1408a460134b2d2cMathias Agopian# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 263330b203039dea366d4981db1408a460134b2d2cMathias Agopian# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 277460160b801b4230f20722efbafcac347312e702Mathias Agopian# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 287460160b801b4230f20722efbafcac347312e702Mathias Agopian 297460160b801b4230f20722efbafcac347312e702Mathias Agopianimport unittest 307460160b801b4230f20722efbafcac347312e702Mathias Agopian 317460160b801b4230f20722efbafcac347312e702Mathias Agopianfrom webkitpy.common.host_mock import MockHost 327460160b801b4230f20722efbafcac347312e702Mathias Agopianfrom webkitpy.layout_tests.print_layout_test_types import main 337460160b801b4230f20722efbafcac347312e702Mathias Agopian 347460160b801b4230f20722efbafcac347312e702Mathias Agopian 357460160b801b4230f20722efbafcac347312e702Mathias Agopianclass PrintLayoutTestTimesTest(unittest.TestCase): 367460160b801b4230f20722efbafcac347312e702Mathias Agopian 377460160b801b4230f20722efbafcac347312e702Mathias Agopian def check(self, args, expected_output, files=None): 387460160b801b4230f20722efbafcac347312e702Mathias Agopian host = MockHost() 397460160b801b4230f20722efbafcac347312e702Mathias Agopian files = files or {} 407460160b801b4230f20722efbafcac347312e702Mathias Agopian for path, contents in files.items(): 417460160b801b4230f20722efbafcac347312e702Mathias Agopian host.filesystem.write_binary_file(path, contents) 427460160b801b4230f20722efbafcac347312e702Mathias Agopian orig_get = host.port_factory.get 437460160b801b4230f20722efbafcac347312e702Mathias Agopian host.port_factory.get = lambda *args, **kwargs: orig_get('test') 447460160b801b4230f20722efbafcac347312e702Mathias Agopian main(host, args) 457460160b801b4230f20722efbafcac347312e702Mathias Agopian self.assertEqual(host.stdout.getvalue(), expected_output) 467460160b801b4230f20722efbafcac347312e702Mathias Agopian 477460160b801b4230f20722efbafcac347312e702Mathias Agopian def test_test_list(self): 487460160b801b4230f20722efbafcac347312e702Mathias Agopian files = {'/tmp/test_list': 'passes/image.html'} 493330b203039dea366d4981db1408a460134b2d2cMathias Agopian self.check(['--test-list', '/tmp/test_list'], 'passes/image.html pixel\n', files=files) 507460160b801b4230f20722efbafcac347312e702Mathias Agopian 517460160b801b4230f20722efbafcac347312e702Mathias Agopian def test_type(self): 527460160b801b4230f20722efbafcac347312e702Mathias Agopian self.check(['--type', 'audio', 'passes'], 'passes/audio.html\n') 537460160b801b4230f20722efbafcac347312e702Mathias Agopian 547460160b801b4230f20722efbafcac347312e702Mathias Agopian def test_basic(self): 557460160b801b4230f20722efbafcac347312e702Mathias Agopian self.check(['failures/unexpected/missing_image.html', 'passes/image.html', 'passes/audio.html', 'passes/reftest.html'], 567460160b801b4230f20722efbafcac347312e702Mathias Agopian 'failures/unexpected/missing_image.html text\n' 577460160b801b4230f20722efbafcac347312e702Mathias Agopian 'passes/image.html pixel\n' 587460160b801b4230f20722efbafcac347312e702Mathias Agopian 'passes/audio.html audio\n' 597460160b801b4230f20722efbafcac347312e702Mathias Agopian 'passes/reftest.html ref\n') 603330b203039dea366d4981db1408a460134b2d2cMathias Agopian