forked from nextcloud/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NMC-1929: Collabora related customization with test cases.
- Loading branch information
1 parent
9f7370f
commit 4b150ea
Showing
23 changed files
with
461 additions
and
78 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
app/src/androidTest/java/com/nmc/android/OCFileListBottomSheetDialogIT.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package com.nmc.android | ||
|
||
import android.os.Looper | ||
import androidx.activity.result.contract.ActivityResultContract | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.assertion.ViewAssertions.matches | ||
import androidx.test.espresso.intent.rule.IntentsTestRule | ||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed | ||
import androidx.test.espresso.matcher.ViewMatchers.withText | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.gson.Gson | ||
import com.nextcloud.client.device.DeviceInfo | ||
import com.nextcloud.client.documentscan.AppScanOptionalFeature | ||
import com.nextcloud.utils.EditorUtils | ||
import com.owncloud.android.AbstractIT | ||
import com.owncloud.android.datamodel.ArbitraryDataProvider | ||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl | ||
import com.owncloud.android.datamodel.OCFile | ||
import com.owncloud.android.lib.common.Creator | ||
import com.owncloud.android.lib.common.DirectEditing | ||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType | ||
import com.owncloud.android.ui.activity.FileDisplayActivity | ||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions | ||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog | ||
import com.owncloud.android.utils.MimeTypeUtil | ||
import com.owncloud.android.utils.theme.CapabilityUtils | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mockito.Mock | ||
import org.mockito.MockitoAnnotations | ||
|
||
class OCFileListBottomSheetDialogIT : AbstractIT() { | ||
|
||
@Mock | ||
private lateinit var actions: OCFileListBottomSheetActions | ||
|
||
@get:Rule | ||
val activityRule = IntentsTestRule(FileDisplayActivity::class.java, true, true) | ||
|
||
@Before | ||
fun setUp() { | ||
MockitoAnnotations.initMocks(this) | ||
} | ||
|
||
@Test | ||
fun validateCreateTextDocumentMenuOption() { | ||
if (Looper.myLooper() == null) { | ||
Looper.prepare() | ||
} | ||
|
||
val info = DeviceInfo() | ||
val ocFile = OCFile("/test.md") | ||
|
||
// add direct editing info | ||
val creatorMap = mutableMapOf<String, Creator>() | ||
creatorMap["1"] = Creator( | ||
"1", | ||
"md", | ||
"markdown file", | ||
".md", | ||
MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN, | ||
false | ||
) | ||
|
||
val directEditing = DirectEditing( | ||
creators = creatorMap | ||
) | ||
|
||
val json = Gson().toJson(directEditing) | ||
ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue( | ||
user.accountName, | ||
ArbitraryDataProvider.DIRECT_EDITING, | ||
json | ||
) | ||
|
||
val capability = activityRule.activity.capabilities | ||
capability.richDocuments = CapabilityBooleanType.TRUE | ||
capability.richDocumentsDirectEditing = CapabilityBooleanType.TRUE | ||
capability.richDocumentsTemplatesAvailable = CapabilityBooleanType.TRUE | ||
capability.accountName = user.accountName | ||
CapabilityUtils.updateCapability(capability) | ||
|
||
val appScanOptionalFeature: AppScanOptionalFeature = object : AppScanOptionalFeature() { | ||
override fun getScanContract(): ActivityResultContract<Unit, String?> { | ||
throw UnsupportedOperationException("Document scan is not available") | ||
} | ||
} | ||
|
||
val editorUtils = EditorUtils(ArbitraryDataProviderImpl(targetContext)) | ||
val sut = OCFileListBottomSheetDialog( | ||
activityRule.activity, | ||
actions, | ||
info, | ||
user, | ||
ocFile, | ||
activityRule.activity.themeUtils, | ||
activityRule.activity.viewThemeUtils, | ||
editorUtils, | ||
appScanOptionalFeature | ||
) | ||
|
||
activityRule.activity.runOnUiThread { sut.show() } | ||
|
||
waitForIdleSync() | ||
|
||
sut.behavior.state = BottomSheetBehavior.STATE_EXPANDED | ||
|
||
shortSleep() | ||
|
||
onView(withText("Create text document")).check(matches(isCompletelyDisplayed())) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M4,21.75a3,3 0,0 1,-3 -3L1,2.25L7.5,2.25a3.65,3.65 0,0 1,2.7 1.2l0.45,0.45a1.43,1.43 0,0 0,0.85 0.35L23,4.25v14.5a3,3 0,0 1,-3 3ZM2.5,18.75a1.46,1.46 0,0 0,1.43 1.5L20,20.25a1.47,1.47 0,0 0,1.5 -1.44L21.5,5.75h-10A2.57,2.57 0,0 1,9.6 4.9l-0.45,-0.45a2.38,2.38 0,0 0,-1.65 -0.7h-5Z" | ||
android:fillColor="#262626"/> | ||
<path | ||
android:pathData="M14.14,16.56L9.86,16.56a1.07,1.07 0,0 1,-1.07 -1.08L8.79,12.09h0.89v-0.71a2.32,2.32 0,0 1,4.64 0v0.71h0.89v3.39A1.07,1.07 0,0 1,14.14 16.56ZM12,13.56a0.54,0.54 0,0 0,-0.54 0.53,0.55 0.55,0 0,0 0.18,0.4v0.68h0.72v-0.68a0.53,0.53 0,0 0,0 -0.75A0.52,0.52 0,0 0,12 13.52ZM12,9.63a1.79,1.79 0,0 0,-1.79 1.79v0.71h3.58v-0.71A1.79,1.79 0,0 0,12 9.59Z" | ||
android:fillColor="#262626"/> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M17.75,0.5L8,0.5L8,3.5L5,3.5L5,6.5L2,6.5L2,21.25C2,22.4925 3.0075,23.5 4.25,23.5L13.25,23.5C14.4925,23.5 15.5,22.4925 15.5,21.25L15.5,20.5L16.25,20.5C17.4925,20.5 18.5,19.4925 18.5,18.25L18.5,17.5L19.25,17.5C20.4925,17.5 21.5,16.4925 21.5,15.25L21.5,4.3635L17.75,0.5ZM14,21.25C14,21.6635 13.6635,22 13.25,22L4.25,22C3.8365,22 3.5,21.6635 3.5,21.25L3.5,8L5,8L5,18.25C5,19.4925 6.0075,20.5 7.25,20.5L14,20.5L14,21.25ZM17,18.25C17,18.6635 16.6635,19 16.25,19L7.25,19C6.8365,19 6.5,18.6635 6.5,18.25L6.5,5L8,5L8,15.25C8,16.4925 9.0075,17.5 10.25,17.5L17,17.5L17,18.25ZM19.25,16L10.25,16C9.8365,16 9.5,15.6635 9.5,15.25L9.5,2L16,2L16,4.1705C16,4.9045 16.595,5.5 17.3295,5.5L20,5.5L20,15.25C20,15.6635 19.6635,16 19.25,16Z" | ||
android:strokeWidth="1" | ||
android:fillColor="#262626" | ||
android:fillType="nonZero" | ||
android:strokeColor="#00000000"/> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<group> | ||
<clip-path | ||
android:pathData="M3,1l17.9997,0l0,22l-17.9997,0z"/> | ||
<path | ||
android:pathData="M4.4997,20C4.4997,20.828 5.1717,21.5 5.9997,21.5L14.9997,21.5L14.9997,18.5C14.9997,17.672 15.6717,17 16.4997,17L19.4997,17L19.4997,2.5L4.4997,2.5L4.4997,20ZM5.9997,23C4.3437,23 2.9997,21.657 2.9997,20L2.9997,1L20.9997,1L20.9997,18L15.9997,23L5.9997,23Z" | ||
android:strokeWidth="1" | ||
android:fillColor="#262626" | ||
android:fillType="evenOdd" | ||
android:strokeColor="#00000000"/> | ||
</group> | ||
<path | ||
android:pathData="M8.0817,14.8262C7.6757,14.8262 7.3467,14.4972 7.3467,14.0912C7.3467,13.6842 7.6757,13.3552 8.0817,13.3552L15.9187,13.3552C16.3247,13.3552 16.6537,13.6842 16.6537,14.0912C16.6537,14.4972 16.3247,14.8262 15.9187,14.8262L8.0817,14.8262Z" | ||
android:strokeWidth="1" | ||
android:fillColor="#262626" | ||
android:fillType="evenOdd" | ||
android:strokeColor="#00000000"/> | ||
<path | ||
android:pathData="M8.0817,11.397C7.6757,11.397 7.3467,11.068 7.3467,10.662C7.3467,10.256 7.6757,9.927 8.0817,9.927L15.9187,9.927C16.3247,9.927 16.6537,10.256 16.6537,10.662C16.6537,11.068 16.3247,11.397 15.9187,11.397L8.0817,11.397Z" | ||
android:strokeWidth="1" | ||
android:fillColor="#262626" | ||
android:fillType="evenOdd" | ||
android:strokeColor="#00000000"/> | ||
<path | ||
android:pathData="M8.0817,7.9678C7.6757,7.9678 7.3477,7.6388 7.3477,7.2338C7.3477,6.8278 7.6757,6.4988 8.0817,6.4988L15.9187,6.4988C16.3237,6.4988 16.6527,6.8278 16.6527,7.2338C16.6527,7.6388 16.3237,7.9678 15.9187,7.9678L8.0817,7.9678Z" | ||
android:strokeWidth="1" | ||
android:fillColor="#262626" | ||
android:fillType="evenOdd" | ||
android:strokeColor="#00000000"/> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M2.5,1L2.5,20C2.5,21.65 3.85,23 5.5,23L15.5,23L20.5,18L20.5,1L2.5,1ZM4,20L4,2.5L19,2.5L19,17L16,17C15.15,17 14.5,17.65 14.5,18.5L14.5,21.5L5.5,21.5C4.65,21.5 4,20.85 4,20Z" | ||
android:strokeWidth="1" | ||
android:fillColor="#262626" | ||
android:fillType="evenOdd" | ||
android:strokeColor="#00000000"/> | ||
</vector> |
This file contains 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
Oops, something went wrong.