return THEME_MANAGER_ERROR_NONE;
}
+extern "C" EXPORT_API int theme_is_key_exist(theme_h handle, const char* key,
+ bool* val) {
+ if (handle == nullptr || key == nullptr || val == nullptr) {
+ LOG(ERROR) << "Invalid parameter";
+ return THEME_MANAGER_ERROR_INVALID_PARAMETER;
+ }
+
+ auto p = *static_cast<std::shared_ptr<ThemeInfo>*>(handle);
+ *val = p->HasKey(std::string(key));
+
+ return THEME_MANAGER_ERROR_NONE;
+}
+
extern "C" EXPORT_API int theme_clone(theme_h handle, theme_h* new_handle) {
if (handle == nullptr || new_handle == nullptr) {
LOG(ERROR) << "Invalid parameter";
*/
int theme_get_bool(theme_h handle, const char *key, bool *val);
+/**
+ * @brief Check the given key is exist or not.
+ * @since_tizen 6.5
+ * @param[in] handle The theme information
+ * @param[in] key String key to check existence
+ * @param[out] val Value corresponding to given key
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #THEME_MANAGER_ERROR_NONE Successful
+ * @retval #THEME_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int theme_is_key_exist(theme_h handle, const char *key, bool *val);
+
/**
* @brief Clones the given theme information.
* @since_tizen 6.0
throw std::invalid_argument("Required key not available");
}
+bool ThemeInfo::HasKey(const std::string& key) const {
+ return (bundle_.GetType(key) != BUNDLE_TYPE_NONE);
+}
+
tizen_base::Bundle ThemeInfo::Serialize() const {
return bundle_;
}
int GetInt(const std::string& key) const;
float GetFloat(const std::string& key) const;
bool GetBool(const std::string& key) const;
+ bool HasKey(const std::string& key) const;
tizen_base::Bundle Serialize() const;
int ret = theme_get_path_array(nullptr, "/arraykey", &paths, &count);
EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
}
+
+TEST_F(ThemeTest, Theme_IsKeyExist_P) {
+ std::shared_ptr<ThemeInfo> info(new ThemeInfo(b_));
+
+ theme_h handle = static_cast<void*>(&info);
+ bool val;
+ int ret = theme_is_key_exist(handle, "/intkey", &val);
+ EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
+ EXPECT_EQ(val, true);
+
+ ret = theme_is_key_exist(handle, "/notexist", &val);
+ EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
+ EXPECT_EQ(val, false);
+}
+
+TEST_F(ThemeTest, Theme_IsKeyExist_N) {
+ std::shared_ptr<ThemeInfo> info(new ThemeInfo());
+
+ theme_h handle = static_cast<void*>(&info);
+ bool val;
+ int ret = theme_is_key_exist(nullptr, "/intkey", &val);
+ EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
+ ret = theme_is_key_exist(handle, nullptr, &val);
+ EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
+ ret = theme_is_key_exist(handle, "/intkey", nullptr);
+ EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
+}