~ubuntu-branches/ubuntu/trusty/compiz/trusty

« back to all changes in this revision

Viewing changes to plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-22 06:58:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3352.
  • Revision ID: package-import@ubuntu.com-20130822065807-17nlzez0d30y09so
Tags: upstream-0.9.10+13.10.20130822
ImportĀ upstreamĀ versionĀ 0.9.10+13.10.20130822

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24
24
 */
25
25
 
 
26
#include <tr1/tuple>
26
27
#include <test-constrain-to-workarea.h>
27
28
#include <constrain-to-workarea.h>
28
29
#include <iostream>
29
30
#include <stdlib.h>
30
31
#include <cstring>
31
32
 
32
 
class CompPlaceTestConstrainToWorkarea :
 
33
namespace cw = compiz::window;
 
34
namespace cwe = cw::extents;
 
35
namespace cp = compiz::place;
 
36
 
 
37
using ::testing::WithParamInterface;
 
38
using ::testing::ValuesIn;
 
39
using ::testing::Combine;
 
40
 
 
41
class PlaceClampGeometryToWorkArea :
33
42
    public CompPlaceTest
34
43
{
 
44
    public:
 
45
 
 
46
        PlaceClampGeometryToWorkArea () :
 
47
            screensize (1000, 2000),
 
48
            workArea (50, 50, 900, 1900),
 
49
            flags (0)
 
50
        {
 
51
            memset (&extents, 0, sizeof (cwe::Extents));
 
52
        }
 
53
 
 
54
    protected:
 
55
 
 
56
        CompSize screensize;
 
57
        CompRect workArea;
 
58
        cw::Geometry g;
 
59
        cwe::Extents extents;
 
60
        unsigned int flags;
35
61
};
36
62
 
37
 
TEST_F(CompPlaceTestConstrainToWorkarea, TestConstrainToWorkarea)
38
 
