This file contains hidden or 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
package com.aktepetugce.pagingmovieexample.di | |
import com.aktepetugce.pagingmovieexample.util.ApiConstants | |
import dagger.Module | |
import dagger.Provides | |
import dagger.hilt.InstallIn | |
import dagger.hilt.components.SingletonComponent | |
import javax.inject.Singleton | |
@Module |
This file contains hidden or 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
@UninstallModules( | |
UrlModule::class | |
) | |
@HiltAndroidTest | |
@RunWith(AndroidJUnit4::class) | |
class MainActivityTest { | |
@get:Rule | |
val hiltRule = HiltAndroidRule(this) |
This file contains hidden or 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
{ | |
"page": 1, | |
"results": [ | |
{ | |
"adult": false, | |
"backdrop_path": "/nGxUxi3PfXDRm7Vg95VBNgNM8yc.jpg", | |
"genre_ids": [ | |
28, | |
12, | |
16, |
This file contains hidden or 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 FileReader { | |
fun readStringFromFile(fileName: String): String { | |
try { | |
val inputStream = (InstrumentationRegistry.getInstrumentation().targetContext | |
.applicationContext as HiltTestApplication).assets.open(fileName) | |
val builder = StringBuilder() | |
val reader = InputStreamReader(inputStream, "UTF-8") | |
reader.readLines().forEach { | |
builder.append(it) | |
} |
This file contains hidden or 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
@UninstallModules( | |
UrlModule::class | |
) | |
@HiltAndroidTest | |
@RunWith(AndroidJUnit4::class) | |
class MainActivityTest { | |
@get:Rule | |
val hiltRule = HiltAndroidRule(this) |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<network-security-config> | |
<base-config cleartextTrafficPermitted="@string/clear_text_config"> | |
<trust-anchors> | |
<certificates src="system" /> | |
</trust-anchors> | |
</base-config> | |
</network-security-config> |
This file contains hidden or 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
buildTypes { | |
getByName("release") { | |
isMinifyEnabled = false | |
proguardFiles( | |
getDefaultProguardFile("proguard-android-optimize.txt"), | |
"proguard-rules.pro" | |
) | |
resValue("string", "clear_text_config","false") | |
} | |
getByName("debug") { |
This file contains hidden or 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
import okhttp3.mockwebserver.Dispatcher | |
import okhttp3.mockwebserver.MockResponse | |
import okhttp3.mockwebserver.RecordedRequest | |
class MockWebServerDispatcher { | |
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" -> |
This file contains hidden or 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
@UninstallModules( | |
UrlModule::class | |
) | |
@HiltAndroidTest | |
@RunWith(AndroidJUnit4::class) | |
class MainActivityTest { | |
@get:Rule | |
val hiltRule = HiltAndroidRule(this) |
This file contains hidden or 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
@Test | |
fun showErrorWhenMovieLoadFailed() { | |
mockWebServer.dispatcher = MockServerDispatcher().ErrorDispatcher() | |
val scenario = launchActivity<MainActivity>() | |
onView(withText(Constants.ERROR_MESSAGE)).check(matches(isDisplayed())) | |
scenario.close() | |
} |
OlderNewer