|
8 | 8 | package com.owncloud.android.datamodel; |
9 | 9 |
|
10 | 10 | import android.content.ContentValues; |
| 11 | +import android.util.Pair; |
11 | 12 |
|
| 13 | +import com.nextcloud.utils.extensions.FileDataStorageManagerExtensionsKt; |
12 | 14 | import com.owncloud.android.AbstractOnServerIT; |
13 | 15 | import com.owncloud.android.db.ProviderMeta; |
14 | 16 | import com.owncloud.android.lib.common.operations.RemoteOperationResult; |
@@ -353,4 +355,27 @@ public void testOCCapability() { |
353 | 355 | assertEquals(capability.getUserStatus(), newCapability.getUserStatus()); |
354 | 356 | } |
355 | 357 |
|
| 358 | + @Test |
| 359 | + public void testGenerateFileNameForConflictResolution() { |
| 360 | + Pair<String, String>[] names = new Pair[]{ |
| 361 | + // Files |
| 362 | + new Pair<String, String>("hello", "hello (1)"), |
| 363 | + new Pair<String, String>("hello.txt", "hello (1).txt"), |
| 364 | + new Pair<String, String>("hello (1).txt", "hello (2).txt"), |
| 365 | + new Pair<String, String>("hello (18y5).txt", "hello (18y5) (1).txt"), |
| 366 | + new Pair<String, String>("hello (hey)", "hello (hey) (1)"), |
| 367 | + new Pair<String, String>("hello (hey).txt", "hello (hey) (1).txt"), |
| 368 | + // Folders |
| 369 | + new Pair<String, String>("hello/", "hello (1)/"), |
| 370 | + new Pair<String, String>("hello (1)/", "hello (2)/"), |
| 371 | + new Pair<String, String>("hello.hello/", "hello.hello (1)/"), |
| 372 | + new Pair<String, String>("hello.hello (y)/", "hello.hello (y) (1)/"), |
| 373 | + }; |
| 374 | + |
| 375 | + for (Pair<String, String> name : names) { |
| 376 | + String gen = FileDataStorageManagerExtensionsKt.generateFileNameForConflictResolution(name.first); |
| 377 | + assertEquals(gen, name.second); |
| 378 | + } |
| 379 | + } |
| 380 | + |
356 | 381 | } |
0 commit comments