Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Tobias Kaminsky 2024-09-26 03:38:32 +02:00
commit c132553521
7 changed files with 162 additions and 91 deletions

View file

@ -49,7 +49,7 @@ jobs:
repository: ${{ steps.get-vars.outputs.repo }} repository: ${{ steps.get-vars.outputs.repo }}
ref: ${{ steps.get-vars.outputs.branch }} ref: ${{ steps.get-vars.outputs.branch }}
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0 uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with: with:
distribution: "temurin" distribution: "temurin"
java-version: 17 java-version: 17

View file

@ -39,11 +39,11 @@ jobs:
with: with:
swap-size-gb: 10 swap-size-gb: 10
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 uses: github/codeql-action/init@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0 uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with: with:
distribution: "temurin" distribution: "temurin"
java-version: 17 java-version: 17
@ -53,4 +53,4 @@ jobs:
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
./gradlew assembleDebug ./gradlew assembleDebug
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 uses: github/codeql-action/analyze@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9

View file

@ -42,6 +42,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard. # Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning" - name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
with: with:
sarif_file: results.sarif sarif_file: results.sarif

View file

@ -1,6 +1,7 @@
/* /*
* Nextcloud - Android Client * Nextcloud - Android Client
* *
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me> * SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com> * SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com>
* SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com> * SPDX-FileCopyrightText: 2020 Chris Narkiewicz <hello@ezaquarii.com>
@ -8,7 +9,13 @@
*/ */
package com.owncloud.android.ui.fragment package com.owncloud.android.ui.fragment
import androidx.test.espresso.intent.rule.IntentsTestRule import androidx.annotation.UiThread
import androidx.test.core.app.launchActivity
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import com.nextcloud.test.TestActivity import com.nextcloud.test.TestActivity
import com.nextcloud.ui.ImageDetailFragment import com.nextcloud.ui.ImageDetailFragment
import com.owncloud.android.AbstractIT import com.owncloud.android.AbstractIT
@ -18,80 +25,111 @@ import com.owncloud.android.lib.resources.activities.model.Activity
import com.owncloud.android.lib.resources.activities.model.RichElement import com.owncloud.android.lib.resources.activities.model.RichElement
import com.owncloud.android.lib.resources.activities.model.RichObject import com.owncloud.android.lib.resources.activities.model.RichObject
import com.owncloud.android.lib.resources.activities.models.PreviewObject import com.owncloud.android.lib.resources.activities.models.PreviewObject
import com.owncloud.android.utils.EspressoIdlingResource
import com.owncloud.android.utils.ScreenshotTest import com.owncloud.android.utils.ScreenshotTest
import org.junit.Rule import org.junit.After
import org.junit.Before
import org.junit.Test import org.junit.Test
import java.io.File
import java.util.GregorianCalendar import java.util.GregorianCalendar
class FileDetailFragmentStaticServerIT : AbstractIT() { class FileDetailFragmentStaticServerIT : AbstractIT() {
@get:Rule private val testClassName = "com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT"
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
var file = getFile("gps.jpg") @Before
val oCFile = OCFile("/").apply { fun registerIdlingResource() {
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
}
@After
fun unregisterIdlingResource() {
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
}
private var file: File = getFile("gps.jpg")
private val oCFile: OCFile = OCFile("/").apply {
storagePath = file.absolutePath storagePath = file.absolutePath
fileId = 12 fileId = 12
fileDataStorageManager.saveFile(this) fileDataStorageManager.saveFile(this)
} }
@Test @Test
@UiThread
@ScreenshotTest @ScreenshotTest
fun showFileDetailActivitiesFragment() { fun showFileDetailActivitiesFragment() {
val sut = testActivityRule.launchActivity(null) launchActivity<TestActivity>().use { scenario ->
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user)) scenario.onActivity { sut ->
onIdleSync {
EspressoIdlingResource.increment()
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user))
EspressoIdlingResource.decrement()
waitForIdleSync() val screenShotName = createName(testClassName + "_" + "showFileDetailActivitiesFragment", "")
shortSleep() onView(isRoot()).check(matches(isDisplayed()))
shortSleep() screenshotViaName(sut, screenShotName)
screenshot(sut) }
}
}
} }
@Test @Test
@UiThread
@ScreenshotTest @ScreenshotTest
fun showFileDetailSharingFragment() { fun showFileDetailSharingFragment() {
val sut = testActivityRule.launchActivity(null) launchActivity<TestActivity>().use { scenario ->
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user)) scenario.onActivity { sut ->
onIdleSync {
EspressoIdlingResource.increment()
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user))
EspressoIdlingResource.decrement()
waitForIdleSync() val screenShotName = createName(testClassName + "_" + "showFileDetailSharingFragment", "")
shortSleep() onView(isRoot()).check(matches(isDisplayed()))
shortSleep() screenshotViaName(sut, screenShotName)
screenshot(sut) }
}
}
} }
@Test @Test
@UiThread
@ScreenshotTest @ScreenshotTest
fun showFileDetailDetailsFragment() { fun showFileDetailDetailsFragment() {
val activity = testActivityRule.launchActivity(null) launchActivity<TestActivity>().use { scenario ->
val sut = ImageDetailFragment.newInstance(oCFile, user) scenario.onActivity { sut ->
activity.addFragment(sut) onIdleSync {
EspressoIdlingResource.increment()
val fragment = ImageDetailFragment.newInstance(oCFile, user).apply {
hideMap()
}
sut.addFragment(fragment)
EspressoIdlingResource.decrement()
shortSleep() val screenShotName = createName(testClassName + "_" + "showFileDetailDetailsFragment", "")
shortSleep() onView(isRoot()).check(matches(isDisplayed()))
waitForIdleSync() screenshotViaName(sut, screenShotName)
}
activity.runOnUiThread { }
sut.hideMap()
} }
screenshot(activity)
} }
@Test @Test
@UiThread
@ScreenshotTest @ScreenshotTest
@Suppress("MagicNumber") @Suppress("MagicNumber")
fun showDetailsActivities() { fun showDetailsActivities() {
val date = GregorianCalendar() val date = GregorianCalendar().apply {
date.set(2005, 4, 17, 10, 35, 30) // random date set(2005, 4, 17, 10, 35, 30)
}
val richObjectList: ArrayList<RichObject> = ArrayList() val richObjectList = ArrayList<RichObject>().apply {
richObjectList.add(RichObject("file", "abc", "text.txt", "/text.txt", "link", "tag")) add(RichObject("file", "abc", "text.txt", "/text.txt", "link", "tag"))
richObjectList.add(RichObject("file", "1", "text.txt", "/text.txt", "link", "tag")) add(RichObject("file", "1", "text.txt", "/text.txt", "link", "tag"))
}
val previewObjectList1: ArrayList<PreviewObject> = ArrayList() val previewObjectList1 = ArrayList<PreviewObject>().apply {
previewObjectList1.add(PreviewObject(1, "source", "link", true, "text/plain", "view", "text.txt")) add(PreviewObject(1, "source", "link", true, "text/plain", "view", "text.txt"))
}
val richObjectList2: ArrayList<RichObject> = ArrayList()
richObjectList2.add(RichObject("user", "admin", "Admin", "", "", ""))
val activities = mutableListOf( val activities = mutableListOf(
Activity( Activity(
@ -132,67 +170,85 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
) )
) )
val sut = FileDetailFragment.newInstance(oCFile, user, 0) launchActivity<TestActivity>().use { scenario ->
testActivityRule.launchActivity(null).apply { scenario.onActivity { sut ->
addFragment(sut) onIdleSync {
waitForIdleSync() EspressoIdlingResource.increment()
runOnUiThread { val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
sut.fileDetailActivitiesFragment.populateList(activities as List<Any>?, true) sut.addFragment(fragment)
fragment.fileDetailActivitiesFragment.populateList(activities as List<Any>?, true)
EspressoIdlingResource.decrement()
val screenShotName = createName(testClassName + "_" + "showDetailsActivities", "")
onView(isRoot()).check(matches(isDisplayed()))
screenshotViaName(sut, screenShotName)
}
} }
longSleep()
screenshot(sut.fileDetailActivitiesFragment.binding.swipeContainingList)
} }
} }
// @Test
// @ScreenshotTest
fun showDetailsActivitiesNone() {
val activity = testActivityRule.launchActivity(null)
val sut = FileDetailFragment.newInstance(oCFile, user, 0)
activity.addFragment(sut)
waitForIdleSync()
activity.runOnUiThread {
sut.fileDetailActivitiesFragment.populateList(emptyList(), true)
}
shortSleep()
shortSleep()
screenshot(sut.fileDetailActivitiesFragment.binding.list)
}
@Test @Test
@UiThread
@ScreenshotTest
fun showDetailsActivitiesNone() {
launchActivity<TestActivity>().use { scenario ->
scenario.onActivity { sut ->
onIdleSync {
EspressoIdlingResource.increment()
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
sut.addFragment(fragment)
fragment.fileDetailActivitiesFragment.populateList(emptyList(), true)
EspressoIdlingResource.decrement()
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesNone", "")
onView(isRoot()).check(matches(isDisplayed()))
screenshotViaName(sut, screenShotName)
}
}
}
}
@Test
@UiThread
@ScreenshotTest @ScreenshotTest
fun showDetailsActivitiesError() { fun showDetailsActivitiesError() {
val activity = testActivityRule.launchActivity(null) launchActivity<TestActivity>().use { scenario ->
val sut = FileDetailFragment.newInstance(oCFile, user, 0) scenario.onActivity { sut ->
activity.addFragment(sut) onIdleSync {
EspressoIdlingResource.increment()
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
sut.addFragment(fragment)
fragment.fileDetailActivitiesFragment.disableLoadingActivities()
fragment.fileDetailActivitiesFragment.setErrorContent(
targetContext.resources.getString(R.string.file_detail_activity_error)
)
EspressoIdlingResource.decrement()
waitForIdleSync() val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesError", "")
onView(isRoot()).check(matches(isDisplayed()))
activity.runOnUiThread { screenshotViaName(sut, screenShotName)
sut.fileDetailActivitiesFragment.disableLoadingActivities() }
sut }
.fileDetailActivitiesFragment
.setErrorContent(targetContext.resources.getString(R.string.file_detail_activity_error))
} }
shortSleep()
shortSleep()
screenshot(sut.fileDetailActivitiesFragment.binding.emptyList.emptyListView)
} }
@Test @Test
@UiThread
@ScreenshotTest @ScreenshotTest
fun showDetailsSharing() { fun showDetailsSharing() {
val sut = testActivityRule.launchActivity(null) launchActivity<TestActivity>().use { scenario ->
sut.addFragment(FileDetailFragment.newInstance(oCFile, user, 1)) scenario.onActivity { sut ->
onIdleSync {
EspressoIdlingResource.increment()
val fragment = FileDetailFragment.newInstance(oCFile, user, 1)
sut.addFragment(fragment)
EspressoIdlingResource.decrement()
waitForIdleSync() val screenShotName = createName(testClassName + "_" + "showDetailsSharing", "")
onView(isRoot()).check(matches(isDisplayed()))
shortSleep() screenshotViaName(sut, screenShotName)
shortSleep() }
screenshot(sut) }
}
} }
} }

