I have a method:
public LayoutParams getLayoutParamsFromView(View view){
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
int height, width;
if (layoutParams == null) {
height = LayoutParams.WRAP_CONTENT;
width = LayoutParams.MATCH_PARENT;
layoutParams = new LayoutParams(width, height);
layoutParams.setMargins(left, top, right, bottom);
} else {
layoutParams.setMargins(left, top, right, bottom);
}
return layoutParams;
}
Note: Variables left, top, right, bottom are instance variables initialized on constructor call.
I want to test this method. I have mocked view and also setMargin method. But method is not setting margin parameters as mentioned and I am getting all parameters of LayoutParams(leftMargin, rightMargin, topMargin, bottomMargin) 0.0 in test though it's working correctly in code. What should I do so that I will get values as expected.
Please help me ! Any help will be appreciated..
Aucun commentaire:
Enregistrer un commentaire