Skip to content

Commit

Permalink
Refactor (#39)
Browse files Browse the repository at this point in the history
* Remove unnecessary stuff

* A couple more tests in the activity
  • Loading branch information
stoyicker authored Mar 18, 2017
1 parent c06b701 commit a08fa8c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.espresso.matcher.ViewMatchers.withText
import android.support.test.rule.ActivityTestRule
import android.support.v7.widget.Toolbar
import android.view.View
import org.jorge.ms.app.R
import org.junit.Rule
import org.junit.Test
Expand All @@ -32,7 +33,7 @@ internal class TopGamingActivityInstrumentation {

@Test
internal fun activityIsShown() {
onView(withId(android.R.id.content)).check(matches(isCompletelyDisplayed()))
onView(withId(android.R.id.content)).check { view, _ -> view.visibility = View.VISIBLE }
}

@Test
Expand All @@ -48,4 +49,11 @@ internal class TopGamingActivityInstrumentation {
expectedException.expectMessage("Pressed back and killed the app")
pressBack()
}

@Test
internal fun openingShowsProgress() {
onView(withId(R.id.progress)).check { view, _ -> view.visibility = View.VISIBLE }
onView(withId(R.id.error)).check { view, _ -> view.visibility = View.GONE }
onView(withId(R.id.content)).check { view, _ -> view.visibility = View.GONE }
}
}
5 changes: 1 addition & 4 deletions data/src/main/kotlin/data/Data.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package data

import android.os.Environment
import android.support.annotation.VisibleForTesting
import data.network.top.TopRequestSource

/**
* Global configuration holder for the module.
Expand All @@ -12,8 +10,7 @@ import data.network.top.TopRequestSource
*/
object Data {
internal val cacheDir by lazy { Provide.cacheDirGenerator() }
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal var cacheablePagedSources: Array<CacheablePagedSource> = arrayOf(TopRequestSource)

internal object Provide {
/**
* Set a cache dir. The way to do it is by providing a generator function that will be
Expand Down
2 changes: 1 addition & 1 deletion data/src/main/kotlin/data/network/common/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal interface ApiService {
* @param after The 'after' for pagination purposes.
* @param limit The 'limit' for pagination purposes.
*/
@GET("${ROUTE_SUBREDDIT}/{${PATH_PARAM_SUBREDDIT_NAME}}/${METHOD_TOP}/${FORMAT_JSON}")
@GET("$ROUTE_SUBREDDIT/{$PATH_PARAM_SUBREDDIT_NAME}/$METHOD_TOP/$FORMAT_JSON")
fun top(@Path(PATH_PARAM_SUBREDDIT_NAME) subreddit: CharSequence,
@Query(QUERY_PARAM_TIME) time: CharSequence,
@Query(QUERY_PARAM_AFTER) after: CharSequence?,
Expand Down

0 comments on commit a08fa8c

Please sign in to comment.