webkitpy: Add IOSDevicePort and IOSPort tests
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 17:22:02 +0000 (17:22 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 17:22:02 +0000 (17:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170206
<rdar://problem/31308364>

Reviewed by Alexey Proskuryakov.

* Scripts/webkitpy/port/darwin_testcase.py: Removed unused import.
* Scripts/webkitpy/port/ios_device_unittest.py: Added.
(iosDeviceTest): Contains tests for the IOSDevicePort.
(iosDeviceTest.make_port): Creates an IOSDevicePort with arguments.
(iosDeviceTest.test_operating_system): Check for the correct operating system.
* Scripts/webkitpy/port/ios_simulator_unittest.py: Moved from Tools/Scripts/webkitpy/port/ios_unittest.py.
(iosSimulatorTest): Inherit from ios_testcase.
(iosSimulatorTest.make_port): Ditto.
(iosSimulatorTest.test_get_crash_log): Ditto.
* Scripts/webkitpy/port/ios_testcase.py: Added.
(iOSTest): Contains shared tests for the IOSDevicePort and IOSSimulatorPort.
(iOSTest.test_driver_name): Tests for iOS app driver.
(iOSTest.test_baseline_searchpath): Check that ios and ios-wk1 are in the baseline search path.
* Scripts/webkitpy/port/ios_unittest.py: Moved to ios_simulator_unittest.py.
* Scripts/webkitpy/port/port_testcase.py:
(PortTestCase): Rename is_simulator to disable_setup to more accurately describe it's meaning.
(PortTestCase.test_diff_image): Use disable_setup instead of is_simulator.
(PortTestCase.test_diff_image_crashed): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214542 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/port/darwin_testcase.py
Tools/Scripts/webkitpy/port/ios_device_unittest.py [new file with mode: 0644]
Tools/Scripts/webkitpy/port/ios_simulator_unittest.py [moved from Tools/Scripts/webkitpy/port/ios_unittest.py with 87% similarity]
Tools/Scripts/webkitpy/port/ios_testcase.py [new file with mode: 0644]
Tools/Scripts/webkitpy/port/port_testcase.py

index bee8cb5..71adf26 100644 (file)
@@ -1,3 +1,30 @@
+2017-03-29  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Add IOSDevicePort and IOSPort tests
+        https://bugs.webkit.org/show_bug.cgi?id=170206
+        <rdar://problem/31308364>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Scripts/webkitpy/port/darwin_testcase.py: Removed unused import.
+        * Scripts/webkitpy/port/ios_device_unittest.py: Added.
+        (iosDeviceTest): Contains tests for the IOSDevicePort.
+        (iosDeviceTest.make_port): Creates an IOSDevicePort with arguments.
+        (iosDeviceTest.test_operating_system): Check for the correct operating system.
+        * Scripts/webkitpy/port/ios_simulator_unittest.py: Moved from Tools/Scripts/webkitpy/port/ios_unittest.py.
+        (iosSimulatorTest): Inherit from ios_testcase.
+        (iosSimulatorTest.make_port): Ditto.
+        (iosSimulatorTest.test_get_crash_log): Ditto.
+        * Scripts/webkitpy/port/ios_testcase.py: Added.
+        (iOSTest): Contains shared tests for the IOSDevicePort and IOSSimulatorPort.
+        (iOSTest.test_driver_name): Tests for iOS app driver.
+        (iOSTest.test_baseline_searchpath): Check that ios and ios-wk1 are in the baseline search path.
+        * Scripts/webkitpy/port/ios_unittest.py: Moved to ios_simulator_unittest.py.
+        * Scripts/webkitpy/port/port_testcase.py:
+        (PortTestCase): Rename is_simulator to disable_setup to more accurately describe it's meaning.
+        (PortTestCase.test_diff_image): Use disable_setup instead of is_simulator.
+        (PortTestCase.test_diff_image_crashed): Ditto.
+
 2017-03-28  Jason Marcell  <jmarcell@apple.com>
 
         Fix `index-expected.txt` for dashboard test results.
index 52b7805..2c3aca4 100644 (file)
@@ -21,7 +21,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 from webkitpy.port import port_testcase
-from webkitpy.common.system.filesystem_mock import MockFileSystem
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.mocktool import MockOptions
 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, MockProcess, ScriptError
diff --git a/Tools/Scripts/webkitpy/port/ios_device_unittest.py b/Tools/Scripts/webkitpy/port/ios_device_unittest.py
new file mode 100644 (file)
index 0000000..6d60c32
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from webkitpy.port.ios_device import IOSDevicePort
+from webkitpy.port import ios_testcase
+
+
+class IOSDeviceTest(ios_testcase.IOSTest):
+    os_name = 'ios-device'
+    os_version = ''
+    port_name = 'ios-device'
+    port_maker = IOSDevicePort
+
+    def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=None, **kwargs):
+        port = super(IOSDeviceTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, s_version=os_version, kwargs=kwargs)
+        return port
+
+    def test_operating_system(self):
+        self.assertEqual('ios-device', self.make_port().operating_system())
 import time
 
 from webkitpy.port.ios_simulator import IOSSimulatorPort
-from webkitpy.port import darwin_testcase
-from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.port import ios_testcase
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.mocktool import MockOptions
-from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, MockProcess, ScriptError
-from webkitpy.common.system.systemhost_mock import MockSystemHost
+from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
 
 
-class iosTest(darwin_testcase.DarwinTest):
+class IOSSimulatorTest(ios_testcase.IOSTest):
     os_name = 'ios-simulator'
     os_version = ''
     port_name = 'ios-simulator'
     port_maker = IOSSimulatorPort
-    is_simulator = True
 
     def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=None, **kwargs):
