Add LCOV remarkers to increase line coverage rate
[platform/core/api/maps-service.git] / src / view / marker_constructor.cpp
1 /* Copyright (c) 2010-2014 Samsung Electronics Co., Ltd. All rights reserved.
2  *
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include "marker_constructor.h"
19
20 extern int _maps_view_object_create(const maps_view_object_type_e type, maps_view_object_h *object);
21
22 extern int _maps_view_object_marker_set_type(maps_view_object_h marker, maps_view_marker_type_e type);
23
24 maps_view_object_h view::marker_constructor::construct(maps_coordinates_h coordinates,
25                                                 const char *image_file_path, maps_view_marker_type_e type)
26 {
27         if (!coordinates || !image_file_path) {
28                 __error = MAPS_ERROR_INVALID_PARAMETER;
29                 return NULL;
30         }
31
32         if ((type < MAPS_VIEW_MARKER_PIN) || (type > MAPS_VIEW_MARKER_STICKER)) {
33                 //LCOV_EXCL_START
34                 __error = MAPS_ERROR_INVALID_PARAMETER;
35                 return NULL;
36                 //LCOV_EXCL_STOP
37         }
38
39         __error = MAPS_ERROR_NONE;
40
41         maps_view_object_h marker = NULL;
42         do {
43                 /* 1. Create a visual object for marker */
44                 __error = _maps_view_object_create(MAPS_VIEW_OBJECT_MARKER, &marker);
45                 if (__error != MAPS_ERROR_NONE)
46                         break;
47
48                 /* 2. Set the marker image file pathe */
49                 __error = maps_view_object_marker_set_image_file(marker, image_file_path);
50                 if (__error != MAPS_ERROR_NONE)
51                         break;
52
53                 /* 3. Set the marker type */
54                 __error = _maps_view_object_marker_set_type(marker, type);
55                 if (__error != MAPS_ERROR_NONE)
56                         break;
57
58                 /* 4 Move the marker to the given coordinates */
59                 __error = maps_view_object_marker_set_coordinates(marker, coordinates);
60                 if (__error != MAPS_ERROR_NONE)
61                         break;
62
63                 /* SUCCESS */
64                 return marker;
65         } while (false);
66
67         //LCOV_EXCL_START
68         /* FAILURE: Releasing objects */
69         maps_view_object_destroy(marker);
70         return NULL;
71         //LCOV_EXCL_STOP
72 }