File: test-selection-float.c

package info (click to toggle)
gimp 3.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 210,076 kB
  • sloc: ansic: 842,287; lisp: 10,761; python: 10,318; cpp: 7,238; perl: 4,355; sh: 1,043; xml: 963; yacc: 609; lex: 348; javascript: 150; makefile: 43
file content (74 lines) | stat: -rw-r--r-- 2,644 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

static GimpValueArray *
gimp_c_test_run (GimpProcedure        *procedure,
                 GimpRunMode           run_mode,
                 GimpImage            *image,
                 GimpDrawable        **drawables,
                 GimpProcedureConfig  *config,
                 gpointer              run_data)
{
  GimpImage     *img;
  GimpDrawable  *layer1;
  GimpDrawable  *layer2;
  GimpDrawable  *group1;
  GimpLayer     *float_layer;

  /* Setup */

  GIMP_TEST_START("gimp_image_new()")
  img = gimp_image_new (32, 32, GIMP_RGB);
  GIMP_TEST_END(GIMP_IS_IMAGE (img))

  layer1 = GIMP_DRAWABLE (gimp_layer_new (img, "layer1", 20, 10,
                          GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL));
  layer2 = GIMP_DRAWABLE (gimp_layer_new (img, "layer2", 10, 20,
                          GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL));
  group1 = GIMP_DRAWABLE (gimp_group_layer_new (img, NULL));

  GIMP_TEST_START("insert layer")
  GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (layer1), NULL, 0))

  GIMP_TEST_START("insert group layer")
  GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (group1), NULL, -1))

  GIMP_TEST_START("insert layer inside group")
  GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (layer2),
                GIMP_LAYER (group1), -1))


  /* Floating selection tests */

  /* 1. Fail with no selection */
  GIMP_TEST_START("Gimp.Selection.float - no selection")
  GIMP_TEST_END(gimp_selection_float (img, (GimpDrawable *[2]) { layer1, NULL }, 10, 10) == NULL)

  /* 2. Fail on a group layer */
  GIMP_TEST_START("Gimp.Selection.float - group layer")
  GIMP_TEST_END(gimp_selection_float (img, (GimpDrawable *[2]) { group1, NULL }, 10, 10) == NULL)

  /* 3. Succeed on a normal layer */
  gimp_image_select_rectangle (img, GIMP_CHANNEL_OP_REPLACE, 5, 5, 20, 20);

  GIMP_TEST_START("gimp_selection_float - normal layer")
  float_layer = gimp_selection_float (img, (GimpDrawable *[2]) { layer1, NULL }, 10, 10);
  GIMP_TEST_END(GIMP_IS_LAYER (float_layer))

  GIMP_TEST_START("gimp_floating_sel_remove")
  GIMP_TEST_END(gimp_floating_sel_remove (float_layer) == TRUE);

  /* 4. Succeed on a layer inside a group */
  gimp_image_select_rectangle (img, GIMP_CHANNEL_OP_REPLACE, 5, 5, 20, 20);

  GIMP_TEST_START("gimp_selection_float - layer inside group")
  float_layer = gimp_selection_float (img, (GimpDrawable *[2]) { layer2, NULL }, 10, 10);
  GIMP_TEST_END(GIMP_IS_LAYER (float_layer))

  GIMP_TEST_START("gimp_floating_sel_remove")
  GIMP_TEST_END(gimp_floating_sel_remove (float_layer) == TRUE);


  /* Teardown */
  gimp_image_delete (img);

  GIMP_TEST_RETURN
}