View file

@ -411,9 +411,14 @@
<string name="file_migration_updating_index">تحديث الفهرس…</string> <string name="file_migration_updating_index">تحديث الفهرس…</string>
<string name="file_migration_use_data_folder">استعمل</string> <string name="file_migration_use_data_folder">استعمل</string>
<string name="file_migration_waiting_for_unfinished_sync">بإنتظار مزامنة كاملة…</string> <string name="file_migration_waiting_for_unfinished_sync">بإنتظار مزامنة كاملة…</string>
<string name="file_name_validator_current_path_is_invalid">الاسم الحالي للمجلد غير صالح. رجاءً، أعِد تسمية المجلد. جارٍ إعادة التوجيه لصفحة البداية ...</string>
<string name="file_name_validator_error_contains_reserved_names_or_invalid_characters">مسار المجلد يحتوي على أسماء محجوزة للنظام أو حروف غير مقبولة</string>
<string name="file_name_validator_error_forbidden_file_extensions">%s هو امتداد غير مسموح به</string> <string name="file_name_validator_error_forbidden_file_extensions">%s هو امتداد غير مسموح به</string>
<string name="file_name_validator_error_forbidden_space_character_extensions">أسماء الملفات يجب ألّا تحتوي على أي مسافات في بدايتها أو في نهايتها</string>
<string name="file_name_validator_error_invalid_character">يحتوي الاسم على حروف غير مقبولة: %s</string>
<string name="file_name_validator_error_reserved_names">%s اسم ممنوع</string> <string name="file_name_validator_error_reserved_names">%s اسم ممنوع</string>
<string name="file_name_validator_rename_before_move_or_copy">%s. قُم رجاءً بتغيير اسم الملف قبل نقله أو نسخه</string> <string name="file_name_validator_rename_before_move_or_copy">%s. قُم رجاءً بتغيير اسم الملف قبل نقله أو نسخه</string>
<string name="file_name_validator_upload_content_error">بعض المحتوى لا يمكن رفعه لأنه يحتوي إمّا على أسماء محجوزة للنظام أو على حروف غير مقبولة</string>
<string name="file_not_found">تعذر العثور على الملف</string> <string name="file_not_found">تعذر العثور على الملف</string>
<string name="file_not_synced">الملف لا يمكن مزامنته. عرض آخر إصدار متوفر.</string> <string name="file_not_synced">الملف لا يمكن مزامنته. عرض آخر إصدار متوفر.</string>
<string name="file_rename">إعادة التسمية</string> <string name="file_rename">إعادة التسمية</string>

