-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish release plugins configuration
- Loading branch information
Showing
5 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## Release 0.1.0 | ||
#### New in release 0.1.0 | ||
|
||
First basic functionality to test an android application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
espressotools/src/main/java/de/nenick/espressotools/ScreenShot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package de.nenick.espressotools; | ||
|
||
import android.app.Activity; | ||
import android.graphics.Bitmap; | ||
import android.os.Environment; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* https://mobile.awsblog.com/post/TxP90JPTTBPE17/Getting-started-with-Android-testing-on-AWS-Device-Farm-using-Espresso-Part-2-Se | ||
*/ | ||
public class ScreenShot { | ||
|
||
private static final String TAG = "SCREENSHOT_TAG"; | ||
|
||
public static void take(Activity activity, String name) { | ||
final String dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test-screenshots/"; | ||
final String path = dir + name; | ||
|
||
File filePath = new File(dir); // Create directory if not present | ||
if (!filePath.isDirectory()) { | ||
Log.i(TAG, "Creating directory " + filePath); | ||
if(!filePath.mkdirs()) { | ||
Log.i(TAG, "Creating directory failed " + filePath); | ||
} | ||
} | ||
|
||
Log.i(TAG, "Saving to path: " + path); | ||
|
||
View phoneView = activity.getWindow().getDecorView().getRootView(); | ||
phoneView.setDrawingCacheEnabled(true); | ||
Bitmap bitmap = Bitmap.createBitmap(phoneView.getDrawingCache()); | ||
phoneView.setDrawingCacheEnabled(false); | ||
|
||
OutputStream out = null; | ||
|
||
File imageFile = new File(path); | ||
|
||
try { | ||
out = new FileOutputStream(imageFile); | ||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); | ||
out.flush(); | ||
} catch (IOException e) { | ||
Log.e(TAG, e.toString()); | ||
} | ||
|
||
finally { | ||
try { | ||
if (out != null) { | ||
out.close(); | ||
} | ||
} catch (IOException e) { | ||
Log.e(TAG, e.toString()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters