-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
134 additions
and
32 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/FileProviderHelperTest.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,58 @@ | ||
/* | ||
* Copyright (C) 2013-2023 Federico Iosue ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package it.feio.android.omninotes.utils | ||
|
||
|
||
import android.net.Uri | ||
import androidx.core.net.toUri | ||
import it.feio.android.omninotes.OmniNotes.getAppContext | ||
import it.feio.android.omninotes.models.Attachment | ||
import it.feio.android.omninotes.testutils.BaseAndroidTestCase | ||
import it.feio.android.omninotes.utils.ConstantsBase.MIME_TYPE_IMAGE | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import java.io.File | ||
|
||
class FileProviderHelperTest : BaseAndroidTestCase() { | ||
|
||
@Test | ||
fun getShareableUri() { | ||
val file = File("/storage/emulated/0/Android/data/it.feio.android.omninotes/files/424242.png") | ||
assertTrue(file.createNewFile() || file.exists()) | ||
val attachment = Attachment(file.toUri(), MIME_TYPE_IMAGE) | ||
|
||
val res = FileProviderHelper.getShareableUri(attachment) | ||
|
||
assertNotNull(res) | ||
assertNotEquals(file.toUri(), res) | ||
assertTrue(res?.scheme.equals("content") && res?.authority.equals(getAppContext().packageName + ".authority")) | ||
|
||
file.deleteOnExit() | ||
} | ||
|
||
@Test | ||
fun getShareableUri_contentScheme() { | ||
val uri = "content://it.feio.android.omninotes.authority/external_files/Android/data/it.feio.android.omninotes/files/20230418_091959_730.jpeg" | ||
val attachment = Attachment(Uri.parse(uri), "") | ||
|
||
val res = FileProviderHelper.getShareableUri(attachment) | ||
|
||
assertEquals(uri, res) | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/IntentCheckerTest.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,35 @@ | ||
/* | ||
* Copyright (C) 2013-2023 Federico Iosue ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package it.feio.android.omninotes.utils; | ||
|
||
import android.content.Intent | ||
import android.provider.MediaStore.ACTION_IMAGE_CAPTURE | ||
import it.feio.android.omninotes.testutils.BaseAndroidTestCase | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
|
||
class IntentCheckerTest : BaseAndroidTestCase() { | ||
|
||
@Test | ||
fun resolveActivityPackage() { | ||
val res = IntentChecker.resolveActivityPackage(testContext, Intent(ACTION_IMAGE_CAPTURE)) | ||
assertTrue(res.isNotEmpty()) | ||
} | ||
|
||
} |
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
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