Chromium Code Reviews| 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 #include <vector> | 10 #include <vector> |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 } | 306 } |
| 307 | 307 |
| 308 { | 308 { |
| 309 testing::InSequence dummy; | 309 testing::InSequence dummy; |
| 310 size_t source_count = screen ? window_count + 1 : window_count; | 310 size_t source_count = screen ? window_count + 1 : window_count; |
| 311 for (size_t i = 0; i < source_count; ++i) { | 311 for (size_t i = 0; i < source_count; ++i) { |
| 312 EXPECT_CALL(observer_, OnSourceAdded(model_.get(), i)) | 312 EXPECT_CALL(observer_, OnSourceAdded(model_.get(), i)) |
| 313 .WillOnce(CheckListSize(model_.get(), static_cast<int>(i + 1))); | 313 .WillOnce(CheckListSize(model_.get(), static_cast<int>(i + 1))); |
| 314 } | 314 } |
| 315 for (size_t i = 0; i < source_count - 1; ++i) { | 315 for (size_t i = 0; i < source_count - 1; ++i) { |
| 316 EXPECT_CALL(observer_, OnSourceThumbnailChanged(model_.get(), i)); | 316 EXPECT_CALL(observer_, OnSourceThumbnailChanged(model_.get(), i)); |
|
Sergey Ulanov
2016/06/07 23:42:30
For aura Windows add .Times(testing::AtLeast(1)) t
GeorgeZ
2016/06/08 03:02:24
This part checks the first refresh. The OnSourceTh
Sergey Ulanov
2016/06/08 19:56:38
Yeah, Times(AtLeast(1)) would not work here becaus
| |
| 317 } | 317 } |
| 318 EXPECT_CALL(observer_, | 318 EXPECT_CALL(observer_, |
| 319 OnSourceThumbnailChanged(model_.get(), source_count - 1)) | 319 OnSourceThumbnailChanged(model_.get(), source_count - 1)) |
| 320 .WillOnce(QuitMessageLoop(message_loop())); | 320 .WillOnce(QuitMessageLoop(message_loop())); |
| 321 } | 321 } |
| 322 model_->StartUpdating(&observer_); | 322 model_->StartUpdating(&observer_); |
| 323 message_loop()->Run(); | 323 message_loop()->Run(); |
| 324 | 324 |
| 325 if (screen) { | 325 if (screen) { |
| 326 EXPECT_EQ(model_->GetSource(0).id.type, DesktopMediaID::TYPE_SCREEN); | 326 EXPECT_EQ(model_->GetSource(0).id.type, DesktopMediaID::TYPE_SCREEN); |
| 327 EXPECT_EQ(model_->GetSource(0).id.id, 0); | 327 EXPECT_EQ(model_->GetSource(0).id.id, 0); |
| 328 } | 328 } |
| 329 | 329 |
| 330 for (size_t i = 0; i < window_count; ++i) { | 330 for (size_t i = 0; i < window_count; ++i) { |
| 331 size_t source_index = screen ? i + 1 : i; | 331 size_t source_index = screen ? i + 1 : i; |
| 332 EXPECT_EQ(model_->GetSource(source_index).id.type, | 332 EXPECT_EQ(model_->GetSource(source_index).id.type, |
| 333 DesktopMediaID::TYPE_WINDOW); | 333 DesktopMediaID::TYPE_WINDOW); |
| 334 EXPECT_EQ(model_->GetSource(source_index).name, | 334 EXPECT_EQ(model_->GetSource(source_index).name, |
| 335 base::UTF8ToUTF16("Test window")); | 335 base::UTF8ToUTF16("Test window")); |
| 336 int index = has_view_dialog ? i + 1 : i; | 336 int index = has_view_dialog ? i + 1 : i; |
| 337 int native_id = window_list_[index].id; | 337 int native_id = window_list_[index].id; |
| 338 EXPECT_EQ(model_->GetSource(source_index).id.id, native_id); | 338 EXPECT_EQ(model_->GetSource(source_index).id.id, native_id); |
| 339 #if defined(USE_AURA) | 339 #if defined(USE_AURA) |
| 340 if (i >= aura_window_first_index) | 340 if (i >= aura_window_first_index) |
| 341 EXPECT_EQ(model_->GetSource(source_index).id.aura_id, | 341 EXPECT_EQ(model_->GetSource(source_index).id.aura_id, |
| 342 native_aura_id_map_[native_id]); | 342 native_aura_id_map_[native_id]); |
| 343 #endif | 343 #endif |
| 344 } | 344 } |
| 345 testing::Mock::VerifyAndClearExpectations(&observer_); | 345 testing::Mock::VerifyAndClearExpectations(&observer_); |
| 346 } | 346 } |
|
Sergey Ulanov
2016/06/08 19:56:38
Add the expectations here? something like this:
f
GeorgeZ
2016/06/08 21:27:41
This will lead to TEST_F(NativeDesktopMediaListTes
Sergey Ulanov
2016/06/08 21:40:16
Just add it for the UpdateThumbnail test? That's t
GeorgeZ
2016/06/08 22:16:40
Done.
| |
| 347 | 347 |
| 348 protected: | 348 protected: |
| 349 // Must be listed before |model_|, so it's destroyed last. | 349 // Must be listed before |model_|, so it's destroyed last. |
| 350 MockObserver observer_; | 350 MockObserver observer_; |
| 351 | 351 |
| 352 // Owned by |model_|; | 352 // Owned by |model_|; |
| 353 FakeWindowCapturer* window_capturer_; | 353 FakeWindowCapturer* window_capturer_; |
| 354 | 354 |
| 355 webrtc::WindowCapturer::WindowList window_list_; | 355 webrtc::WindowCapturer::WindowList window_list_; |
| 356 std::vector<std::unique_ptr<views::Widget>> desktop_widgets_; | 356 std::vector<std::unique_ptr<views::Widget>> desktop_widgets_; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 const std::string kTestTitle = "New Title"; | 472 const std::string kTestTitle = "New Title"; |
| 473 window_list_[0].title = kTestTitle; | 473 window_list_[0].title = kTestTitle; |
| 474 window_capturer_->SetWindowList(window_list_); | 474 window_capturer_->SetWindowList(window_list_); |
| 475 | 475 |
| 476 message_loop()->Run(); | 476 message_loop()->Run(); |
| 477 | 477 |
| 478 EXPECT_EQ(model_->GetSource(1).name, base::UTF8ToUTF16(kTestTitle)); | 478 EXPECT_EQ(model_->GetSource(1).name, base::UTF8ToUTF16(kTestTitle)); |
| 479 } | 479 } |
| 480 | 480 |
| 481 TEST_F(NativeDesktopMediaListTest, UpdateThumbnail) { | 481 TEST_F(NativeDesktopMediaListTest, UpdateThumbnail) { |
| 482 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); | 482 AddWindowsAndVerify(true, kDefaultWindowCount, 0, false); |
| 483 | 483 |
| 484 EXPECT_CALL(observer_, OnSourceThumbnailChanged(model_.get(), 1)) | 484 EXPECT_CALL(observer_, OnSourceThumbnailChanged(model_.get(), 1)) |
| 485 .WillOnce(QuitMessageLoop(message_loop())); | 485 .WillOnce(QuitMessageLoop(message_loop())); |
| 486 | 486 |
| 487 // Update frame for the window and verify that we get notification about it. | 487 // Update frame for the window and verify that we get notification about it. |
| 488 window_capturer_->SetNextFrameValue(1, 10); | 488 window_capturer_->SetNextFrameValue(1, 10); |
| 489 | 489 |
| 490 message_loop()->Run(); | 490 message_loop()->Run(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 TEST_F(NativeDesktopMediaListTest, MoveWindow) { | 493 TEST_F(NativeDesktopMediaListTest, MoveWindow) { |
| 494 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); | 494 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); |
| 495 | 495 |
| 496 EXPECT_CALL(observer_, OnSourceMoved(model_.get(), 2, 1)) | 496 EXPECT_CALL(observer_, OnSourceMoved(model_.get(), 2, 1)) |
| 497 .WillOnce(DoAll(CheckListSize(model_.get(), kDefaultWindowCount + 1), | 497 .WillOnce(DoAll(CheckListSize(model_.get(), kDefaultWindowCount + 1), |
| 498 QuitMessageLoop(message_loop()))); | 498 QuitMessageLoop(message_loop()))); |
| 499 | 499 |
| 500 // Swap the two windows. | 500 // Swap the two windows. |
| 501 webrtc::WindowCapturer::Window temp = window_list_[0]; | 501 webrtc::WindowCapturer::Window temp = window_list_[0]; |
| 502 window_list_[0] = window_list_[1]; | 502 window_list_[0] = window_list_[1]; |
| 503 window_list_[1] = temp; | 503 window_list_[1] = temp; |
| 504 window_capturer_->SetWindowList(window_list_); | 504 window_capturer_->SetWindowList(window_list_); |
| 505 | 505 |
| 506 message_loop()->Run(); | 506 message_loop()->Run(); |
| 507 } | 507 } |
| OLD | NEW |