OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from pylib import chrome_test_server_spawner |
| 6 from pylib import forwarder |
| 7 from pylib.base import test_server |
| 8 |
| 9 |
| 10 class LocalTestServerSpawner(test_server.TestServer): |
| 11 |
| 12 def __init__(self, port, device, tool): |
| 13 super(LocalTestServerSpawner, self).__init__() |
| 14 self._device = device |
| 15 self._spawning_server = chrome_test_server_spawner.SpawningServer( |
| 16 port, device, tool) |
| 17 self._tool = tool |
| 18 |
| 19 @property |
| 20 def server_address(self): |
| 21 return self._spawning_server.server.server_address |
| 22 |
| 23 @property |
| 24 def port(self): |
| 25 return self.server_address[1] |
| 26 |
| 27 #override |
| 28 def SetUp(self): |
| 29 self._device.WriteFile( |
| 30 '%s/net-test-server-ports' % self._device.GetExternalStoragePath(), |
| 31 '%s:0' % str(self.port)) |
| 32 forwarder.Forwarder.Map( |
| 33 [(self.port, self.port)], self._device, self._tool) |
| 34 self._spawning_server.Start() |
| 35 |
| 36 #override |
| 37 def Reset(self): |
| 38 self._spawning_server.CleanupState() |
| 39 |
| 40 #override |
| 41 def TearDown(self): |
| 42 self.Reset() |
| 43 self._spawning_server.Stop() |
| 44 forwarder.Forwarder.UnmapDevicePort(self.port, self._device) |
| 45 |
OLD | NEW |