Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. @RunWith(PowerMockRunner.class)
  2. @PrepareForTest( {ByteBitmapConverters.class, BitmapFactory.class })
  3. public class ByteBitmapConvertersTest {
  4.  
  5. @Before
  6. public void setup() {
  7. //MockitoAnnotations.initMocks(this);
  8. PowerMockito.mockStatic(BitmapFactory.class);
  9. }
  10.  
  11. public Bitmap LoadBitmapFromTestResources(){
  12. ClassLoader classLoader = getClass().getClassLoader();
  13. URL resource = classLoader.getResource("for_tests.png");
  14. File file = new File(resource.getPath());
  15. boolean exists = file.exists(); //equals "true", so file exists
  16. BitmapFactory.Options options = new BitmapFactory.Options();
  17. options.inPreferredConfig = Bitmap.Config.ARGB_8888;
  18. return BitmapFactory.decodeFile(resource.getPath(), options);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement