DroidDriverのJavaDocをもすこし読んでみた。
io.appium.droiddriverのJavaDocsより
以下、いくつかピックアップして読んでみた。
BaseDroidDriver
DroidDriverを使ってテストを記述するとき、通常は BaseDroidDriverTest を継承して使う。 BaseDroidDriverTest は、 D2ActivityInstrumentationTestCase2 を継承している。 D2ActivityInstrumentationTestCase2 は ActivityInstrumentationTestCase2 を継承している。
D2ActivityInstrumentationTestCase2 は ActivityInstrumentationTestCase2 で既知の不具合であるISCよりも小さなバージョンのOSで再現するNullPointerExceptionの修正を含んでいるとのこと。
D2ActivityInstrumentationTestCase2 にある scrubClass の引用
Fixes a bug in ActivityTestCase.scrubClass(java.lang.Class) that causes NullPointerException if your leaf-level test class declares static fields. This is a known bug that has been fixed in ICS Android release. But it still exists on devices older than ICS. If your test class extends this class, it can work on older devices.
In addition to the official fix in ICS and beyond, which skips final fields, the fix below also skips static fields, which should be the expectation of Java programmers.
ここまでを見てみるに、DroidDriverはUIAutoamtion2.0がAPI Level 18以上なのに対して、同様な機能をAPI Level 18未満にも現実的な段階で適用しようとしているものな感じ。
InstrumentationDriver
instrumentation 経由で BaseDroidDriver を操作するためのクラス
AccessibilityDriver
- DroidDriverを継承して、Accessibility APIや同期的なイベントを使うことができるクラスの
UiAutomationDriverを継承しているクラス - validationを行っているそうなので、ここで対象OSがAccessibility API を正しく使えるとか、そいう判断しているのかな。
他
Pollerは、pollingを行うクラスの親らしい。
UiDriverとかはuiautomatorのものをそのままとってきて、というところ。
締め
UIAutomator2.0は、API Level 18以上が必要になるいっぽうで、DroidDriverはそれ以下でも対応できる。以前、testotips.ioで話した時にEspressoをすこし拡張した形な印象がある、と伝えたのですが、おおかた外れなさそうな予感。
すこしDroidDriverでテスト書いてみよう。
そして、EspressoかDroidDriverでテスト書いていこうかな。