私はエスプレッソを使用してUIテストを実装しています。 私の上司は、特定のアクションの後で、linearLayoutが新しい、正しい色を持っていることを確認したいと思っています。私はこのLinearLayout getBackground()。getColor()戻り値が間違っています。
public static Matcher<View> withBgColor(final int color) {
Checks.checkNotNull(color);
return new BoundedMatcher<View, LinearLayout>(LinearLayout.class) {
@Override
public boolean matchesSafely(LinearLayout layout) {
MyLog.debug(String.valueOf(color) + " vs " + String.valueOf(((ColorDrawable) layout.getBackground()).getColor()));
return color == ((ColorDrawable) layout.getBackground()).getColor();
//return color == (((PaintDrawable) layout.getBackground()).getPaint()).getColor();
}
@Override
public void describeTo(Description description) {
description.appendText("With background color: ");
}
};
}
私の問題が背景から提供色と色の比較は同じではないことであるように見えるカスタム照合を書いてきました。アプリでは、正しい色が設定されていることがわかります。すぐにテストは、彼らが互いに異なる値を比較しようとして
holder.linearLayout.setBackgroundColor(ctx.getResources().getColor(R.color.grey_300));
:
私はこの.check(matches(withBgColor(R.color.grey_300)));
などのマッチャができ呼ん
Log: CustomMatcher: 17170432 vs -2039584
それは次のように行われています色が合っているかどうかを私が確認できる方法は誰ですか?私がやった方法は、感謝
ありがとうございました。なんて愚かなミスステ..私の日を救った! – glethien
問題ありません! 'ArgbEvaluator'を使っていくつかの色の値をアニメーション化するときに、まったく同じことが私にしばらく起こりました... – npace