Skip to content

Commit e39351e

Browse files
committed
tests for appinfo + manifest
1 parent e070188 commit e39351e

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
package io.rebble.libpebblecommon.metadata.pbw.appinfo
2+
3+
import kotlinx.serialization.decodeFromString
4+
import kotlinx.serialization.encodeToString
5+
import kotlinx.serialization.json.Json
6+
import kotlin.test.Test
7+
import kotlin.test.assertEquals
8+
9+
class TestAppInfo {
10+
companion object {
11+
const val APP_INFO_JSON_SIMPLICITY = "{\"versionLabel\": \"3.2\", \"companyName\": \"Pebble Technology\", \"targetPlatforms\": [\"aplite\", \"basalt\", \"chalk\"], \"resources\": {\"media\": [{\"name\": \"IMAGE_MENU_ICON\", \"type\": \"png\", \"file\": \"images/menu_icon_simplicity.png\", \"menuIcon\": true}]}, \"sdkVersion\": \"3\", \"longName\": \"Simplicity\", \"watchapp\": {\"watchface\": true}, \"projectType\": \"native\", \"capabilities\": [\"\"], \"uuid\": \"54eada19-67fd-4947-a7c5-256f24e3a7d7\", \"shortName\": \"Simplicity\", \"appKeys\": {}}"
12+
const val APP_INFO_JSON_DIALER_FOR_PEBBLE = "{\"targetPlatforms\":[\"aplite\",\"basalt\",\"chalk\"],\"projectType\":\"native\",\"messageKeys\":{},\"companyName\":\"matejdro\",\"enableMultiJS\":false,\"watchapp\":{\"onlyShownOnCommunication\":false,\"hiddenApp\":false,\"watchface\":false},\"versionLabel\":\"3.3\",\"longName\":\"Dialer\",\"shortName\":\"Dialer\",\"name\":\"Dialer\",\"sdkVersion\":\"3\",\"displayName\":\"Dialer\",\"uuid\":\"158a074d-85ce-43d2-ab7d-14416ddc1058\",\"appKeys\":{},\"capabilities\":[],\"resources\":{\"media\":[{\"menuIcon\":true,\"type\":\"bitmap\",\"name\":\"ICON\",\"file\":\"icon.png\"},{\"type\":\"bitmap\",\"name\":\"ANSWER\",\"file\":\"answer.png\"},{\"type\":\"bitmap\",\"name\":\"ENDCALL\",\"file\":\"endcall.png\"},{\"type\":\"bitmap\",\"name\":\"MIC_OFF\",\"file\":\"mic_off.png\"},{\"type\":\"bitmap\",\"name\":\"MIC_ON\",\"file\":\"micon.png\"},{\"type\":\"bitmap\",\"name\":\"SPEAKER_ON\",\"file\":\"speakeron.png\"},{\"type\":\"bitmap\",\"name\":\"SPEAKER_OFF\",\"file\":\"speakeroff.png\"},{\"type\":\"bitmap\",\"name\":\"VOLUME_UP\",\"file\":\"volumeup.png\"},{\"type\":\"bitmap\",\"name\":\"VOLUME_DOWN\",\"file\":\"volumedown.png\"},{\"type\":\"bitmap\",\"name\":\"CALL_HISTORY\",\"file\":\"callhistory.png\"},{\"type\":\"bitmap\",\"name\":\"CONTACTS\",\"file\":\"contacts.png\"},{\"type\":\"bitmap\",\"name\":\"CONTACT_GROUP\",\"file\":\"contactgroup.png\"},{\"type\":\"bitmap\",\"name\":\"INCOMING_CALL\",\"file\":\"incomingcall.png\"},{\"type\":\"bitmap\",\"name\":\"OUTGOING_CALL\",\"file\":\"outgoingcall.png\"},{\"type\":\"bitmap\",\"name\":\"MISSED_CALL\",\"file\":\"missedcall.png\"},{\"type\":\"bitmap\",\"name\":\"MESSAGE\",\"file\":\"message.png\"},{\"type\":\"bitmap\",\"name\":\"CALL\",\"file\":\"call.png\"}]}}"
13+
14+
val APP_INFO_OBJ_SIMPLICITY = PbwAppInfo(
15+
uuid = "54eada19-67fd-4947-a7c5-256f24e3a7d7",
16+
shortName = "Simplicity",
17+
longName = "Simplicity",
18+
companyName = "Pebble Technology",
19+
versionLabel = "3.2",
20+
capabilities = listOf(""),
21+
resources = Resources(
22+
media = listOf(
23+
Media(
24+
resourceFile = "images/menu_icon_simplicity.png",
25+
menuIcon = true,
26+
name = "IMAGE_MENU_ICON",
27+
type = "png"
28+
)
29+
)
30+
),
31+
sdkVersion = "3",
32+
targetPlatforms = listOf("aplite", "basalt", "chalk"),
33+
watchapp = Watchapp(
34+
watchface = true
35+
)
36+
)
37+
38+
val APP_INFO_OBJ_DIALER_FOR_PEBBLE = PbwAppInfo(
39+
uuid = "158a074d-85ce-43d2-ab7d-14416ddc1058",
40+
shortName = "Dialer",
41+
longName = "Dialer",
42+
companyName = "matejdro",
43+
versionLabel = "3.3",
44+
resources = Resources(
45+
media = listOf(
46+
Media(
47+
resourceFile = "icon.png",
48+
menuIcon = true,
49+
name = "ICON",
50+
type = "bitmap"
51+
),
52+
Media(
53+
resourceFile = "answer.png",
54+
name = "ANSWER",
55+
type = "bitmap"
56+
),
57+
Media(
58+
resourceFile = "endcall.png",
59+
name = "ENDCALL",
60+
type = "bitmap"
61+
),
62+
Media(
63+
resourceFile = "mic_off.png",
64+
name = "MIC_OFF",
65+
type = "bitmap"
66+
),
67+
Media(
68+
resourceFile = "micon.png",
69+
name = "MIC_ON",
70+
type = "bitmap"
71+
),
72+
Media(
73+
resourceFile = "speakeron.png",
74+
name = "SPEAKER_ON",
75+
type = "bitmap"
76+
),
77+
Media(
78+
resourceFile = "speakeroff.png",
79+
name = "SPEAKER_OFF",
80+
type = "bitmap"
81+
),
82+
Media(
83+
resourceFile = "volumeup.png",
84+
name = "VOLUME_UP",
85+
type = "bitmap"
86+
),
87+
Media(
88+
resourceFile = "volumedown.png",
89+
name = "VOLUME_DOWN",
90+
type = "bitmap"
91+
),
92+
Media(
93+
resourceFile = "callhistory.png",
94+
name = "CALL_HISTORY",
95+
type = "bitmap"
96+
),
97+
Media(
98+
resourceFile = "contacts.png",
99+
name = "CONTACTS",
100+
type = "bitmap"
101+
),
102+
Media(
103+
resourceFile = "contactgroup.png",
104+
name = "CONTACT_GROUP",
105+
type = "bitmap"
106+
),
107+
Media(
108+
resourceFile = "incomingcall.png",
109+
name = "INCOMING_CALL",
110+
type = "bitmap"
111+
),
112+
Media(
113+
resourceFile = "outgoingcall.png",
114+
name = "OUTGOING_CALL",
115+
type = "bitmap"
116+
),
117+
Media(
118+
resourceFile = "missedcall.png",
119+
name = "MISSED_CALL",
120+
type = "bitmap"
121+
),
122+
Media(
123+
resourceFile = "message.png",
124+
name = "MESSAGE",
125+
type = "bitmap"
126+
),
127+
Media(
128+
resourceFile = "call.png",
129+
name = "CALL",
130+
type = "bitmap"
131+
)
132+
)
133+
),
134+
sdkVersion = "3",
135+
targetPlatforms = listOf("aplite", "basalt", "chalk"),
136+
watchapp = Watchapp()
137+
)
138+
}
139+
@Test
140+
fun deserialization() {
141+
val json = Json{ ignoreUnknownKeys = true }
142+
val simplicity: PbwAppInfo = json.decodeFromString(APP_INFO_JSON_SIMPLICITY)
143+
assertEquals(APP_INFO_OBJ_SIMPLICITY, simplicity)
144+
145+
val dialerForPebble: PbwAppInfo = json.decodeFromString(APP_INFO_JSON_DIALER_FOR_PEBBLE)
146+
assertEquals(APP_INFO_OBJ_DIALER_FOR_PEBBLE, dialerForPebble)
147+
}
148+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package io.rebble.libpebblecommon.metadata.pbw.manifest
2+
3+
import io.rebble.libpebblecommon.metadata.pbw.appinfo.PbwAppInfo
4+
import io.rebble.libpebblecommon.metadata.pbw.appinfo.TestAppInfo
5+
import kotlinx.serialization.decodeFromString
6+
import kotlinx.serialization.json.Json
7+
import kotlin.test.Test
8+
import kotlin.test.assertEquals
9+
10+
class TestManifest {
11+
companion object {
12+
const val MANIFEST_JSON_SIMPLICITY_V1 = "{\"manifestVersion\": 1, \"generatedBy\": \"46e8a544-50dc-4610-aa27-d86115f76f11\", \"generatedAt\": 1449884654, \"application\": {\"timestamp\": 1449884653, \"sdk_version\": {\"major\": 5, \"minor\": 19}, \"crc\": 893549736, \"name\": \"pebble-app.bin\", \"size\": 1339}, \"debug\": {}, \"type\": \"application\", \"resources\": {\"timestamp\": 1449884653, \"crc\": 3436670150, \"name\": \"app_resources.pbpack\", \"size\": 4232}}"
13+
const val MANIFEST_JSON_SIMPLICITY = "{\"manifestVersion\": 2, \"generatedBy\": \"46e8a544-50dc-4610-aa27-d86115f76f11\", \"generatedAt\": 1449884654, \"application\": {\"timestamp\": 1449884653, \"sdk_version\": {\"major\": 5, \"minor\": 72}, \"crc\": 266802728, \"name\": \"pebble-app.bin\", \"size\": 1363}, \"debug\": {}, \"app_layouts\": \"layouts.json\", \"type\": \"application\", \"resources\": {\"timestamp\": 1449884653, \"crc\": 3168848230, \"name\": \"app_resources.pbpack\", \"size\": 4218}}"
14+
15+
val MANIFEST_OBJ_SIMPLICITY_V1 = PbwManifest(
16+
application = PbwBlob(
17+
crc = 893549736,
18+
name = "pebble-app.bin",
19+
sdkVersion = SdkVersion(
20+
major = 5,
21+
minor = 19
22+
),
23+
size = 1339,
24+
timestamp = 1449884653
25+
),
26+
resources = PbwBlob(
27+
crc = 3436670150,
28+
name = "app_resources.pbpack",
29+
size = 4232,
30+
timestamp = 1449884653
31+
),
32+
debug = Debug(),
33+
generatedAt = 1449884654,
34+
generatedBy = "46e8a544-50dc-4610-aa27-d86115f76f11",
35+
manifestVersion = 1,
36+
type = "application"
37+
)
38+
}
39+
40+
@Test
41+
fun deserialization() {
42+
val json = Json{ ignoreUnknownKeys = true }
43+
val simplicityv1: PbwManifest = json.decodeFromString(MANIFEST_JSON_SIMPLICITY_V1)
44+
assertEquals(MANIFEST_OBJ_SIMPLICITY_V1, simplicityv1)
45+
46+
//TODO: v2 manifest
47+
}
48+
}

0 commit comments

Comments
 (0)