-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support concurrent formatting of Text (#138)
* Support concurrent formatting of Text * add TextOperationResult * update version to 0.4.7
- Loading branch information
Showing
11 changed files
with
115 additions
and
21 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
45 changes: 45 additions & 0 deletions
45
yorkie/src/androidTest/kotlin/dev/yorkie/document/json/JsonTextTest.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,45 @@ | ||
package dev.yorkie.document.json | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import dev.yorkie.assertJsonContentEquals | ||
import dev.yorkie.core.withTwoClientsAndDocuments | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class JsonTextTest { | ||
|
||
@Test | ||
fun test_concurrent_insertion_and_deletion() { | ||
withTwoClientsAndDocuments(realTimeSync = false) { c1, c2, d1, d2, _ -> | ||
d1.updateAsync { root, _ -> | ||
root.setNewText("k1").apply { | ||
edit(0, 0, "AB") | ||
} | ||
}.await() | ||
|
||
c1.syncAsync().await() | ||
c2.syncAsync().await() | ||
|
||
assertJsonContentEquals("""{"k1":[{"val":"AB"}]}""", d1.toJson()) | ||
assertJsonContentEquals(d1.toJson(), d2.toJson()) | ||
|
||
d1.updateAsync { root, _ -> | ||
root.getAs<JsonText>("k1").edit(0, 2, "") | ||
}.await() | ||
assertJsonContentEquals("""{"k1":[]}""", d1.toJson()) | ||
|
||
d2.updateAsync { root, _ -> | ||
root.getAs<JsonText>("k1").edit(1, 1, "C") | ||
}.await() | ||
assertJsonContentEquals("""{"k1":[{"val":"A"},{"val":"C"},{"val":"B"}]}""", d2.toJson()) | ||
|
||
c1.syncAsync().await() | ||
c2.syncAsync().await() | ||
c1.syncAsync().await() | ||
|
||
assertJsonContentEquals("""{"k1":[{"val":"C"}]}""", d1.toJson()) | ||
assertJsonContentEquals(d1.toJson(), d2.toJson()) | ||
} | ||
} | ||
} |
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
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