}
}
+bool ThemeInfoBuilder::KeysExist(const std::vector<std::string>& keys) {
+ for (const std::string& key : keys) {
+ switch (bundle_.GetType(key)) {
+ case bundle_type::BUNDLE_TYPE_NONE:
+ LOG(ERROR) << "Key [" << key << "] is not exists";
+ return false;
+ case bundle_type::BUNDLE_TYPE_STR:
+ if (bundle_.GetString(key).empty()) {
+ LOG(ERROR) << "The value of key [" << key << "] can not be empty";
+ return false;
+ }
+ break;
+ case bundle_type::BUNDLE_TYPE_STR_ARRAY:
+ if (bundle_.GetStringArray(key).empty()) {
+ LOG(ERROR) << "The value of key [" << key << "] can not be empty";
+ return false;
+ }
+ break;
+ default:
+ LOG(ERROR) << "This key [" << key << "] is invalid type";
+ return false;
+ }
+ }
+
+ return true;
+}
+
} // namespace plugin
} // namespace ttm
loader::ThemeInfo Build();
void GenerateFileKey(const std::string& root);
void GenerateFileKeyWithoutExtension();
+ bool KeysExist(const std::vector<std::string>& keys);
private:
tizen_base::Bundle bundle_;
const int kJsonDepthLimit = 50;
const int kKeyLengthLimit = 128;
const int kValueLengthLimit = 1024;
+const std::vector<std::string> kMandatoryKeys = {
+ "/version",
+ "/tool_version",
+ "/title",
+ "/description",
+ "/resolution",
+ "/preview"
+};
std::string GetFileKeyRootPath(const char* pkgid) {
pkgmgrinfo_pkginfo_h handle;
return {};
}
+ if (!builder.KeysExist(kMandatoryKeys)) {
+ LOG(ERROR) << "Mandatory key is missed";
+ return {};
+ }
+
if (auto_file_key_gen_)
builder.GenerateFileKey(GetFileKeyRootPath(pkgid.c_str()));
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"50D_array" :
[
[
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"50D_array" :
[
[
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"1st" : {
"2st" : {
"3st" : {
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"1st" : {
"2st" : {
"3st" : {
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"array" : [
null,
"a",
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"array" : [
]
}
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"invalid"
}
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"128_length_key__________________________________________________________________________________________________________________" : "invalid"
}
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"127_length_key_________________________________________________________________________________________________________________" : "valid"
}
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"valid_length_value" : "................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................"
}
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"valid_length_value" : [
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................"
]
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"valid_length_value" : "..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................."
}
{
+ "version" : "1.0.0",
+ "tool_version" : "1.0.0",
+ "title" : "test_title",
+ "description" : "test_description",
+ "resolution" : "720x1280",
+ "preview" : "preview.png",
"1D_array" : ["1", "2", "3"],
"2D_array" : [
["1", "2", "3"],
"tool_version": "1.00.38.820793",
"title": "GOGO Theme",
"description": "Example for theme spec",
+ "resolution": "720x1280",
+ "preview": "GOGO_Preview.png",
"header": {
- "profile": "wearable",
- "resolutions": [
- "720x1280"
- ]
+ "profile": "wearable"
},
"theme": {
- "preview": [
- "GOGO_Preview.png"
- ],
"watchface": {
"id": "org.tizen.gogowatch",
"url": "https://www.download.gogowatch/get"
EXPECT_EQ(info.GetVersion(), "1.0.0");
EXPECT_EQ(info.GetToolVersion(), "1.00.38.820793");
EXPECT_EQ(info.GetTitle(), "GOGO Theme");
+ EXPECT_EQ(info.GetPreview(), "GOGO_Preview.png");
EXPECT_EQ(info.GetDescription(), "Example for theme spec");
EXPECT_EQ(info.GetString("/header/profile"), "wearable");
EXPECT_EQ(info.GetString("/theme/home/app_tray"), "tray.png");
EXPECT_EQ(info.GetString("/theme/watchface/id"), "org.tizen.gogowatch");
EXPECT_EQ(info.GetString("/theme/watchface/url"),
"https://www.download.gogowatch/get");
- EXPECT_EQ(info.GetStringArray("/theme/preview"),
- std::vector<std::string>({"GOGO_Preview.png"}));
EXPECT_EQ(info.GetString("/theme/files/theme_resources"),
"shared/res/theme_resources");
EXPECT_EQ(info.GetString("/object_array/0/key_A"), "A");