wayland_positioner_unittest.cc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/exo/wayland/wayland_positioner.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. #include "ui/gfx/geometry/rect.h"
  7. #include "xdg-shell-server-protocol.h"
  8. #include "xdg-shell-unstable-v6-server-protocol.h"
  9. namespace exo {
  10. namespace wayland {
  11. namespace {
  12. class WaylandPositionerTest : public testing::Test {
  13. protected:
  14. // By default the test cases happen on a 5x5 grid with an anchor rect at
  15. // (2,2,1x1).
  16. struct TestCaseBuilder {
  17. WaylandPositioner positioner;
  18. gfx::Rect work_area = {0, 0, 5, 5};
  19. explicit TestCaseBuilder(WaylandPositioner::Version v) : positioner(v) {
  20. positioner.SetAnchorRect({2, 2, 1, 1});
  21. }
  22. TestCaseBuilder& SetFlipState(bool x, bool y) {
  23. return *this;
  24. }
  25. TestCaseBuilder& SetAnchor(uint32_t anchor) {
  26. positioner.SetAnchor(anchor);
  27. return *this;
  28. }
  29. TestCaseBuilder& SetGravity(uint32_t gravity) {
  30. positioner.SetGravity(gravity);
  31. return *this;
  32. }
  33. TestCaseBuilder& SetAdjustment(uint32_t adjustment) {
  34. positioner.SetAdjustment(adjustment);
  35. return *this;
  36. }
  37. TestCaseBuilder& SetAnchorRect(int x, int y, int w, int h) {
  38. positioner.SetAnchorRect({x, y, w, h});
  39. return *this;
  40. }
  41. TestCaseBuilder& SetWorkArea(const gfx::Rect& rect) {
  42. work_area = rect;
  43. return *this;
  44. }
  45. TestCaseBuilder& SetSize(int w, int h) {
  46. positioner.SetSize({w, h});
  47. return *this;
  48. }
  49. WaylandPositioner::Result Solve() const {
  50. return positioner.CalculateBounds(work_area);
  51. }
  52. gfx::Rect SolveToRect() const {
  53. WaylandPositioner::Result result = Solve();
  54. return {result.origin.x(), result.origin.y(), result.size.width(),
  55. result.size.height()};
  56. }
  57. };
  58. };
  59. // Tests for the unstable protocol.
  60. TEST_F(WaylandPositionerTest, UnconstrainedCasesUnstable) {
  61. // No gravity or anchor.
  62. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  63. .SetSize(1, 1)
  64. .SolveToRect(),
  65. gfx::Rect(2, 2, 1, 1));
  66. // Anchor without gravity.
  67. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  68. .SetSize(2, 1)
  69. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_RIGHT)
  70. .SolveToRect(),
  71. gfx::Rect(2, 2, 2, 1));
  72. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  73. .SetSize(2, 1)
  74. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_LEFT)
  75. .SolveToRect(),
  76. gfx::Rect(1, 2, 2, 1));
  77. // Gravity without anchor.
  78. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  79. .SetSize(1, 2)
  80. .SetAnchorRect(2, 2, 0, 0)
  81. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_TOP)
  82. .SolveToRect(),
  83. gfx::Rect(2, 0, 1, 2));
  84. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  85. .SetSize(1, 2)
  86. .SetAnchorRect(2, 2, 0, 0)
  87. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM)
  88. .SolveToRect(),
  89. gfx::Rect(2, 2, 1, 2));
  90. // Gravity + anchor in the same direction.
  91. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  92. .SetSize(2, 2)
  93. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  94. ZXDG_POSITIONER_V6_GRAVITY_LEFT)
  95. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
  96. ZXDG_POSITIONER_V6_ANCHOR_LEFT)
  97. .SolveToRect(),
  98. gfx::Rect(0, 3, 2, 2));
  99. // Gravity + anchor in opposing directions.
  100. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  101. .SetSize(2, 2)
  102. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  103. ZXDG_POSITIONER_V6_GRAVITY_LEFT)
  104. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_TOP |
  105. ZXDG_POSITIONER_V6_ANCHOR_RIGHT)
  106. .SolveToRect(),
  107. gfx::Rect(1, 2, 2, 2));
  108. }
  109. TEST_F(WaylandPositionerTest, FlipSlideResizePriorityUnstable) {
  110. TestCaseBuilder builder{WaylandPositioner::Version::UNSTABLE};
  111. builder.SetAnchorRect(4, 4, 0, 0)
  112. .SetSize(2, 2)
  113. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  114. ZXDG_POSITIONER_V6_GRAVITY_RIGHT)
  115. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
  116. ZXDG_POSITIONER_V6_ANCHOR_RIGHT);
  117. // Flip is enabled, so the result will be at 2,2 (i.e. flipping a 2-wide
  118. // square around 4,4).
  119. EXPECT_EQ(
  120. builder.SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE)
  121. .SolveToRect(),
  122. gfx::Rect(2, 2, 2, 2));
  123. // If we cant flip on an axis, that axis will slide to 3 instead.
  124. EXPECT_EQ(
  125. builder.SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X)
  126. .SolveToRect(),
  127. gfx::Rect(3, 2, 2, 2));
  128. EXPECT_EQ(
  129. builder.SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y)
  130. .SolveToRect(),
  131. gfx::Rect(2, 3, 2, 2));
  132. // If we cant flip or slide, we resize.
  133. EXPECT_EQ(
  134. builder
  135. .SetAdjustment(ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X |
  136. ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y)
  137. .SolveToRect(),
  138. gfx::Rect(4, 4, 1, 1));
  139. }
  140. TEST_F(WaylandPositionerTest, TriesToMaximizeAreaUnstable) {
  141. // The size is too large to fit where the anchor is.
  142. WaylandPositioner::Result result =
  143. TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  144. .SetAnchorRect(2, 4, 0, 0)
  145. .SetSize(4, 10)
  146. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  147. ZXDG_POSITIONER_V6_GRAVITY_RIGHT)
  148. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
  149. ZXDG_POSITIONER_V6_ANCHOR_RIGHT)
  150. .SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE)
  151. .Solve();
  152. // We can slide to 1 on x, but we must resize on y (after sliding to 0).
  153. EXPECT_EQ(result.origin, gfx::Point(1, 0));
  154. // The x size will be preserved but y shrinks to the work area.
  155. EXPECT_EQ(result.size, gfx::Size(4, 5));
  156. }
  157. TEST_F(WaylandPositionerTest, PropagatesAnInitialFlipUnstable) {
  158. WaylandPositioner::Result result =
  159. TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  160. .SetAnchorRect(3, 1, 0, 0)
  161. .SetSize(2, 2)
  162. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  163. ZXDG_POSITIONER_V6_GRAVITY_RIGHT)
  164. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
  165. ZXDG_POSITIONER_V6_ANCHOR_RIGHT)
  166. .SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE)
  167. .SetFlipState(true, true)
  168. .Solve();
  169. // With a propagated flip state:
  170. // - X and Y remain flipped to be positioned by the client.
  171. EXPECT_EQ(result.origin, gfx::Point(3, 1));
  172. EXPECT_EQ(result.size, gfx::Size(2, 2));
  173. }
  174. // This is a common case for dropdown menus. In ChromeOS we do not let them
  175. // slide if they might occlude the anchor rectangle. For this case, x axis does
  176. // slide but the y axis resized instead.
  177. TEST_F(WaylandPositionerTest, PreventsSlidingThatOccludesAnchorRectUnstable) {
  178. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  179. .SetSize(3, 3)
  180. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  181. ZXDG_POSITIONER_V6_GRAVITY_RIGHT)
  182. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_BOTTOM |
  183. ZXDG_POSITIONER_V6_ANCHOR_LEFT)
  184. .SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE)
  185. .SolveToRect(),
  186. gfx::Rect(2, 3, 3, 2));
  187. // Here we ensure that the 4x4 popup does slide, which is allowed because
  188. // the anchor rect is already occluded.
  189. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  190. .SetSize(4, 4)
  191. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  192. ZXDG_POSITIONER_V6_GRAVITY_RIGHT)
  193. .SetAnchor(ZXDG_POSITIONER_V6_ANCHOR_TOP |
  194. ZXDG_POSITIONER_V6_ANCHOR_LEFT)
  195. .SetAdjustment(~ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE)
  196. .SolveToRect(),
  197. gfx::Rect(1, 1, 4, 4));
  198. }
  199. // Allowing sliding which will occlude the anchor if there are no other
  200. // positioning options which do not result in a constrained view available.
  201. TEST_F(WaylandPositionerTest,
  202. AllowsSlidingThatOccludesWhenThereAreNoOtherOptionsUnstable) {
  203. EXPECT_EQ(
  204. TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  205. .SetSize(4, 4)
  206. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  207. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_LEFT)
  208. // Disable resizing in both axes which will force sliding.
  209. .SetAdjustment(~(ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X |
  210. ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y))
  211. .SolveToRect(),
  212. gfx::Rect(1, 1, 4, 4));
  213. }
  214. TEST_F(WaylandPositionerTest,
  215. AllowsAdditionalAdjustmentsIfNoSolutionCanBeFoundUnstable) {
  216. EXPECT_EQ(
  217. TestCaseBuilder(WaylandPositioner::Version::UNSTABLE)
  218. .SetWorkArea(gfx::Rect(5, 5))
  219. .SetSize(10, 10)
  220. .SetAnchorRect(0, 0, 0, 0)
  221. .SetGravity(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
  222. ZXDG_POSITIONER_V6_GRAVITY_RIGHT)
  223. // No solution should forcibly allow resize
  224. .SetAdjustment(ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X |
  225. ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y)
  226. .SolveToRect(),
  227. gfx::Rect(0, 0, 5, 5));
  228. }
  229. // Tests for the stable protocol.
  230. TEST_F(WaylandPositionerTest, UnconstrainedCases) {
  231. // No gravity or anchor.
  232. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  233. .SetSize(1, 1)
  234. .SolveToRect(),
  235. gfx::Rect(2, 2, 1, 1));
  236. // Anchor without gravity.
  237. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  238. .SetSize(2, 1)
  239. .SetAnchor(XDG_POSITIONER_ANCHOR_RIGHT)
  240. .SolveToRect(),
  241. gfx::Rect(2, 2, 2, 1));
  242. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  243. .SetSize(2, 1)
  244. .SetAnchor(XDG_POSITIONER_ANCHOR_LEFT)
  245. .SolveToRect(),
  246. gfx::Rect(1, 2, 2, 1));
  247. // Gravity without anchor.
  248. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  249. .SetSize(1, 2)
  250. .SetAnchorRect(2, 2, 0, 0)
  251. .SetGravity(XDG_POSITIONER_GRAVITY_TOP)
  252. .SolveToRect(),
  253. gfx::Rect(2, 0, 1, 2));
  254. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  255. .SetSize(1, 2)
  256. .SetAnchorRect(2, 2, 0, 0)
  257. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM)
  258. .SolveToRect(),
  259. gfx::Rect(2, 2, 1, 2));
  260. // Gravity + anchor in the same direction.
  261. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  262. .SetSize(2, 2)
  263. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_LEFT)
  264. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_LEFT)
  265. .SolveToRect(),
  266. gfx::Rect(0, 3, 2, 2));
  267. // Gravity + anchor in opposing directions.
  268. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  269. .SetSize(2, 2)
  270. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_LEFT)
  271. .SetAnchor(XDG_POSITIONER_ANCHOR_TOP_RIGHT)
  272. .SolveToRect(),
  273. gfx::Rect(1, 2, 2, 2));
  274. }
  275. TEST_F(WaylandPositionerTest, FlipSlideResizePriority) {
  276. TestCaseBuilder builder{WaylandPositioner::Version::STABLE};
  277. builder.SetAnchorRect(4, 4, 0, 0)
  278. .SetSize(2, 2)
  279. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  280. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT);
  281. // Flip is enabled, so the result will be at 2,2 (i.e. flipping a 2-wide
  282. // square around 4,4).
  283. EXPECT_EQ(builder.SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  284. .SolveToRect(),
  285. gfx::Rect(2, 2, 2, 2));
  286. // If we cant flip on an axis, that axis will slide to 3 instead.
  287. EXPECT_EQ(builder.SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X)
  288. .SolveToRect(),
  289. gfx::Rect(3, 2, 2, 2));
  290. EXPECT_EQ(builder.SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y)
  291. .SolveToRect(),
  292. gfx::Rect(2, 3, 2, 2));
  293. // If we cant flip or slide, we resize.
  294. EXPECT_EQ(builder
  295. .SetAdjustment(XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X |
  296. XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y)
  297. .SolveToRect(),
  298. gfx::Rect(4, 4, 1, 1));
  299. }
  300. TEST_F(WaylandPositionerTest, TriesToMaximizeArea) {
  301. // The size is too large to fit where the anchor is.
  302. WaylandPositioner::Result result =
  303. TestCaseBuilder(WaylandPositioner::Version::STABLE)
  304. .SetAnchorRect(2, 4, 0, 0)
  305. .SetSize(4, 10)
  306. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  307. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT)
  308. .SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  309. .Solve();
  310. // We can slide to 1 on x, but we must resize on y (after sliding to 0).
  311. EXPECT_EQ(result.origin, gfx::Point(1, 0));
  312. // The x size will be preserved but y shrinks to the work area.
  313. EXPECT_EQ(result.size, gfx::Size(4, 5));
  314. }
  315. TEST_F(WaylandPositionerTest, PropagatesAnInitialFlip) {
  316. WaylandPositioner::Result result =
  317. TestCaseBuilder(WaylandPositioner::Version::STABLE)
  318. .SetAnchorRect(3, 1, 0, 0)
  319. .SetSize(2, 2)
  320. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  321. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT)
  322. .SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  323. .SetFlipState(true, true)
  324. .Solve();
  325. // With a propagated flip state:
  326. // - X and Y remain flipped to be positioned by the client.
  327. EXPECT_EQ(result.origin, gfx::Point(3, 1));
  328. EXPECT_EQ(result.size, gfx::Size(2, 2));
  329. }
  330. // This is a common case for dropdown menus. In ChromeOS we do not let them
  331. // slide if they might occlude the anchor rectangle. For this case, x axis does
  332. // slide but the y axis resized instead.
  333. TEST_F(WaylandPositionerTest, PreventsSlidingThatOccludesAnchorRect) {
  334. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  335. .SetSize(3, 3)
  336. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  337. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_LEFT)
  338. .SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  339. .SolveToRect(),
  340. gfx::Rect(2, 3, 3, 2));
  341. // Here we ensure that the 4x4 popup does slide, which is allowed because
  342. // the anchor rect is already occluded.
  343. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  344. .SetSize(4, 4)
  345. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  346. .SetAnchor(XDG_POSITIONER_ANCHOR_TOP_LEFT)
  347. .SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  348. .SolveToRect(),
  349. gfx::Rect(1, 1, 4, 4));
  350. }
  351. // Allowing sliding which will occlude the anchor if there are no other
  352. // positioning options which do not result in a constrained view available.
  353. TEST_F(WaylandPositionerTest,
  354. AllowsSlidingThatOccludesWhenThereAreNoOtherOptions) {
  355. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  356. .SetSize(4, 4)
  357. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  358. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM_LEFT)
  359. // Disable resizing in both axes which will force sliding.
  360. .SetAdjustment(~(XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X |
  361. XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y))
  362. .SolveToRect(),
  363. gfx::Rect(1, 1, 4, 4));
  364. }
  365. // Make sure that the size should never be an empty even if the constraints
  366. // resulted in empty size.
  367. TEST_F(WaylandPositionerTest, ResizableShouldNotBeEmpty) {
  368. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  369. .SetSize(3, 3)
  370. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM)
  371. .SetAnchor(XDG_POSITIONER_ANCHOR_BOTTOM)
  372. .SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  373. .SetAnchorRect(1, -10, 4, 4)
  374. .SolveToRect(),
  375. gfx::Rect(2, 0, 3, 1));
  376. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  377. .SetSize(3, 3)
  378. .SetGravity(XDG_POSITIONER_GRAVITY_RIGHT)
  379. .SetAnchor(XDG_POSITIONER_ANCHOR_RIGHT)
  380. .SetAdjustment(~XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE)
  381. .SetAnchorRect(-10, 2, 4, 4)
  382. .SolveToRect(),
  383. gfx::Rect(0, 2, 1, 3));
  384. }
  385. TEST_F(WaylandPositionerTest,
  386. AllowsAdditionalAdjustmentsIfNoSolutionCanBeFound) {
  387. EXPECT_EQ(TestCaseBuilder(WaylandPositioner::Version::STABLE)
  388. .SetWorkArea(gfx::Rect(5, 5))
  389. .SetSize(10, 10)
  390. .SetAnchorRect(0, 0, 0, 0)
  391. .SetGravity(XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT)
  392. // No solution should forcibly allow resize
  393. .SetAdjustment(XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X |
  394. XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y)
  395. .SolveToRect(),
  396. gfx::Rect(0, 0, 5, 5));
  397. }
  398. } // namespace
  399. } // namespace wayland
  400. } // namespace exo