OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/media/native_desktop_media_list.h" | 5 #include "chrome/browser/media/native_desktop_media_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 DesktopMediaListTest() | 147 DesktopMediaListTest() |
148 : window_capturer_(NULL), | 148 : window_capturer_(NULL), |
149 ui_thread_(content::BrowserThread::UI, | 149 ui_thread_(content::BrowserThread::UI, |
150 &message_loop_) { | 150 &message_loop_) { |
151 } | 151 } |
152 | 152 |
153 void CreateWithDefaultCapturers() { | 153 void CreateWithDefaultCapturers() { |
154 window_capturer_ = new FakeWindowCapturer(); | 154 window_capturer_ = new FakeWindowCapturer(); |
155 model_.reset(new NativeDesktopMediaList( | 155 model_.reset(new NativeDesktopMediaList( |
156 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer()), | 156 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer()), |
157 scoped_ptr<webrtc::WindowCapturer>(window_capturer_))); | 157 scoped_ptr<webrtc::WindowCapturer>(window_capturer_), false)); |
158 | 158 |
159 // Set update period to reduce the time it takes to run tests. | 159 // Set update period to reduce the time it takes to run tests. |
160 model_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(0)); | 160 model_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(0)); |
161 } | 161 } |
162 | 162 |
163 webrtc::WindowCapturer::WindowList AddWindowsAndVerify( | 163 webrtc::WindowCapturer::WindowList AddWindowsAndVerify( |
164 size_t count, bool window_only) { | 164 size_t count, bool window_only) { |
165 webrtc::WindowCapturer::WindowList list; | 165 webrtc::WindowCapturer::WindowList list; |
166 for (size_t i = 0; i < count; ++i) { | 166 for (size_t i = 0; i < count; ++i) { |
167 webrtc::WindowCapturer::Window window; | 167 webrtc::WindowCapturer::Window window; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 webrtc::WindowCapturer::WindowList list = AddWindowsAndVerify(2, false); | 229 webrtc::WindowCapturer::WindowList list = AddWindowsAndVerify(2, false); |
230 | 230 |
231 EXPECT_EQ(model_->GetSource(0).id.type, content::DesktopMediaID::TYPE_SCREEN); | 231 EXPECT_EQ(model_->GetSource(0).id.type, content::DesktopMediaID::TYPE_SCREEN); |
232 EXPECT_EQ(model_->GetSource(0).id.id, 0); | 232 EXPECT_EQ(model_->GetSource(0).id.id, 0); |
233 } | 233 } |
234 | 234 |
235 TEST_F(DesktopMediaListTest, WindowsOnly) { | 235 TEST_F(DesktopMediaListTest, WindowsOnly) { |
236 window_capturer_ = new FakeWindowCapturer(); | 236 window_capturer_ = new FakeWindowCapturer(); |
237 model_.reset(new NativeDesktopMediaList( | 237 model_.reset(new NativeDesktopMediaList( |
238 scoped_ptr<webrtc::ScreenCapturer>(), | 238 scoped_ptr<webrtc::ScreenCapturer>(), |
239 scoped_ptr<webrtc::WindowCapturer>(window_capturer_))); | 239 scoped_ptr<webrtc::WindowCapturer>(window_capturer_), false)); |
240 AddWindowsAndVerify(1, true); | 240 AddWindowsAndVerify(1, true); |
241 } | 241 } |
242 | 242 |
243 TEST_F(DesktopMediaListTest, ScreenOnly) { | 243 TEST_F(DesktopMediaListTest, ScreenOnly) { |
244 model_.reset(new NativeDesktopMediaList( | 244 model_.reset(new NativeDesktopMediaList( |
245 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer), | 245 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer), |
246 scoped_ptr<webrtc::WindowCapturer>())); | 246 scoped_ptr<webrtc::WindowCapturer>(), false)); |
247 | 247 |
248 { | 248 { |
249 testing::InSequence dummy; | 249 testing::InSequence dummy; |
250 EXPECT_CALL(observer_, OnSourceAdded(0)) | 250 EXPECT_CALL(observer_, OnSourceAdded(0)) |
251 .WillOnce(CheckListSize(model_.get(), 1)); | 251 .WillOnce(CheckListSize(model_.get(), 1)); |
252 EXPECT_CALL(observer_, OnSourceThumbnailChanged(0)) | 252 EXPECT_CALL(observer_, OnSourceThumbnailChanged(0)) |
253 .WillOnce(QuitMessageLoop(&message_loop_)); | 253 .WillOnce(QuitMessageLoop(&message_loop_)); |
254 } | 254 } |
255 model_->StartUpdating(&observer_); | 255 model_->StartUpdating(&observer_); |
256 | 256 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // Swap the two windows. | 350 // Swap the two windows. |
351 webrtc::WindowCapturer::Window temp = list[0]; | 351 webrtc::WindowCapturer::Window temp = list[0]; |
352 list[0] = list[1]; | 352 list[0] = list[1]; |
353 list[1] = temp; | 353 list[1] = temp; |
354 window_capturer_->SetWindowList(list); | 354 window_capturer_->SetWindowList(list); |
355 | 355 |
356 message_loop_.Run(); | 356 message_loop_.Run(); |
357 } | 357 } |
358 | 358 |
359 } // namespace | 359 } // namespace |
OLD | NEW |