std::unique_ptr<IEditable::Geometry>(new IEditable::Geometry(0, 0, 100, 100)),
IEditable::EditableShapeType::Circle)));
- complication2 = new WatchComplication(0, default_type, EventTap,
+ complication2 = new WatchComplication(1, default_type, EventTap,
providerId2.c_str(), ShortText);
complication2->Init();
}
EXPECT_STREQ(value, "TEST_VALUE");
}
+TEST_F(WC, DuplicateID)
+{
+ WatchComplication* comp = nullptr;
+ try {
+ comp = new WatchComplication(0, default_type, EventTap,
+ providerId.c_str(), ShortText);
+ } catch (Exception &ex) {
+ cout << "Exception " << ex.what() << " (" << ex.GetErrorCode() << ") " << endl;
+ EXPECT_EQ(ex.GetErrorCode(), WATCHFACE_COMPLICATION_ERROR_EXIST_ID);
+ }
+ EXPECT_EQ(comp, nullptr);
+}
+
TEST_F(WC, ApplyAllowedList)
{
std::list<std::unique_ptr<Complication::ProviderInfo>> allowed_list;
static const std::string provider_type_key_;
static const std::string supported_events_error_key_;
static const std::string privilege_error_key_;
+ static std::list<int> complication_id_list_;
IEditable::EditableState ed_state_ = Complete;
guint periodic_timer_ = 0;
std::map<std::string, int> sender_info_;
#define QUERY_MAXLEN 4096
namespace watchface_complication {
-
+std::list<int> Complication::Impl::complication_id_list_;
const std::string Complication::Impl::provider_id_key_ = "__PROVIDER_ID_KEY__";
const std::string Complication::Impl::provider_type_key_ = "__PROVIDER_TYPE_KEY__";
const std::string Complication::Impl::supported_events_error_key_ = "__SUPPORTED_EVENTS_ERROR_KEY__";
gdbus_(std::unique_ptr<IGDBus>(ComplicationConnector::GetInst(mock).CreateGDBus(mock))),
package_(std::unique_ptr<IPackageManager>(ComplicationConnector::GetInst(mock).CreatePackageManager(mock))),
mock_(mock) {
+ for (auto& i : complication_id_list_) {
+ if (i == complication_id_) {
+ LOGE("Exist complication id (%d)", complication_id_);
+ THROW(WATCHFACE_COMPLICATION_ERROR_EXIST_ID);
+ }
+ }
+ complication_id_list_.emplace_back(complication_id_);
LOGI("complication create %d", complication_id_);
}
if (periodic_timer_)
g_source_remove(periodic_timer_);
package_.get()->UnWatch(this);
+ for (auto& i : complication_id_list_) {
+ if (i == complication_id_) {
+ complication_id_list_.remove(i);
+ LOGW("remove %d from id list", i);
+ break;
+ }
+ }
}
void Complication::Impl::OnVanish(const std::string& name) {