source: mainline/uspace/lib/display/test/wndresize.c

Last change on this file was 9901f267, checked in by Jiri Svoboda <jiri@…>, 5 years ago

Display server needs to override cursor when resizing windows

Although the pointer moves, the window is not resized until button
is released. Therefore we need override the cursor from what it
would be just based on where the pointer is located.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Copyright (c) 2020 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <display/wndresize.h>
30#include <errno.h>
31#include <limits.h>
32#include <pcut/pcut.h>
33
34PCUT_INIT;
35
36PCUT_TEST_SUITE(wndresize);
37
38/** display_cursor_from_wrsz() correctly translates resize type to cursor */
39PCUT_TEST(cursor_from_wrsz)
40{
41 PCUT_ASSERT_INT_EQUALS(dcurs_size_ud,
42 display_cursor_from_wrsz(display_wr_top));
43 PCUT_ASSERT_INT_EQUALS(dcurs_size_ud,
44 display_cursor_from_wrsz(display_wr_bottom));
45 PCUT_ASSERT_INT_EQUALS(dcurs_size_lr,
46 display_cursor_from_wrsz(display_wr_left));
47 PCUT_ASSERT_INT_EQUALS(dcurs_size_lr,
48 display_cursor_from_wrsz(display_wr_right));
49 PCUT_ASSERT_INT_EQUALS(dcurs_size_uldr,
50 display_cursor_from_wrsz(display_wr_top_left));
51 PCUT_ASSERT_INT_EQUALS(dcurs_size_uldr,
52 display_cursor_from_wrsz(display_wr_bottom_right));
53 PCUT_ASSERT_INT_EQUALS(dcurs_size_urdl,
54 display_cursor_from_wrsz(display_wr_top_right));
55 PCUT_ASSERT_INT_EQUALS(dcurs_size_urdl,
56 display_cursor_from_wrsz(display_wr_bottom_left));
57}
58
59/** display_wndrsz_valid() correctly verifies window resize type */
60PCUT_TEST(wndrsz_valid)
61{
62 PCUT_ASSERT_FALSE(display_wndrsz_valid(INT_MIN));
63 PCUT_ASSERT_FALSE(display_wndrsz_valid(display_wr_top - 1));
64 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_top));
65 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_left));
66 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_bottom));
67 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_right));
68 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_top_left));
69 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_top_right));
70 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_bottom_left));
71 PCUT_ASSERT_TRUE(display_wndrsz_valid(display_wr_bottom_right));
72 PCUT_ASSERT_FALSE(display_wndrsz_valid(display_wr_bottom_right + 1));
73 PCUT_ASSERT_FALSE(display_wndrsz_valid(
74 display_wr_top | display_wr_bottom));
75 PCUT_ASSERT_FALSE(display_wndrsz_valid(
76 display_wr_left | display_wr_right));
77 PCUT_ASSERT_FALSE(display_wndrsz_valid(
78 display_wr_top | display_wr_left | display_wr_right));
79 PCUT_ASSERT_FALSE(display_wndrsz_valid(
80 display_wr_bottom | display_wr_left | display_wr_right));
81 PCUT_ASSERT_FALSE(display_wndrsz_valid(
82 display_wr_top | display_wr_bottom | display_wr_left));
83 PCUT_ASSERT_FALSE(display_wndrsz_valid(
84 display_wr_top | display_wr_bottom | display_wr_right));
85 PCUT_ASSERT_FALSE(display_wndrsz_valid(
86 display_wr_top | display_wr_bottom |
87 display_wr_left | display_wr_right));
88 PCUT_ASSERT_FALSE(display_wndrsz_valid(INT_MAX));
89}
90
91PCUT_EXPORT(wndresize);
Note: See TracBrowser for help on using the repository browser.