{
39
 
    CompSize screensize (1000, 2000);
40
 
    CompRect workArea (50, 50, 900, 1900);
41
 
    compiz::window::Geometry g (100, 100, 200, 200, 0);
42
 
    compiz::window::extents::Extents extents;
43
 
    unsigned int flags = 0;
44
 
 
45
 
    memset (&extents, 0, sizeof (compiz::window::extents::Extents));
 
63
namespace
 
64
{
 
65
    const cw::Geometry LimitOfAllowedGeometry (50, 50, 900, 1900, 0);
 
66
}
 
67
 
 
68
namespace compiz
 
69
{
 
70
namespace window
 
71
{
 
72
std::ostream & operator<<(std::ostream &os, const Geometry &g)
 
73
{
 
74
    return os << "Window Geometry: (" << g.x () <<
 
75
                 ", " << g.y () <<
 
76
                 ", " << g.width () <<
 
77
                 ", " << g.height () <<
 
78
                 ", " << g.border () << ")";
 
79
}
 
80
namespace extents
 
81
{
 
82
std::ostream & operator<<(std::ostream &os, const Extents &e)
 
83
{
 
84
    return os << "Window Extents: (left: " << e.left <<
 
85
                 ", right: " << e.right <<
 
86
                 ", top: " << e.top <<
 
87
                 ", bottom: " << e.bottom << ")";
 
88
}
 
89
}
 
90
}
 
91
}
 
92
 
 
93
std::ostream & operator<<(std::ostream &os, const CompPoint &p)
 
94
{
 
95
    return os << "Point: (" << p.x () << ", " << p.y () << ")";
 
96
}
 
97
 
 
98
TEST_F (PlaceClampGeometryToWorkArea, NoConstrainmentRequired)
 
99
{
 
100
    g = cw::Geometry (100, 100, 200, 200, 0);
46
101
 
47
102
    /* Do nothing */
48
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
49
 
 
50
 
    EXPECT_EQ (g, compiz::window::Geometry (100, 100, 200, 200, 0));
51
 
 
 
103
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
104
 
 
105
    EXPECT_EQ (g, cw::Geometry (100, 100, 200, 200, 0));
 
106
}
 
107
 
 
108
TEST_F (PlaceClampGeometryToWorkArea, LargerThanWorkAreaConstrainsToWorkAreaSize)
 
109
{
52
110
    /* Larger than workArea */
53
 
    g = compiz::window::Geometry (50, 50, 950, 1950, 0);
54
 
 
55
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
56
 
 
57
 
    EXPECT_EQ (g, compiz::window::Geometry (50, 50, 900, 1900, 0));
58
 
 
 
111
    g = cw::Geometry (50, 50, 950, 1950, 0);
 
112
 
 
113
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
114
 
 
115
    EXPECT_EQ (g, LimitOfAllowedGeometry);
 
116
}
 
117
 
 
118
TEST_F (PlaceClampGeometryToWorkArea, OutsideTopLeftConstrainment)
 
119
{
59
120
    /* Outside top left */
60
 
    g = compiz::window::Geometry (0, 0, 900, 1900, 0);
61
 
 
62
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
63
 
 
64
 
    EXPECT_EQ (g, compiz::window::Geometry (50, 50, 900, 1900, 0));
65
 
 
 
121
    g = cw::Geometry (0, 0, 900, 1900, 0);
 
122
 
 
123
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
124
 
 
125
    EXPECT_EQ (g, LimitOfAllowedGeometry);
 
126
}
 
127
 
 
128
TEST_F (PlaceClampGeometryToWorkArea, OutsideTopRightConstrainment)
 
129
{
66
130
    /* Outside top right */
67
 
    g = compiz::window::Geometry (100, 0, 900, 1900, 0);
68
 
 
69
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
70
 
 
71
 
    EXPECT_EQ (g, compiz::window::Geometry (50, 50, 900, 1900, 0));
72
 
 
 
131
    g = cw::Geometry (100, 0, 900, 1900, 0);
 
132
 
 
133
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
134
 
 
135
    EXPECT_EQ (g, LimitOfAllowedGeometry);
 
136
}
 
137
 
 
138
TEST_F (PlaceClampGeometryToWorkArea, OutsideBottomLeftConstrainment)
 
139
{
73
140
    /* Outside bottom left */
74
 
    g = compiz::window::Geometry (0, 100, 900, 1900, 0);
75
 
 
76
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
77
 
 
78
 
    EXPECT_EQ (g, compiz::window::Geometry (50, 50, 900, 1900, 0));
79
 
 
 
141
    g = cw::Geometry (0, 100, 900, 1900, 0);
 
142
 
 
143
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
144
 
 
145
    EXPECT_EQ (g, LimitOfAllowedGeometry);
 
146
}
 
147
 
 
148
TEST_F (PlaceClampGeometryToWorkArea, OutsideBottomRightConstrainment)
 
149
{
80
150
    /* Outside bottom right */
81
 
    g = compiz::window::Geometry (100, 100, 900, 1900, 0);
82
 
 
83
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
84
 
 
85
 
    EXPECT_EQ (g, compiz::window::Geometry (50, 50, 900, 1900, 0));
86
 
 
 
151
    g = cw::Geometry (100, 100, 900, 1900, 0);
 
152
 
 
153
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
154
 
 
155
    EXPECT_EQ (g, LimitOfAllowedGeometry);
 
156
}
 
157
 
 
158
TEST_F (PlaceClampGeometryToWorkArea, NoChangePositionIfSizeUnchanged)
 
159
{
87
160
    /* For the size only case, we should not
88
161
     * change the position of the window if
89
162
     * the size does not change */
90
 
    g = compiz::window::Geometry (0, 0, 900, 1900, 0);
91
 
    flags = compiz::place::clampGeometrySizeOnly;
92
 
 
93
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
94
 
 
95
 
    EXPECT_EQ (g, compiz::window::Geometry (0, 0, 900, 1900, 0));
96
 
 
97
 
    g = compiz::window::Geometry (0, 0, 1000, 2000, 0);
98
 
    flags = compiz::place::clampGeometrySizeOnly;
99
 
 
100
 
    compiz::place::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
101
 
 
102
 
    EXPECT_EQ (g, compiz::window::Geometry (50, 50, 900, 1900, 0));
 
163
    g = cw::Geometry (0, 0, 900, 1900, 0);
 
164
    flags = cp::clampGeometrySizeOnly;
 
165
 
 
166
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
167
 
 
168
    EXPECT_EQ (g, cw::Geometry (0, 0, 900, 1900, 0));
 
169
}
 
170
 
 
171
TEST_F (PlaceClampGeometryToWorkArea, ChangePositionIfSizeChanged)
 
172
{
 
173
    g = cw::Geometry (0, 0, 1000, 2000, 0);
 
174
    flags = cp::clampGeometrySizeOnly;
 
175
 
 
176
    cp::clampGeometryToWorkArea (g, workArea, extents, flags, screensize);
 
177
 
 
178
    EXPECT_EQ (g, LimitOfAllowedGeometry);
 
179
}
 
180
 
 
181
namespace
 
182
{
 
183
typedef std::tr1::tuple <cw::Geometry, cwe::Extents> ConstrainPositionToWorkAreaParam;
 
184
 
 
185
const cw::Geometry & WindowGeometry (const ConstrainPositionToWorkAreaParam &p)
 
186
{
 
187
    return std::tr1::get <0> (p);
 
188
}
 
189
 
 
190
const cwe::Extents & WindowExtents (const ConstrainPositionToWorkAreaParam &p)
 
191
{
 
192
    return std::tr1::get <1> (p);
 
193
}
 
194
 
 
195
CompPoint InitialPosition (const ConstrainPositionToWorkAreaParam &p)
 
196
{
 
197
    /* Initial position is where the window is right now */
 
198
    return (std::tr1::get <0> (p)).pos ();
 
199
}
 
200
 
 
201
const CompRect  WArea (50, 50, 900, 1900);
 
202
const CompPoint ExpectedPosition (WArea.pos ());
 
203
}
 
204
 
 
205
class PlaceConstrainPositionToWorkArea :
 
206
    public CompPlaceTest,
 
207
    public WithParamInterface <ConstrainPositionToWorkAreaParam>
 
208
{
 
209
    public:
 
210
 
 
211
        PlaceConstrainPositionToWorkArea ()
 
212
        {
 
213
            memset (&extents, 0, sizeof (cwe::Extents));
 
214
        }
 
215
 
 
216
    protected:
 
217
 
 
218
        CompRect workArea;
 
219
        cw::Geometry g;
 
220
        cwe::Extents extents;
 
221
};
 
222
 
 
223
TEST_P (PlaceConstrainPositionToWorkArea, PositionConstrainedWithExtents)
 
224
{
 
225
    g = WindowGeometry (GetParam ());
 
226
    extents = WindowExtents (GetParam ());
 
227
 
 
228
    CompPoint pos = InitialPosition (GetParam ());
 
229
    pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea);
 
230
 
 
231
    const CompPoint expectedAfterExtentsAdjustment = ExpectedPosition +
 
232
                                                     CompPoint (extents.left,
 
233
                                                                extents.top);
 
234
 
 
235
    EXPECT_EQ (expectedAfterExtentsAdjustment, pos);
 
236
}
 
