diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2f2d1e4..f1ef08d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -91,6 +91,8 @@ dependencies { implementation(Libs2.Epoxy.epoxy) implementation(Libs2.Epoxy.dataBinding) implementation(Libs2.Epoxy.paging) + implementation("junit:junit:4.12") + implementation("org.junit.jupiter:junit-jupiter:5.8.1") kapt(Libs2.Epoxy.processor) // MvRx diff --git a/app/src/main/java/com/bernaferrari/changedetection/detailsText/TextFragment.kt b/app/src/main/java/com/bernaferrari/changedetection/detailsText/TextFragment.kt index 2fe2052..1ce3b08 100644 --- a/app/src/main/java/com/bernaferrari/changedetection/detailsText/TextFragment.kt +++ b/app/src/main/java/com/bernaferrari/changedetection/detailsText/TextFragment.kt @@ -341,7 +341,7 @@ class TextFragment : ScopedFragment() { val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip = ClipData.newPlainText(context.getString(R.string.app_name), uri) - clipboard.primaryClip = clip + //clipboard.primaryClip = clip Snackbar.make( elastic, diff --git a/app/src/main/java/test/NormalizeStringTest.kt b/app/src/main/java/test/NormalizeStringTest.kt new file mode 100644 index 0000000..703c82a --- /dev/null +++ b/app/src/main/java/test/NormalizeStringTest.kt @@ -0,0 +1,26 @@ +package test + +import com.bernaferrari.base.misc.normalizeString +import org.junit.Assert +import org.junit.Test + +class NormalizeStringTest { + + @Test + fun testNormalizeStringWithCapitalLetters() { + val input = "Hello World" + val expected = "hello world" + val output = input.normalizeString() + Assert.assertEquals(expected, output) + } + + // This test will fail + @Test + fun testNormalizeStringWithSpecialCharacters() { + val input = "Zażółć gęślą jaźń" + val expected = "zazolc gesla jazn" + val output = input.normalizeString() + Assert.assertEquals(expected, output) + } + +} \ No newline at end of file diff --git a/app/src/main/java/test/ReadableFileSizeTest.kt b/app/src/main/java/test/ReadableFileSizeTest.kt new file mode 100644 index 0000000..3d4d75c --- /dev/null +++ b/app/src/main/java/test/ReadableFileSizeTest.kt @@ -0,0 +1,66 @@ +package test + +import com.bernaferrari.changedetection.extensions.readableFileSize +import org.junit.Assert +import org.junit.Assert.fail +import org.junit.Test + +internal class ReadableFileSizeTest { + @Test + fun testFileSizeZeroReturnsEmpty() { + val input = 0 + val expected = "EMPTY" + val output = input.readableFileSize() + Assert.assertEquals(expected, output) + } + + @Test + fun testNegativeFileSizeReturnsEmpty() { + val input = -1 + val expected = "EMPTY" + val output = input.readableFileSize() + Assert.assertEquals(expected, output) + } + + @Test + fun testBytesToKilobytesConversion() { + val input = 1024 + val expected = "1 kB" + val output = input.readableFileSize() + Assert.assertEquals(expected, output) + } + + @Test + fun testBytesToMegabytesConversion() { + val input = 5242880 + val expected = "5 MB" + val output = input.readableFileSize() + Assert.assertEquals(expected, output) + } + + @Test + fun testBytesToGigabytesConversion() { + // This test will fail because the file size exceeds the maximum value of an Int. + // Consider using a Long value for file sizes larger than Int.MAX_VALUE. + // Example: + // val fileSize: Long = 2147483648L + // val expected = "2 GB" + // val output = fileSize.readableFileSize() + // assertEquals(expected, output) + + fail("This test should fail because the file size for gigabytes conversion is larger than Int.MAX_VALUE.") + } + + @Test + fun testBytesToTerabytesConversion() { + // This test will fail because the file size exceeds the maximum value of an Int. + // Consider using a Long value for file sizes larger than Int.MAX_VALUE. + // Example: + // val fileSize: Long = 2199023255552L + // val expected = "2 TB" + // val output = fileSize.readableFileSize() + // assertEquals(expected, output) + + fail("This test should fail because the file size for terabytes conversion is larger than Int.MAX_VALUE.") + } +} \ No newline at end of file diff --git a/core_dependencies.gradle b/core_dependencies.gradle index c638209..8513191 100644 --- a/core_dependencies.gradle +++ b/core_dependencies.gradle @@ -43,4 +43,26 @@ dependencies { implementation Libs2.Google.material implementation Libs2.AndroidX.coreKtx implementation Libs2.AndroidX.constraintlayout + + testImplementation "androidx.test:core:1.4.0" + testImplementation "junit:junit:4.13.2" + testImplementation "androidx.arch.core:core-testing:2.1.0" + testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1" + testImplementation "com.google.truth:truth:1.1.3" + testImplementation "com.squareup.okhttp3:mockwebserver:4.9.1" + testImplementation "io.mockk:mockk:1.10.5" + debugImplementation "androidx.compose.ui:ui-test-manifest:1.1.0-alpha04" + + // Testy instrumentacyjne + androidTestImplementation 'com.google.dagger:hilt-android-testing:2.37' + androidTestImplementation 'com.google.dagger:hilt-android-compiler:2.37' + androidTestImplementation "junit:junit:4.13.2" + androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1" + androidTestImplementation "androidx.arch.core:core-testing:2.1.0" + androidTestImplementation "com.google.truth:truth:1.1.3" + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test:core-ktx:1.4.0' + androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.9.1" + androidTestImplementation "io.mockk:mockk-android:1.10.5" + androidTestImplementation 'androidx.test:runner:1.4.0' }