tests/vector-renderer.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #undef G_DISABLE_ASSERT | ||
| 2 | |||
| 3 | #include <glib-object.h> | ||
| 4 | #include <shumate/shumate.h> | ||
| 5 | #include "shumate/shumate-tile-private.h" | ||
| 6 | #include "shumate/shumate-vector-renderer-private.h" | ||
| 7 | #include "shumate/shumate-utils-private.h" | ||
| 8 | #include "shumate/shumate-vector-value-private.h" | ||
| 9 | |||
| 10 | static void | ||
| 11 | 2 | test_vector_renderer_render (void) | |
| 12 | { | ||
| 13 | 2 | GError *error = NULL; | |
| 14 | 4 | g_autoptr(GBytes) style_json = NULL; | |
| 15 |
1/2✓ Branch 31 → 32 taken 2 times.
✗ Branch 31 → 33 not taken.
|
2 | g_autoptr(GBytes) tile_data = NULL; |
| 16 |
1/2✓ Branch 29 → 30 taken 2 times.
✗ Branch 29 → 31 not taken.
|
2 | g_autoptr(ShumateVectorRenderer) renderer = NULL; |
| 17 |
1/2✓ Branch 27 → 28 taken 2 times.
✗ Branch 27 → 29 not taken.
|
4 | g_autoptr(ShumateTile) tile = shumate_tile_new_full (0, 0, 512, 0); |
| 18 |
1/2✓ Branch 25 → 26 taken 2 times.
✗ Branch 25 → 27 not taken.
|
2 | g_autoptr(GdkPaintable) paintable = NULL; |
| 19 |
1/2✓ Branch 23 → 24 taken 2 times.
✗ Branch 23 → 25 not taken.
|
2 | g_autoptr(GPtrArray) symbols = NULL; |
| 20 | 2 | ShumateGridPosition source_position = { 0, 0, 0 }; | |
| 21 | |||
| 22 | 2 | style_json = g_resources_lookup_data ("/org/gnome/shumate/Tests/style.json", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); | |
| 23 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 2 times.
|
2 | g_assert_no_error (error); |
| 24 | |||
| 25 | 2 | renderer = shumate_vector_renderer_new ("", g_bytes_get_data (style_json, NULL), &error); | |
| 26 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 2 times.
|
2 | g_assert_no_error (error); |
| 27 | |||
| 28 | 2 | tile_data = g_resources_lookup_data ("/org/gnome/shumate/Tests/0.pbf", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); | |
| 29 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_assert_no_error (error); |
| 30 | |||
| 31 | 2 | shumate_vector_renderer_render (renderer, tile, tile_data, &source_position, &paintable, &symbols); | |
| 32 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 2 times.
|
2 | g_assert_no_error (error); |
| 33 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_true (GDK_IS_PAINTABLE (paintable)); |
| 34 |
2/4✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 2 times.
✓ Branch 21 → 22 taken 2 times.
✗ Branch 21 → 23 not taken.
|
2 | g_assert_nonnull (symbols); |
| 35 | 2 | } | |
| 36 | |||
| 37 | void | ||
| 38 | 2 | test_vector_renderer_global_state (void) | |
| 39 | { | ||
| 40 | 2 | GError *error = NULL; | |
| 41 | 4 | g_autoptr(GBytes) style_json = NULL; | |
| 42 |
1/2✓ Branch 37 → 38 taken 2 times.
✗ Branch 37 → 39 not taken.
|
2 | g_autoptr(ShumateVectorRenderer) renderer = NULL; |
| 43 |
1/2✓ Branch 35 → 36 taken 2 times.
✗ Branch 35 → 37 not taken.
|
2 | g_auto(ShumateVectorValue) in_value = SHUMATE_VECTOR_VALUE_INIT; |
| 44 | 2 | ShumateVectorValue *out_value = NULL; | |
| 45 | 2 | double number; | |
| 46 | |||
| 47 | 2 | style_json = g_resources_lookup_data ("/org/gnome/shumate/Tests/style.json", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); | |
| 48 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_no_error (error); |
| 49 | |||
| 50 | 2 | renderer = shumate_vector_renderer_new ("", g_bytes_get_data (style_json, NULL), &error); | |
| 51 |
1/2✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 2 times.
|
2 | g_assert_no_error (error); |
| 52 | |||
| 53 | 2 | out_value = shumate_vector_renderer_get_global_state (renderer, "test_number"); | |
| 54 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 2 times.
|
2 | g_assert_true (shumate_vector_value_get_number (out_value, &number)); |
| 55 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 2 times.
|
2 | g_assert_cmpfloat (number, ==, 1.0); |
| 56 | |||
| 57 | 2 | shumate_vector_value_set_number (&in_value, 42.0); | |
| 58 | 2 | shumate_vector_renderer_set_global_state (renderer, "test_number", &in_value); | |
| 59 | 2 | shumate_vector_value_unset (&in_value); | |
| 60 | 2 | out_value = shumate_vector_renderer_get_global_state (renderer, "test_number"); | |
| 61 |
1/2✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 2 times.
|
2 | g_assert_true (shumate_vector_value_get_number (out_value, &number)); |
| 62 |
1/2✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 2 times.
|
2 | g_assert_cmpfloat (number, ==, 42.0); |
| 63 | |||
| 64 | 2 | shumate_vector_renderer_reset_global_state (renderer, "test_number"); | |
| 65 | 2 | out_value = shumate_vector_renderer_get_global_state (renderer, "test_number"); | |
| 66 |
1/2✗ Branch 27 → 28 not taken.
✓ Branch 27 → 29 taken 2 times.
|
2 | g_assert_true (shumate_vector_value_get_number (out_value, &number)); |
| 67 |
1/2✗ Branch 29 → 30 not taken.
✓ Branch 29 → 31 taken 2 times.
|
2 | g_assert_cmpfloat (number, ==, 1.0); |
| 68 | |||
| 69 | 2 | out_value = shumate_vector_renderer_get_global_state (renderer, "non_existent_key"); | |
| 70 |
1/2✗ Branch 32 → 33 not taken.
✓ Branch 32 → 34 taken 2 times.
|
2 | g_assert_null (out_value); |
| 71 | 2 | } | |
| 72 | |||
| 73 | int | ||
| 74 | 2 | main (int argc, char *argv[]) | |
| 75 | { | ||
| 76 | 2 | g_test_init (&argc, &argv, NULL); | |
| 77 | |||
| 78 | 2 | g_test_add_func ("/vector-renderer/render", test_vector_renderer_render); | |
| 79 | 2 | g_test_add_func ("/vector-renderer/global-state", test_vector_renderer_global_state); | |
| 80 | |||
| 81 | 2 | return g_test_run (); | |
| 82 | } | ||
| 83 |