From 0df780870b9165f4b5c82f1c432588a464773eb8 Mon Sep 17 00:00:00 2001 From: Raymond Lai Date: Mon, 23 Oct 2023 23:11:07 +0800 Subject: [PATCH] Fix "None on top" sort mode When the option is "None on top", I think there should be no file and/or folder header labels displayed. Fixes #942. --- .../filemanager/adapters/RecyclerAdapter.java | 52 +- .../asynctasks/LoadFilesListTask.java | 6 +- .../filesystem/files/FileListSorter.kt | 173 ++-- .../fragments/data/MainFragmentViewModel.kt | 13 +- .../filesystem/files/FileListSorterTest.kt | 792 +++++++++--------- 5 files changed, 527 insertions(+), 509 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java b/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java index 72c262372d..15f4e90e67 100644 --- a/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java +++ b/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java @@ -21,6 +21,7 @@ package com.amaze.filemanager.adapters; import static com.amaze.filemanager.filesystem.compressed.CompressedHelper.*; +import static com.amaze.filemanager.filesystem.files.FileListSorter.SORT_NONE_ON_TOP; import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_COLORIZE_ICONS; import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_SHOW_FILE_SIZE; import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_SHOW_GOBACK_BUTTON; @@ -609,34 +610,43 @@ private void setItems( } public void createHeaders(boolean invalidate, List uris) { - boolean[] headers = new boolean[] {false, false}; + if ((mainFragment.getMainFragmentViewModel() != null + && mainFragment.getMainFragmentViewModel().getDsort() == SORT_NONE_ON_TOP) + || getItemsDigested() == null + || getItemsDigested().isEmpty()) { + return; + } else { + boolean[] headers = new boolean[] {false, false}; - for (int i = 0; i < getItemsDigested().size(); i++) { + for (int i = 0; i < getItemsDigested().size(); i++) { - if (getItemsDigested().get(i).layoutElementParcelable != null) { - LayoutElementParcelable nextItem = getItemsDigested().get(i).layoutElementParcelable; + if (getItemsDigested().get(i).layoutElementParcelable != null) { + LayoutElementParcelable nextItem = getItemsDigested().get(i).layoutElementParcelable; - if (!headers[0] && nextItem.isDirectory) { - headers[0] = true; - getItemsDigested().add(i, new ListItem(TYPE_HEADER_FOLDERS)); - uris.add(i, null); - continue; - } + if (nextItem != null) { + if (!headers[0] && nextItem.isDirectory) { + headers[0] = true; + getItemsDigested().add(i, new ListItem(TYPE_HEADER_FOLDERS)); + uris.add(i, null); + continue; + } - if (!headers[1] - && !nextItem.isDirectory - && !nextItem.title.equals(".") - && !nextItem.title.equals("..")) { - headers[1] = true; - getItemsDigested().add(i, new ListItem(TYPE_HEADER_FILES)); - uris.add(i, null); - continue; // leave this continue for symmetry + if (!headers[1] + && !nextItem.isDirectory + && !nextItem.title.equals(".") + && !nextItem.title.equals("..")) { + headers[1] = true; + getItemsDigested().add(i, new ListItem(TYPE_HEADER_FILES)); + uris.add(i, null); + continue; // leave this continue for symmetry + } + } } } - } - if (invalidate) { - notifyDataSetChanged(); + if (invalidate) { + notifyDataSetChanged(); + } } } diff --git a/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java b/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java index 4ae437aaa6..fdf51c6b98 100644 --- a/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java +++ b/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java @@ -22,6 +22,8 @@ import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.Q; +import static com.amaze.filemanager.filesystem.files.FileListSorter.SORT_ASC; +import static com.amaze.filemanager.filesystem.files.FileListSorter.SORT_DSC; import java.io.File; import java.lang.ref.WeakReference; @@ -258,9 +260,9 @@ private void postListCustomPathProcess( if (sortType <= 3) { sortBy = sortType; - isAscending = 1; + isAscending = SORT_ASC; } else { - isAscending = -1; + isAscending = SORT_DSC; sortBy = sortType - 4; } diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/files/FileListSorter.kt b/app/src/main/java/com/amaze/filemanager/filesystem/files/FileListSorter.kt index df4bdb7e06..aac05a8f85 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/files/FileListSorter.kt +++ b/app/src/main/java/com/amaze/filemanager/filesystem/files/FileListSorter.kt @@ -18,36 +18,34 @@ * along with this program. If not, see . */ -package com.amaze.filemanager.filesystem.files; +package com.amaze.filemanager.filesystem.files -import java.util.Comparator; +import androidx.annotation.IntDef +import com.amaze.filemanager.adapters.data.LayoutElementParcelable +import java.util.Locale -import com.amaze.filemanager.adapters.data.LayoutElementParcelable; - -public class FileListSorter implements Comparator { - - private int dirsOnTop = 0; - private int asc = 1; - private int sort = 0; - - public FileListSorter(int dir, int sort, int asc) { - this.dirsOnTop = dir; - this.asc = asc; - this.sort = sort; - } - - private boolean isDirectory(LayoutElementParcelable path) { - return path.isDirectory; - } - - /** - * Compares two elements and return negative, zero and positive integer if first argument is less - * than, equal to or greater than second - */ - @Override - public int compare(LayoutElementParcelable file1, LayoutElementParcelable file2) { +/** + * [Comparator] implementation to sort [LayoutElementParcelable]s. + */ +class FileListSorter( + @DirSortMode dirArg: Int, + @SortBy sortArg: Int, + @SortOrder ascArg: Int +) : Comparator { + private var dirsOnTop = dirArg + private val asc = ascArg + private val sort = sortArg + + private fun isDirectory(path: LayoutElementParcelable): Boolean { + return path.isDirectory + } - /*File f1; + /** + * Compares two elements and return negative, zero and positive integer if first argument is less + * than, equal to or greater than second + */ + override fun compare(file1: LayoutElementParcelable, file2: LayoutElementParcelable): Int { + /*File f1; if(!file1.hasSymlink()) { @@ -64,63 +62,90 @@ public class FileListSorter implements Comparator { } else { f2=new File(file1.getSymlink()); }*/ + if (dirsOnTop == SORT_DIR_ON_TOP) { + if (isDirectory(file1) && !isDirectory(file2)) { + return -1 + } else if (isDirectory(file2) && !isDirectory(file1)) { + return 1 + } + } else if (dirsOnTop == SORT_FILE_ON_TOP) { + if (isDirectory(file1) && !isDirectory(file2)) { + return 1 + } else if (isDirectory(file2) && !isDirectory(file1)) { + return -1 + } + } - if (dirsOnTop == 0) { - if (isDirectory(file1) && !isDirectory(file2)) { - return -1; - - } else if (isDirectory(file2) && !isDirectory(file1)) { - return 1; - } - } else if (dirsOnTop == 1) { - if (isDirectory(file1) && !isDirectory(file2)) { - - return 1; - } else if (isDirectory(file2) && !isDirectory(file1)) { - return -1; - } + when (sort) { + SORT_BY_NAME -> { + // sort by name + return asc * file1.title.compareTo(file2.title, ignoreCase = true) + } + SORT_BY_LAST_MODIFIED -> { + // sort by last modified + return asc * java.lang.Long.valueOf(file1.date).compareTo(file2.date) + } + SORT_BY_SIZE -> { + // sort by size + return if (!file1.isDirectory && !file2.isDirectory) { + asc * java.lang.Long.valueOf(file1.longSize).compareTo(file2.longSize) + } else { + file1.title.compareTo(file2.title, ignoreCase = true) + } + } + SORT_BY_TYPE -> { + // sort by type + return if (!file1.isDirectory && !file2.isDirectory) { + val ext_a = getExtension(file1.title) + val ext_b = getExtension(file2.title) + val res = asc * ext_a.compareTo(ext_b) + if (res == 0) { + asc * file1.title.compareTo(file2.title, ignoreCase = true) + } else { + res + } + } else { + file1.title.compareTo(file2.title, ignoreCase = true) + } + } + else -> return 0 + } } - if (sort == 0) { + companion object { - // sort by name - return asc * file1.title.compareToIgnoreCase(file2.title); - } else if (sort == 1) { + const val SORT_BY_NAME = 0 + const val SORT_BY_LAST_MODIFIED = 1 + const val SORT_BY_SIZE = 2 + const val SORT_BY_TYPE = 3 - // sort by last modified - return asc * Long.valueOf(file1.date).compareTo(file2.date); - } else if (sort == 2) { + const val SORT_DIR_ON_TOP = 0 + const val SORT_FILE_ON_TOP = 1 + const val SORT_NONE_ON_TOP = 2 - // sort by size - if (!file1.isDirectory && !file2.isDirectory) { + const val SORT_ASC = 1 + const val SORT_DSC = -1 - return asc * Long.valueOf(file1.longSize).compareTo(file2.longSize); - } else { + @Retention(AnnotationRetention.SOURCE) + @IntDef(SORT_BY_NAME, SORT_BY_LAST_MODIFIED, SORT_BY_SIZE, SORT_BY_TYPE) + annotation class SortBy - return file1.title.compareToIgnoreCase(file2.title); - } + @Retention(AnnotationRetention.SOURCE) + @IntDef(SORT_DIR_ON_TOP, SORT_FILE_ON_TOP, SORT_NONE_ON_TOP) + annotation class DirSortMode - } else if (sort == 3) { + @Retention(AnnotationRetention.SOURCE) + @IntDef(SORT_ASC, SORT_DSC) + annotation class SortOrder - // sort by type - if (!file1.isDirectory && !file2.isDirectory) { - - final String ext_a = getExtension(file1.title); - final String ext_b = getExtension(file2.title); - - final int res = asc * ext_a.compareTo(ext_b); - if (res == 0) { - return asc * file1.title.compareToIgnoreCase(file2.title); + /** + * Convenience method to get the file extension in given path. + * + * TODO: merge with same definition somewhere else (if any) + */ + @JvmStatic + fun getExtension(a: String): String { + return a.substringAfterLast('.').lowercase(Locale.getDefault()) } - return res; - } else { - return file1.title.compareToIgnoreCase(file2.title); - } } - return 0; - } - - public static String getExtension(String a) { - return a.substring(a.lastIndexOf(".") + 1).toLowerCase(); - } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/data/MainFragmentViewModel.kt b/app/src/main/java/com/amaze/filemanager/ui/fragments/data/MainFragmentViewModel.kt index 1c236605c5..0dd638e396 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/data/MainFragmentViewModel.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/data/MainFragmentViewModel.kt @@ -31,13 +31,16 @@ import com.amaze.filemanager.adapters.data.LayoutElementParcelable import com.amaze.filemanager.database.CloudHandler import com.amaze.filemanager.fileoperations.filesystem.OpenMode import com.amaze.filemanager.filesystem.HybridFileParcelable +import com.amaze.filemanager.filesystem.files.FileListSorter.Companion.DirSortMode +import com.amaze.filemanager.filesystem.files.FileListSorter.Companion.SortBy +import com.amaze.filemanager.filesystem.files.FileListSorter.Companion.SortOrder import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_GRID_COLUMNS import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_GRID_COLUMNS_DEFAULT import com.amaze.filemanager.utils.DataUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import java.util.* +import java.util.Objects class MainFragmentViewModel : ViewModel() { @@ -56,11 +59,19 @@ class MainFragmentViewModel : ViewModel() { var searchHelper = ArrayList() var no = 0 + @SortBy var sortby = 0 + + @DirSortMode var dsort = 0 + + @SortOrder var asc = 0 + var home: String? = null + var results: Boolean = false + lateinit var openMode: OpenMode // defines the current visible tab, default either 0 or 1 diff --git a/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt b/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt index 35aa967cd1..15ef3a1be3 100644 --- a/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt +++ b/app/src/test/java/com/amaze/filemanager/filesystem/files/FileListSorterTest.kt @@ -18,47 +18,40 @@ * along with this program. If not, see . */ -package com.amaze.filemanager.filesystem.files; - -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.P; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; - -import com.amaze.filemanager.adapters.data.LayoutElementParcelable; -import com.amaze.filemanager.fileoperations.filesystem.OpenMode; -import com.amaze.filemanager.shadows.ShadowMultiDex; - -import android.os.Build; - -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; +package com.amaze.filemanager.filesystem.files + +import android.os.Build +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.amaze.filemanager.adapters.data.LayoutElementParcelable +import com.amaze.filemanager.fileoperations.filesystem.OpenMode +import com.amaze.filemanager.shadows.ShadowMultiDex +import org.hamcrest.Matchers +import org.junit.Assert +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.annotation.Config /** * because of test based on mock-up, extension testing isn't tested so, assume all extension is * "*{slash}*" */ -@RunWith(AndroidJUnit4.class) +@RunWith(AndroidJUnit4::class) @Config( - shadows = {ShadowMultiDex.class}, - sdk = {KITKAT, P, Build.VERSION_CODES.R}) -public class FileListSorterTest { - /** - * Purpose: when dirsOnTop is 0, if file1 is directory && file2 is not directory, result is -1 - * Input: FileListSorter(0,0,1) dir(=dirsOnTop) is 0 / compare(file1,file2) file1 is dir, file2 is - * not dir Expected: return -1 - */ - @Test - public void testDir0File1DirAndFile2NoDir() { - FileListSorter fileListSorter = new FileListSorter(0, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + shadows = [ShadowMultiDex::class], + sdk = [Build.VERSION_CODES.KITKAT, Build.VERSION_CODES.P, Build.VERSION_CODES.R] +) +@Suppress("StringLiteralDuplication", "ComplexMethod", "LongMethod", "LargeClass") +class FileListSorterTest { + /** + * Purpose: when dirsOnTop is 0, if file1 is directory && file2 is not directory, result is -1 + * Input: FileListSorter(0,0,1) dir(=dirsOnTop) is 0 / compare(file1,file2) file1 is dir, file2 is + * not dir Expected: return -1 + */ + @Test + fun testDir0File1DirAndFile2NoDir() { + val fileListSorter = FileListSorter(0, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1", "C:\\AmazeFileManager\\abc1", @@ -70,9 +63,9 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -84,27 +77,25 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), -1); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), -1) + } - /* + /* public LayoutElementParcelable(String title, String path, String permissions, String symlink, String size, long longSize, boolean header, String date, boolean isDirectory, boolean useThumbs, OpenMode openMode) */ - - /** - * Purpose: when dirsOnTop is 0, if file1 is not directory && file2 is directory, result is 1 - * Input: FileListSorter(0,0,1) dir(=dirsOnTop) is 0 / compare(file1,file2) file1 is not dir, - * file2 is dir Expected: return 1 - */ - @Test - public void testDir0File1NoDirAndFile2Dir() { - FileListSorter fileListSorter = new FileListSorter(0, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when dirsOnTop is 0, if file1 is not directory && file2 is directory, result is 1 + * Input: FileListSorter(0,0,1) dir(=dirsOnTop) is 0 / compare(file1,file2) file1 is not dir, + * file2 is dir Expected: return 1 + */ + @Test + fun testDir0File1NoDirAndFile2Dir() { + val fileListSorter = FileListSorter(0, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1.txt", "C:\\AmazeFileManager\\abc1", @@ -116,9 +107,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2", "C:\\AmazeFileManager\\abc2", @@ -130,21 +121,20 @@ public class FileListSorterTest { "1235", true, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), 1); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 1) + } - /** - * Purpose: when dirsOnTop is 1, if file1 is directory && file2 is not directory, result is 1 - * Input: FileListSorter(1,0,1) dir(=dirsOnTop) is 1 / compare(file1,file2) file1 is dir, file2 is - * not dir Expected: return 1 - */ - @Test - public void testDir1File1DirAndFile2NoDir() { - FileListSorter fileListSorter = new FileListSorter(1, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when dirsOnTop is 1, if file1 is directory && file2 is not directory, result is 1 + * Input: FileListSorter(1,0,1) dir(=dirsOnTop) is 1 / compare(file1,file2) file1 is dir, file2 is + * not dir Expected: return 1 + */ + @Test + fun testDir1File1DirAndFile2NoDir() { + val fileListSorter = FileListSorter(1, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1", "C:\\AmazeFileManager\\abc1", @@ -156,9 +146,9 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -170,21 +160,20 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 1) + } - assertEquals(fileListSorter.compare(file1, file2), 1); - } - - /** - * Purpose: when dirsOnTop is 1, if file1 is not directory && file2 is directory, result is -1 - * Input: FileListSorter(1,0,1) dir(=dirsOnTop) is 1 / compare(file1,file2) file1 is not dir, - * file2 is dir Expected: return -1 - */ - @Test - public void testDir1File1NoDirAndFile2Dir() { - FileListSorter fileListSorter = new FileListSorter(1, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when dirsOnTop is 1, if file1 is not directory && file2 is directory, result is -1 + * Input: FileListSorter(1,0,1) dir(=dirsOnTop) is 1 / compare(file1,file2) file1 is not dir, + * file2 is dir Expected: return -1 + */ + @Test + fun testDir1File1NoDirAndFile2Dir() { + val fileListSorter = FileListSorter(1, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1.txt", "C:\\AmazeFileManager\\abc1", @@ -196,9 +185,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2", "C:\\AmazeFileManager\\abc2", @@ -210,23 +199,21 @@ public class FileListSorterTest { "1235", true, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), -1); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), -1) + } - // From here, use dir is not 0 or 1. -> Select dir is -1 - - /** - * Purpose: when sort is 0, if file1 title's length bigger than file2 title's length, result is - * positive Input: FileListSorter(-1,0,1) sort is 0 / compare(file1,file2) file1 title's length > - * file2 title's length Expected: return positive integer - */ - @Test - public void testSort0File1TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + // From here, use dir is not 0 or 1. -> Select dir is -1 + /** + * Purpose: when sort is 0, if file1 title's length bigger than file2 title's length, result is + * positive Input: FileListSorter(-1,0,1) sort is 0 / compare(file1,file2) file1 title's length > + * file2 title's length Expected: return positive integer + */ + @Test + fun testSort0File1TitleBigger() { + val fileListSorter = FileListSorter(-1, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1.txt", "C:\\AmazeFileManager\\abc1", @@ -238,9 +225,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -252,21 +239,20 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), greaterThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.greaterThan(0)) + } - /** - * Purpose: when sort is 0, if file1 title's length smaller than file2 title's length, result is - * negative Input: FileListSorter(-1,0,1) sort is 0 / compare(file1,file2) file1 title's length < - * file2 title's length Expected: return negative integer - */ - @Test - public void testSort0File2TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 0, if file1 title's length smaller than file2 title's length, result is + * negative Input: FileListSorter(-1,0,1) sort is 0 / compare(file1,file2) file1 title's length < + * file2 title's length Expected: return negative integer + */ + @Test + fun testSort0File2TitleBigger() { + val fileListSorter = FileListSorter(-1, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -278,9 +264,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -292,21 +278,20 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.lessThan(0)) + } - assertThat(fileListSorter.compare(file1, file2), lessThan(0)); - } - - /** - * Purpose: when sort is 0, if file1 title's length and file2 title's length are same, result is - * zero Input: FileListSorter(-1,0,1) sort is 0 / compare(file1,file2) file1 title's length = - * file2 title's length Expected: return zero - */ - @Test - public void testSort0TitleSame() { - FileListSorter fileListSorter = new FileListSorter(-1, 0, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 0, if file1 title's length and file2 title's length are same, result is + * zero Input: FileListSorter(-1,0,1) sort is 0 / compare(file1,file2) file1 title's length = + * file2 title's length Expected: return zero + */ + @Test + fun testSort0TitleSame() { + val fileListSorter = FileListSorter(-1, 0, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -318,9 +303,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "ABC.txt", "C:\\AmazeFileManager\\ABC", @@ -332,21 +317,20 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), 0); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 0) + } - /** - * Purpose: when sort is 1, if file1 date more recent than file2 date, result is positive Input: - * FileListSorter(-1,1,1) sort is 1 / compare(file1,file2) file1 date > file2 date Expected: - * return positive integer - */ - @Test - public void testSort1File1DateLastest() { - FileListSorter fileListSorter = new FileListSorter(-1, 1, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 1, if file1 date more recent than file2 date, result is positive Input: + * FileListSorter(-1,1,1) sort is 1 / compare(file1,file2) file1 date > file2 date Expected: + * return positive integer + */ + @Test + fun testSort1File1DateLastest() { + val fileListSorter = FileListSorter(-1, 1, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -358,9 +342,9 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -372,21 +356,20 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), greaterThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.greaterThan(0)) + } - /** - * Purpose: when sort is 1, if file2 date more recent than file1 date, result is negative Input: - * FileListSorter(-1,1,1) sort is 1 / compare(file1,file2) file1 date < file2 date Expected: - * return negative integer - */ - @Test - public void testSort1File2DateLastest() { - FileListSorter fileListSorter = new FileListSorter(-1, 1, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 1, if file2 date more recent than file1 date, result is negative Input: + * FileListSorter(-1,1,1) sort is 1 / compare(file1,file2) file1 date < file2 date Expected: + * return negative integer + */ + @Test + fun testSort1File2DateLastest() { + val fileListSorter = FileListSorter(-1, 1, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -398,9 +381,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -412,21 +395,20 @@ public class FileListSorterTest { "1235", false, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.lessThan(0)) + } - assertThat(fileListSorter.compare(file1, file2), lessThan(0)); - } - - /** - * Purpose: when sort is 1, if file1 date and file2 date are same, result is zero Input: - * FileListSorter(-1,1,1) sort is 1 / compare(file1,file2) file1 date = file2 date Expected: - * return zero - */ - @Test - public void testSort1FileDateSame() { - FileListSorter fileListSorter = new FileListSorter(-1, 1, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 1, if file1 date and file2 date are same, result is zero Input: + * FileListSorter(-1,1,1) sort is 1 / compare(file1,file2) file1 date = file2 date Expected: + * return zero + */ + @Test + fun testSort1FileDateSame() { + val fileListSorter = FileListSorter(-1, 1, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -438,9 +420,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -452,21 +434,20 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), 0); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 0) + } - /** - * Purpose: when sort is 2, if two file are not directory && file1 size bigger than file2 size, - * result is positive Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 size > - * file2 size Expected: return positive integer - */ - @Test - public void testSort2NoDirAndFile1SizeBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if two file are not directory && file1 size bigger than file2 size, + * result is positive Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 size > + * file2 size Expected: return positive integer + */ + @Test + fun testSort2NoDirAndFile1SizeBigger() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -478,9 +459,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -492,21 +473,20 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.greaterThan(0)) + } - assertThat(fileListSorter.compare(file1, file2), greaterThan(0)); - } - - /** - * Purpose: when sort is 2, if two file are not directory && file1 size smaller than file2 size, - * result is negative Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 size < - * file2 size Expected: return negative integer - */ - @Test - public void testSort2NoDirAndFile2SizeBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if two file are not directory && file1 size smaller than file2 size, + * result is negative Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 size < + * file2 size Expected: return negative integer + */ + @Test + fun testSort2NoDirAndFile2SizeBigger() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -518,9 +498,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -532,21 +512,20 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), lessThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.lessThan(0)) + } - /** - * Purpose: when sort is 2, if two file are not directory && file1 size and file2 size are same, - * result is zero Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 size = - * file2 size Expected: return zero - */ - @Test - public void testSort2NoDirAndFileSizeSame() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if two file are not directory && file1 size and file2 size are same, + * result is zero Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 size = + * file2 size Expected: return zero + */ + @Test + fun testSort2NoDirAndFileSizeSame() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -558,9 +537,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -572,22 +551,21 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 0) + } - assertEquals(fileListSorter.compare(file1, file2), 0); - } - - /** - * Purpose: when sort is 2, if file1 is directory && file1 title's length bigger than file2 - * title's length, result is positive Input: FileListSorter(-1,2,1) sort is 2 / - * compare(file1,file2) file1 title's length > file2 title's length Expected: return positive - * integer - */ - @Test - public void testSort2File1DirAndFile1TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if file1 is directory && file1 title's length bigger than file2 + * title's length, result is positive Input: FileListSorter(-1,2,1) sort is 2 / + * compare(file1,file2) file1 title's length > file2 title's length Expected: return positive + * integer + */ + @Test + fun testSort2File1DirAndFile1TitleBigger() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1", "C:\\AmazeFileManager\\abc1", @@ -599,9 +577,9 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -613,22 +591,21 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), greaterThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.greaterThan(0)) + } - /** - * Purpose: when sort is 2, if file1 is directory && file1 title's length smaller than file2 - * title's length, result is negative Input: FileListSorter(-1,2,1) sort is 2 / - * compare(file1,file2) file1 title's length < file2 title's length Expected: return negative - * integer - */ - @Test - public void testSort2File1DirAndFile2TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if file1 is directory && file1 title's length smaller than file2 + * title's length, result is negative Input: FileListSorter(-1,2,1) sort is 2 / + * compare(file1,file2) file1 title's length < file2 title's length Expected: return negative + * integer + */ + @Test + fun testSort2File1DirAndFile2TitleBigger() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc", "C:\\AmazeFileManager\\abc", @@ -640,9 +617,9 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -654,22 +631,21 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), lessThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.lessThan(0)) + } - /** - * Purpose: when sort is 2, if file2 is directory && file1 title's length bigger than file2 - * title's length, result is positive Input: FileListSorter(-1,2,1) sort is 2 / - * compare(file1,file2) file1 title's length > file2 title's length Expected: return positive - * integer - */ - @Test - public void testSort2File2DirAndFile1TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if file2 is directory && file1 title's length bigger than file2 + * title's length, result is positive Input: FileListSorter(-1,2,1) sort is 2 / + * compare(file1,file2) file1 title's length > file2 title's length Expected: return positive + * integer + */ + @Test + fun testSort2File2DirAndFile1TitleBigger() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1.txt", "C:\\AmazeFileManager\\abc1", @@ -681,9 +657,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc", "C:\\AmazeFileManager\\abc", @@ -695,22 +671,21 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.greaterThan(0)) + } - assertThat(fileListSorter.compare(file1, file2), greaterThan(0)); - } - - /** - * Purpose: when sort is 2, if file2 is directory && file1 title's length smaller than file2 - * title's length, result is negative Input: FileListSorter(-1,2,1) sort is 2 / - * compare(file1,file2) file1 title's length < file2 title's length Expected: return negative - * integer - */ - @Test - public void testSort2File2DirAndFile2TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if file2 is directory && file1 title's length smaller than file2 + * title's length, result is negative Input: FileListSorter(-1,2,1) sort is 2 / + * compare(file1,file2) file1 title's length < file2 title's length Expected: return negative + * integer + */ + @Test + fun testSort2File2DirAndFile2TitleBigger() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -722,9 +697,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2", "C:\\AmazeFileManager\\abc2", @@ -736,21 +711,20 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), lessThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.lessThan(0)) + } - /** - * Purpose: when sort is 2, if file2 is directory && file1 title's length and file2 title's length - * are same, result is zero Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 - * title's length = file2 title's length Expected: return zero - */ - @Test - public void testSort2File2DirAndFileTitleSame() { - FileListSorter fileListSorter = new FileListSorter(-1, 2, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 2, if file2 is directory && file1 title's length and file2 title's length + * are same, result is zero Input: FileListSorter(-1,2,1) sort is 2 / compare(file1,file2) file1 + * title's length = file2 title's length Expected: return zero + */ + @Test + fun testSort2File2DirAndFileTitleSame() { + val fileListSorter = FileListSorter(-1, 2, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc", "C:\\AmazeFileManager\\abc", @@ -762,9 +736,9 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc", "C:\\AmazeFileManager\\abc", @@ -776,23 +750,22 @@ public class FileListSorterTest { "1234", true, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 0) + } - assertEquals(fileListSorter.compare(file1, file2), 0); - } - - /** - * Purpose: when sort is 3, if file1 extension's length and file2 extension's length are same && - * file1 title's length bigger than file2 title's length, result is positive Input: - * FileListSorter(-1,3,1) sort is 3 / compare(file1,file2) file1 extension's length = file2 - * extension's length && file1 title's length > file2 title's length Expected: return positive - * integer - */ - @Test - public void testSort3FileExtensionSameAndFile1TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 3, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 3, if file1 extension's length and file2 extension's length are same && + * file1 title's length bigger than file2 title's length, result is positive Input: + * FileListSorter(-1,3,1) sort is 3 / compare(file1,file2) file1 extension's length = file2 + * extension's length && file1 title's length > file2 title's length Expected: return positive + * integer + */ + @Test + fun testSort3FileExtensionSameAndFile1TitleBigger() { + val fileListSorter = FileListSorter(-1, 3, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc1.txt", "C:\\AmazeFileManager\\abc1", @@ -804,9 +777,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -818,23 +791,22 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertThat(fileListSorter.compare(file1, file2), greaterThan(0)); - } + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.greaterThan(0)) + } - /** - * Purpose: when sort is 3, if file1 extension's length and file2 extension's length are same && - * file1 title's length smaller than file2 title's length, result is negative Input: - * FileListSorter(-1,3,1) sort is 3 / compare(file1,file2) file1 extension's length = file2 - * extension's length && file1 title's length < file2 title's length Expected: return negative - * integer - */ - @Test - public void testSort3FileExtensionSameAndFile2TitleBigger() { - FileListSorter fileListSorter = new FileListSorter(-1, 3, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 3, if file1 extension's length and file2 extension's length are same && + * file1 title's length smaller than file2 title's length, result is negative Input: + * FileListSorter(-1,3,1) sort is 3 / compare(file1,file2) file1 extension's length = file2 + * extension's length && file1 title's length < file2 title's length Expected: return negative + * integer + */ + @Test + fun testSort3FileExtensionSameAndFile2TitleBigger() { + val fileListSorter = FileListSorter(-1, 3, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -846,9 +818,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc2.txt", "C:\\AmazeFileManager\\abc2", @@ -860,22 +832,21 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); + OpenMode.UNKNOWN + ) + Assert.assertThat(fileListSorter.compare(file1, file2), Matchers.lessThan(0)) + } - assertThat(fileListSorter.compare(file1, file2), lessThan(0)); - } - - /** - * Purpose: when sort is 3, if file1 extension's length and file2 extension's length are same && - * file1 title's length and file2 title's length are same, result is zero Input: - * FileListSorter(-1,3,1) sort is 3 / compare(file1,file2) file1 extension's length = file2 - * extension's length && file1 title's length = file2 title's length Expected: return zero - */ - @Test - public void testSort3FileExtensionSameAndFileTitleSame() { - FileListSorter fileListSorter = new FileListSorter(-1, 3, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is 3, if file1 extension's length and file2 extension's length are same && + * file1 title's length and file2 title's length are same, result is zero Input: + * FileListSorter(-1,3,1) sort is 3 / compare(file1,file2) file1 extension's length = file2 + * extension's length && file1 title's length = file2 title's length Expected: return zero + */ + @Test + fun testSort3FileExtensionSameAndFileTitleSame() { + val fileListSorter = FileListSorter(-1, 3, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -887,9 +858,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "ABC.txt", "C:\\AmazeFileManager\\ABC", @@ -901,20 +872,19 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), 0); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 0) + } - /** - * Purpose: when sort is not 0,1,2,3, result is zero Input: FileListSorter(-1,4,1) sort is 4 - * Expected: return zero - */ - @Test - public void testSortAnotherNumber() { - FileListSorter fileListSorter = new FileListSorter(-1, 4, 1); - LayoutElementParcelable file1 = - new LayoutElementParcelable( + /** + * Purpose: when sort is not 0,1,2,3, result is zero Input: FileListSorter(-1,4,1) sort is 4 + * Expected: return zero + */ + @Test + fun testSortAnotherNumber() { + val fileListSorter = FileListSorter(-1, 4, 1) + val file1 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "abc.txt", "C:\\AmazeFileManager\\abc", @@ -926,9 +896,9 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - LayoutElementParcelable file2 = - new LayoutElementParcelable( + OpenMode.UNKNOWN + ) + val file2 = LayoutElementParcelable( ApplicationProvider.getApplicationContext(), "ABC.txt", "C:\\AmazeFileManager\\ABC", @@ -940,8 +910,8 @@ public class FileListSorterTest { "1234", false, false, - OpenMode.UNKNOWN); - - assertEquals(fileListSorter.compare(file1, file2), 0); - } + OpenMode.UNKNOWN + ) + Assert.assertEquals(fileListSorter.compare(file1, file2).toLong(), 0) + } }