| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 from webkitpy.common.host_mock import MockHost | 29 from webkitpy.common.host_mock import MockHost |
| 30 | 30 |
| 31 # FIXME: Old-style "Ports" need to die and be replaced by modern layout_tests.po
rt which needs to move to common. | |
| 32 from webkitpy.common.config.ports_mock import MockPort | |
| 33 | |
| 34 | 31 |
| 35 # FIXME: We should just replace this with optparse.Values(default=kwargs) | 32 # FIXME: We should just replace this with optparse.Values(default=kwargs) |
| 36 class MockOptions(object): | 33 class MockOptions(object): |
| 37 """Mock implementation of optparse.Values.""" | 34 """Mock implementation of optparse.Values.""" |
| 38 | 35 |
| 39 def __init__(self, **kwargs): | 36 def __init__(self, **kwargs): |
| 40 # The caller can set option values using keyword arguments. We don't | 37 # The caller can set option values using keyword arguments. We don't |
| 41 # set any values by default because we don't know how this | 38 # set any values by default because we don't know how this |
| 42 # object will be used. Generally speaking unit tests should | 39 # object will be used. Generally speaking unit tests should |
| 43 # subclass this or provider wrapper functions that set a common | 40 # subclass this or provider wrapper functions that set a common |
| 44 # set of options. | 41 # set of options. |
| 45 self.update(**kwargs) | 42 self.update(**kwargs) |
| 46 | 43 |
| 47 def update(self, **kwargs): | 44 def update(self, **kwargs): |
| 48 self.__dict__.update(**kwargs) | 45 self.__dict__.update(**kwargs) |
| 49 return self | 46 return self |
| 50 | 47 |
| 51 def ensure_value(self, key, value): | 48 def ensure_value(self, key, value): |
| 52 if getattr(self, key, None) is None: | 49 if getattr(self, key, None) is None: |
| 53 self.__dict__[key] = value | 50 self.__dict__[key] = value |
| 54 return self.__dict__[key] | 51 return self.__dict__[key] |
| 55 | 52 |
| 56 | 53 |
| 57 # FIXME: This should be renamed MockWebKitPatch. | 54 # FIXME: This should be renamed MockWebKitPatch. |
| 58 class MockTool(MockHost): | 55 class MockTool(MockHost): |
| 59 | 56 |
| 60 def __init__(self, *args, **kwargs): | 57 def __init__(self, *args, **kwargs): |
| 61 MockHost.__init__(self, *args, **kwargs) | 58 MockHost.__init__(self, *args, **kwargs) |
| 62 | 59 |
| 63 self._deprecated_port = MockPort() | |
| 64 | |
| 65 def deprecated_port(self): | |
| 66 return self._deprecated_port | |
| 67 | |
| 68 def path(self): | 60 def path(self): |
| 69 return "echo" | 61 return "echo" |
| OLD | NEW |