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 |
(...skipping 25 matching lines...) Expand all Loading... |
36 frame_ = std::move(frame); | 36 frame_ = std::move(frame); |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 std::unique_ptr<WindowCapturer> capturer_; | 40 std::unique_ptr<WindowCapturer> capturer_; |
41 std::unique_ptr<DesktopFrame> frame_; | 41 std::unique_ptr<DesktopFrame> frame_; |
42 }; | 42 }; |
43 | 43 |
44 // Verify that we can enumerate windows. | 44 // Verify that we can enumerate windows. |
45 TEST_F(WindowCapturerTest, Enumerate) { | 45 TEST_F(WindowCapturerTest, Enumerate) { |
46 WindowCapturer::WindowList windows; | 46 DesktopCapturer::SourceList sources; |
47 EXPECT_TRUE(capturer_->GetWindowList(&windows)); | 47 EXPECT_TRUE(capturer_->GetSourceList(&sources)); |
48 | 48 |
49 // Verify that window titles are set. | 49 // Verify that window titles are set. |
50 for (WindowCapturer::WindowList::iterator it = windows.begin(); | 50 for (auto it = sources.begin(); it != sources.end(); ++it) { |
51 it != windows.end(); ++it) { | |
52 EXPECT_FALSE(it->title.empty()); | 51 EXPECT_FALSE(it->title.empty()); |
53 } | 52 } |
54 } | 53 } |
55 | 54 |
56 // Verify we can capture a window. | 55 // Verify we can capture a window. |
57 // | 56 // |
58 // TODO(sergeyu): Currently this test just looks at the windows that already | 57 // TODO(sergeyu): Currently this test just looks at the windows that already |
59 // exist. Ideally it should create a test window and capture from it, but there | 58 // exist. Ideally it should create a test window and capture from it, but there |
60 // is no easy cross-platform way to create new windows (potentially we could | 59 // is no easy cross-platform way to create new windows (potentially we could |
61 // have a python script showing Tk dialog, but launching code will differ | 60 // have a python script showing Tk dialog, but launching code will differ |
62 // between platforms). | 61 // between platforms). |
63 TEST_F(WindowCapturerTest, Capture) { | 62 TEST_F(WindowCapturerTest, Capture) { |
64 WindowCapturer::WindowList windows; | 63 DesktopCapturer::SourceList sources; |
65 capturer_->Start(this); | 64 capturer_->Start(this); |
66 EXPECT_TRUE(capturer_->GetWindowList(&windows)); | 65 EXPECT_TRUE(capturer_->GetSourceList(&sources)); |
67 | 66 |
68 // Verify that we can select and capture each window. | 67 // Verify that we can select and capture each window. |
69 for (WindowCapturer::WindowList::iterator it = windows.begin(); | 68 for (auto it = sources.begin(); it != sources.end(); ++it) { |
70 it != windows.end(); ++it) { | |
71 frame_.reset(); | 69 frame_.reset(); |
72 if (capturer_->SelectWindow(it->id)) { | 70 if (capturer_->SelectSource(it->id)) { |
73 capturer_->CaptureFrame(); | 71 capturer_->CaptureFrame(); |
74 } | 72 } |
75 | 73 |
76 // If we failed to capture a window make sure it no longer exists. | 74 // If we failed to capture a window make sure it no longer exists. |
77 if (!frame_.get()) { | 75 if (!frame_.get()) { |
78 WindowCapturer::WindowList new_list; | 76 DesktopCapturer::SourceList new_list; |
79 EXPECT_TRUE(capturer_->GetWindowList(&new_list)); | 77 EXPECT_TRUE(capturer_->GetSourceList(&new_list)); |
80 for (WindowCapturer::WindowList::iterator new_list_it = new_list.begin(); | 78 for (auto new_list_it = new_list.begin(); new_list_it != new_list.end(); |
81 new_list_it != new_list.end(); ++new_list_it) { | 79 ++new_list_it) { |
82 EXPECT_FALSE(it->id == new_list_it->id); | 80 EXPECT_FALSE(it->id == new_list_it->id); |
83 } | 81 } |
84 continue; | 82 continue; |
85 } | 83 } |
86 | 84 |
87 EXPECT_GT(frame_->size().width(), 0); | 85 EXPECT_GT(frame_->size().width(), 0); |
88 EXPECT_GT(frame_->size().height(), 0); | 86 EXPECT_GT(frame_->size().height(), 0); |
89 } | 87 } |
90 } | 88 } |
91 | 89 |
92 } // namespace webrtc | 90 } // namespace webrtc |
OLD | NEW |