[xharness] Add support for manually reloading devices/simulators from the html UI. (#2753)
This is useful when forgetting to plug in a device before launching the web ui.
This commit is contained in:
Родитель
71a17aa673
Коммит
1ba523011a
|
@ -932,6 +932,12 @@ namespace xharness
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "/reload-devices":
|
||||||
|
GC.KeepAlive (Devices.LoadAsync (DeviceLoadLog, force: true));
|
||||||
|
break;
|
||||||
|
case "/reload-simulators":
|
||||||
|
GC.KeepAlive (Simulators.LoadAsync (SimulatorLoadLog, force: true));
|
||||||
|
break;
|
||||||
case "/quit":
|
case "/quit":
|
||||||
using (var writer = new StreamWriter (response.OutputStream)) {
|
using (var writer = new StreamWriter (response.OutputStream)) {
|
||||||
writer.WriteLine ("<!DOCTYPE html>");
|
writer.WriteLine ("<!DOCTYPE html>");
|
||||||
|
@ -1196,7 +1202,7 @@ namespace xharness
|
||||||
|
|
||||||
#nav {
|
#nav {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 300px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nav > * {
|
#nav > * {
|
||||||
|
@ -1514,6 +1520,12 @@ function oninitialload ()
|
||||||
<li class=""adminitem""><a href='javascript:toggleVisibility (""toggleable-ignored"");'>Ignored tests</a></li>
|
<li class=""adminitem""><a href='javascript:toggleVisibility (""toggleable-ignored"");'>Ignored tests</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li>Reload
|
||||||
|
<ul>
|
||||||
|
<li class=""adminitem""><a href='javascript:sendrequest (""reload-devices"");'>Devices</a></li>
|
||||||
|
<li class=""adminitem""><a href='javascript:sendrequest (""reload-simulators"");'>Simulators</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>");
|
</ul>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,16 @@ namespace xharness
|
||||||
public IEnumerable<SimDevice> AvailableDevices => available_devices;
|
public IEnumerable<SimDevice> AvailableDevices => available_devices;
|
||||||
public IEnumerable<SimDevicePair> AvailableDevicePairs => available_device_pairs;
|
public IEnumerable<SimDevicePair> AvailableDevicePairs => available_device_pairs;
|
||||||
|
|
||||||
public async Task LoadAsync (Log log)
|
public async Task LoadAsync (Log log, bool force = false)
|
||||||
{
|
{
|
||||||
if (loaded)
|
if (loaded) {
|
||||||
|
if (!force)
|
||||||
return;
|
return;
|
||||||
|
supported_runtimes.Reset ();
|
||||||
|
supported_device_types.Reset ();
|
||||||
|
available_devices.Reset ();
|
||||||
|
available_device_pairs.Reset ();
|
||||||
|
}
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
await Task.Run (async () =>
|
await Task.Run (async () =>
|
||||||
|
@ -497,10 +503,14 @@ namespace xharness
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LoadAsync (Log log, bool extra_data = false, bool removed_locked = false)
|
public async Task LoadAsync (Log log, bool extra_data = false, bool removed_locked = false, bool force = false)
|
||||||
{
|
{
|
||||||
if (loaded)
|
if (loaded) {
|
||||||
|
if (!force)
|
||||||
return;
|
return;
|
||||||
|
connected_devices.Reset ();
|
||||||
|
}
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
await Task.Run (async () =>
|
await Task.Run (async () =>
|
||||||
|
@ -726,6 +736,12 @@ namespace xharness
|
||||||
completed.Task.Wait ();
|
completed.Task.Wait ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Reset ()
|
||||||
|
{
|
||||||
|
completed = new TaskCompletionSource<bool> ();
|
||||||
|
list.Clear ();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator ()
|
public IEnumerator<T> GetEnumerator ()
|
||||||
{
|
{
|
||||||
return new Enumerator (this);
|
return new Enumerator (this);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче