Code example for ImageView

Methods: measure, setLayoutParams

0
	private ImageAware mImageAware;
 
	@Before 
	public void setUp() throws Exception { 
		mActivity = new Activity();
 
		// Make and set view with some prelim values to test 
		mView = new TestImageView(mActivity);
		mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
		mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
 
		mImageAware = new ImageViewAware(mView);
	} 
 
	@Test 
	public void testGetImageSizeScaleTo_useImageActualSize() throws Exception { 
		// We layout the view to give it a width and height 
		mView.measure(View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY));
		mView.layout(0, 0, 200, 200);
 
		ImageSize expected = new ImageSize(200, 200);