Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2025 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.common.test

import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
import java.util.Locale

class FixedLocaleRule(private val locale: Locale = Locale.US) : TestRule {

override fun apply(base: Statement, description: Description) = object : Statement() {
override fun evaluate() {
val originalLocale = Locale.getDefault()
Locale.setDefault(locale)
try {
base.evaluate()
} finally {
Locale.setDefault(originalLocale)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.android.billingclient.api.ProductDetails.SubscriptionOfferDetails
import com.android.billingclient.api.PurchaseHistoryRecord
import com.duckduckgo.autofill.api.email.EmailManager
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.test.FixedLocaleRule
import com.duckduckgo.common.utils.CurrentTimeProvider
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
import com.duckduckgo.feature.toggles.api.Toggle.State
Expand Down Expand Up @@ -108,6 +109,9 @@ class RealSubscriptionsManagerTest(private val authApiV2Enabled: Boolean) {
@get:Rule
val coroutineRule = CoroutineTestRule()

@get:Rule
val fixedLocalRule = FixedLocaleRule()

private val authService: AuthService = mock()
private val subscriptionsService: SubscriptionsService = mock()
private val authDataStore: FakeSubscriptionsDataStore = FakeSubscriptionsDataStore()
Expand Down
Loading