Remove auto selection for design elements 20/174220/5
authorhyunho <hhstark.kang@samsung.com>
Thu, 29 Mar 2018 07:06:00 +0000 (16:06 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 30 Mar 2018 00:57:22 +0000 (09:57 +0900)
Change-Id: I56c35a8f5f45c69eaccce55228bb1ec5f5d9cb15
Signed-off-by: hyunho <hhstark.kang@samsung.com>
unittest/src/test_complication.cc
unittest/src/test_editor.cc
watchface-complication/design-element-implementation.h
watchface-complication/design-element.cc
watchface-complication/include/watchface-editable.h
watchface-complication/watchface-editable.cc

index b1ed4b4..ca048f5 100644 (file)
@@ -70,7 +70,8 @@ TEST_F(WC, Create)
 
 TEST_F(WC, GetEditableId)
 {
-  EXPECT_EQ(WC::complication->GetEditableId(), 0);
+  EXPECT_EQ(WC::complication->SetEditableId(1), 0);
+  EXPECT_EQ(WC::complication->GetEditableId(), 1);
 }
 
 TEST_F(WC, GetGeo)
index ebde610..91cc48d 100644 (file)
@@ -71,7 +71,7 @@ TEST_F(WE, EditPreview)
 
   ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)));
   IEditable* ed = static_cast<IEditable*>(re);
-  EXPECT_EQ(WE::editor->EditPreview(*ed, cur_data_idx), -1);
+  EXPECT_EQ(WE::editor->EditPreview(*ed, cur_data_idx), COMPLICATION_ERROR_EDIT_NOT_READY);
   delete re;
 }
 
@@ -131,7 +131,7 @@ int _editable_list_foreach_cb(const editable_h handle, void *user_data) {
 TEST_F(WEL, EditPreview)
 {
   IEditable* ed = static_cast<IEditable*>(WEL::received);
-  EXPECT_EQ(editor_edit_preview(ed, 0), -1);
+  EXPECT_EQ(editor_edit_preview(ed, 0), COMPLICATION_ERROR_EDIT_NOT_READY);
 }
 
 TEST_F(WEL, EditReady)
index 84df8df..0043873 100755 (executable)
@@ -41,13 +41,10 @@ class DesignElement::Impl {
   Impl(Impl && other) = default;
   Impl& operator=(Impl const& other) = default;
   Impl& operator=(Impl && other) = default;
-  void RestoreStateOrSetDefault();
-
 
  private:
   DesignElement* parent_;
   int id_ = -1;
-  int default_data_idx_;
   int cur_data_idx_;
   int last_data_idx_;
   std::list<std::unique_ptr<Bundle>> candidates_list_;
index 7460868..565c62d 100755 (executable)
 
 namespace watchface_complication {
 
-DesignElement::DesignElement(int id, int default_data_idx,
+DesignElement::DesignElement(int id, int cur_data_idx,
                              std::list<std::unique_ptr<Bundle>> candidates_list,
                              std::shared_ptr<IEditable::Geometry> geo)
-  : impl_(new Impl(this, id, default_data_idx, std::move(candidates_list), geo)) {
+  : impl_(new Impl(this, id, cur_data_idx, std::move(candidates_list), geo)) {
 }
 
 DesignElement::~DesignElement() {
   LOGE("design element destroy %d", impl_->id_);
 }
 DesignElement::Impl::Impl(DesignElement* parent, int id,
-                          int default_data_idx,
+                          int cur_data_idx,
                           std::list<std::unique_ptr<Bundle>> candidates_list,
                           std::shared_ptr<IEditable::Geometry> geo)
-  : parent_(parent), id_(id), default_data_idx_(default_data_idx),
+  : parent_(parent), id_(id), cur_data_idx_(cur_data_idx),
     candidates_list_(std::move(candidates_list)),
     geo_(geo) {
-  RestoreStateOrSetDefault();
-}
-
-void DesignElement::Impl::RestoreStateOrSetDefault() {
-  std::unique_ptr<Bundle> setting_data =
-      EditablesManager::GetInst().LoadSetting(id_);
-
-  cur_data_idx_ = default_data_idx_;
-  last_data_idx_ = cur_data_idx_;
-  if (setting_data == nullptr) {
-    LOGI("no setting data");
-    return;
-  }
-
-  int idx = 0;
-  for (auto& i : candidates_list_) {
-    Bundle& data = *(i.get());
-    if (strcmp(data.ToString(), (setting_data.get())->ToString()) == 0) {
-      LOGI("restore default value idx : %d", idx);
-      cur_data_idx_ = idx;
-      break;
-    }
-    idx++;
-  }
-
   last_data_idx_ = cur_data_idx_;
-  LOGI("cur data idx : %d", cur_data_idx_);
 }
 
 int DesignElement::GetEditableId() {
index 1e6d220..757663a 100755 (executable)
@@ -59,7 +59,7 @@ typedef int (*on_edit_ready)(editable_container_h handle,
                              const char *editor_appid, void *user_data);
 
 int editable_add_design_element(editable_container_h handle, int editable_id,
-                                int default_data_idx, GList *candiates_list,
+                                int cur_data_idx, GList *candiates_list,
                                 editable_geo geo, const char *editable_name);
 int editable_get_editable_name(const editable_h handle,
     const char **editable_name);
index c70664f..c6fb954 100755 (executable)
@@ -130,7 +130,7 @@ class EditablesContainerStub : public EditablesContainer {
 
 static EditablesContainerStub *__container;
 extern "C" EXPORT_API int editable_add_design_element(editable_container_h handle,
-    int edit_id, int default_data_idx, GList* candiatelist, editable_geo geo,
+    int edit_id, int cur_data_idx, GList* candiatelist, editable_geo geo,
     const char* editable_name) {
   if (handle == NULL || candiatelist == NULL || editable_name == NULL)
     return COMPLICATION_ERROR_INVALID_PARAMETER;
@@ -155,8 +155,7 @@ extern "C" EXPORT_API int editable_add_design_element(editable_container_h handl
     LOGE("ID already exist");
     return COMPLICATION_ERROR_EXIST_ID;
   }
-  auto de = std::shared_ptr<IEditable>(new DesignElement(edit_id,
-                      default_data_idx,
+  auto de = std::shared_ptr<IEditable>(new DesignElement(edit_id, cur_data_idx,
                       std::move(new_list),
                       std::shared_ptr<IEditable::Geometry>(
                         new IEditable::Geometry(0, 0, 100, 100))));