-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from snuhcs-course/develop
Update latest features for UI testing
- Loading branch information
Showing
155 changed files
with
34,715 additions
and
1,367 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
This file was deleted.
Oops, something went wrong.
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
113 changes: 113 additions & 0 deletions
113
...p/src/androidTest/java/com/goliath/emojihub/data_sources/local/MediaDataSourceImplTest.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.goliath.emojihub.data_sources.local | ||
|
||
import android.media.MediaMetadataRetriever | ||
import android.net.Uri | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import io.mockk.every | ||
import io.mockk.mockkObject | ||
import org.junit.Assert.* | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.io.File | ||
import java.io.IOException | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class MediaDataSourceImplTest { | ||
private val context = InstrumentationRegistry.getInstrumentation().targetContext | ||
private val mediaDataSourceImpl = MediaDataSourceImpl(context) | ||
|
||
private fun getSampleVideoUri(videoFileName: String): Uri { | ||
val x3dDataSourceImpl = X3dDataSourceImpl(context) | ||
val sampleVideoAbsolutePath = x3dDataSourceImpl.assetFilePath(videoFileName) | ||
return Uri.fromFile(File(sampleVideoAbsolutePath)) | ||
} | ||
|
||
@Test | ||
fun loadVideoMediaMetadataRetriever_validVideoUri_returnsMediaMetadataRetriever() { | ||
// given | ||
val videoUri = getSampleVideoUri("Hagrid/test_palm_video.mp4") | ||
// when | ||
val mediaMetadataRetriever = mediaDataSourceImpl.loadVideoMediaMetadataRetriever(videoUri) | ||
// then | ||
assert(mediaMetadataRetriever is MediaMetadataRetriever) | ||
assertTrue( | ||
(mediaMetadataRetriever?.extractMetadata( | ||
MediaMetadataRetriever.METADATA_KEY_DURATION | ||
)?.toLong() ?: 0) > 0 | ||
) | ||
} | ||
|
||
@Test | ||
fun loadVideoMediaMetadataRetriever_invalidVideoUri_returnsNull() { | ||
// given | ||
val videoUri = Uri.EMPTY | ||
// when | ||
val mediaMetadataRetriever = mediaDataSourceImpl.loadVideoMediaMetadataRetriever(videoUri) | ||
// then | ||
assertNull(mediaMetadataRetriever) | ||
} | ||
|
||
@Test | ||
fun extractFrameImagesFromVideo_validMediaMetadataRetriever_returnsBitmapList() { | ||
// given | ||
val videoUri = getSampleVideoUri("Hagrid/test_palm_video.mp4") | ||
val mediaMetadataRetriever = mediaDataSourceImpl.loadVideoMediaMetadataRetriever(videoUri) | ||
// when | ||
val bitmapList = mediaDataSourceImpl | ||
.extractFrameImagesFromVideo(mediaMetadataRetriever!!, 1) | ||
// then | ||
assertEquals(1, bitmapList.size) | ||
} | ||
|
||
@Test | ||
fun extractFrameImagesFromVideo_errorOnLoadingVideo_returnsEmptyBitmapList() { | ||
// given | ||
val videoUri = getSampleVideoUri("Hagrid/test_palm_video.mp4") | ||
val mediaMetadataRetriever = mediaDataSourceImpl.loadVideoMediaMetadataRetriever(videoUri) | ||
mockkObject(mediaMetadataRetriever!!) | ||
every { | ||
mediaMetadataRetriever.getFrameAtTime(any(), any()) | ||
} throws IOException() | ||
// when | ||
val bitmapList = mediaDataSourceImpl | ||
.extractFrameImagesFromVideo(mediaMetadataRetriever, 1) | ||
// then | ||
assertTrue(bitmapList.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun bitmapToBase64Utf8_withBitmapImage_returnsBase64String() { | ||
// given | ||
val videoUri = getSampleVideoUri("Hagrid/test_palm_video.mp4") | ||
val mediaMetadataRetriever = mediaDataSourceImpl.loadVideoMediaMetadataRetriever(videoUri) | ||
val bitmapList = mediaDataSourceImpl | ||
.extractFrameImagesFromVideo(mediaMetadataRetriever!!, 1) | ||
// when | ||
val base64String = mediaDataSourceImpl.bitmapToBase64Utf8(bitmapList[0]) | ||
// then | ||
assertTrue(base64String.isNotEmpty()) | ||
} | ||
|
||
@Test | ||
fun getJSONObjectFromAssets_zeroShotClassNameToUnicodeFileName_returnsJSONObject() { | ||
// given | ||
val classNameToUnicodeFileName = "zero_shot_classname_to_unicode.json" | ||
// when | ||
val jsonObject = mediaDataSourceImpl.getJSONObjectFromAssets(classNameToUnicodeFileName) | ||
// then | ||
val likeUnicode = jsonObject?.getString("like") | ||
assertEquals("U+1F44D", likeUnicode) | ||
} | ||
|
||
@Test | ||
fun getJSONObjectFromAssets_invalidFileName_returnsNull() { | ||
// given | ||
val invalidFileName = "invalid_file_name.json" | ||
// when | ||
val jsonObject = mediaDataSourceImpl.getJSONObjectFromAssets(invalidFileName) | ||
// then | ||
assertNull(jsonObject) | ||
} | ||
} |
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
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
android/app/src/main/assets/zero_shot_classname_to_unicode.json
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 @@ | ||
{ | ||
"call": "U+1F919", | ||
"dislike": "U+1F645", | ||
"fist": "U+1F44A", | ||
"like": "U+1F44D", | ||
"mute": "U+1F92B", | ||
"ok": "U+1F646", | ||
"palm": "U+1F64B", | ||
"peace": "U+270C", | ||
"rock": "U+1F918", | ||
"stop": "U+270B" | ||
} |
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
4 changes: 2 additions & 2 deletions
4
android/app/src/main/java/com/goliath/emojihub/data_sources/BottomNavigationController.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
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.