Rename WebKitTools to Tools
[WebKit-https.git] / Tools / Scripts / webkitpy / layout_tests / port / chromium_gpu_unittest.py
1 #!/usr/bin/env python
2 # Copyright (C) 2010 Google Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 #     * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 #     * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 import os
28 import unittest
29
30 from webkitpy.tool import mocktool
31 import chromium_gpu
32
33
34 class ChromiumGpuTest(unittest.TestCase):
35     def test_get_chromium_gpu_linux(self):
36         self.assertOverridesWorked('chromium-gpu-linux')
37
38     def test_get_chromium_gpu_mac(self):
39         self.assertOverridesWorked('chromium-gpu-mac')
40
41     def test_get_chromium_gpu_win(self):
42         self.assertOverridesWorked('chromium-gpu-win')
43
44     def assertOverridesWorked(self, port_name):
45         # test that we got the right port
46         mock_options = mocktool.MockOptions(accelerated_compositing=None,
47                                             accelerated_2d_canvas=None,
48                                             builder_name='foo',
49                                             child_processes=None)
50         port = chromium_gpu.get(port_name=port_name, options=mock_options)
51         self.assertTrue(port._options.accelerated_compositing)
52         self.assertTrue(port._options.accelerated_2d_canvas)
53         self.assertEqual(port.default_child_processes(), 1)
54         self.assertEqual(port._options.builder_name, 'foo - GPU')
55
56         # we use startswith() instead of Equal to gloss over platform versions.
57         self.assertTrue(port.name().startswith(port_name))
58
59         # test that it has the right directories in front of the search path.
60         paths = port.baseline_search_path()
61         self.assertEqual(port._webkit_baseline_path(port_name), paths[0])
62         if port_name == 'chromium-gpu-linux':
63             self.assertEqual(port._webkit_baseline_path('chromium-gpu-win'), paths[1])
64             self.assertEqual(port._webkit_baseline_path('chromium-gpu'), paths[2])
65         else:
66             self.assertEqual(port._webkit_baseline_path('chromium-gpu'), paths[1])
67
68         # Test that we have the right expectations file.
69         self.assertTrue('chromium-gpu' in
70                         port.path_to_test_expectations_file())
71
72 if __name__ == '__main__':
73     unittest.main()