237
 
 
238
namespace
 
239
{
 
240
cwe::Extents PossibleExtents[] =
 
241
{
 
242
    cwe::Extents (0, 0, 0, 0),
 
243
    cwe::Extents (1, 0, 0, 0),
 
244
    cwe::Extents (0, 1, 0, 0),
 
245
    cwe::Extents (0, 0, 1, 0),
 
246
    cwe::Extents (0, 0, 0, 1)
 
247
};
 
248
 
 
249
cw::Geometry PossibleGeometries[] =
 
250
{
 
251
    cw::Geometry (WArea.x (), WArea.y (),
 
252
                  WArea.width (), WArea.height (), 0),
 
253
    cw::Geometry (WArea.x () - 1, WArea.y (),
 
254
                  WArea.width (), WArea.height (), 0),
 
255
    cw::Geometry (WArea.x (), WArea.y () - 1,
 
256
                  WArea.width (), WArea.height (), 0),
 
257
    cw::Geometry (WArea.x () + 1, WArea.y (),
 
258
                  WArea.width (), WArea.height (), 0),
 
259
    cw::Geometry (WArea.x (), WArea.y () + 1,
 
260
                  WArea.width (), WArea.height (), 0)
 
261
};
 
262
}
 
263
 
 
264
INSTANTIATE_TEST_CASE_P (PlacementData,
 
265
                         PlaceConstrainPositionToWorkArea,
 
266
                         Combine (ValuesIn (PossibleGeometries),
 
267
                                  ValuesIn (PossibleExtents)));
 
