Skip to content

Commit 3e22b00

Browse files
committed
test: improve TestChangeSubscriber docs
1 parent 5377e4d commit 3e22b00

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

AnkiDroid/src/test/java/com/ichi2/testutils/TestChangeSubscriber.kt

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
* Copyright (c) 2024 David Allison <davidallisongithub@gmail.com>
3-
*
4-
* This program is free software; you can redistribute it and/or modify it under
5-
* the terms of the GNU General Public License as published by the Free Software
6-
* Foundation; either version 3 of the License, or (at your option) any later
7-
* version.
8-
*
9-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11-
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12-
*
13-
* You should have received a copy of the GNU General Public License along with
14-
* this program. If not, see <http://www.gnu.org/licenses/>.
15-
*/
1+
// SPDX-License-Identifier: GPL-3.0-or-later
162

173
package com.ichi2.testutils
184

@@ -22,7 +8,7 @@ import timber.log.Timber
228
import kotlin.test.fail
239

2410
/**
25-
* Ensures no calls to [ChangeManager.notifySubscribers] via [undoableOp]
11+
* Asserts no calls to [ChangeManager.notifySubscribers] are made (typically via `undoableOp`)
2612
*/
2713
suspend fun ensureNoOpsExecuted(block: suspend () -> Unit) {
2814
val subscription = ChangeCounter()
@@ -37,7 +23,7 @@ suspend fun ensureNoOpsExecuted(block: suspend () -> Unit) {
3723
}
3824

3925
/**
40-
* Ensures no calls to [ChangeManager.notifySubscribers] via [undoableOp]
26+
* Asserts [count] calls are made to [ChangeManager.notifySubscribers]
4127
*/
4228
suspend fun ensureOpsExecuted(
4329
count: Int,
@@ -53,11 +39,11 @@ suspend fun ensureOpsExecuted(
5339
return
5440
}
5541

56-
fail("ChangeManager: expected $count calls; ${ChangeManager.subscriberCount} subscribers")
42+
fail("ChangeManager: expected $count calls, got ${subscription.changeCount}; ${ChangeManager.subscriberCount} subscribers")
5743
}
5844

5945
/**
60-
* Ensures that [ChangeManager.notifySubscribers] is called with [handler] as the handler
46+
* Asserts that [ChangeManager.notifySubscribers] is called with [handler] as the handler
6147
*/
6248
suspend fun ensureOpWithHandler(
6349
handler: Any,

0 commit comments

Comments
 (0)