File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
common/common-test/src/main/java/com/duckduckgo/common/test
subscriptions/subscriptions-impl/src/test/java/com/duckduckgo/subscriptions/impl Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025 DuckDuckGo
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package com.duckduckgo.common.test
18+
19+ import org.junit.rules.TestRule
20+ import org.junit.runner.Description
21+ import org.junit.runners.model.Statement
22+ import java.util.Locale
23+
24+ class FixedLocaleRule (private val locale : Locale = Locale .US ) : TestRule {
25+
26+ override fun apply (base : Statement , description : Description ) = object : Statement () {
27+ override fun evaluate () {
28+ val originalLocale = Locale .getDefault()
29+ Locale .setDefault(locale)
30+ try {
31+ base.evaluate()
32+ } finally {
33+ Locale .setDefault(originalLocale)
34+ }
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import com.android.billingclient.api.ProductDetails.SubscriptionOfferDetails
1010import com.android.billingclient.api.PurchaseHistoryRecord
1111import com.duckduckgo.autofill.api.email.EmailManager
1212import com.duckduckgo.common.test.CoroutineTestRule
13+ import com.duckduckgo.common.test.FixedLocaleRule
1314import com.duckduckgo.common.utils.CurrentTimeProvider
1415import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
1516import com.duckduckgo.feature.toggles.api.Toggle.State
@@ -108,6 +109,9 @@ class RealSubscriptionsManagerTest(private val authApiV2Enabled: Boolean) {
108109 @get:Rule
109110 val coroutineRule = CoroutineTestRule ()
110111
112+ @get:Rule
113+ val fixedLocalRule = FixedLocaleRule ()
114+
111115 private val authService: AuthService = mock()
112116 private val subscriptionsService: SubscriptionsService = mock()
113117 private val authDataStore: FakeSubscriptionsDataStore = FakeSubscriptionsDataStore ()
You can’t perform that action at this time.
0 commit comments