OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/desktop_capture/rgba_color.h" | 11 #include "webrtc/modules/desktop_capture/rgba_color.h" |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "webrtc/test/gtest.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 TEST(RgbaColorTest, ConvertFromAndToUInt32) { | 19 TEST(RgbaColorTest, ConvertFromAndToUInt32) { |
20 static const std::vector<uint32_t> cases{ | 20 static const std::vector<uint32_t> cases{ |
21 0, 1000, 2693, 3725, 4097, 12532, | 21 0, 1000, 2693, 3725, 4097, 12532, |
22 19902, 27002, 27723, 30944, 65535, 65536, | 22 19902, 27002, 27723, 30944, 65535, 65536, |
23 231194, 255985, 322871, 883798, 9585200, 12410056, | 23 231194, 255985, 322871, 883798, 9585200, 12410056, |
24 12641940, 30496970, 105735668, 110117847, 482769275, 542368468, | 24 12641940, 30496970, 105735668, 110117847, 482769275, 542368468, |
25 798173396, 2678656711, 3231043200, UINT32_MAX, | 25 798173396, 2678656711, 3231043200, UINT32_MAX, |
26 }; | 26 }; |
27 | 27 |
28 for (uint32_t value : cases) { | 28 for (uint32_t value : cases) { |
29 RgbaColor left(value); | 29 RgbaColor left(value); |
30 ASSERT_EQ(left.ToUInt32(), value); | 30 ASSERT_EQ(left.ToUInt32(), value); |
31 RgbaColor right(left); | 31 RgbaColor right(left); |
32 ASSERT_EQ(left.ToUInt32(), right.ToUInt32()); | 32 ASSERT_EQ(left.ToUInt32(), right.ToUInt32()); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 TEST(RgbaColorTest, AlphaChannelEquality) { | 36 TEST(RgbaColorTest, AlphaChannelEquality) { |
37 RgbaColor left(10, 10, 10, 0); | 37 RgbaColor left(10, 10, 10, 0); |
38 RgbaColor right(10, 10, 10, 255); | 38 RgbaColor right(10, 10, 10, 255); |
39 ASSERT_EQ(left, right); | 39 ASSERT_EQ(left, right); |
40 right.alpha = 128; | 40 right.alpha = 128; |
41 ASSERT_NE(left, right); | 41 ASSERT_NE(left, right); |
42 } | 42 } |
43 | 43 |
44 } // namespace webrtc | 44 } // namespace webrtc |
OLD | NEW |