268
class PlaceGetEdgePositions :
 
269
    public CompPlaceTest
 
270
{
 
271
    public:
 
272
 
 
273
        PlaceGetEdgePositions () :
 
274
            geom (100, 200, 300, 400, 1),
 
275
            border (1, 2, 3, 4),
 
276
            pos (geom.pos ())
 
277
        {
 
278
        }
 
279
 
 
280
    protected:
 
281
 
 
282
        cw::Geometry geom;
 
283
        cwe::Extents border;
 
284
        CompPoint    pos;
 
285
};
 
286
 
 
287
TEST_F (PlaceGetEdgePositions, GetEdgePositions)
 
288
{
 
289
    int left = geom.x () - border.left;
 
290
    int right = left + (geom.widthIncBorders ()) +
 
291
                    (border.left + border.right);
 
292
    int top = geom.y () - border.top;
 
293
    int bottom = top + (geom.heightIncBorders ()) +
 
294
                    (border.top + border.bottom);
 
295
 
 
296
    const cwe::Extents ExpectedExtents (left, right, top, bottom);
 
297
    cwe::Extents actualExtents (cp::getWindowEdgePositions (pos,
 
298
                                                            geom,
 
299
                                                            border));
 
300
 
 
301
    EXPECT_EQ (ExpectedExtents, actualExtents);
 
302
}
 
303
 
 
304
namespace
 
305
{
 
306
const CompSize     SCREEN_SIZE (1000, 1000);
 
307
const unsigned int WINDOW_SIZE = 250;
 
308
}
 
309
 
 
310
TEST (PlaceGetViewportRelativeCoordinates, WithinScreenWidth)
 
311
{
 
312
    cw::Geometry geom (SCREEN_SIZE.width () / 2,
 
313
                       SCREEN_SIZE.height () / 2,
 
314
                       WINDOW_SIZE, WINDOW_SIZE,
 
315
                       0);
 
316
 
 
317
    CompPoint    position (cp::getViewportRelativeCoordinates (geom,
 
318
                                                               SCREEN_SIZE));
 
319
    EXPECT_EQ (geom.pos ().x (), position.x ());
 
320
}
 
321
 
 
322
TEST (PlaceGetViewportRelativeCoordinates, WithinScreenHeight)
 
323
{
 
324
    cw::Geometry geom (SCREEN_SIZE.width () / 2,
 
325
                       SCREEN_SIZE.height () / 2,
 
326
                       WINDOW_SIZE, WINDOW_SIZE,
 
327
                       0);
 
328
 
 
329
    CompPoint    position (cp::getViewportRelativeCoordinates (geom,
 
330
                                                               SCREEN_SIZE));
 
331
    EXPECT_EQ (geom.pos ().y (), position.y ());
 
332
}
 
333
 
 
334
TEST (PlaceGetViewportRelativeCoordinates, OutsideOuterScreenWidth)
 
