Mårten Kongstad | af3da9d | 2023-07-24 11:10:00 +0200 | [diff] [blame] | 1 | import static com.android.aconfig.test.Flags.FLAG_DISABLED_RO; |
| 2 | import static com.android.aconfig.test.Flags.FLAG_DISABLED_RW; |
| 3 | import static com.android.aconfig.test.Flags.FLAG_ENABLED_RO; |
| 4 | import static com.android.aconfig.test.Flags.FLAG_ENABLED_RW; |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 5 | import static com.android.aconfig.test.Flags.disabledRo; |
| 6 | import static com.android.aconfig.test.Flags.disabledRw; |
| 7 | import static com.android.aconfig.test.Flags.enabledRo; |
| 8 | import static com.android.aconfig.test.Flags.enabledRw; |
Mårten Kongstad | af3da9d | 2023-07-24 11:10:00 +0200 | [diff] [blame] | 9 | import static org.junit.Assert.assertEquals; |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 10 | import static org.junit.Assert.assertFalse; |
Zhi Dou | a720011 | 2023-08-07 18:09:28 +0000 | [diff] [blame] | 11 | import static org.junit.Assert.assertThrows; |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 12 | import static org.junit.Assert.assertTrue; |
| 13 | |
| 14 | import org.junit.Test; |
| 15 | import org.junit.runner.RunWith; |
| 16 | import org.junit.runners.JUnit4; |
| 17 | |
Zhi Dou | a720011 | 2023-08-07 18:09:28 +0000 | [diff] [blame] | 18 | import com.android.aconfig.test.FakeFeatureFlagsImpl; |
| 19 | import com.android.aconfig.test.FeatureFlags; |
| 20 | |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 21 | @RunWith(JUnit4.class) |
| 22 | public final class AconfigTest { |
| 23 | @Test |
| 24 | public void testDisabledReadOnlyFlag() { |
Mårten Kongstad | af3da9d | 2023-07-24 11:10:00 +0200 | [diff] [blame] | 25 | assertEquals("com.android.aconfig.test.disabled_ro", FLAG_DISABLED_RO); |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 26 | assertFalse(disabledRo()); |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | @Test |
| 30 | public void testEnabledReadOnlyFlag() { |
Mårten Kongstad | af3da9d | 2023-07-24 11:10:00 +0200 | [diff] [blame] | 31 | assertEquals("com.android.aconfig.test.disabled_rw", FLAG_DISABLED_RW); |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 32 | // TODO: change to assertTrue(enabledRo()) when the build supports reading tests/*.values |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 33 | // (currently all flags are assigned the default READ_ONLY + DISABLED) |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 34 | assertFalse(enabledRo()); |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | @Test |
| 38 | public void testDisabledReadWriteFlag() { |
Mårten Kongstad | af3da9d | 2023-07-24 11:10:00 +0200 | [diff] [blame] | 39 | assertEquals("com.android.aconfig.test.enabled_ro", FLAG_ENABLED_RO); |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 40 | assertFalse(disabledRw()); |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | @Test |
| 44 | public void testEnabledReadWriteFlag() { |
Mårten Kongstad | af3da9d | 2023-07-24 11:10:00 +0200 | [diff] [blame] | 45 | assertEquals("com.android.aconfig.test.enabled_rw", FLAG_ENABLED_RW); |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 46 | // TODO: change to assertTrue(enabledRw()) when the build supports reading tests/*.values |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 47 | // (currently all flags are assigned the default READ_ONLY + DISABLED) |
Zhi Dou | af81e20 | 2023-06-14 20:38:20 +0000 | [diff] [blame] | 48 | assertFalse(enabledRw()); |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 49 | } |
Zhi Dou | a720011 | 2023-08-07 18:09:28 +0000 | [diff] [blame] | 50 | |
| 51 | @Test |
| 52 | public void testFakeFeatureFlagsImplNotImpl() { |
| 53 | FeatureFlags featureFlags = new FakeFeatureFlagsImpl(); |
| 54 | assertThrows(UnsupportedOperationException.class, () -> featureFlags.enabledRw()); |
| 55 | } |
Mårten Kongstad | 9c59c31 | 2023-05-30 11:15:02 +0200 | [diff] [blame] | 56 | } |