Last active
October 2, 2024 15:50
-
-
Save jfresen/44f3838fbd00e3c4342c7be4c9a4e6f7 to your computer and use it in GitHub Desktop.
Revisions
-
jfresen revised this gist
Oct 2, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,12 +6,12 @@ private var I = 0 // add a sequence number to every log message for disambiguati @Test fun test() = runComposeUiTest { withApplyAndWriteObserver { // your test here } } private inline fun withApplyAndWriteObserver(block: () -> Any) { var unregisterApplyObserver: ObserverHandle? = null var unregisterWriteObserver: ObserverHandle? = null try { -
jfresen revised this gist
Oct 2, 2024 . 2 changed files with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ private val TAG = "TEST_TAG" private var I = 0 // add a sequence number to every log message for disambiguation private var unregisterApplyObserver: ObserverHandle? = null private var unregisterWriteObserver: ObserverHandle? = null @Test fun test() { @@ -19,9 +20,13 @@ fun setup() { Log.d(TAG, "[${I++}] modified: $obj") } } unregisterWriteObserver = Snapshot.registerGlobalWriteObserver { mutatedObject -> Log.d(TAG, "[${I++}] writing in snapshot: $mutatedObject") } } @After fun tearDown() { unregisterApplyObserver?.dispose() unregisterWriteObserver?.dispose() } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,15 +13,20 @@ fun test() = runComposeUiTest { private inline fun withApplyObserver(block: () -> Any) { var unregisterApplyObserver: ObserverHandle? = null var unregisterWriteObserver: ObserverHandle? = null try { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i(TAG, "[${I++}] applying snapshot") for (obj in mutatedObjects) { Log.d(TAG, "[${I++}] modified: $obj") } } unregisterWriteObserver = Snapshot.registerGlobalWriteObserver { mutatedObject -> Log.d(TAG, "[${I++}] writing in snapshot: $mutatedObject") } block() } finally { unregisterApplyObserver?.dispose() unregisterWriteObserver?.dispose() } } -
jfresen revised this gist
Aug 19, 2024 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ fun setup() { val colon = if (mutatedObjects.isNotEmpty()) ":" else "" Log.i(TAG, "[${I++}] applying snapshot$colon") for (obj in mutatedObjects) { Log.d(TAG, "[${I++}] modified: $obj") } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ private inline fun withApplyObserver(block: () -> Any) { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i(TAG, "[${I++}] applying snapshot") for (obj in mutatedObjects) { Log.d(TAG, "[${I++}] modified: $obj") } } block() -
jfresen revised this gist
Aug 15, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,8 @@ fun test() { @Before fun setup() { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> val colon = if (mutatedObjects.isNotEmpty()) ":" else "" Log.i(TAG, "[${I++}] applying snapshot$colon") for (obj in mutatedObjects) { Log.d(TAG, "[${I++}] object $obj modified") } -
jfresen revised this gist
May 8, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ private val TAG = "TEST_TAG" private var I = 0 // add a sequence number to every log message for disambiguation @Test fun test() = runComposeUiTest { @@ -13,6 +12,7 @@ fun test() = runComposeUiTest { } private inline fun withApplyObserver(block: () -> Any) { var unregisterApplyObserver: ObserverHandle? = null try { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i(TAG, "[${I++}] applying snapshot") -
jfresen revised this gist
May 7, 2024 . 2 changed files with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,14 @@ // Use the other template if you use ComposeUiTest (runComposeUiTest()) private val TAG = "TEST_TAG" private var I = 0 // add a sequence number to every log message for disambiguation private var unregisterApplyObserver: ObserverHandle? = null @Test fun test() { // your test here } @Before fun setup() { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,16 @@ // Use the other template if you use ComposeTestRule (createComposeRule()) private val TAG = "TEST_TAG" private var I = 0 // add a sequence number to every log message for disambiguation private var unregisterApplyObserver: ObserverHandle? = null @Test fun test() = runComposeUiTest { withApplyObserver { // your test here } } private inline fun withApplyObserver(block: () -> Any) { try { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> -
jfresen revised this gist
May 7, 2024 . 2 changed files with 25 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,16 @@ // Use this template if you use ComposeTestRule (createComposeRule()) // Use the other template if you use ComposeUiTest (runComposeUiTest()) private val TAG = "TEST_TAG" private var I = 0 // disable logcat duplication filtering private var unregisterApplyObserver: ObserverHandle? = null @Before fun setup() { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i(TAG, "[${I++}] applying snapshot") for (obj in mutatedObjects) { Log.d(TAG, "[${I++}] object $obj modified") } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // Use this template if you use ComposeUiTest (runComposeUiTest()) // Use the other template if you use ComposeTestRule (createComposeRule()) private val TAG = "TEST_TAG" private var unregisterApplyObserver: ObserverHandle? = null private inline fun withApplyObserver(block: () -> Any) { try { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i(TAG, "[${I++}] applying snapshot") for (obj in mutatedObjects) { Log.d(TAG, "[${I++}] object $obj modified") } } block() } finally { unregisterApplyObserver?.dispose() } } -
jfresen revised this gist
Feb 22, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ fun setup() { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i("TEST_TAG", "[${I++}] applying snapshot") for (obj in mutatedObjects) { Log.d("TEST_TAG", "[${I++}] object $obj modified") } } } -
jfresen renamed this gist
Feb 22, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jfresen created this gist
Feb 22, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ private var I = 0 // disable logcat duplication filtering private var unregisterApplyObserver: ObserverHandle? = null @Before fun setup() { unregisterApplyObserver = Snapshot.registerApplyObserver { mutatedObjects, snapshot -> Log.i("TEST_TAG", "[${I++}] applying snapshot") for (obj in mutatedObjects) { Log.d("TEST_TAG", "[${I++}] state $obj modified") } } } @After fun tearDown() { unregisterApplyObserver?.dispose() }