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 "base/location.h" | 7 #include "base/location.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 DesktopMediaListTest() | 142 DesktopMediaListTest() |
143 : window_capturer_(NULL), | 143 : window_capturer_(NULL), |
144 ui_thread_(content::BrowserThread::UI, | 144 ui_thread_(content::BrowserThread::UI, |
145 &message_loop_) { | 145 &message_loop_) { |
146 } | 146 } |
147 | 147 |
148 void CreateWithDefaultCapturers() { | 148 void CreateWithDefaultCapturers() { |
149 window_capturer_ = new FakeWindowCapturer(); | 149 window_capturer_ = new FakeWindowCapturer(); |
150 model_.reset(new NativeDesktopMediaList( | 150 model_.reset(new NativeDesktopMediaList( |
151 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer()), | 151 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer()), |
152 scoped_ptr<webrtc::WindowCapturer>(window_capturer_))); | 152 scoped_ptr<webrtc::WindowCapturer>(window_capturer_), false)); |
153 | 153 |
154 // Set update period to reduce the time it takes to run tests. | 154 // Set update period to reduce the time it takes to run tests. |
155 model_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(0)); | 155 model_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(0)); |
156 } | 156 } |
157 | 157 |
158 webrtc::WindowCapturer::WindowList AddWindowsAndVerify( | 158 webrtc::WindowCapturer::WindowList AddWindowsAndVerify( |
159 size_t count, bool window_only) { | 159 size_t count, bool window_only) { |
160 webrtc::WindowCapturer::WindowList list; | 160 webrtc::WindowCapturer::WindowList list; |
161 for (size_t i = 0; i < count; ++i) { | 161 for (size_t i = 0; i < count; ++i) { |
162 webrtc::WindowCapturer::Window window; | 162 webrtc::WindowCapturer::Window window; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 webrtc::WindowCapturer::WindowList list = AddWindowsAndVerify(2, false); | 224 webrtc::WindowCapturer::WindowList list = AddWindowsAndVerify(2, false); |
225 | 225 |
226 EXPECT_EQ(model_->GetSource(0).id.type, content::DesktopMediaID::TYPE_SCREEN); | 226 EXPECT_EQ(model_->GetSource(0).id.type, content::DesktopMediaID::TYPE_SCREEN); |
227 EXPECT_EQ(model_->GetSource(0).id.id, 0); | 227 EXPECT_EQ(model_->GetSource(0).id.id, 0); |
228 } | 228 } |
229 | 229 |
230 TEST_F(DesktopMediaListTest, WindowsOnly) { | 230 TEST_F(DesktopMediaListTest, WindowsOnly) { |
231 window_capturer_ = new FakeWindowCapturer(); | 231 window_capturer_ = new FakeWindowCapturer(); |
232 model_.reset(new NativeDesktopMediaList( | 232 model_.reset(new NativeDesktopMediaList( |
233 scoped_ptr<webrtc::ScreenCapturer>(), | 233 scoped_ptr<webrtc::ScreenCapturer>(), |
234 scoped_ptr<webrtc::WindowCapturer>(window_capturer_))); | 234 scoped_ptr<webrtc::WindowCapturer>(window_capturer_), false)); |
235 AddWindowsAndVerify(1, true); | 235 AddWindowsAndVerify(1, true); |
236 } | 236 } |
237 | 237 |
238 TEST_F(DesktopMediaListTest, ScreenOnly) { | 238 TEST_F(DesktopMediaListTest, ScreenOnly) { |
239 model_.reset(new NativeDesktopMediaList( | 239 model_.reset(new NativeDesktopMediaList( |
240 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer), | 240 scoped_ptr<webrtc::ScreenCapturer>(new FakeScreenCapturer), |
241 scoped_ptr<webrtc::WindowCapturer>())); | 241 scoped_ptr<webrtc::WindowCapturer>(), false)); |
qiangchen
2015/12/07 22:45:56
Consider adding a test case say "TabOnly"
GeorgeZ
2015/12/09 19:36:38
Need modify unit tests desktop_meida_list_ash_unin
| |
242 | 242 |
243 { | 243 { |
244 testing::InSequence dummy; | 244 testing::InSequence dummy; |
245 EXPECT_CALL(observer_, OnSourceAdded(0)) | 245 EXPECT_CALL(observer_, OnSourceAdded(0)) |
246 .WillOnce(CheckListSize(model_.get(), 1)); | 246 .WillOnce(CheckListSize(model_.get(), 1)); |
247 EXPECT_CALL(observer_, OnSourceThumbnailChanged(0)) | 247 EXPECT_CALL(observer_, OnSourceThumbnailChanged(0)) |
248 .WillOnce(QuitMessageLoop(&message_loop_)); | 248 .WillOnce(QuitMessageLoop(&message_loop_)); |
249 } | 249 } |
250 model_->StartUpdating(&observer_); | 250 model_->StartUpdating(&observer_); |
251 | 251 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 // Swap the two windows. | 345 // Swap the two windows. |
346 webrtc::WindowCapturer::Window temp = list[0]; | 346 webrtc::WindowCapturer::Window temp = list[0]; |
347 list[0] = list[1]; | 347 list[0] = list[1]; |
348 list[1] = temp; | 348 list[1] = temp; |
349 window_capturer_->SetWindowList(list); | 349 window_capturer_->SetWindowList(list); |
350 | 350 |
351 message_loop_.Run(); | 351 message_loop_.Run(); |
352 } | 352 } |
353 | 353 |
354 } // namespace | 354 } // namespace |
OLD | NEW |