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
object MockApiService { | |
// all available methods | |
enum class Method { | |
getData | |
} | |
// expatiations | |
private val expectationMap = mutableMapOf<Method, Expectation>() |
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
android { | |
... | |
defaultConfig { | |
... | |
testInstrumentationRunner "com.grumpyshoe.myapplication.core.MockTestRunner" | |
... | |
} | |
... | |
} |
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
open class MockTestRunner : AndroidJUnitRunner() { | |
override fun onCreate(arguments: Bundle) { | |
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build()) | |
super.onCreate(arguments) | |
} | |
@Throws(InstantiationException::class, IllegalAccessException::class, ClassNotFoundException::class) | |
override fun newApplication(cl: ClassLoader, className: String, context: Context): 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
class MainViewModelTest { | |
private lateinit var apiService: ApiService | |
@Rule | |
@JvmField | |
var rule: TestRule = InstantTaskExecutorRule() | |
@Before | |
fun setUp() { |
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
# opening and closing windows and popovers | |
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false | |
# smooth scrolling | |
defaults write -g NSScrollAnimationEnabled -bool false | |
# showing and hiding sheets, resizing preference windows, zooming windows | |
# float 0 doesn't work | |
defaults write -g NSWindowResizeTime -float 0.001 |
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
onView(withId(R.id.spinner)).perform(click()); | |
onView(allOf(withId(R.id.textview_in_custom_spinner), withText("DummyText"))).perform(click()); |
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
Example of how to reset a master branch to a specific commit (doen't matter which branch of) | |
git checkout master | |
git reset --hard <newBaseCommitId> | |
git push -f origin master | |
git merge <speceficCommitId> | |
git push origin master |
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
git branch -m old_branch new_branch # Rename your branch locally | |
git push origin :old_branch # Delete the old remote branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
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
public static Bitmap loadBitmapFromView(View v) { | |
b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); | |
Canvas c = new Canvas(b); | |
v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); | |
v.draw(c); | |
if (v.getMeasuredHeight() <= 0) { | |
v.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); | |
Bitmap b = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888); |
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
@Rule | |
public IntentsTestRule<MainActivity> mTestRule = new IntentsTestRule<MainActivity>(MainActivity.class){ | |
@Override | |
protected Intent getActivityIntent() { | |
Context targetContext = InstrumentationRegistry.getInstrumentation() | |
.getTargetContext(); | |
Intent result = new Intent(targetContext, MainActivity.class); | |
result.putExtra("Name", "Value"); | |
return result; | |
} |