代码之家  ›  专栏  ›  技术社区  ›  Roberto Pinheiro

用带有“hasTextColor”的浓缩咖啡测试

  •  5
  • Roberto Pinheiro  · 技术社区  · 7 年前

    我如何用文本的颜色做一个浓缩咖啡测试? 当前使用 hasTextColor() :

    onView(withId(R.id.editText)).check(matches(hasTextColor(Color.BLACK)));
    

    但出现错误:

    安卓所容纳之物res.Resources$NotFoundException:资源ID#0xff000000 在安卓。所容纳之物res.ResourcesImpl。getValue(ResourcesImpl.java:195)

    ...

    细节:

    <EditText
     android:id="@+id/editText"
     android:textColor="#ff000000"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_marginTop="48dp"/>
    
    1 回复  |  直到 7 年前
        1
  •  5
  •   chrjs    7 年前

    您需要对照参考资料中定义的颜色进行检查,如 hasTextColor(R.color.red)

    它也写在您提供的文档链接中: colorResId : int