Merge lp:~alan-griffiths/mir/fix-1717061 into lp:mir
- fix-1717061
- Merge into development-branch
Status: | Merged |
---|---|
Merged at revision: | 4255 |
Proposed branch: | lp:~alan-griffiths/mir/fix-1717061 |
Merge into: | lp:mir |
Prerequisite: | lp:~alan-griffiths/mir/fix-FTBFS-on-artful-clang |
Diff against target: |
316 lines (+160/-23) 7 files modified
debian/changelog (+2/-0) src/miral/CMakeLists.txt (+1/-0) src/miral/window_info.cpp (+49/-15) src/miral/window_info_defaults.h (+36/-0) src/miral/window_management_trace.cpp (+10/-8) tests/miral/CMakeLists.txt (+1/-0) tests/miral/window_info.cpp (+61/-0) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/fix-1717061 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Needs Fixing | |
Gerry Boland (community) | Approve | ||
Review via email:
|
Commit message
Clamp the window aspect ratio dimensions (to avoid ldiv0) and define default window settings in one place. (LP: #1717061)
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4256
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
ABORTED: https:/
ABORTED: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
+unsigned clamp_dim(unsigned dim)
+{
+ return std::min<unsigned long>(std:
+}
Why max "long" - the signedness of it confuses me. What is this clamping "dim" to?
If sizeof(unsigned) < sizeof(long), this always returns "dim", so the only interesting case is if sizeof(unsigned) == sizeof(long), where this clamps dim in the bottom 1/2 of the unsigned ints. Intended?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
> +unsigned clamp_dim(unsigned dim)
> +{
> + return std::min<unsigned long>(std:
> +}
>
> Why max "long" - the signedness of it confuses me. What is this clamping "dim"
> to?
>
> If sizeof(unsigned) < sizeof(long), this always returns "dim", so the only
> interesting case is if sizeof(unsigned) == sizeof(long), where this clamps dim
> in the bottom 1/2 of the unsigned ints. Intended?
That was the intent, yes. To clamp dim to the shared range of long and unsigned int.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
So you want bottom 1/2 only to ensure the sign bit is always positive. Ok
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4258
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
Landing by hand
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2017-09-14 09:27:21 +0000 | |||
3 | +++ debian/changelog 2017-09-18 08:45:41 +0000 | |||
4 | @@ -47,6 +47,8 @@ | |||
5 | 47 | . [miral-shell] Don't allow splashscreen to be occluded (LP: #1705973) | 47 | . [miral-shell] Don't allow splashscreen to be occluded (LP: #1705973) |
6 | 48 | . [miral-shell] Update maximized windows on display changes (LP: #1705695) | 48 | . [miral-shell] Update maximized windows on display changes (LP: #1705695) |
7 | 49 | . Make racy DragAndDrop test reliable. (LP: #1704780) | 49 | . Make racy DragAndDrop test reliable. (LP: #1704780) |
8 | 50 | . [libmiral] Define default window settings in one place and clamp the | ||
9 | 51 | actual values to avoid ldiv0. (LP: #1717061) | ||
10 | 50 | 52 | ||
11 | 51 | -- Alan Griffiths <alan.griffiths@canonical.com> Thu, 10 Aug 2017 11:54:30 +0000 | 53 | -- Alan Griffiths <alan.griffiths@canonical.com> Thu, 10 Aug 2017 11:54:30 +0000 |
12 | 52 | 54 | ||
13 | 53 | 55 | ||
14 | === modified file 'src/miral/CMakeLists.txt' | |||
15 | --- src/miral/CMakeLists.txt 2017-09-08 08:45:02 +0000 | |||
16 | +++ src/miral/CMakeLists.txt 2017-09-18 08:45:41 +0000 | |||
17 | @@ -61,6 +61,7 @@ | |||
18 | 61 | window_manager_tools.cpp ${miral_include}/miral/window_manager_tools.h | 61 | window_manager_tools.cpp ${miral_include}/miral/window_manager_tools.h |
19 | 62 | ${miral_include}/miral/window_management_policy_addendum2.h | 62 | ${miral_include}/miral/window_management_policy_addendum2.h |
20 | 63 | ${miral_include}/miral/window_management_policy_addendum3.h | 63 | ${miral_include}/miral/window_management_policy_addendum3.h |
21 | 64 | window_info_defaults.h | ||
22 | 64 | ) | 65 | ) |
23 | 65 | 66 | ||
24 | 66 | target_include_directories(mirclientcpp | 67 | target_include_directories(mirclientcpp |
25 | 67 | 68 | ||
26 | === modified file 'src/miral/window_info.cpp' | |||
27 | --- src/miral/window_info.cpp 2017-08-21 14:18:55 +0000 | |||
28 | +++ src/miral/window_info.cpp 2017-09-18 08:45:41 +0000 | |||
29 | @@ -17,6 +17,7 @@ | |||
30 | 17 | */ | 17 | */ |
31 | 18 | 18 | ||
32 | 19 | #include "miral/window_info.h" | 19 | #include "miral/window_info.h" |
33 | 20 | #include "window_info_defaults.h" | ||
34 | 20 | 21 | ||
35 | 21 | #include "both_versions.h" | 22 | #include "both_versions.h" |
36 | 22 | 23 | ||
37 | @@ -35,7 +36,40 @@ | |||
38 | 35 | { | 36 | { |
39 | 36 | return optional_value.is_set() ? optional_value.value() : default_; | 37 | return optional_value.is_set() ? optional_value.value() : default_; |
40 | 37 | } | 38 | } |
42 | 38 | } | 39 | |
43 | 40 | unsigned clamp_dim(unsigned dim) | ||
44 | 41 | { | ||
45 | 42 | return std::min<unsigned long>(std::numeric_limits<long>::max(), dim); | ||
46 | 43 | } | ||
47 | 44 | |||
48 | 45 | // For our convenience when doing calculations we clamp the dimensions of the aspect ratio | ||
49 | 46 | // so they will fit into a long without overflow. | ||
50 | 47 | miral::WindowInfo::AspectRatio clamp(miral::WindowInfo::AspectRatio const& source) | ||
51 | 48 | { | ||
52 | 49 | return {clamp_dim(source.width), clamp_dim(source.height)}; | ||
53 | 50 | } | ||
54 | 51 | |||
55 | 52 | miral::Width clamp(miral::Width const& source) | ||
56 | 53 | { | ||
57 | 54 | return std::min(miral::default_max_width, std::max(miral::default_min_width, source)); | ||
58 | 55 | } | ||
59 | 56 | |||
60 | 57 | miral::Height clamp(miral::Height const& source) | ||
61 | 58 | { | ||
62 | 59 | return std::min(miral::default_max_height, std::max(miral::default_min_height, source)); | ||
63 | 60 | } | ||
64 | 61 | } | ||
65 | 62 | |||
66 | 63 | miral::Width const miral::default_min_width{0}; | ||
67 | 64 | miral::Height const miral::default_min_height{0}; | ||
68 | 65 | miral::Width const miral::default_max_width{std::numeric_limits<int>::max()}; | ||
69 | 66 | miral::Height const miral::default_max_height{std::numeric_limits<int>::max()}; | ||
70 | 67 | miral::DeltaX const miral::default_width_inc{1}; | ||
71 | 68 | miral::DeltaY const miral::default_height_inc{1}; | ||
72 | 69 | miral::WindowInfo::AspectRatio const miral::default_min_aspect_ratio{ | ||
73 | 70 | clamp(WindowInfo::AspectRatio{0U, std::numeric_limits<unsigned>::max()})}; | ||
74 | 71 | miral::WindowInfo::AspectRatio const miral::default_max_aspect_ratio{ | ||
75 | 72 | clamp(WindowInfo::AspectRatio{std::numeric_limits<unsigned>::max(), 0U})}; | ||
76 | 39 | 73 | ||
77 | 40 | struct miral::WindowInfo::Self | 74 | struct miral::WindowInfo::Self |
78 | 41 | { | 75 | { |
79 | @@ -71,16 +105,16 @@ | |||
80 | 71 | type{optional_value_or_default(params.type(), mir_window_type_normal)}, | 105 | type{optional_value_or_default(params.type(), mir_window_type_normal)}, |
81 | 72 | state{optional_value_or_default(params.state(), mir_window_state_restored)}, | 106 | state{optional_value_or_default(params.state(), mir_window_state_restored)}, |
82 | 73 | restore_rect{params.top_left().value(), params.size().value()}, | 107 | restore_rect{params.top_left().value(), params.size().value()}, |
87 | 74 | min_width{optional_value_or_default(params.min_width())}, | 108 | min_width{optional_value_or_default(params.min_width(), miral::default_min_width)}, |
88 | 75 | min_height{optional_value_or_default(params.min_height())}, | 109 | min_height{optional_value_or_default(params.min_height(), miral::default_min_height)}, |
89 | 76 | max_width{optional_value_or_default(params.max_width(), Width{std::numeric_limits<int>::max()})}, | 110 | max_width{optional_value_or_default(params.max_width(), miral::default_max_width)}, |
90 | 77 | max_height{optional_value_or_default(params.max_height(), Height{std::numeric_limits<int>::max()})}, | 111 | max_height{optional_value_or_default(params.max_height(), miral::default_max_height)}, |
91 | 78 | preferred_orientation{optional_value_or_default(params.preferred_orientation(), mir_orientation_mode_any)}, | 112 | preferred_orientation{optional_value_or_default(params.preferred_orientation(), mir_orientation_mode_any)}, |
92 | 79 | confine_pointer(optional_value_or_default(params.confine_pointer(), mir_pointer_unconfined)), | 113 | confine_pointer(optional_value_or_default(params.confine_pointer(), mir_pointer_unconfined)), |
97 | 80 | width_inc{optional_value_or_default(params.width_inc(), DeltaX{1})}, | 114 | width_inc{optional_value_or_default(params.width_inc(), default_width_inc)}, |
98 | 81 | height_inc{optional_value_or_default(params.height_inc(), DeltaY{1})}, | 115 | height_inc{optional_value_or_default(params.height_inc(), default_height_inc)}, |
99 | 82 | min_aspect(optional_value_or_default(params.min_aspect(), AspectRatio{0U, std::numeric_limits<unsigned>::max()})), | 116 | min_aspect(optional_value_or_default(params.min_aspect(), default_min_aspect_ratio)), |
100 | 83 | max_aspect(optional_value_or_default(params.max_aspect(), AspectRatio{std::numeric_limits<unsigned>::max(), 0U})), | 117 | max_aspect(optional_value_or_default(params.max_aspect(), default_max_aspect_ratio)), |
101 | 84 | shell_chrome(optional_value_or_default(params.shell_chrome(), mir_shell_chrome_normal)) | 118 | shell_chrome(optional_value_or_default(params.shell_chrome(), mir_shell_chrome_normal)) |
102 | 85 | { | 119 | { |
103 | 86 | if (params.output_id().is_set()) | 120 | if (params.output_id().is_set()) |
104 | @@ -450,7 +484,7 @@ | |||
105 | 450 | 484 | ||
106 | 451 | void miral::WindowInfo::min_width(mir::geometry::Width min_width) | 485 | void miral::WindowInfo::min_width(mir::geometry::Width min_width) |
107 | 452 | { | 486 | { |
109 | 453 | self->min_width = min_width; | 487 | self->min_width = clamp(min_width); |
110 | 454 | } | 488 | } |
111 | 455 | 489 | ||
112 | 456 | auto miral::WindowInfo::min_height() const -> mir::geometry::Height | 490 | auto miral::WindowInfo::min_height() const -> mir::geometry::Height |
113 | @@ -460,7 +494,7 @@ | |||
114 | 460 | 494 | ||
115 | 461 | void miral::WindowInfo::min_height(mir::geometry::Height min_height) | 495 | void miral::WindowInfo::min_height(mir::geometry::Height min_height) |
116 | 462 | { | 496 | { |
118 | 463 | self->min_height = min_height; | 497 | self->min_height = clamp(min_height); |
119 | 464 | } | 498 | } |
120 | 465 | 499 | ||
121 | 466 | auto miral::WindowInfo::max_width() const -> mir::geometry::Width | 500 | auto miral::WindowInfo::max_width() const -> mir::geometry::Width |
122 | @@ -470,7 +504,7 @@ | |||
123 | 470 | 504 | ||
124 | 471 | void miral::WindowInfo::max_width(mir::geometry::Width max_width) | 505 | void miral::WindowInfo::max_width(mir::geometry::Width max_width) |
125 | 472 | { | 506 | { |
127 | 473 | self->max_width = max_width; | 507 | self->max_width = clamp(max_width); |
128 | 474 | } | 508 | } |
129 | 475 | 509 | ||
130 | 476 | auto miral::WindowInfo::max_height() const -> mir::geometry::Height | 510 | auto miral::WindowInfo::max_height() const -> mir::geometry::Height |
131 | @@ -480,7 +514,7 @@ | |||
132 | 480 | 514 | ||
133 | 481 | void miral::WindowInfo::max_height(mir::geometry::Height max_height) | 515 | void miral::WindowInfo::max_height(mir::geometry::Height max_height) |
134 | 482 | { | 516 | { |
136 | 483 | self->max_height = max_height; | 517 | self->max_height = clamp(max_height); |
137 | 484 | } | 518 | } |
138 | 485 | 519 | ||
139 | 486 | auto miral::WindowInfo::userdata() const -> std::shared_ptr<void> | 520 | auto miral::WindowInfo::userdata() const -> std::shared_ptr<void> |
140 | @@ -520,7 +554,7 @@ | |||
141 | 520 | 554 | ||
142 | 521 | void miral::WindowInfo::min_aspect(AspectRatio min_aspect) | 555 | void miral::WindowInfo::min_aspect(AspectRatio min_aspect) |
143 | 522 | { | 556 | { |
145 | 523 | self->min_aspect = min_aspect; | 557 | self->min_aspect = clamp(min_aspect); |
146 | 524 | } | 558 | } |
147 | 525 | 559 | ||
148 | 526 | auto miral::WindowInfo::max_aspect() const -> AspectRatio | 560 | auto miral::WindowInfo::max_aspect() const -> AspectRatio |
149 | @@ -530,7 +564,7 @@ | |||
150 | 530 | 564 | ||
151 | 531 | void miral::WindowInfo::max_aspect(AspectRatio max_aspect) | 565 | void miral::WindowInfo::max_aspect(AspectRatio max_aspect) |
152 | 532 | { | 566 | { |
154 | 533 | self->max_aspect = max_aspect; | 567 | self->max_aspect = clamp(max_aspect); |
155 | 534 | } | 568 | } |
156 | 535 | 569 | ||
157 | 536 | bool miral::WindowInfo::has_output_id() const | 570 | bool miral::WindowInfo::has_output_id() const |
158 | 537 | 571 | ||
159 | === added file 'src/miral/window_info_defaults.h' | |||
160 | --- src/miral/window_info_defaults.h 1970-01-01 00:00:00 +0000 | |||
161 | +++ src/miral/window_info_defaults.h 2017-09-18 08:45:41 +0000 | |||
162 | @@ -0,0 +1,36 @@ | |||
163 | 1 | /* | ||
164 | 2 | * Copyright © 2017 Canonical Ltd. | ||
165 | 3 | * | ||
166 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
167 | 5 | * under the terms of the GNU General Public License version 2 or 3, | ||
168 | 6 | * as published by the Free Software Foundation. | ||
169 | 7 | * | ||
170 | 8 | * This program is distributed in the hope that it will be useful, | ||
171 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
172 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
173 | 11 | * GNU General Public License for more details. | ||
174 | 12 | * | ||
175 | 13 | * You should have received a copy of the GNU General Public License | ||
176 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
177 | 15 | * | ||
178 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
179 | 17 | */ | ||
180 | 18 | |||
181 | 19 | #ifndef MIR_WINDOW_INFO_DEFAULTS_H | ||
182 | 20 | #define MIR_WINDOW_INFO_DEFAULTS_H | ||
183 | 21 | |||
184 | 22 | #include "miral/window_info.h" | ||
185 | 23 | |||
186 | 24 | namespace miral | ||
187 | 25 | { | ||
188 | 26 | Width extern const default_min_width; | ||
189 | 27 | Height extern const default_min_height; | ||
190 | 28 | Width extern const default_max_width; | ||
191 | 29 | Height extern const default_max_height; | ||
192 | 30 | DeltaX extern const default_width_inc; | ||
193 | 31 | DeltaY extern const default_height_inc; | ||
194 | 32 | WindowInfo::AspectRatio extern const default_min_aspect_ratio; | ||
195 | 33 | WindowInfo::AspectRatio extern const default_max_aspect_ratio; | ||
196 | 34 | } | ||
197 | 35 | |||
198 | 36 | #endif //MIR_WINDOW_INFO_DEFAULTS_H | ||
199 | 0 | 37 | ||
200 | === modified file 'src/miral/window_management_trace.cpp' | |||
201 | --- src/miral/window_management_trace.cpp 2017-08-21 14:18:55 +0000 | |||
202 | +++ src/miral/window_management_trace.cpp 2017-09-18 08:45:41 +0000 | |||
203 | @@ -17,6 +17,7 @@ | |||
204 | 17 | */ | 17 | */ |
205 | 18 | 18 | ||
206 | 19 | #include "window_management_trace.h" | 19 | #include "window_management_trace.h" |
207 | 20 | #include "window_info_defaults.h" | ||
208 | 20 | 21 | ||
209 | 21 | #include <miral/application_info.h> | 22 | #include <miral/application_info.h> |
210 | 22 | #include <miral/window_info.h> | 23 | #include <miral/window_info.h> |
211 | @@ -133,18 +134,19 @@ | |||
212 | 133 | APPEND(name); | 134 | APPEND(name); |
213 | 134 | APPEND(type); | 135 | APPEND(type); |
214 | 135 | APPEND(state); | 136 | APPEND(state); |
215 | 137 | bout.append("size", info.window().size()); | ||
216 | 136 | if (info.state() != mir_window_state_restored) APPEND(restore_rect); | 138 | if (info.state() != mir_window_state_restored) APPEND(restore_rect); |
217 | 137 | if (std::shared_ptr<mir::scene::Surface> parent = info.parent()) | 139 | if (std::shared_ptr<mir::scene::Surface> parent = info.parent()) |
218 | 138 | bout.append("parent", parent->name()); | 140 | bout.append("parent", parent->name()); |
219 | 139 | bout.append("children", dump_of(info.children())); | 141 | bout.append("children", dump_of(info.children())); |
228 | 140 | if (info.min_width() != Width{0}) APPEND(min_width); | 142 | if (info.min_width() != miral::default_min_width) APPEND(min_width); |
229 | 141 | if (info.min_height() != Height{0}) APPEND(min_height); | 143 | if (info.min_height() != miral::default_min_height) APPEND(min_height); |
230 | 142 | if (info.max_width() != Width{std::numeric_limits<int>::max()}) APPEND(max_width); | 144 | if (info.max_width() != miral::default_max_width) APPEND(max_width); |
231 | 143 | if (info.max_height() != Height{std::numeric_limits<int>::max()}) APPEND(max_height); | 145 | if (info.max_height() != miral::default_max_height) APPEND(max_height); |
232 | 144 | if (info.width_inc() != DeltaX{1}) APPEND(width_inc); | 146 | if (info.width_inc() != miral::default_width_inc) APPEND(width_inc); |
233 | 145 | if (info.height_inc() != DeltaY{1}) APPEND(height_inc); | 147 | if (info.height_inc() != miral::default_height_inc) APPEND(height_inc); |
234 | 146 | if (info.min_aspect() != miral::WindowInfo::AspectRatio{0U, std::numeric_limits<unsigned>::max()}) APPEND(min_aspect); | 148 | if (info.min_aspect() != miral::default_min_aspect_ratio) APPEND(min_aspect); |
235 | 147 | if (info.max_aspect() != miral::WindowInfo::AspectRatio{std::numeric_limits<unsigned>::max(), 0U}) APPEND(max_aspect); | 149 | if (info.max_aspect() != miral::default_max_aspect_ratio) APPEND(max_aspect); |
236 | 148 | APPEND(preferred_orientation); | 150 | APPEND(preferred_orientation); |
237 | 149 | APPEND(confine_pointer); | 151 | APPEND(confine_pointer); |
238 | 150 | 152 | ||
239 | 151 | 153 | ||
240 | === modified file 'tests/miral/CMakeLists.txt' | |||
241 | --- tests/miral/CMakeLists.txt 2017-09-14 09:22:16 +0000 | |||
242 | +++ tests/miral/CMakeLists.txt 2017-09-18 08:45:41 +0000 | |||
243 | @@ -40,6 +40,7 @@ | |||
244 | 40 | workspaces.cpp | 40 | workspaces.cpp |
245 | 41 | drag_and_drop.cpp | 41 | drag_and_drop.cpp |
246 | 42 | client_mediated_gestures.cpp | 42 | client_mediated_gestures.cpp |
247 | 43 | window_info.cpp | ||
248 | 43 | ) | 44 | ) |
249 | 44 | 45 | ||
250 | 45 | target_link_libraries(miral-test | 46 | target_link_libraries(miral-test |
251 | 46 | 47 | ||
252 | === added file 'tests/miral/window_info.cpp' | |||
253 | --- tests/miral/window_info.cpp 1970-01-01 00:00:00 +0000 | |||
254 | +++ tests/miral/window_info.cpp 2017-09-18 08:45:41 +0000 | |||
255 | @@ -0,0 +1,61 @@ | |||
256 | 1 | /* | ||
257 | 2 | * Copyright © 2017 Canonical Ltd. | ||
258 | 3 | * | ||
259 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
260 | 5 | * under the terms of the GNU General Public License version 2 or 3 as | ||
261 | 6 | * published by the Free Software Foundation. | ||
262 | 7 | * | ||
263 | 8 | * This program is distributed in the hope that it will be useful, | ||
264 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
265 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
266 | 11 | * GNU General Public License for more details. | ||
267 | 12 | * | ||
268 | 13 | * You should have received a copy of the GNU General Public License | ||
269 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
270 | 15 | * | ||
271 | 16 | * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com> | ||
272 | 17 | */ | ||
273 | 18 | |||
274 | 19 | #include <miral/window_info.h> | ||
275 | 20 | |||
276 | 21 | #include "mir_test_framework/process.h" | ||
277 | 22 | |||
278 | 23 | #include <gtest/gtest.h> | ||
279 | 24 | #include <gmock/gmock.h> | ||
280 | 25 | |||
281 | 26 | using namespace miral; | ||
282 | 27 | namespace mtf = mir_test_framework; | ||
283 | 28 | |||
284 | 29 | namespace | ||
285 | 30 | { | ||
286 | 31 | static int a_successful_exit_function() | ||
287 | 32 | { | ||
288 | 33 | return EXIT_SUCCESS; | ||
289 | 34 | } | ||
290 | 35 | } | ||
291 | 36 | |||
292 | 37 | // Test for crash http://paste.ubuntu.com/25523431/ | ||
293 | 38 | TEST(WindowInfo, negative_window_size_does_not_divide_by_zero) | ||
294 | 39 | { | ||
295 | 40 | auto p = mtf::fork_and_run_in_a_different_process( | ||
296 | 41 | [] { | ||
297 | 42 | Window window; | ||
298 | 43 | WindowSpecification params; | ||
299 | 44 | |||
300 | 45 | Point p{0, 0}; | ||
301 | 46 | Size s{-300, -300}; | ||
302 | 47 | |||
303 | 48 | params.name() = ""; | ||
304 | 49 | params.top_left() = p; | ||
305 | 50 | params.size() = s; | ||
306 | 51 | |||
307 | 52 | WindowInfo info(window, params); | ||
308 | 53 | |||
309 | 54 | info.min_width(s.width); | ||
310 | 55 | info.min_height(s.height); | ||
311 | 56 | |||
312 | 57 | info.constrain_resize(p, s); | ||
313 | 58 | }, a_successful_exit_function); | ||
314 | 59 | |||
315 | 60 | EXPECT_TRUE(p->wait_for_termination().succeeded()); | ||
316 | 61 | } |
FAILED: Continuous integration, rev:4254 /mir-jenkins. ubuntu. com/job/ mir-ci/ 3662/ /mir-jenkins. ubuntu. com/job/ build-mir/ 5011/console /mir-jenkins. ubuntu. com/job/ build-0- fetch/5240 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= artful/ 5228 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial/ 5228 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= zesty/5228 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= artful/ 5054 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= artful/ 5054/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/5054/ console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= artful/ 5054 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= artful/ 5054/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial/ 5054 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial/ 5054/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/5054/ console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= artful/ 5054 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= artful/ 5054/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= zesty/5054 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= zesty/5054/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial/ 5054 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial/ 5054/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 3662/rebuild
https:/