public class UMAppAdapterTest extends ActivityInstrumentationTestCase2<MockActivity> { /** * */ private Activity mActivity = null; /** * */ private UMBaseAdapter mAdapter = null; /** * @Title: UMAppAdapterTest * @Description: * UMAppAdapterTest Constructor * * @param activityClass */ public UMAppAdapterTest(Class<MockActivity> activityClass) { super(activityClass); } public UMAppAdapterTest() { super(MockActivity.class); setName("MockActivity"); } @Before protected void setUp() throws Exception { super.setUp(); mActivity = getActivity(); assertNotNull(mActivity); } @After protected void tearDown() throws Exception { super.tearDown(); mActivity = null; clearState(); } @Test public void testGetBitmap() { mAdapter = new UMAppAdapter(mActivity); // 实际会触发截屏操作,返回当前截屏 assertNotNull(mAdapter.getBitmap()); // 使用控制器来截图, 实际上调用的是mAdapter.getBitmap() UMScrShotController controller = UMScrShotController.getInstance(); controller.setAdapter(mAdapter); assertNotNull(controller.takeScreenShot()); } } |