Modify enumeration of component state 08/212208/2
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 19 Aug 2019 03:13:57 +0000 (12:13 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 19 Aug 2019 03:22:28 +0000 (12:22 +0900)
The elements of enumeration are changed.

Change-Id: I0c084f1fd88761bac580d3a840a1485dbdf41e9d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/component_context.h
src/component_context.c
unit_tests/mock/mock_aul_comp_types.h [new file with mode: 0644]
unit_tests/src/test_component_context.cc

index d9a4339..145599e 100644 (file)
@@ -46,11 +46,12 @@ typedef void *component_context_h;
  * @since_tizen 5.5
  */
 typedef enum {
-       COMPONENT_STATE_UNDEFINED,      /**< The undefined state. */
-       COMPONENT_STATE_FOREGROUND,     /**< The frame component is running in the foreground. */
-       COMPONENT_STATE_BACKGROUND,     /**< The frame component is running in the background. */
-       COMPONENT_STATE_SERVICE,        /**< The service component is running. */
-       COMPONENT_STATE_TERMINATED,     /**< The component is terminated. */
+       COMPONENT_STATE_INITIALIZED,    /**< The initialized state. This is the state when the component is constructed but the create callback is not called yet */
+       COMPONENT_STATE_CREATED,        /**< The created state. This state is reached after the create callback is called.  */
+       COMPONENT_STATE_STARTED,        /**< The started state. This state is reached after the start callback is called. */
+       COMPONENT_STATE_RESUMED,        /**< The resumed state. This state is reached after the resume callback is called. */
+       COMPONENT_STATE_PAUSED,         /**< The paused state. This state is reached after the pause callback is called. */
+       COMPONENT_STATE_DESTROYED,      /**< The destroyed state. This state is reached right before the destroy callback call. */
 } component_state_e;
 
 /**
index 52765cb..c199b8c 100644 (file)
@@ -285,21 +285,23 @@ static component_state_e __get_component_state(int status)
        component_state_e state;
 
        switch (status) {
-       case STATUS_VISIBLE:
-               state = COMPONENT_STATE_FOREGROUND;
+       case COMP_STATUS_INITIALIZED:
+               state = COMPONENT_STATE_INITIALIZED;
                break;
-       case STATUS_LAUNCHING:
-       case STATUS_BG:
-               state = COMPONENT_STATE_BACKGROUND;
+       case COMP_STATUS_CREATED:
+               state = COMPONENT_STATE_CREATED;
                break;
-       case STATUS_SERVICE:
-               state = COMPONENT_STATE_SERVICE;
+       case COMP_STATUS_STARTED:
+               state = COMPONENT_STATE_STARTED;
                break;
-       case STATUS_TERMINATE:
-               state = COMPONENT_STATE_TERMINATED;
+       case COMP_STATUS_RESUMED:
+               state = COMPONENT_STATE_RESUMED;
+               break;
+       case COMP_STATUS_PAUSED:
+               state = COMPONENT_STATE_PAUSED;
                break;
        default:
-               state = COMPONENT_STATE_UNDEFINED;
+               state = COMPONENT_STATE_DESTROYED;
                break;
        }
 
diff --git a/unit_tests/mock/mock_aul_comp_types.h b/unit_tests/mock/mock_aul_comp_types.h
new file mode 100644 (file)
index 0000000..c798d8c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_MOCK_AUL_COMP_TYPES_H__
+#define UNIT_TESTS_MOCK_MOCK_AUL_COMP_TYPES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       COMP_STATUS_INITIALIZED,
+       COMP_STATUS_CREATED,
+       COMP_STATUS_STARTED,
+       COMP_STATUS_RESUMED,
+       COMP_STATUS_PAUSED,
+       COMP_STATUS_DESTROYED,
+} comp_status_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // UNIT_TESTS_MOCK_MOCK_AUL_COMP_TYPES_H__
index 650c25d..0961ca8 100644 (file)
@@ -23,6 +23,7 @@
 #include <iostream>
 #include <memory>
 
+#include "mock_aul_comp_types.h"
 #include "mock_aul_comp_context.h"
 #include "component_manager.h"
 
@@ -78,7 +79,7 @@ static int __fake_aul_comp_context_get_pid(aul_comp_context_h handle,
 
 static int __fake_aul_comp_context_get_status(aul_comp_context_h handle,
     int* status) {
-  *status = STATUS_VISIBLE;
+  *status = COMP_STATUS_RESUMED;
   return AUL_R_OK;
 }
 
@@ -238,11 +239,11 @@ TEST_F(ComponentContextTest, component_context_get_instance_id_Negative) {
 
 TEST_F(ComponentContextTest, component_context_get_component_state_Positive) {
   component_context_h handle = GetHandle();
-  component_state_e state = COMPONENT_STATE_UNDEFINED;
+  component_state_e state = COMPONENT_STATE_INITIALIZED;
 
   int ret = component_context_get_component_state(handle, &state);
   EXPECT_EQ(ret, COMPONENT_MANAGER_ERROR_NONE);
-  EXPECT_EQ(state, COMPONENT_STATE_FOREGROUND);
+  EXPECT_EQ(state, COMPONENT_STATE_RESUMED);
 }
 
 TEST_F(ComponentContextTest, component_context_get_component_state_Negative) {