335
{
 
336
    cw::Geometry geom (SCREEN_SIZE.width () + 1,
 
337
                       SCREEN_SIZE.height () / 2,
 
338
                       WINDOW_SIZE, WINDOW_SIZE,
 
339
                       0);
 
340
 
 
341
    CompPoint    position (cp::getViewportRelativeCoordinates (geom,
 
342
                                                               SCREEN_SIZE));
 
343
    EXPECT_EQ (1, position.x ());
 
344
}
 
345
 
 
346
TEST (PlaceGetViewportRelativeCoordinates, OutsideInnerScreenWidth)
 
347
{
 
348
    cw::Geometry geom (-(WINDOW_SIZE + 1),
 
349
                       SCREEN_SIZE.height () / 2,
 
350
                       WINDOW_SIZE, WINDOW_SIZE,
 
351
                       0);
 
352
 
 
353
    CompPoint    position (cp::getViewportRelativeCoordinates (geom,
 
354
                                                               SCREEN_SIZE));
 
355
    EXPECT_EQ (SCREEN_SIZE.width () - (WINDOW_SIZE + 1),
 
356
               position.x ());
 
357
}
 
358
 
 
359
TEST (PlaceGetViewportRelativeCoordinates, OutsideOuterScreenHeight)
 
360
{
 
361
    cw::Geometry geom (SCREEN_SIZE.width () / 2,
 
362
                       SCREEN_SIZE.height () + 1,
 
363
                       WINDOW_SIZE, WINDOW_SIZE,
 
364
                       0);
 
365
 
 
366
    CompPoint    position (cp::getViewportRelativeCoordinates (geom,
 
367
                                                               SCREEN_SIZE));
 
368
    EXPECT_EQ (1, position.y ());
 
369
}
 
370
 
 
371
TEST (PlaceGetViewportRelativeCoordinates, OutsideInnerScreenHeight)
 
372
{
 
373
    cw::Geometry geom (SCREEN_SIZE.width () / 2,
 
374
                       -(WINDOW_SIZE + 1),
 
375
                       WINDOW_SIZE, WINDOW_SIZE,
 
376
                       0);
 
377
 
 
378
    CompPoint    position (cp::getViewportRelativeCoordinates (geom,
 
379
                                                               SCREEN_SIZE));
 
380
    EXPECT_EQ (SCREEN_SIZE.height () - (WINDOW_SIZE + 1),
 
381
               position.y ());
 
382
}
 
383
 
 
384
namespace
 
385
{
 
386
const CompRect WORK_AREA (25, 25, 1000, 1000);
 
387
 
 
388
const cwe::Extents EdgePositions[] =
 
389
{
 
390
    /* Exact match */
 
391
    cwe::Extents (WORK_AREA.left (), WORK_AREA.right (),
 
392
                  WORK_AREA.top (), WORK_AREA.bottom ()),
 
393
    /* Just within */
 
394
    cwe::Extents (WORK_AREA.left () + 1, WORK_AREA.right () - 1,
 
395
                  WORK_AREA.top () + 1, WORK_AREA.bottom () - 1),
 
396
    /* Just outside right */
 
397
    cwe::Extents (WORK_AREA.left () + 1, WORK_AREA.right () + 1,
 
398
                  WORK_AREA.top (), WORK_AREA.bottom ()),
 
399
    /* Just outside left */
 
400
    cwe::Extents (WORK_AREA.left () - 1, WORK_AREA.right () - 1,
 
401
                  WORK_AREA.top (), WORK_AREA.bottom ()),
 
402
    /* Just outside top */
 
403
    cwe::Extents (WORK_AREA.left (), WORK_AREA.right (),
 
404
                  WORK_AREA.top () - 1, WORK_AREA.bottom () - 1),
 
405
    /* Just outside bottom */
 
406
    cwe::Extents (WORK_AREA.left (), WORK_AREA.right (),
 
407
                  WORK_AREA.top () + 1, WORK_AREA.bottom () + 1),
 
408
};
 
409
}
 
