OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 <memory> |
| 12 |
11 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "webrtc/base/scoped_ptr.h" | |
13 #include "webrtc/modules/desktop_capture/differ.h" | 14 #include "webrtc/modules/desktop_capture/differ.h" |
14 #include "webrtc/modules/desktop_capture/differ_block.h" | 15 #include "webrtc/modules/desktop_capture/differ_block.h" |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 | 18 |
18 // 96x96 screen gives a 4x4 grid of blocks. | 19 // 96x96 screen gives a 4x4 grid of blocks. |
19 const int kScreenWidth= 96; | 20 const int kScreenWidth= 96; |
20 const int kScreenHeight = 96; | 21 const int kScreenHeight = 96; |
21 | 22 |
22 // To test partial blocks, we need a width and height that are not multiples | 23 // To test partial blocks, we need a width and height that are not multiples |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 width * kBlockSize, height * kBlockSize); | 182 width * kBlockSize, height * kBlockSize); |
182 | 183 |
183 // Verify that the region contains expected_rect and it's the only | 184 // Verify that the region contains expected_rect and it's the only |
184 // rectangle. | 185 // rectangle. |
185 DesktopRegion::Iterator it(dirty); | 186 DesktopRegion::Iterator it(dirty); |
186 return !it.IsAtEnd() && expected_rect.equals(it.rect()) && | 187 return !it.IsAtEnd() && expected_rect.equals(it.rect()) && |
187 (it.Advance(), it.IsAtEnd()); | 188 (it.Advance(), it.IsAtEnd()); |
188 } | 189 } |
189 | 190 |
190 // The differ class we're testing. | 191 // The differ class we're testing. |
191 rtc::scoped_ptr<Differ> differ_; | 192 std::unique_ptr<Differ> differ_; |
192 | 193 |
193 // Screen/buffer info. | 194 // Screen/buffer info. |
194 int width_; | 195 int width_; |
195 int height_; | 196 int height_; |
196 int bytes_per_pixel_; | 197 int bytes_per_pixel_; |
197 int stride_; | 198 int stride_; |
198 | 199 |
199 // Size of each screen buffer. | 200 // Size of each screen buffer. |
200 int buffer_size_; | 201 int buffer_size_; |
201 | 202 |
202 // Previous and current screen buffers. | 203 // Previous and current screen buffers. |
203 rtc::scoped_ptr<uint8_t[]> prev_; | 204 std::unique_ptr<uint8_t[]> prev_; |
204 rtc::scoped_ptr<uint8_t[]> curr_; | 205 std::unique_ptr<uint8_t[]> curr_; |
205 | 206 |
206 private: | 207 private: |
207 RTC_DISALLOW_COPY_AND_ASSIGN(DifferTest); | 208 RTC_DISALLOW_COPY_AND_ASSIGN(DifferTest); |
208 }; | 209 }; |
209 | 210 |
210 TEST_F(DifferTest, Setup) { | 211 TEST_F(DifferTest, Setup) { |
211 InitDiffer(kScreenWidth, kScreenHeight); | 212 InitDiffer(kScreenWidth, kScreenHeight); |
212 // 96x96 pixels results in 3x3 array. Add 1 to each dimension as boundary. | 213 // 96x96 pixels results in 3x3 array. Add 1 to each dimension as boundary. |
213 // +---+---+---+---+ | 214 // +---+---+---+---+ |
214 // | o | o | o | _ | | 215 // | o | o | o | _ | |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 644 |
644 dirty.Clear(); | 645 dirty.Clear(); |
645 MergeBlocks(&dirty); | 646 MergeBlocks(&dirty); |
646 | 647 |
647 ASSERT_EQ(2, RegionRectCount(dirty)); | 648 ASSERT_EQ(2, RegionRectCount(dirty)); |
648 ASSERT_TRUE(CheckDirtyRegionContainsRect(dirty, 0, 0, 2, 2)); | 649 ASSERT_TRUE(CheckDirtyRegionContainsRect(dirty, 0, 0, 2, 2)); |
649 ASSERT_TRUE(CheckDirtyRegionContainsRect(dirty, 1, 2, 1, 1)); | 650 ASSERT_TRUE(CheckDirtyRegionContainsRect(dirty, 1, 2, 1, 1)); |
650 } | 651 } |
651 | 652 |
652 } // namespace webrtc | 653 } // namespace webrtc |
OLD | NEW |