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.
5 from pylib
import chrome_test_server_spawner
6 from pylib
import forwarder
7 from pylib
.base
import test_server
10 class LocalTestServerSpawner(test_server
.TestServer
):
12 def __init__(self
, port
, device
, tool
):
13 super(LocalTestServerSpawner
, self
).__init
__()
15 self
._spawning
_server
= chrome_test_server_spawner
.SpawningServer(
20 def server_address(self
):
21 return self
._spawning
_server
.server
.server_address
25 return self
.server_address
[1]
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()
38 self
._spawning
_server
.CleanupState()
43 self
._spawning
_server
.Stop()
44 forwarder
.Forwarder
.UnmapDevicePort(self
.port
, self
._device
)