diff options
Diffstat (limited to 'updater_sample/tests')
4 files changed, 31 insertions, 20 deletions
diff --git a/updater_sample/tests/res/raw/update_config_001_stream.json b/updater_sample/tests/res/raw/update_config_001_stream.json index be51b7c95..b024ad947 100644 --- a/updater_sample/tests/res/raw/update_config_001_stream.json +++ b/updater_sample/tests/res/raw/update_config_001_stream.json @@ -2,7 +2,9 @@ "name": "streaming-001", "url": "http://foo.bar/update.zip", "ab_install_type": "STREAMING", - "ab_streaming_metadata": { + "ab_config": { + "verify_payload_metadata": true, + "force_switch_slot": true, "property_files": [ { "filename": "payload.bin", @@ -10,8 +12,5 @@ "size": 8 } ] - }, - "ab_config": { - "force_switch_slot": true } } diff --git a/updater_sample/tests/res/raw/update_config_002_stream.json b/updater_sample/tests/res/raw/update_config_002_stream.json index 40c8fe1c1..12c18bb70 100644 --- a/updater_sample/tests/res/raw/update_config_002_stream.json +++ b/updater_sample/tests/res/raw/update_config_002_stream.json @@ -1,10 +1,8 @@ { "__": "*** Generated using tools/gen_update_config.py ***", "ab_config": { - "force_switch_slot": false - }, - "ab_install_type": "STREAMING", - "ab_streaming_metadata": { + "verify_payload_metadata": true, + "force_switch_slot": false, "property_files": [ { "filename": "payload_metadata.bin", @@ -38,6 +36,7 @@ } ] }, + "ab_install_type": "STREAMING", "name": "S ota_002_package", "url": "file:///data/my-sample-ota-builds-dir/ota_002_package.zip" }
\ No newline at end of file diff --git a/updater_sample/tests/res/raw/update_config_003_nonstream.json b/updater_sample/tests/res/raw/update_config_003_nonstream.json index 7c78b9d21..2011f76d9 100644 --- a/updater_sample/tests/res/raw/update_config_003_nonstream.json +++ b/updater_sample/tests/res/raw/update_config_003_nonstream.json @@ -1,7 +1,15 @@ { "__": "*** Generated using tools/gen_update_config.py ***", "ab_config": { - "force_switch_slot": false + "verify_payload_metadata": true, + "force_switch_slot": false, + "property_files": [ + { + "filename": "payload.bin", + "offset": 195, + "size": 8 + } + ] }, "ab_install_type": "NON_STREAMING", "name": "S ota_002_package", diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java index 1cbd8601e..48d0e424d 100644 --- a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java +++ b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java @@ -44,10 +44,12 @@ import java.io.InputStreamReader; @SmallTest public class UpdateConfigTest { - private static final String JSON_NON_STREAMING = - "{\"name\": \"vip update\", \"url\": \"file:///builds/a.zip\", " - + " \"ab_install_type\": \"NON_STREAMING\"," - + " \"ab_config\": { \"force_switch_slot\": false } }"; + private static final String JSON_NON_STREAMING = "{" + + " \"name\": \"vip update\", \"url\": \"file:///my-builds/a.zip\"," + + " \"ab_install_type\": \"NON_STREAMING\"," + + " \"ab_config\": {" + + " \"force_switch_slot\": false," + + " \"verify_payload_metadata\": false } }"; @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -71,7 +73,7 @@ public class UpdateConfigTest { assertSame("type is parsed", UpdateConfig.AB_INSTALL_TYPE_NON_STREAMING, config.getInstallType()); - assertEquals("url is parsed", "file:///builds/a.zip", config.getUrl()); + assertEquals("url is parsed", "file:///my-builds/a.zip", config.getUrl()); } @Test @@ -81,9 +83,9 @@ public class UpdateConfigTest { assertEquals("http://foo.bar/update.zip", config.getUrl()); assertSame(UpdateConfig.AB_INSTALL_TYPE_STREAMING, config.getInstallType()); assertEquals("payload.bin", - config.getStreamingMetadata().getPropertyFiles()[0].getFilename()); - assertEquals(195, config.getStreamingMetadata().getPropertyFiles()[0].getOffset()); - assertEquals(8, config.getStreamingMetadata().getPropertyFiles()[0].getSize()); + config.getAbConfig().getPropertyFiles()[0].getFilename()); + assertEquals(195, config.getAbConfig().getPropertyFiles()[0].getOffset()); + assertEquals(8, config.getAbConfig().getPropertyFiles()[0].getSize()); assertTrue(config.getAbConfig().getForceSwitchSlot()); } @@ -96,9 +98,12 @@ public class UpdateConfigTest { @Test public void getUpdatePackageFile_throwsErrorIfNotAFile() throws Exception { - String json = "{\"name\": \"upd\", \"url\": \"http://foo.bar\"," + String json = "{" + + " \"name\": \"upd\", \"url\": \"http://foo.bar\"," + " \"ab_install_type\": \"NON_STREAMING\"," - + " \"ab_config\": { \"force_switch_slot\": false } }"; + + " \"ab_config\": {" + + " \"force_switch_slot\": false," + + " \"verify_payload_metadata\": false } }"; UpdateConfig config = UpdateConfig.fromJson(json); thrown.expect(RuntimeException.class); config.getUpdatePackageFile(); @@ -107,7 +112,7 @@ public class UpdateConfigTest { @Test public void getUpdatePackageFile_works() throws Exception { UpdateConfig c = UpdateConfig.fromJson(JSON_NON_STREAMING); - assertEquals("/builds/a.zip", c.getUpdatePackageFile().getAbsolutePath()); + assertEquals("/my-builds/a.zip", c.getUpdatePackageFile().getAbsolutePath()); } private String readResource(int id) throws IOException { |