View file

@ -411,9 +411,14 @@
<string name="file_migration_updating_index">Actualizando o índice…</string> <string name="file_migration_updating_index">Actualizando o índice…</string>
<string name="file_migration_use_data_folder">Usar</string> <string name="file_migration_use_data_folder">Usar</string>
<string name="file_migration_waiting_for_unfinished_sync">Agardando que rematen as sincronizacións…</string> <string name="file_migration_waiting_for_unfinished_sync">Agardando que rematen as sincronizacións…</string>
<string name="file_name_validator_current_path_is_invalid">O nome actual do cartafol non é válido, cambie o nome do cartafol. Redirixindo ao cartafol principal…</string>
<string name="file_name_validator_error_contains_reserved_names_or_invalid_characters">A ruta do cartafol contén nomes reservados ou caracteres non válidos</string>
<string name="file_name_validator_error_forbidden_file_extensions">.%s é unha extensión de ficheiro prohibida</string> <string name="file_name_validator_error_forbidden_file_extensions">.%s é unha extensión de ficheiro prohibida</string>
<string name="file_name_validator_error_forbidden_space_character_extensions">Os nomes de ficheiros non deben conter espazos nin no principio nin no final</string>
<string name="file_name_validator_error_invalid_character">O nome contén caracteres non válidos: %s</string>
<string name="file_name_validator_error_reserved_names">%s é un nome prohibido.</string> <string name="file_name_validator_error_reserved_names">%s é un nome prohibido.</string>
<string name="file_name_validator_rename_before_move_or_copy">%s. Cambie o nome do ficheiro antes de mover ou copiar</string> <string name="file_name_validator_rename_before_move_or_copy">%s. Cambie o nome do ficheiro antes de mover ou copiar</string>
<string name="file_name_validator_upload_content_error">Non é posíbel enviar algún contido porque contén nomes reservados ou caracteres non válidos</string>
<string name="file_not_found">Non se atopou o ficheiro</string> <string name="file_not_found">Non se atopou o ficheiro</string>
<string name="file_not_synced">Non foi posíbel sincronizar o ficheiro. Amosase a última versión dispoñíbel.</string> <string name="file_not_synced">Non foi posíbel sincronizar o ficheiro. Amosase a última versión dispoñíbel.</string>
<string name="file_rename">Cambiar o nome</string> <string name="file_rename">Cambiar o nome</string>

