At least make integration tests compile
This commit is contained in:
parent
1268f5c977
commit
fe08782803
|
@ -4,6 +4,7 @@ import android.Manifest
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.Intent.ACTION_CHOOSER
|
||||
import android.widget.ImageButton
|
||||
import androidx.fragment.app.testing.launchFragmentInContainer
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.espresso.intent.Intents
|
||||
|
@ -14,7 +15,6 @@ import com.h.pixeldroid.utils.db.entities.UserDatabaseEntity
|
|||
import com.h.pixeldroid.postCreation.camera.CameraFragment
|
||||
import com.h.pixeldroid.testUtility.clearData
|
||||
import com.h.pixeldroid.testUtility.initDB
|
||||
import kotlinx.android.synthetic.main.camera_ui_container.*
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.hamcrest.Matcher
|
||||
import org.junit.After
|
||||
|
@ -50,9 +50,9 @@ class CameraTest {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
@ -88,7 +88,7 @@ class CameraTest {
|
|||
|
||||
val scenario = launchFragmentInContainer<CameraFragment>()
|
||||
scenario.onFragment { fragment ->
|
||||
fragment.photo_view_button.performClick()
|
||||
fragment.view?.findViewById<ImageButton>(R.id.photo_view_button)?.performClick()
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
|
||||
|
@ -102,7 +102,7 @@ class CameraTest {
|
|||
fun switchButton() {
|
||||
val scenario = launchFragmentInContainer<CameraFragment>()
|
||||
scenario.onFragment { fragment ->
|
||||
fragment.camera_switch_button.performClick()
|
||||
fragment.view?.findViewById<ImageButton>(R.id.camera_switch_button)?.performClick()
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
scenario.onFragment { fragment ->
|
||||
|
|
|
@ -61,9 +61,9 @@ class DrawerMenuTest {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
@ -132,8 +132,7 @@ class DrawerMenuTest {
|
|||
onView(withText(R.string.menu_account)).perform(click())
|
||||
// Check that profile activity was opened.
|
||||
onView(withId(R.id.editButton)).check(matches(isDisplayed()))
|
||||
val followersText = context.getString(R.string.nb_followers)
|
||||
.format(68)
|
||||
val followersText = context.resources.getQuantityString(R.plurals.nb_followers, 68)
|
||||
onView(withText(followersText)).perform(click())
|
||||
onView(withText("Dobios")).check(matches(isDisplayed()))
|
||||
}
|
||||
|
@ -144,8 +143,7 @@ class DrawerMenuTest {
|
|||
onView(withText(R.string.menu_account)).perform(click())
|
||||
// Check that profile activity was opened.
|
||||
onView(withId(R.id.editButton)).check(matches(isDisplayed()))
|
||||
val followingText = context.getString(R.string.nb_following)
|
||||
.format(27)
|
||||
val followingText = context.resources.getQuantityString(R.plurals.nb_followers, 27)
|
||||
onView(withText(followingText)).perform(click())
|
||||
onView(withText("Dobios")).check(matches(isDisplayed()))
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
|||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.h.pixeldroid.adapters.ThumbnailAdapter
|
||||
import com.h.pixeldroid.postCreation.photoEdit.PhotoEditActivity
|
||||
import com.h.pixeldroid.postCreation.photoEdit.ThumbnailAdapter
|
||||
import com.h.pixeldroid.settings.AboutActivity
|
||||
import com.h.pixeldroid.testUtility.CustomMatchers
|
||||
import com.h.pixeldroid.testUtility.clearData
|
||||
import junit.framework.Assert.assertTrue
|
||||
import kotlinx.android.synthetic.main.fragment_edit_image.*
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.junit.*
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.rules.Timeout
|
||||
import org.junit.runner.RunWith
|
||||
import java.io.File
|
||||
|
@ -141,9 +141,9 @@ class EditPhotoTest {
|
|||
Espresso.onView(withId(R.id.seekbar_contrast)).perform(setProgress(change))
|
||||
Espresso.onView(withId(R.id.seekbar_saturation)).perform(setProgress(change))
|
||||
|
||||
Assert.assertEquals(change, activity.seekbar_brightness.progress)
|
||||
Assert.assertEquals(change, activity.seekbar_contrast.progress)
|
||||
Assert.assertEquals(change, activity.seekbar_saturation.progress)
|
||||
Assert.assertEquals(change, activity.findViewById<SeekBar>(R.id.seekbar_brightness).progress)
|
||||
Assert.assertEquals(change, activity.findViewById<SeekBar>(R.id.seekbar_contrast).progress)
|
||||
Assert.assertEquals(change, activity.findViewById<SeekBar>(R.id.seekbar_saturation).progress)
|
||||
|
||||
Thread.sleep(1000)
|
||||
|
||||
|
@ -152,9 +152,9 @@ class EditPhotoTest {
|
|||
Espresso.onView(withId(R.id.seekbar_contrast)).perform(setProgress(change))
|
||||
Espresso.onView(withId(R.id.seekbar_saturation)).perform(setProgress(change))
|
||||
|
||||
Assert.assertEquals(change, activity.seekbar_brightness.progress)
|
||||
Assert.assertEquals(change, activity.seekbar_contrast.progress)
|
||||
Assert.assertEquals(change, activity.seekbar_saturation.progress)
|
||||
Assert.assertEquals(change, activity.findViewById<SeekBar>(R.id.seekbar_brightness).progress)
|
||||
Assert.assertEquals(change, activity.findViewById<SeekBar>(R.id.seekbar_contrast).progress)
|
||||
Assert.assertEquals(change, activity.findViewById<SeekBar>(R.id.seekbar_saturation).progress)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -181,7 +181,7 @@ class EditPhotoTest {
|
|||
@Test
|
||||
fun alreadyUploadingDialog() {
|
||||
activityScenario.onActivity { a -> a.saving = true }
|
||||
Espresso.onView(withId(R.id.action_upload)).perform(click())
|
||||
Espresso.onView(withId(R.id.action_save)).perform(click())
|
||||
Thread.sleep(1000)
|
||||
Espresso.onView(withText(R.string.busy_dialog_text)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
|
|
@ -68,9 +68,9 @@ class HomeFeedTest {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
|
|
@ -85,9 +85,9 @@ class IntentTest {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
|
|
@ -124,9 +124,9 @@ class LoginActivityOnlineTest {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.h.pixeldroid
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.Intent.ACTION_VIEW
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
|
@ -28,8 +27,6 @@ import org.junit.runner.RunWith
|
|||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LoginCheckIntent {
|
||||
private lateinit var context: Context
|
||||
|
||||
|
||||
@get:Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(100)
|
||||
|
|
|
@ -16,13 +16,13 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
|||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.h.pixeldroid.utils.db.AppDatabase
|
||||
import com.h.pixeldroid.utils.db.entities.InstanceDatabaseEntity
|
||||
import com.h.pixeldroid.utils.db.entities.UserDatabaseEntity
|
||||
import com.h.pixeldroid.testUtility.MockServer
|
||||
import com.h.pixeldroid.testUtility.clearData
|
||||
import com.h.pixeldroid.testUtility.initDB
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import org.hamcrest.Matcher
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
|
@ -96,9 +96,9 @@ class PostFragmentUITests {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
@ -114,7 +114,7 @@ class PostFragmentUITests {
|
|||
@Test
|
||||
fun newPostUiTest() {
|
||||
ActivityScenario.launch(MainActivity::class.java).onActivity {
|
||||
a -> a.tabs.getTabAt(2)!!.select()
|
||||
it.findViewById<TabLayout>(R.id.tabs).getTabAt(2)!!.select()
|
||||
}
|
||||
Thread.sleep(1500)
|
||||
onView(withId(R.id.photo_view_button)).check(matches(isDisplayed()))
|
||||
|
|
|
@ -63,9 +63,9 @@ class PostTest {
|
|||
avatar_static = "some_avatar_url",
|
||||
isActive = true,
|
||||
accessToken = "token",
|
||||
refreshToken = refreshToken,
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
refreshToken = "refreshToken",
|
||||
clientId = "clientId",
|
||||
clientSecret = "clientSecret"
|
||||
)
|
||||
)
|
||||
db.close()
|
||||
|
@ -76,14 +76,15 @@ class PostTest {
|
|||
fun saveToGalleryTestSimplePost() {
|
||||
val attachment = Attachment(
|
||||
id = "12",
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png"
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png",
|
||||
meta = null
|
||||
)
|
||||
val post = Status(
|
||||
id = "12",
|
||||
account = Account(
|
||||
id = "12",
|
||||
username = "douze",
|
||||
url = "https://pixelfed.de/douze"
|
||||
url = "https://pixelfed.de/douze",
|
||||
),
|
||||
media_attachments = listOf(attachment)
|
||||
)
|
||||
|
@ -106,11 +107,13 @@ class PostTest {
|
|||
fun saveToGalleryTestAlbum() {
|
||||
val attachment1 = Attachment(
|
||||
id = "12",
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png"
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png",
|
||||
meta = null
|
||||
)
|
||||
val attachment2 = Attachment(
|
||||
id = "13",
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png"
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png",
|
||||
meta = null
|
||||
)
|
||||
val post = Status(
|
||||
id = "12",
|
||||
|
@ -141,14 +144,15 @@ class PostTest {
|
|||
val expectedIntent: Matcher<Intent> = IntentMatchers.hasAction(Intent.ACTION_CHOOSER)
|
||||
val attachment = Attachment(
|
||||
id = "12",
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png"
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png",
|
||||
meta = null
|
||||
)
|
||||
val post = Status(
|
||||
id = "12",
|
||||
account = Account(
|
||||
id = "12",
|
||||
username = "douze",
|
||||
url = "https://pixelfed.de/douze"
|
||||
url = "https://pixelfed.de/douze",
|
||||
),
|
||||
media_attachments = listOf(attachment)
|
||||
)
|
||||
|
@ -166,11 +170,13 @@ class PostTest {
|
|||
val expectedIntent: Matcher<Intent> = IntentMatchers.hasAction(Intent.ACTION_CHOOSER)
|
||||
val attachment1 = Attachment(
|
||||
id = "12",
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png"
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png",
|
||||
meta = null
|
||||
)
|
||||
val attachment2 = Attachment(
|
||||
id = "13",
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png"
|
||||
url = "https://wiki.gnugen.ch/lib/tpl/gnugen/images/logo_web.png",
|
||||
meta = null
|
||||
)
|
||||
val post = Status(
|
||||
id = "12",
|
||||
|
@ -208,7 +214,7 @@ class PostTest {
|
|||
media_attachments= listOf(
|
||||
Attachment(id="15888", type= Attachment.AttachmentType.image, url="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg",
|
||||
preview_url="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg",
|
||||
remote_url=null, text_url=null, description=null, blurhash=null)
|
||||
remote_url=null, text_url=null, description=null, blurhash=null, meta = null)
|
||||
),
|
||||
application= Application(name="web", website=null, vapid_key=null), mentions=emptyList(),
|
||||
tags= listOf(Tag(name="hiking", url="https://pixelfed.de/discover/tags/hiking", history=null), Tag(name="nature", url="https://pixelfed.de/discover/tags/nature", history=null), Tag(name="rotavicentina", url="https://pixelfed.de/discover/tags/rotavicentina", history=null)),
|
||||
|
@ -235,7 +241,7 @@ class PostTest {
|
|||
media_attachments= listOf(
|
||||
Attachment(id="15888", type= Attachment.AttachmentType.image, url="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB.jpeg",
|
||||
preview_url="https://pixelfed.de/storage/m/113a3e2124a33b1f5511e531953f5ee48456e0c7/34dd6d9fb1762dac8c7ddeeaf789d2d8fa083c9f/JtjO0eAbELpgO1UZqF5ydrKbCKRVyJUM1WAaqIeB_thumb.jpeg",
|
||||
remote_url=null, text_url=null, description=null, blurhash=null)
|
||||
remote_url=null, text_url=null, description=null, blurhash=null, meta = null)
|
||||
),
|
||||
application= Application(name="web", website=null, vapid_key=null), mentions=emptyList(),
|
||||
tags= listOf(Tag(name="hiking", url="https://pixelfed.de/discover/tags/hiking", history=null), Tag(name="nature", url="https://pixelfed.de/discover/tags/nature", history=null), Tag(name="rotavicentina", url="https://pixelfed.de/discover/tags/rotavicentina", history=null)),
|
||||
|
|
|
@ -49,7 +49,7 @@ private val REQUIRED_PERMISSIONS = arrayOf(
|
|||
|
||||
class PhotoEditActivity : BaseActivity() {
|
||||
|
||||
private var saving: Boolean = false
|
||||
var saving: Boolean = false
|
||||
private val BITMAP_CONFIG = Bitmap.Config.ARGB_8888
|
||||
private val BRIGHTNESS_START = 0
|
||||
private val SATURATION_START = 1.0f
|
||||
|
|
Loading…
Reference in New Issue