IMPORTANT: The file content has been truncated. Status: Showing lines 520-580 of 608 total lines. Action: To read more of the file, you can use the 'start_line' and 'end_line' parameters in a subsequent 'read_file' call. For example, to read the next section of the file, use start_line: 581. --- FILE CONTENT (truncated) --- testScope.runTest { every { mockBillingClient.isReady } returns true stubQueryPurchases(errorResult(), emptyList()) val result = billingManagerImpl.restorePurchases() assertThat(result).isEqualTo(RestoreResult.Error(BillingClient.BillingResponseCode.ERROR)) } // ── Tests: DebugBillingOverride — FORCE_PREMIUM short-circuit ──────────────── @Test fun `FORCE_PREMIUM sets isPremium to true and short-circuits purchase flow`() = testScope.runTest { preferences.setDebugBillingOverrideMode(DebugBillingOverrideMode.FORCE_PREMIUM) advanceUntilIdle() assertThat(billingManagerImpl.isPremium.value).isTrue() val mockActivity = mockk(relaxed = true) val result = billingManagerImpl.launchPremiumPurchaseFlow(mockActivity) assertThat(result).isEqualTo(BillingLaunchResult.Success) // Ensure real BillingClient was NOT asked to launch flow or query details verify(exactly = 0) { mockBillingClient.launchBillingFlow(any(), any()) } } @Test fun `FORCE_FREE sets isPremium to false even if real purchase exists`() = testScope.runTest { // Real purchase exists val purchase = makePurchase(state = Purchase.PurchaseState.PURCHASED, acknowledged = true) stubStartConnectionOk() stubQueryPurchases(okResult(), listOf(purchase)) stubQueryProductDetailsOk() billingManagerImpl.startConnection() advanceUntilIdle() assertThat(billingManagerImpl.isPremium.value).isTrue() // Apply FORCE_FREE override preferences.setDebugBillingOverrideMode(DebugBillingOverrideMode.FORCE_FREE) advanceUntilIdle() assertThat(billingManagerImpl.isPremium.value).isFalse() } @Test fun `FORCE_PREMIUM makes restorePurchases return Success(hadPurchase=true)`() = testScope.runTest { preferences.setDebugBillingOverrideMode(DebugBillingOverrideMode.FORCE_PREMIUM) advanceUntilIdle() val result = billingManagerImpl.restorePurchases() assertThat(result).isEqualTo(RestoreResult.Success(hadPurchase = true)) verify(exactly = 0) { mockBillingClient.queryPurchasesAsync(any(), any()) } } // ── Test fakes ─────────────────────────────────────────────────────────────── private inner class FakeAppPreferencesStore(