Skip to content

Instantly share code, notes, and snippets.

View tugceaktepe's full-sized avatar
🏠
Working from home

Tugce Aktepe tugceaktepe

🏠
Working from home
  • Trendyol
  • Istanbul
View GitHub Profile
@tugceaktepe
tugceaktepe / MainActivityTest.kt
Created June 15, 2023 22:29
OkHttp3IdlingResource usage in a UI test
@Inject
lateinit var okHttp: OkHttpClient
private lateinit var okHttp3IdlingResource: OkHttp3IdlingResource
@Before
fun setup() {
hiltRule.inject()
okHttp3IdlingResource = OkHttp3IdlingResource.create("okhttp", okHttp)
IdlingRegistry.getInstance().register(okHttp3IdlingResource)
@tugceaktepe
tugceaktepe / MockWebServerDispatcher.kt
Created June 15, 2023 22:34
throttleBody example
internal inner class RequestDispatcher : Dispatcher() {
override fun dispatch(request: RecordedRequest): MockResponse {
return when (request.path) {
"/movie/top_rated?api_key=${API_KEY}&language=en-US&page=1" ->
MockResponse().setResponseCode(200)
.setBody(FileReader.readStringFromFile("success_response.json"))
.throttleBody(1024, 200L, TimeUnit.MILLISECONDS)
else -> MockResponse().setResponseCode(400)
}
}
@tugceaktepe
tugceaktepe / Dockerfile
Created June 18, 2023 10:47
Android SDK Setup in Docker image
FROM example-registry.company-domain.com/image/openjdk:11
ENV ANDROID_COMPILE_SDK=33
ENV ANDROID_BUILD_TOOLS=33.0.0
ENV ANDROID_SDK_TOOLS=6514223
ENV EMULATOR_VERSION=24
SHELL ["/bin/bash", "-c"]
RUN apt-get --quiet update --yes
@tugceaktepe
tugceaktepe / Dockerfile
Created June 18, 2023 11:04
QEMU Enabled Dockerfile
FROM ubuntu:18.04
RUN apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils vagrant && \
apt-get autoclean && \
apt-get autoremove && \
vagrant plugin install vagrant-libvirt
COPY start.sh /
ENTRYPOINT [ "/start.sh" ]
@tugceaktepe
tugceaktepe / start.sh
Created June 18, 2023 11:05
start.sh for docker image
set -eou pipefail
chown root:kvm /dev/kvm
service libvirtd start
service virtlogd start
exec "$@"
@tugceaktepe
tugceaktepe / sdk_update.sh
Created June 18, 2023 14:00
Download Android SDK
apt-get update -y
install -d $ANDROID_HOME
wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip --no-check-certificate
pushd $ANDROID_HOME
unzip -d cmdline-tools cmdline-tools.zip
popd
sdkmanager --version
yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses || true
sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}"
sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
@tugceaktepe
tugceaktepe / .bashrc
Created June 18, 2023 14:01
bashrc file for Android
export ANDROID_COMPILE_SDK=33
export ANDROID_BUILD_TOOLS=33.0.0
export ANDROID_SDK_TOOLS=6514223
export EMULATOR_VERSION=31
export ANDROID_HOME="${PWD}/android-home"
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin/:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator
@tugceaktepe
tugceaktepe / emulator_update.sh
Created June 18, 2023 14:03
Emulator scripts
apt-get update -y
apt-get --quiet install --yes libx11-dev libgl1 libpulse0 libnss3 libxcomposite-dev libxcursor1 libasound2
apt-get update
apt-get install -y libgl1-mesa-glx
sdkmanager --update > update.log
sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};default;x86_64" > installEmulator.log
wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
chmod +x android-wait-for-emulator
chmod +x gradlew
@tugceaktepe
tugceaktepe / turn_off_animations.sh
Created June 18, 2023 14:05
Turn off animations on emulator
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
@tugceaktepe
tugceaktepe / run_emulator.sh
Last active June 19, 2023 09:16
Create & Run emulator from command line
echo no | avdmanager create avd --force -n yourEmulatorName -k "system-images;android-${EMULATOR_VERSION};default;x86_64"
adb start-server
emulator -avd yourEmulatorName -no-window -no-audio -no-boot-anim -gpu off
./android-wait-for-emulator
adb shell input keyevent 82