openstf / stf

Control and manage Android devices from your browser.
https://openstf.io
Other
13.35k stars 2.78k forks source link

Q: How to integrate custom provider (custom device) for STF #1182

Open jupe opened 4 years ago

jupe commented 4 years ago

I know that main target of STF project is to provide phones to under test, but what about use cases where we need custom device like bluetooth gadget (that is actual DUT) along with phone ? I love to use STF but it makes system very complex if STF can't provide also these custom DUT's. Would it make sense to create custom provider (mostly company internal stuff) which provide some kind of interface ("a.k.a ADB") for clients ? Which "app roles" it would affects (obviously would need custom provider, stf-api?, DB?) ?

Minimum features I would like to get is:

Does anybody have experiences with this ? How other's use STF along with custom devices ?

What makes this even more challenging at the R&D stage is that because quite often this custom DUT requires other accessories together, like power supply/relay, power meter, JTAG etc - which might be even mandatory to be able to run system level tests along with phone.. Those could still be "hidden" behind custom provider I think. Anyway, could STF be "the frame" that provide all of these, does it make sense ?

petemyron commented 4 years ago

I think the hard part will be just how custom this would be per device unless it's android-based. For example, we composited all the various iOS stuff people have been doing (plus a coordinating app because iOS is ridiculous and hard) and only built the stf-provider portion. The backend didn't need to be updated. We just stuffed some of the details (IMEI, OS, web socket details, etc.) into the channel that existed in the Android STF-provider.

So, you probably could do something, it just gets weird if there's not much else to use in STF other than the reservation system. But, go for it!

nanoscopic commented 4 years ago

Take a look at https://github.com/nanoscopic/stf-ios-provider This is a custom provider for IOS used by https://github.com/tmobile/stf_ios_support There is a custom device-ios unit, as well as a custom provider. In this case both are started by stf_ios_support. In the standard Android way the provider starts the device-ios unit itself.

The main functionality implemented so far is video and clicking.

Video is provided by https://github.com/nanoscopic/ios_video_stream It is fed jpeg frames through nanosmsg. For standard android devices minicap is used https://github.com/openstf/minicap

Clicking is done using WDA. This line of code is what is mainly responsible within the device-ios unit: https://github.com/nanoscopic/stf-ios-provider/blob/master/lib/units/device-ios/plugins/touch/index.js#L118 For standard android devices minitouch is used to generate touch events into Android: https://github.com/openstf/minitouch

If you clone the provider and alter the touch mechanism, and feed your own jpeg frames to ios_video_stream, then you can implement a device of some other sort.