410
 
 
411
class PlaceClampEdgePositions :
 
412
    public CompPlaceTest,
 
413
    public WithParamInterface <CompWindowExtents>
 
414
{
 
415
};
 
416
 
 
417
TEST_P (PlaceClampEdgePositions, WithinWorkAreaWidth)
 
418
{
 
419
    CompWindowExtents edgePositions (GetParam ());
 
420
    cp::clampHorizontalEdgePositionsToWorkArea (edgePositions,
 
421
                                                WORK_AREA);
 
422
 
 
423
    const int edgePositionsWidth = edgePositions.right - edgePositions.left;
 
424
 
 
425
    ASSERT_GT (edgePositionsWidth, 0);
 
426
    EXPECT_LE (edgePositionsWidth, WORK_AREA.width ());
 
427
}
 
428
 
 
429
TEST_P (PlaceClampEdgePositions, OutsideLeft)
 
430
{
 
431
    CompWindowExtents edgePositions (GetParam ());
 
432
    cp::clampHorizontalEdgePositionsToWorkArea (edgePositions,
 
433
                                                WORK_AREA);
 
434
 
 
435
    ASSERT_GE (edgePositions.left, WORK_AREA.left ());
 
436
    ASSERT_GE (edgePositions.right, WORK_AREA.left ());
 
437
}
 
438
 
 
439
TEST_P (PlaceClampEdgePositions, OutsideRight)
 
440
{
 
441
    CompWindowExtents edgePositions (GetParam ());
 
442
    cp::clampHorizontalEdgePositionsToWorkArea (edgePositions,
 
443
                                                WORK_AREA);
 
444
 
 
445
    ASSERT_LE (edgePositions.left, WORK_AREA.right ());
 
446
    ASSERT_LE (edgePositions.right, WORK_AREA.right ());
 
447
}
 
448
 
 
449
TEST_P (PlaceClampEdgePositions, WithinWorkAreaHeight)
 
450
{
 
451
    CompWindowExtents edgePositions (GetParam ());
 
452
    cp::clampVerticalEdgePositionsToWorkArea (edgePositions,
 
453
                                              WORK_AREA);
 
454
 
 
455
    const int edgePositionsHeight = edgePositions.bottom - edgePositions.top;
 
456
 
 
457
    ASSERT_GT (edgePositionsHeight, 0);
 
458
    EXPECT_LE (edgePositionsHeight, WORK_AREA.height ());
 
459
}
 
460
 
 
461
TEST_P (PlaceClampEdgePositions, OutsideTop)
 
462
{
 
463
    CompWindowExtents edgePositions (GetParam ());
 
464
    cp::clampVerticalEdgePositionsToWorkArea (edgePositions,
 
465
                                              WORK_AREA);
 
466
 
 
467
    ASSERT_GE (edgePositions.top, WORK_AREA.top ());
 
468
    ASSERT_GE (edgePositions.bottom, WORK_AREA.top ());
 
469
}
 
470
 
 
471
TEST_P (PlaceClampEdgePositions, OutsideBottom)
 
472
{
 
473
    CompWindowExtents edgePositions (GetParam ());
 
474
    cp::clampVerticalEdgePositionsToWorkArea (edgePositions,
 
475
                                              WORK_AREA);
 
476
 
 
477
    ASSERT_LE (edgePositions.top, WORK_AREA.bottom ());
 
478
    ASSERT_LE (edgePositions.bottom, WORK_AREA.bottom ());
 
479
}
 
480
 
 
481
INSTANTIATE_TEST_CASE_P (WAEdgePositions, PlaceClampEdgePositions,
 
482
                         ValuesIn (EdgePositions));
 
483
 
 
484
TEST (PlaceSubtractBordersFromEdgePositions, NormalGravity)
 