View file

@ -411,9 +411,14 @@
<string name="file_migration_updating_index">正在更新索引……</string> <string name="file_migration_updating_index">正在更新索引……</string>
<string name="file_migration_use_data_folder">使用</string> <string name="file_migration_use_data_folder">使用</string>
<string name="file_migration_waiting_for_unfinished_sync">正在等待完全同步……</string> <string name="file_migration_waiting_for_unfinished_sync">正在等待完全同步……</string>
<string name="file_name_validator_current_path_is_invalid">目前資料夾名稱無效,請重新命名資料夾。重新導向到家目錄……</string>
<string name="file_name_validator_error_contains_reserved_names_or_invalid_characters">資料夾路徑包含保留名稱或無效字元</string>
<string name="file_name_validator_error_forbidden_file_extensions">%s 是禁止使用的副檔名</string> <string name="file_name_validator_error_forbidden_file_extensions">%s 是禁止使用的副檔名</string>
<string name="file_name_validator_error_forbidden_space_character_extensions">檔案名稱不應包含開頭或結尾空白</string>
<string name="file_name_validator_error_invalid_character">名稱包含了無效字元:%s</string>
<string name="file_name_validator_error_reserved_names">%s 是禁止的名稱</string> <string name="file_name_validator_error_reserved_names">%s 是禁止的名稱</string>
<string name="file_name_validator_rename_before_move_or_copy">%s。請在移動或複製前重新命名檔案</string> <string name="file_name_validator_rename_before_move_or_copy">%s。請在移動或複製前重新命名檔案</string>
<string name="file_name_validator_upload_content_error">部份內容因包含保留名稱或無效字元而無法上傳</string>
<string name="file_not_found">找不到檔案</string> <string name="file_not_found">找不到檔案</string>
<string name="file_not_synced">檔案無法同步,將顯示最新可用版本。</string> <string name="file_not_synced">檔案無法同步,將顯示最新可用版本。</string>
<string name="file_rename">重新命名</string> <string name="file_rename">重新命名</string>