LCOV - code coverage report
Current view: top level - tests - map.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 34 34 100.0 %
Date: 2024-05-11 21:41:31 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 16 50.0 %

           Branch data     Line data    Source code
       1                 :            : #undef G_DISABLE_ASSERT
       2                 :            : 
       3                 :            : #include <gtk/gtk.h>
       4                 :            : #include <shumate/shumate.h>
       5                 :            : 
       6                 :            : static void
       7                 :          2 : test_map_add_layers (void)
       8                 :            : {
       9                 :          2 :   ShumateMap *map = shumate_map_new ();
      10                 :          2 :   ShumateViewport *viewport = shumate_map_get_viewport (map);
      11                 :          2 :   ShumateLayer *layer1 = SHUMATE_LAYER (shumate_path_layer_new (viewport));
      12                 :          2 :   ShumateLayer *layer2 = SHUMATE_LAYER (shumate_path_layer_new (viewport));
      13                 :          2 :   ShumateLayer *layer3;
      14                 :            : 
      15                 :            :   // Add layer1
      16                 :          2 :   shumate_map_add_layer (map, layer1);
      17         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_first_child (GTK_WIDGET (map)) == GTK_WIDGET (layer1));
      18                 :            : 
      19                 :            :   // Add layer2, should end up on top
      20                 :          2 :   shumate_map_add_layer (map, layer2);
      21         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_last_child (GTK_WIDGET (map)) == GTK_WIDGET (layer2));
      22                 :            : 
      23                 :            :   // Add layer3 above layer2
      24                 :          2 :   layer3 = SHUMATE_LAYER (shumate_path_layer_new (viewport));
      25                 :          2 :   shumate_map_insert_layer_above (map, layer3, layer2);
      26         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_last_child (GTK_WIDGET (map)) == GTK_WIDGET (layer3));
      27                 :            : 
      28                 :            :   // Remove layer3
      29                 :          2 :   shumate_map_remove_layer (map, layer3);
      30         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_last_child (GTK_WIDGET (map)) == GTK_WIDGET (layer2));
      31                 :            : 
      32                 :            :   // Add layer3 behind layer1
      33                 :          2 :   layer3 = SHUMATE_LAYER (shumate_path_layer_new (viewport));
      34                 :          2 :   shumate_map_insert_layer_behind (map, layer3, layer1);
      35         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_first_child (GTK_WIDGET (map)) == GTK_WIDGET (layer3));
      36                 :            : 
      37                 :            :   // Remove layer3
      38                 :          2 :   shumate_map_remove_layer (map, layer3);
      39         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_first_child (GTK_WIDGET (map)) == GTK_WIDGET (layer1));
      40                 :            : 
      41                 :            :   // Add layer3 behind NULL
      42                 :          2 :   layer3 = SHUMATE_LAYER (shumate_path_layer_new (viewport));
      43                 :          2 :   shumate_map_insert_layer_behind (map, layer3, NULL);
      44         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_last_child (GTK_WIDGET (map)) == GTK_WIDGET (layer3));
      45                 :          2 :   shumate_map_remove_layer (map, layer3);
      46                 :            : 
      47                 :            :   // Add layer3 above NULL
      48                 :          2 :   layer3 = SHUMATE_LAYER (shumate_path_layer_new (viewport));
      49                 :          2 :   shumate_map_insert_layer_above (map, layer3, NULL);
      50         [ -  + ]:          2 :   g_assert_true (gtk_widget_get_first_child (GTK_WIDGET (map)) == GTK_WIDGET (layer3));
      51                 :          2 :   shumate_map_remove_layer (map, layer3);
      52                 :          2 : }
      53                 :            : 
      54                 :            : int
      55                 :          2 : main (int argc, char *argv[])
      56                 :            : {
      57                 :          2 :   g_test_init (&argc, &argv, NULL);
      58                 :          2 :   gtk_init ();
      59                 :            : 
      60                 :          2 :   g_test_add_func ("/map/add-layers", test_map_add_layers);
      61                 :            : 
      62                 :          2 :   return g_test_run ();
      63                 :            : }

Generated by: LCOV version 1.14