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