OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 mockedDefaultSubs = mock(DefaultSubscriptions::class.java) | 47 mockedDefaultSubs = mock(DefaultSubscriptions::class.java) |
48 RuntimeEnvironment.application.resources | 48 RuntimeEnvironment.application.resources |
49 .openRawResource(R.raw.subscriptions).use{ subscriptionsXml -> m
ockedDefaultSubs = | 49 .openRawResource(R.raw.subscriptions).use{ subscriptionsXml -> m
ockedDefaultSubs = |
50 DefaultSubscriptions.fromStream(subscriptionsXml) } | 50 DefaultSubscriptions.fromStream(subscriptionsXml) } |
51 } | 51 } |
52 | 52 |
53 @Test | 53 @Test |
54 fun subscriptionUtilsChooseDefaultSubscriptionForEmptyList() | 54 fun subscriptionUtilsChooseDefaultSubscriptionForEmptyList() |
55 { | 55 { |
56 assertEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( | 56 assertEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( |
57 emptyList<DefaultSubscriptionInfo>()), Engine.EASYLIST_URL) | 57 emptyList<DefaultSubscriptionInfo>()), SubscriptionUtils.EASYLIS
T_URL) |
58 } | 58 } |
59 | 59 |
60 @Test | 60 @Test |
61 fun subscriptionUtilsDefaultSubscriptionForChinaIsNotEasylist() | 61 fun subscriptionUtilsDefaultSubscriptionForChinaIsNotEasylist() |
62 { | 62 { |
63 Resources.getSystem().configuration.setLocale(Locale.CHINA) | 63 Resources.getSystem().configuration.setLocale(Locale.CHINA) |
64 assertNotEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( | 64 assertNotEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( |
65 mockedDefaultSubs?.adsSubscriptions), Engine.EASYLIST_URL) | 65 mockedDefaultSubs?.adsSubscriptions), SubscriptionUtils.EASYLIST
_URL) |
66 } | 66 } |
67 | 67 |
68 @Test | 68 @Test |
69 fun subscriptionUtilsChooseDefaultSubscriptionUrlForGerman() | 69 fun subscriptionUtilsChooseDefaultSubscriptionUrlForGerman() |
70 { | 70 { |
71 Resources.getSystem().configuration.setLocale(Locale.GERMANY) | 71 Resources.getSystem().configuration.setLocale(Locale.GERMANY) |
72 assertEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( | 72 assertEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( |
73 mockedDefaultSubs?.adsSubscriptions), EASYLIST_GERMANY_COMPLETE_
URL) | 73 mockedDefaultSubs?.adsSubscriptions), EASYLIST_GERMANY_COMPLETE_
URL) |
74 } | 74 } |
75 | 75 |
76 @Test | 76 @Test |
77 fun subscriptionUtilsChooseDefaultSubscriptionForUnsupportedLanguage() | 77 fun subscriptionUtilsChooseDefaultSubscriptionForUnsupportedLanguage() |
78 { | 78 { |
79 Resources.getSystem().configuration.setLocale(Locale.forLanguageTag("ab-
xy")) | 79 Resources.getSystem().configuration.setLocale(Locale.forLanguageTag("ab-
xy")) |
80 assertEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( | 80 assertEquals(SubscriptionUtils.chooseDefaultSubscriptionUrl( |
81 mockedDefaultSubs?.adsSubscriptions), Engine.EASYLIST_URL) | 81 mockedDefaultSubs?.adsSubscriptions), SubscriptionUtils.EASYLIST
_URL) |
82 } | 82 } |
83 | 83 |
84 @Test | 84 @Test |
85 fun sharedPrefsUtilsPutAndGetSameBoolean() | 85 fun sharedPrefsUtilsPutAndGetSameBoolean() |
86 { | 86 { |
87 val testBoolean = true | 87 val testBoolean = true |
88 SharedPrefsUtils.putBoolean(context, R.string.key_aa_info_shown, testBoo
lean) | 88 SharedPrefsUtils.putBoolean(context, R.string.key_aa_info_shown, testBoo
lean) |
89 val equalBoolean = SharedPrefsUtils.getBoolean(context, R.string.key_aa_
info_shown, | 89 val equalBoolean = SharedPrefsUtils.getBoolean(context, R.string.key_aa_
info_shown, |
90 !testBoolean) | 90 !testBoolean) |
91 assertEquals(testBoolean, equalBoolean) | 91 assertEquals(testBoolean, equalBoolean) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 @Test | 154 @Test |
155 fun sharedPrefsUtilsPutAndGetDifferentStringSet() | 155 fun sharedPrefsUtilsPutAndGetDifferentStringSet() |
156 { | 156 { |
157 val testStringSet = setOf("Hello", "World") | 157 val testStringSet = setOf("Hello", "World") |
158 SharedPrefsUtils.putStringSet(context, R.string.key_previous_version_cod
e, testStringSet) | 158 SharedPrefsUtils.putStringSet(context, R.string.key_previous_version_cod
e, testStringSet) |
159 val unequalStringSet = SharedPrefsUtils.getStringSet(context, | 159 val unequalStringSet = SharedPrefsUtils.getStringSet(context, |
160 R.string.key_aa_info_shown, setOf("Hello", "World", "!")) | 160 R.string.key_aa_info_shown, setOf("Hello", "World", "!")) |
161 assertNotEquals(testStringSet, unequalStringSet) | 161 assertNotEquals(testStringSet, unequalStringSet) |
162 } | 162 } |
163 } | 163 } |
OLD | NEW |