|
@@ -1,6 +1,8 @@
|
|
|
import { describe, it, expect } from '@ohos/hypium'
|
|
import { describe, it, expect } from '@ohos/hypium'
|
|
|
import { MusicCardManager } from '../../../main/ets/common/player/MusicCardManager'
|
|
import { MusicCardManager } from '../../../main/ets/common/player/MusicCardManager'
|
|
|
import { VideoItem } from '../../../main/ets/viewmodel/VideoItem'
|
|
import { VideoItem } from '../../../main/ets/viewmodel/VideoItem'
|
|
|
|
|
+import { createEmptyMusicCardSnapshot } from '../../../main/ets/common/player/MusicCardSnapshot'
|
|
|
|
|
+import { MusicCardSnapshotStore } from '../../../main/ets/common/player/MusicCardSnapshotStore'
|
|
|
|
|
|
|
|
export default function musicCardManagerTest() {
|
|
export default function musicCardManagerTest() {
|
|
|
describe('MusicCardManagerTest', () => {
|
|
describe('MusicCardManagerTest', () => {
|
|
@@ -34,5 +36,31 @@ export default function musicCardManagerTest() {
|
|
|
const result = MusicCardManager.shouldUpdateLyricCardForTest(1000, 2100, 800)
|
|
const result = MusicCardManager.shouldUpdateLyricCardForTest(1000, 2100, 800)
|
|
|
expect(result).assertEqual(true)
|
|
expect(result).assertEqual(true)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ it('notifyPlaybackStateChangedSkipsUpdateWhenWriteFails', 0, () => {
|
|
|
|
|
+ class TestMusicCardManager extends MusicCardManager {
|
|
|
|
|
+ updateCalled: boolean = false
|
|
|
|
|
+
|
|
|
|
|
+ updateAllForms(): void {
|
|
|
|
|
+ this.updateCalled = true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const manager = new TestMusicCardManager()
|
|
|
|
|
+ const snapshot = createEmptyMusicCardSnapshot()
|
|
|
|
|
+ const store = MusicCardSnapshotStore as unknown as {
|
|
|
|
|
+ writeSnapshot: (value: unknown, context?: unknown) => boolean
|
|
|
|
|
+ }
|
|
|
|
|
+ const originalWrite = store.writeSnapshot
|
|
|
|
|
+
|
|
|
|
|
+ store.writeSnapshot = () => false
|
|
|
|
|
+ try {
|
|
|
|
|
+ manager.notifyPlaybackStateChanged(undefined, snapshot)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ store.writeSnapshot = originalWrite
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ expect(manager.updateCalled).assertEqual(false)
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|