OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | |
12 | |
13 #include "webrtc/test/gtest.h" | |
14 | |
15 namespace webrtc { | |
16 | |
17 TEST(DesktopRectTest, UnionBetweenTwoNonEmptyRects) { | |
18 DesktopRect rect = DesktopRect::MakeXYWH(1, 1, 1, 1); | |
19 rect.UnionWith(DesktopRect::MakeXYWH(-2, -2, 1, 1)); | |
20 ASSERT_TRUE(rect.equals(DesktopRect::MakeXYWH(-2, -2, 4, 4))); | |
Do not use (sergeyu)
2017/05/18 17:37:53
nit: this test would be easier to read if it used
Hzj_jie
2017/05/18 19:24:00
Done.
| |
21 } | |
22 | |
23 TEST(DesktopRectTest, UnionWithEmptyRect) { | |
24 DesktopRect rect = DesktopRect::MakeWH(1, 1); | |
25 rect.UnionWith(DesktopRect()); | |
26 ASSERT_TRUE(rect.equals(DesktopRect::MakeWH(1, 1))); | |
27 | |
28 rect = DesktopRect::MakeXYWH(1, 1, 2, 2); | |
29 rect.UnionWith(DesktopRect()); | |
30 ASSERT_TRUE(rect.equals(DesktopRect::MakeXYWH(1, 1, 2, 2))); | |
31 | |
32 rect = DesktopRect::MakeXYWH(1, 1, 2, 2); | |
33 rect.UnionWith(DesktopRect::MakeXYWH(3, 3, 0, 0)); | |
34 ASSERT_TRUE(rect.equals(DesktopRect::MakeXYWH(1, 1, 2, 2))); | |
35 } | |
36 | |
37 TEST(DesktopRectTest, EmptyRectUnionWithNonEmptyOne) { | |
38 DesktopRect rect; | |
39 rect.UnionWith(DesktopRect::MakeWH(1, 1)); | |
40 ASSERT_TRUE(rect.equals(DesktopRect::MakeWH(1, 1))); | |
41 | |
42 rect = DesktopRect(); | |
43 rect.UnionWith(DesktopRect::MakeXYWH(1, 1, 2, 2)); | |
44 ASSERT_TRUE(rect.equals(DesktopRect::MakeXYWH(1, 1, 2, 2))); | |
45 | |
46 rect = DesktopRect::MakeXYWH(3, 3, 0, 0); | |
47 rect.UnionWith(DesktopRect::MakeXYWH(1, 1, 2, 2)); | |
48 ASSERT_TRUE(rect.equals(DesktopRect::MakeXYWH(1, 1, 2, 2))); | |
49 } | |
50 | |
51 TEST(DesktopRectTest, EmptyRectUnionWithEmptyOne) { | |
52 DesktopRect rect; | |
53 rect.UnionWith(DesktopRect()); | |
54 ASSERT_TRUE(rect.equals(DesktopRect())); | |
Do not use (sergeyu)
2017/05/18 17:37:53
rect.is_empty()?
Hzj_jie
2017/05/18 19:24:00
Done.
| |
55 | |
56 rect = DesktopRect::MakeXYWH(1, 1, 0, 0); | |
57 rect.UnionWith(DesktopRect()); | |
58 ASSERT_TRUE(rect.is_empty()); | |
59 | |
60 rect = DesktopRect(); | |
61 rect.UnionWith(DesktopRect::MakeXYWH(1, 1, 0, 0)); | |
62 ASSERT_TRUE(rect.is_empty()); | |
63 | |
64 rect = DesktopRect::MakeXYWH(1, 1, 0, 0); | |
65 rect.UnionWith(DesktopRect::MakeXYWH(-1, -1, 0, 0)); | |
66 ASSERT_TRUE(rect.is_empty()); | |
67 } | |
68 | |
69 } // namespace webrtc | |
OLD | NEW |