Add LCOV remarkers to increase line coverage rate
[platform/core/api/maps-service.git] / src / view / polyline_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 "polyline_constructor.h"
19
20 extern int _maps_view_object_create(const maps_view_object_type_e type,
21                               maps_view_object_h *object);
22
23 maps_view_object_h view::polyline_constructor::construct(const maps_coordinates_list_h
24                                                    coordinates,
25                                                    const unsigned char r,
26                                                    const unsigned char g,
27                                                    const unsigned char b,
28                                                    const unsigned char a,
29                                                    const int width)
30 {
31         if (!coordinates || (width <= 0)) {
32                 //LCOV_EXCL_START
33                 __error = MAPS_ERROR_INVALID_PARAMETER;
34                 return NULL;
35                 //LCOV_EXCL_STOP
36         }
37
38         __error = MAPS_ERROR_NONE;
39
40         maps_view_object_h polyline = NULL;
41         do {
42                 /* 1. Create a visual object for polyline */
43                 __error = _maps_view_object_create(MAPS_VIEW_OBJECT_POLYLINE,
44                                                  &polyline);
45                 if (__error != MAPS_ERROR_NONE)
46                         break;
47
48                 /* 2. Set the polyline points */
49                 __error = maps_view_object_polyline_set_polyline(polyline,
50                                                            coordinates);
51                 if (__error != MAPS_ERROR_NONE)
52                         break;
53
54                 /* 3. Set the polyline color */
55                 __error = maps_view_object_polyline_set_color(polyline,
56                                                              r, g, b, a);
57                 if (__error != MAPS_ERROR_NONE)
58                         break;
59
60                 /* 4. Set the polyline width */
61                 __error = maps_view_object_polyline_set_width(polyline, width);
62                 if (__error != MAPS_ERROR_NONE)
63                         break;
64
65                 /* 5. Set the polyline visible */
66                 __error = maps_view_object_set_visible(polyline, true);
67                 if (__error != MAPS_ERROR_NONE)
68                         break;
69
70                 /* SUCCESS */
71                 return polyline;
72         } while (false);
73
74         //LCOV_EXCL_START
75         /* FAILURE: Releasing objects */
76         maps_view_object_destroy(polyline);
77         return NULL;
78         //LCOV_EXCL_STOP
79 }