diff --git a/app/src/androidTest/java/com/h/pixeldroid/FeedInstrumentedTest.kt b/app/src/androidTest/java/com/h/pixeldroid/FeedInstrumentedTest.kt
deleted file mode 100644
index cbaf16e6..00000000
--- a/app/src/androidTest/java/com/h/pixeldroid/FeedInstrumentedTest.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.h.pixeldroid
-
-import android.content.Context
-import androidx.test.core.app.ActivityScenario
-import androidx.test.espresso.Espresso.onView
-import androidx.test.espresso.action.ViewActions.swipeDown
-import androidx.test.espresso.action.ViewActions.swipeUp
-import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
-import androidx.test.espresso.matcher.ViewMatchers.withId
-import androidx.test.ext.junit.rules.ActivityScenarioRule
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
-import okhttp3.mockwebserver.MockResponse
-import okhttp3.mockwebserver.MockWebServer
-import org.hamcrest.CoreMatchers.not
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-
-//@RunWith(AndroidJUnit4::class)
-class FeedInstrumentedTest {
- /* private val feedJson = """[{"id":"140364967936397312","uri":"https:\/\/pixelfed.de\/p\/Miike\/140364967936397312","url":"https:\/\/pixelfed.de\/p\/Miike\/140364967936397312","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"Day 8 #rotavicentina<\/a> #hiking<\/a> #nature<\/a>","created_at":"2020-03-03T08:00:16.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":0,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[{"name":"hiking","url":"https:\/\/pixelfed.de\/discover\/tags\/hiking"},{"name":"nature","url":"https:\/\/pixelfed.de\/discover\/tags\/nature"},{"name":"rotavicentina","url":"https:\/\/pixelfed.de\/discover\/tags\/rotavicentina"}],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"115114166443970560","username":"Miike","acct":"Miike","display_name":"Miike Duart","locked":false,"created_at":"2019-12-24T15:42:35.000000Z","followers_count":14,"following_count":0,"statuses_count":71,"note":"","url":"https:\/\/pixelfed.de\/Miike","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/011\/511\/416\/644\/397\/056\/0\/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/011\/511\/416\/644\/397\/056\/0\/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15888","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f\/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f\/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg","text_url":null,"meta":null,"description":null}]},{"id":"140349785193451520","uri":"https:\/\/pixelfed.de\/p\/stephan\/140349785193451520","url":"https:\/\/pixelfed.de\/p\/stephan\/140349785193451520","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"","created_at":"2020-03-03T06:59:56.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":2,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"908","username":"stephan","acct":"stephan","display_name":"Stephan","locked":false,"created_at":"2019-03-17T07:46:33.000000Z","followers_count":136,"following_count":25,"statuses_count":136,"note":"Musician, software developer & hobby photographer.","url":"https:\/\/pixelfed.de\/stephan","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/000\/000\/000\/908\/5nQzzsB1mkwKaUqQ9GNN_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/000\/000\/000\/908\/5nQzzsB1mkwKaUqQ9GNN_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15887","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/a1349f5183c2bac7d52880e8f5188df0f3b2d62a\/mvT3nYV6Wdu42Xh56Ny4VYaWU0OzbnC3wjxiqnKS.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/a1349f5183c2bac7d52880e8f5188df0f3b2d62a\/mvT3nYV6Wdu42Xh56Ny4VYaWU0OzbnC3wjxiqnKS_thumb.jpeg","text_url":null,"meta":null,"description":null}]},{"id":"140276879742603264","uri":"https:\/\/pixelfed.de\/p\/fegrimaldi\/140276879742603264","url":"https:\/\/pixelfed.de\/p\/fegrimaldi\/140276879742603264","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"february 2 is the day to give flowers to Iemanj\u00e1. #salvador<\/a> #bahia<\/a> #brazil<\/a> #iemanja<\/a>","created_at":"2020-03-03T02:10:14.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":1,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[{"name":"salvador","url":"https:\/\/pixelfed.de\/discover\/tags\/salvador"},{"name":"bahia","url":"https:\/\/pixelfed.de\/discover\/tags\/bahia"},{"name":"brazil","url":"https:\/\/pixelfed.de\/discover\/tags\/brazil"},{"name":"iemanja","url":"https:\/\/pixelfed.de\/discover\/tags\/iemanja"}],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"137257212828585984","username":"fegrimaldi","acct":"fegrimaldi","display_name":"Fernanda Grimaldi","locked":false,"created_at":"2020-02-23T18:11:09.000000Z","followers_count":2,"following_count":7,"statuses_count":2,"note":"a little piece of Bahia in the fediverse.","url":"https:\/\/pixelfed.de\/fegrimaldi","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/013\/725\/721\/282\/858\/598\/4\/oUPBit0TJso1xNhJfFqg_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/013\/725\/721\/282\/858\/598\/4\/oUPBit0TJso1xNhJfFqg_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15886","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/feb878b4bd60b85ac840670c6b9c809fd76b628b\/lYMrx0WF8LDqn0vTRgNJaRs7stMKtAXrgzpMrWEr.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/feb878b4bd60b85ac840670c6b9c809fd76b628b\/lYMrx0WF8LDqn0vTRgNJaRs7stMKtAXrgzpMrWEr_thumb.jpeg","text_url":null,"meta":null,"description":null}]}]"""
- @get:Rule
- var activityRule: ActivityScenarioRule
- = ActivityScenarioRule(MainActivity::class.java)
- @Before
- fun before(){
- val server = MockWebServer()
- server.enqueue(MockResponse().addHeader("Content-Type", "application/json; charset=utf-8").setBody(feedJson))
- server.start()
- val baseUrl = server.url("")
- val preferences = InstrumentationRegistry.getInstrumentation()
- .targetContext.getSharedPreferences("com.h.pixeldroid.pref", Context.MODE_PRIVATE)
- preferences.edit().putString("accessToken", "azerty").apply()
- preferences.edit().putString("domain", baseUrl.toString()).apply()
- ActivityScenario.launch(MainActivity::class.java)
- }
-
- @Test
- fun swipingDownOnHomepageShowsMorePosts() {
- Thread.sleep(5000)
-
- val firstDesc = withId(R.id.description)
- onView(withId(R.id.view_pager)).perform(swipeUp()).perform(swipeDown()).perform(swipeDown())
- onView(withId(R.id.description)).check(matches(firstDesc))
- }*/
-}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/h/pixeldroid/LoginInstrumentedTest.kt b/app/src/androidTest/java/com/h/pixeldroid/LoginInstrumentedTest.kt
index e9144da2..6f6b3a3e 100644
--- a/app/src/androidTest/java/com/h/pixeldroid/LoginInstrumentedTest.kt
+++ b/app/src/androidTest/java/com/h/pixeldroid/LoginInstrumentedTest.kt
@@ -61,27 +61,27 @@ class LoginInstrumentedTest {
}
}
-//@RunWith(AndroidJUnit4::class)
-//class LoginCheckIntent {
-// @get:Rule
-// val intentsTestRule = IntentsTestRule(LoginActivity::class.java)
-//
-// @Test
-// fun launchesIntent() {
-// val expectedIntent: Matcher = allOf(
-// hasAction(ACTION_VIEW),
-// hasDataString(containsString("pixelfed.social"))
-// )
-//
-// onView(withId(R.id.editText)).perform(ViewActions.replaceText("pixelfed.social"), ViewActions.closeSoftKeyboard())
-// onView(withId(R.id.connect_instance_button)).perform(click())
-//
-// Thread.sleep(5000)
-//
-// intended(expectedIntent)
-//
-// }
-//}
+@RunWith(AndroidJUnit4::class)
+class LoginCheckIntent {
+ @get:Rule
+ val intentsTestRule = IntentsTestRule(LoginActivity::class.java)
+
+ @Test
+ fun launchesIntent() {
+ val expectedIntent: Matcher = allOf(
+ hasAction(ACTION_VIEW),
+ hasDataString(containsString("pixelfed.social"))
+ )
+
+ onView(withId(R.id.editText)).perform(ViewActions.replaceText("pixelfed.social"), ViewActions.closeSoftKeyboard())
+ onView(withId(R.id.connect_instance_button)).perform(click())
+
+ Thread.sleep(5000)
+
+ intended(expectedIntent)
+
+ }
+}
@RunWith(AndroidJUnit4::class)
class AfterIntent {
diff --git a/app/src/androidTest/java/com/h/pixeldroid/MockedServerTest.kt b/app/src/androidTest/java/com/h/pixeldroid/MockedServerTest.kt
new file mode 100644
index 00000000..eb0a32ff
--- /dev/null
+++ b/app/src/androidTest/java/com/h/pixeldroid/MockedServerTest.kt
@@ -0,0 +1,97 @@
+package com.h.pixeldroid
+
+import android.content.Context
+import androidx.test.core.app.ActivityScenario
+import androidx.test.espresso.Espresso.onView
+import androidx.test.espresso.action.ViewActions
+import androidx.test.espresso.assertion.ViewAssertions.matches
+import androidx.test.espresso.matcher.ViewMatchers.withId
+import androidx.test.espresso.matcher.ViewMatchers.withText
+import androidx.test.ext.junit.rules.ActivityScenarioRule
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import okhttp3.mockwebserver.Dispatcher
+import okhttp3.mockwebserver.MockResponse
+import okhttp3.mockwebserver.MockWebServer
+import okhttp3.mockwebserver.RecordedRequest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+
+@RunWith(AndroidJUnit4::class)
+class MockedServerTest {
+ private val accountJson = "{\n" +
+ " \"id\": \"1450\",\n" +
+ " \"username\": \"deerbard_photo\",\n" +
+ " \"acct\": \"deerbard_photo\",\n" +
+ " \"display_name\": \"deerbard photography\",\n" +
+ " \"locked\": false,\n" +
+ " \"created_at\": \"2018-08-01T12:58:21.000000Z\",\n" +
+ " \"followers_count\": 68,\n" +
+ " \"following_count\": 27,\n" +
+ " \"statuses_count\": 72,\n" +
+ " \"note\": \"\",\n" +
+ " \"url\": \"https://pixelfed.social/deerbard_photo\",\n" +
+ " \"avatar\": \"https://pixelfed.social/storage/avatars/000/000/001/450/SMSep5NoabDam1W8UDMh_avatar.png?v=4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a\",\n" +
+ " \"avatar_static\": \"https://pixelfed.social/storage/avatars/000/000/001/450/SMSep5NoabDam1W8UDMh_avatar.png?v=4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a\",\n" +
+ " \"header\": \"\",\n" +
+ " \"header_static\": \"\",\n" +
+ " \"emojis\": [],\n" +
+ " \"moved\": null,\n" +
+ " \"fields\": null,\n" +
+ " \"bot\": false,\n" +
+ " \"software\": \"pixelfed\",\n" +
+ " \"is_admin\": false\n" +
+ " }"
+ private val feedJson = """[{"id":"140364967936397312","uri":"https:\/\/pixelfed.de\/p\/Miike\/140364967936397312","url":"https:\/\/pixelfed.de\/p\/Miike\/140364967936397312","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"Day 8 #rotavicentina<\/a> #hiking<\/a> #nature<\/a>","created_at":"2020-03-03T08:00:16.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":0,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[{"name":"hiking","url":"https:\/\/pixelfed.de\/discover\/tags\/hiking"},{"name":"nature","url":"https:\/\/pixelfed.de\/discover\/tags\/nature"},{"name":"rotavicentina","url":"https:\/\/pixelfed.de\/discover\/tags\/rotavicentina"}],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"115114166443970560","username":"Miike","acct":"Miike","display_name":"Miike Duart","locked":false,"created_at":"2019-12-24T15:42:35.000000Z","followers_count":14,"following_count":0,"statuses_count":71,"note":"","url":"https:\/\/pixelfed.de\/Miike","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/011\/511\/416\/644\/397\/056\/0\/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/011\/511\/416\/644\/397\/056\/0\/ZhaopLJWTWJ3hsVCS5pS_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15888","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f\/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f\/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg","text_url":null,"meta":null,"description":null}]},{"id":"140349785193451520","uri":"https:\/\/pixelfed.de\/p\/stephan\/140349785193451520","url":"https:\/\/pixelfed.de\/p\/stephan\/140349785193451520","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"","created_at":"2020-03-03T06:59:56.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":2,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"908","username":"stephan","acct":"stephan","display_name":"Stephan","locked":false,"created_at":"2019-03-17T07:46:33.000000Z","followers_count":136,"following_count":25,"statuses_count":136,"note":"Musician, software developer & hobby photographer.","url":"https:\/\/pixelfed.de\/stephan","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/000\/000\/000\/908\/5nQzzsB1mkwKaUqQ9GNN_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/000\/000\/000\/908\/5nQzzsB1mkwKaUqQ9GNN_avatar.png?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15887","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/a1349f5183c2bac7d52880e8f5188df0f3b2d62a\/mvT3nYV6Wdu42Xh56Ny4VYaWU0OzbnC3wjxiqnKS.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/a1349f5183c2bac7d52880e8f5188df0f3b2d62a\/mvT3nYV6Wdu42Xh56Ny4VYaWU0OzbnC3wjxiqnKS_thumb.jpeg","text_url":null,"meta":null,"description":null}]},{"id":"140276879742603264","uri":"https:\/\/pixelfed.de\/p\/fegrimaldi\/140276879742603264","url":"https:\/\/pixelfed.de\/p\/fegrimaldi\/140276879742603264","in_reply_to_id":null,"in_reply_to_account_id":null,"reblog":null,"content":"february 2 is the day to give flowers to Iemanj\u00e1. #salvador<\/a> #bahia<\/a> #brazil<\/a> #iemanja<\/a>","created_at":"2020-03-03T02:10:14.000000Z","emojis":[],"replies_count":0,"reblogs_count":0,"favourites_count":1,"reblogged":null,"favourited":null,"muted":null,"sensitive":false,"spoiler_text":"","visibility":"public","mentions":[],"tags":[{"name":"salvador","url":"https:\/\/pixelfed.de\/discover\/tags\/salvador"},{"name":"bahia","url":"https:\/\/pixelfed.de\/discover\/tags\/bahia"},{"name":"brazil","url":"https:\/\/pixelfed.de\/discover\/tags\/brazil"},{"name":"iemanja","url":"https:\/\/pixelfed.de\/discover\/tags\/iemanja"}],"card":null,"poll":null,"application":{"name":"web","website":null},"language":null,"pinned":null,"account":{"id":"137257212828585984","username":"fegrimaldi","acct":"fegrimaldi","display_name":"Fernanda Grimaldi","locked":false,"created_at":"2020-02-23T18:11:09.000000Z","followers_count":2,"following_count":7,"statuses_count":2,"note":"a little piece of Bahia in the fediverse.","url":"https:\/\/pixelfed.de\/fegrimaldi","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/013\/725\/721\/282\/858\/598\/4\/oUPBit0TJso1xNhJfFqg_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/013\/725\/721\/282\/858\/598\/4\/oUPBit0TJso1xNhJfFqg_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"15886","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/feb878b4bd60b85ac840670c6b9c809fd76b628b\/lYMrx0WF8LDqn0vTRgNJaRs7stMKtAXrgzpMrWEr.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/113a3e2124a33b1f5511e531953f5ee48456e0c7\/feb878b4bd60b85ac840670c6b9c809fd76b628b\/lYMrx0WF8LDqn0vTRgNJaRs7stMKtAXrgzpMrWEr_thumb.jpeg","text_url":null,"meta":null,"description":null}]}]"""
+
+ @get:Rule
+ var activityRule: ActivityScenarioRule
+ = ActivityScenarioRule(MainActivity::class.java)
+ private val dispatcher: Dispatcher = object : Dispatcher() {
+ @Throws(InterruptedException::class)
+ override fun dispatch(request: RecordedRequest): MockResponse {
+ when (request.path) {
+ "/api/v1/accounts/verify_credentials" -> return MockResponse().addHeader("Content-Type", "application/json; charset=utf-8").setResponseCode(200).setBody(accountJson)
+ "/api/v1/timelines/home" -> return MockResponse().addHeader("Content-Type", "application/json; charset=utf-8").setResponseCode(200).setBody(feedJson)
+ }
+ return MockResponse().setResponseCode(404)
+ }
+ }
+
+ @Before
+ fun before(){
+ val server = MockWebServer()
+ server.dispatcher = dispatcher
+ server.start()
+ val baseUrl = server.url("")
+ val preferences = InstrumentationRegistry.getInstrumentation()
+ .targetContext.getSharedPreferences("com.h.pixeldroid.pref", Context.MODE_PRIVATE)
+ preferences.edit().putString("accessToken", "azerty").apply()
+ preferences.edit().putString("domain", baseUrl.toString()).apply()
+ ActivityScenario.launch(MainActivity::class.java)
+ }
+ @Test
+ fun testFollowersTextView() {
+ onView(withId(R.id.view_pager)).perform(ViewActions.swipeLeft()).perform(ViewActions.swipeLeft()).perform(
+ ViewActions.swipeLeft()
+ ).perform(ViewActions.swipeLeft())
+ Thread.sleep(1000)
+ onView(withId(R.id.nbFollowersTextView)).check(matches(withText("68\nFollowers")))
+ onView(withId(R.id.accountNameTextView)).check(matches(withText("deerbard_photo")))
+ }
+
+ @Test
+ fun swipingDownOnHomepageShowsMorePosts() {
+ Thread.sleep(1000)
+
+ val firstDesc = withId(R.id.description)
+ onView(withId(R.id.view_pager)).perform(ViewActions.swipeUp()).perform(ViewActions.swipeDown()).perform(
+ ViewActions.swipeDown()
+ )
+ onView(withId(R.id.description)).check(matches(firstDesc))
+ }
+
+}
diff --git a/app/src/androidTest/java/com/h/pixeldroid/MyProfileTest.kt b/app/src/androidTest/java/com/h/pixeldroid/MyProfileTest.kt
deleted file mode 100644
index cf33c3cd..00000000
--- a/app/src/androidTest/java/com/h/pixeldroid/MyProfileTest.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.h.pixeldroid
-
-import android.content.Context
-import androidx.test.core.app.ActivityScenario
-import androidx.test.espresso.Espresso.onView
-import androidx.test.espresso.action.ViewActions
-import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.matcher.ViewMatchers.withId
-import androidx.test.espresso.matcher.ViewMatchers.withText
-import androidx.test.ext.junit.rules.ActivityScenarioRule
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.platform.app.InstrumentationRegistry
-import okhttp3.mockwebserver.MockResponse
-import okhttp3.mockwebserver.MockWebServer
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-
-
-//@RunWith(AndroidJUnit4::class)
-class MyProfileTest {
- /* private val accountJson = "{\n" +
- " \"id\": \"1450\",\n" +
- " \"username\": \"deerbard_photo\",\n" +
- " \"acct\": \"deerbard_photo\",\n" +
- " \"display_name\": \"deerbard photography\",\n" +
- " \"locked\": false,\n" +
- " \"created_at\": \"2018-08-01T12:58:21.000000Z\",\n" +
- " \"followers_count\": 68,\n" +
- " \"following_count\": 27,\n" +
- " \"statuses_count\": 72,\n" +
- " \"note\": \"\",\n" +
- " \"url\": \"https://pixelfed.social/deerbard_photo\",\n" +
- " \"avatar\": \"https://pixelfed.social/storage/avatars/000/000/001/450/SMSep5NoabDam1W8UDMh_avatar.png?v=4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a\",\n" +
- " \"avatar_static\": \"https://pixelfed.social/storage/avatars/000/000/001/450/SMSep5NoabDam1W8UDMh_avatar.png?v=4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a\",\n" +
- " \"header\": \"\",\n" +
- " \"header_static\": \"\",\n" +
- " \"emojis\": [],\n" +
- " \"moved\": null,\n" +
- " \"fields\": null,\n" +
- " \"bot\": false,\n" +
- " \"software\": \"pixelfed\",\n" +
- " \"is_admin\": false\n" +
- " }"
- @get:Rule
- var activityRule: ActivityScenarioRule
- = ActivityScenarioRule(MainActivity::class.java)
-
- @Before
- fun before(){
- val server = MockWebServer()
- server.enqueue(MockResponse().addHeader("Content-Type", "application/json; charset=utf-8").setBody(accountJson))
- server.start()
- val baseUrl = server.url("")
- val preferences = InstrumentationRegistry.getInstrumentation()
- .targetContext.getSharedPreferences("com.h.pixeldroid.pref", Context.MODE_PRIVATE)
- preferences.edit().putString("accessToken", "azerty").apply()
- preferences.edit().putString("domain", baseUrl.toString()).apply()
- ActivityScenario.launch(MainActivity::class.java)
- }
- @Test
- fun testFollowersTextView() {
- onView(withId(R.id.view_pager)).perform(ViewActions.swipeLeft()).perform(ViewActions.swipeLeft()).perform(
- ViewActions.swipeLeft()
- ).perform(ViewActions.swipeLeft())
- Thread.sleep(1000)
-
- onView(withId(R.id.nbFollowersTextView)).check(matches(withText("68\nFollowers")))
- onView(withId(R.id.accountNameTextView)).check(matches(withText("deerbard_photo")))
- }*/
-}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 00aa7bdb..3f184156 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -44,7 +44,6 @@
android:scheme="@string/auth_scheme" />
-
\ No newline at end of file
diff --git a/app/src/main/java/com/h/pixeldroid/FeedActivity.kt b/app/src/main/java/com/h/pixeldroid/FeedActivity.kt
deleted file mode 100644
index 2e6e2bc7..00000000
--- a/app/src/main/java/com/h/pixeldroid/FeedActivity.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.h.pixeldroid
-
-import androidx.appcompat.app.AppCompatActivity
-import android.os.Bundle
-import android.util.Log
-import android.widget.TextView
-import androidx.fragment.app.FragmentManager
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.h.pixeldroid.api.PixelfedAPI
-import com.h.pixeldroid.models.Post
-import com.h.pixeldroid.models.Post.Companion.POST_FRAG_TAG
-import com.h.pixeldroid.objects.*
-import retrofit2.Call
-import retrofit2.Callback
-import retrofit2.Response
-
-class FeedActivity : AppCompatActivity() {
- lateinit var feed : RecyclerView
- lateinit var adapter : FeedRecyclerViewAdapter
- var posts : List = ArrayList()
-
- fun setContent(newPosts : ArrayList) {
- feed = findViewById(R.id.feedList)
- feed?.setHasFixedSize(true)
- feed?.layoutManager = LinearLayoutManager(this)
- posts = newPosts
- adapter = FeedRecyclerViewAdapter(context = this)
- feed?.adapter = adapter
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_feed)
-
- var statuses: ArrayList? = null
- val BASE_URL = "https://pixelfed.de/"
-
- val pixelfedAPI = PixelfedAPI.create(BASE_URL)
-
- val newPosts = ArrayList()
-
- pixelfedAPI.timelinePublic(null, null, null, null, null)
- .enqueue(object : Callback> {
- override fun onResponse(call: Call>, response: Response>) {
- if (response.code() == 200) {
- statuses = response.body() as ArrayList?
- if(!statuses.isNullOrEmpty()) {
- for (status in statuses!!) {
- newPosts.add(Post(status))
- }
- setContent(newPosts)
- Log.e("POSTS", newPosts.toString())
- }
-
- }
- }
-
- override fun onFailure(call: Call>, t: Throwable) {
- Log.e("Ouch, not OK", t.toString())
- }
- })
- }
-}
diff --git a/app/src/main/java/com/h/pixeldroid/FeedRecyclerViewAdapter.kt b/app/src/main/java/com/h/pixeldroid/fragments/FeedRecyclerViewAdapter.kt
similarity index 96%
rename from app/src/main/java/com/h/pixeldroid/FeedRecyclerViewAdapter.kt
rename to app/src/main/java/com/h/pixeldroid/fragments/FeedRecyclerViewAdapter.kt
index 074b84ba..054066cc 100644
--- a/app/src/main/java/com/h/pixeldroid/FeedRecyclerViewAdapter.kt
+++ b/app/src/main/java/com/h/pixeldroid/fragments/FeedRecyclerViewAdapter.kt
@@ -1,17 +1,15 @@
-package com.h.pixeldroid
+package com.h.pixeldroid.fragments
import android.content.Context
import android.graphics.Typeface
-import android.graphics.drawable.Drawable
import android.util.DisplayMetrics
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
-import androidx.annotation.Dimension
+import com.h.pixeldroid.R
import com.h.pixeldroid.models.Post
import com.h.pixeldroid.utils.ImageConverter.Companion.setDefaultImage
import com.h.pixeldroid.utils.ImageConverter.Companion.setImageViewFromURL
diff --git a/app/src/main/java/com/h/pixeldroid/fragments/HomeFragment.kt b/app/src/main/java/com/h/pixeldroid/fragments/HomeFragment.kt
index 16ce0193..36d1d401 100644
--- a/app/src/main/java/com/h/pixeldroid/fragments/HomeFragment.kt
+++ b/app/src/main/java/com/h/pixeldroid/fragments/HomeFragment.kt
@@ -12,7 +12,6 @@ import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.h.pixeldroid.BuildConfig
-import com.h.pixeldroid.FeedRecyclerViewAdapter
import com.h.pixeldroid.R
import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.models.Post
@@ -56,7 +55,7 @@ class HomeFragment : Fragment() {
var statuses: ArrayList? = null
val newPosts = ArrayList()
- pixelfedAPI.timelinePublic(null, null, null, null, null)
+ pixelfedAPI.timelineHome("Bearer $accessToken")
.enqueue(object : Callback> {
override fun onResponse(call: Call>, response: Response>) {
if (response.code() == 200) {
@@ -66,14 +65,13 @@ class HomeFragment : Fragment() {
newPosts.add(Post(status))
}
setContent(newPosts)
- Log.e("POSTS", newPosts.toString())
}
}
}
override fun onFailure(call: Call>, t: Throwable) {
- Log.e("Ouch, not OK", t.toString())
+ Log.e("HomeFragment", t.toString())
}
})
}
diff --git a/app/src/main/res/layout/activity_feed.xml b/app/src/main/res/layout/activity_feed.xml
deleted file mode 100644
index 3f7587b9..00000000
--- a/app/src/main/res/layout/activity_feed.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_feed_list.xml b/app/src/main/res/layout/fragment_feed_list.xml
index ecdeeee7..2762d35b 100644
--- a/app/src/main/res/layout/fragment_feed_list.xml
+++ b/app/src/main/res/layout/fragment_feed_list.xml
@@ -9,5 +9,4 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
- tools:context=".FeedActivity"
tools:listitem="@layout/post_fragment" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index 9e7ee06d..6977f662 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -14,7 +14,6 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
- tools:context=".FeedActivity"
tools:listitem="@layout/post_fragment" />
android:id="@+id/postPicture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:src="@drawable/ic_launcher_foreground"
app:layout_constraintTop_toTopOf="parent" />