-        port = super(iosTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, s_version=os_version, kwargs=kwargs)
+        port = super(IOSSimulatorTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, s_version=os_version, kwargs=kwargs)
         port.set_option('child_processes', 1)
         return port
 
@@ -58,7 +55,7 @@ class iosTest(darwin_testcase.DarwinTest):
         def fake_time_cb():
             times = [0, 20, 40]
             return lambda: times.pop(0)
-        port = self.make_port(port_name='ios-simulator')
+        port = self.make_port(port_name=self.port_name)
         port._get_crash_log('DumpRenderTree', 1234, None, None, time.time(), wait_for_log=False)
 
     def test_32bit(self):
diff --git a/Tools/Scripts/webkitpy/port/ios_testcase.py b/Tools/Scripts/webkitpy/port/ios_testcase.py
new file mode 100644 (file)
index 0000000..aaa5ea9
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from webkitpy.port import darwin_testcase
+from webkitpy.tool.mocktool import MockOptions
+
+
+class IOSTest(darwin_testcase.DarwinTest):
+    disable_setup = True
+
+    def test_driver_name(self):
+        self.assertEqual(self.make_port().driver_name(), 'DumpRenderTree.app')
+
+    def test_baseline_searchpath(self):
+        search_path = self.make_port().default_baseline_search_path()
+        self.assertEqual(search_path[-1], '/mock-checkout/LayoutTests/platform/ios')
+        self.assertEqual(search_path[-2], '/mock-checkout/LayoutTests/platform/ios-wk1')
index 79856ed..3e35379 100644 (file)
@@ -82,7 +82,7 @@ class PortTestCase(unittest.TestCase):
     os_version = None
     port_maker = TestWebKitPort
     port_name = None
-    is_simulator = False
+    disable_setup = False
 
     def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=None, **kwargs):
         host = host or MockSystemHost(os_name=(os_name or self.os_name), os_version=(os_version or self.os_version))
@@ -252,8 +252,8 @@ class PortTestCase(unittest.TestCase):
             self.proc = MockServerProcess(port, nm, cmd, env, lines=['diff: 100% failed\n', 'diff: 100% failed\n'])
             return self.proc
 
-        # FIXME: Can't pretend to run a simulator's setup, so just skip this test.
-        if self.is_simulator:
+        # FIXME: Can't pretend to run setup for some ports, so just skip this test.
+        if self.disable_setup:
             return
 
         port._server_process_constructor = make_proc
@@ -279,8 +279,8 @@ class PortTestCase(unittest.TestCase):
             self.proc = MockServerProcess(port, nm, cmd, env, crashed=True)
             return self.proc
 
-        # FIXME: Can't pretend to run a simulator's setup, so just skip this test.
-        if self.is_simulator:
+        # FIXME: Can't pretend to run setup for some ports, so just skip this test.
+        if self.disable_setup:
             return
 
         port._server_process_constructor = make_proc