485
{
 
486
    const CompWindowExtents borders (1, 2, 3, 4);
 
487
    const CompWindowExtents edgePositions (100, 200, 100, 200);
 
488
    const unsigned int      legacyBorder = 1;
 
489
 
 
490
    CompWindowExtents       expectedEdgePositions (edgePositions.left + (borders.left),
 
491
                                                   edgePositions.right - (borders.right + 2 * legacyBorder),
 
492
                                                   edgePositions.top + (borders.top),
 
493
                                                   edgePositions.bottom - (borders.bottom + 2 * legacyBorder));
 
494
 
 
495
    CompWindowExtents       modifiedEdgePositions (edgePositions);
 
496
 
 
497
    cp::subtractBordersFromEdgePositions (modifiedEdgePositions,
 
498
                                          borders,
 
499
                                          legacyBorder);
 
500
 
 
501
    EXPECT_EQ (expectedEdgePositions, modifiedEdgePositions);
 
502
}
 
503
 
 
504
TEST (PlaceSizeAndPositionChanged, PositionChangedReturnsFalse)
 
505
{
 
506
    EXPECT_FALSE (cp::onlySizeChanged (CWX | CWY));
 
507
}
 
508
 
 
509
TEST (PlaceSizeAndPositionChanged, SizeChangedReturnsTrue)
 
510
{
 
511
    EXPECT_TRUE (cp::onlySizeChanged (CWWidth | CWHeight));
 
512
}
 
513
 
 
514
TEST (PlaceSizeAndPositionChanged, XAndWidthChangedReturnsFalse)
 
515
{
 
516
    EXPECT_FALSE (cp::onlySizeChanged (CWX | CWWidth));
 
517
}
 
518
 
 
519
TEST (PlaceSizeAndPositionChanged, YAndHeightChangedReturnsFalse)
 
520
{
 
521
    EXPECT_FALSE (cp::onlySizeChanged (CWY | CWHeight));
 
522
}
 
523
 
 
524
TEST (PlaceApplyWidthChange, ReturnFalseIfNoChange)
 
525
{
 
526
    CompWindowExtents edgePositions (100, 200, 100, 200);
 
527
    XWindowChanges xwc;
 
528
    xwc.width = 100;
 
529
    unsigned int mask = CWWidth;
 
530
    EXPECT_FALSE (cp::applyWidthChange(edgePositions, xwc, mask));
 
531
}
 
532
 
 
533
TEST (PlaceApplyWidthChange, ApplyWidthAndSetFlag)
 
534
{
 
535
    CompWindowExtents edgePositions (100, 200, 100, 200);
 
536
    XWindowChanges xwc;
 
537
    unsigned int mask = 0;
 
538
    ASSERT_TRUE (cp::applyWidthChange(edgePositions, xwc, mask));
 
539
    EXPECT_EQ (edgePositions.right - edgePositions.left, xwc.width);
 
540
    EXPECT_EQ (CWWidth, mask);
 
541
}
 
542
 
 
543
TEST (PlaceApplyHeightChange, ReturnFalseIfNoChange)
 
544
{
 
545
    CompWindowExtents edgePositions (100, 200, 100, 200);
 
546
    XWindowChanges xwc;
 
547
    xwc.height = 100;
 
548
    unsigned int mask = CWHeight;
 
549
    EXPECT_FALSE (cp::applyHeightChange(edgePositions, xwc, mask));
 
550
}
 
551
 
 
552
TEST (PlaceApplyWidthChange, ApplyHeightAndSetFlag)
 
553
{
 
554
    CompWindowExtents edgePositions (100, 200, 100, 200);
 
555
    XWindowChanges xwc;
 
556
    unsigned int mask = 0;
 
557
    ASSERT_TRUE (cp::applyHeightChange(edgePositions, xwc, mask));
 
558
    EXPECT_EQ (edgePositions.bottom - edgePositions.top, xwc.height);
 
559
    EXPECT_EQ (CWHeight, mask);
103
560
}