Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/media/native_desktop_media_list_unittest.cc

Issue 1895743007: Disable aura window capture unit tests in unix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/unit_tests.gtest_linux.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 #include "ui/views/test/views_test_base.h" 26 #include "ui/views/test/views_test_base.h"
27 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 27 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
28 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
29 29
30 using content::DesktopMediaID; 30 using content::DesktopMediaID;
31 using testing::_; 31 using testing::_;
32 using testing::DoAll; 32 using testing::DoAll;
33 33
34 namespace { 34 namespace {
35 35
36 // Aura window capture unit tests are not stable in linux. crbug.com/602494 and
37 // crbug.com/603823.
38 #if defined(OS_WIN)
39 #define ENABLE_AURA_WINDOW_TESTS
40 #endif
41
36 static const int kDefaultWindowCount = 2; 42 static const int kDefaultWindowCount = 2;
37 #if defined(USE_AURA) 43 #if defined(ENABLE_AURA_WINDOW_TESTS)
38 static const int kDefaultAuraCount = 1; 44 static const int kDefaultAuraCount = 1;
39 #else 45 #else
40 static const int kDefaultAuraCount = 0; 46 static const int kDefaultAuraCount = 0;
41 #endif 47 #endif
42 48
43 class MockObserver : public DesktopMediaListObserver { 49 class MockObserver : public DesktopMediaListObserver {
44 public: 50 public:
45 MOCK_METHOD2(OnSourceAdded, void(DesktopMediaList* list, int index)); 51 MOCK_METHOD2(OnSourceAdded, void(DesktopMediaList* list, int index));
46 MOCK_METHOD2(OnSourceRemoved, void(DesktopMediaList* list, int index)); 52 MOCK_METHOD2(OnSourceRemoved, void(DesktopMediaList* list, int index));
47 MOCK_METHOD3(OnSourceMoved, 53 MOCK_METHOD3(OnSourceMoved,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (window) 185 if (window)
180 window_capturer_ = new FakeWindowCapturer(); 186 window_capturer_ = new FakeWindowCapturer();
181 else 187 else
182 window_capturer_ = nullptr; 188 window_capturer_ = nullptr;
183 189
184 model_.reset(new NativeDesktopMediaList( 190 model_.reset(new NativeDesktopMediaList(
185 std::unique_ptr<webrtc::ScreenCapturer>(screen_capturer), 191 std::unique_ptr<webrtc::ScreenCapturer>(screen_capturer),
186 std::unique_ptr<webrtc::WindowCapturer>(window_capturer_))); 192 std::unique_ptr<webrtc::WindowCapturer>(window_capturer_)));
187 193
188 // Set update period to reduce the time it takes to run tests. 194 // Set update period to reduce the time it takes to run tests.
189 model_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(5)); 195 model_->SetUpdatePeriod(base::TimeDelta::FromMilliseconds(20));
190 } 196 }
191 197
192 void AddNativeWindow(int id) { 198 void AddNativeWindow(int id) {
193 webrtc::WindowCapturer::Window window; 199 webrtc::WindowCapturer::Window window;
194 window.id = id; 200 window.id = id;
195 window.title = "Test window"; 201 window.title = "Test window";
196 window_list_.push_back(window); 202 window_list_.push_back(window);
197 } 203 }
198 204
199 #if defined(USE_AURA) 205 #if defined(USE_AURA)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 webrtc::WindowCapturer::Window window; 387 webrtc::WindowCapturer::Window window;
382 AddNativeWindow(index); 388 AddNativeWindow(index);
383 window_capturer_->SetWindowList(window_list_); 389 window_capturer_->SetWindowList(window_list_);
384 390
385 message_loop()->Run(); 391 message_loop()->Run();
386 392
387 EXPECT_EQ(model_->GetSource(index).id.type, DesktopMediaID::TYPE_WINDOW); 393 EXPECT_EQ(model_->GetSource(index).id.type, DesktopMediaID::TYPE_WINDOW);
388 EXPECT_EQ(model_->GetSource(index).id.id, index); 394 EXPECT_EQ(model_->GetSource(index).id.id, index);
389 } 395 }
390 396
391 #if defined(USE_AURA) 397 #if defined(ENABLE_AURA_WINDOW_TESTS)
392 TEST_F(NativeDesktopMediaListTest, AddAuraWindow) { 398 TEST_F(NativeDesktopMediaListTest, AddAuraWindow) {
393 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); 399 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false);
394 400
395 const int index = kDefaultWindowCount + 1; 401 const int index = kDefaultWindowCount + 1;
396 EXPECT_CALL(observer_, OnSourceAdded(model_.get(), index)) 402 EXPECT_CALL(observer_, OnSourceAdded(model_.get(), index))
397 .WillOnce(DoAll(CheckListSize(model_.get(), index + 1), 403 .WillOnce(DoAll(CheckListSize(model_.get(), index + 1),
398 QuitMessageLoop(message_loop()))); 404 QuitMessageLoop(message_loop())));
399 405
400 AddAuraWindow(); 406 AddAuraWindow();
401 window_capturer_->SetWindowList(window_list_); 407 window_capturer_->SetWindowList(window_list_);
402 408
403 message_loop()->Run(); 409 message_loop()->Run();
404 410
405 int native_id = window_list_.back().id; 411 int native_id = window_list_.back().id;
406 EXPECT_EQ(model_->GetSource(index).id.type, DesktopMediaID::TYPE_WINDOW); 412 EXPECT_EQ(model_->GetSource(index).id.type, DesktopMediaID::TYPE_WINDOW);
407 EXPECT_EQ(model_->GetSource(index).id.id, native_id); 413 EXPECT_EQ(model_->GetSource(index).id.id, native_id);
408 EXPECT_EQ(model_->GetSource(index).id.aura_id, 414 EXPECT_EQ(model_->GetSource(index).id.aura_id,
409 native_aura_id_map_[native_id]); 415 native_aura_id_map_[native_id]);
410 } 416 }
411 #endif // defined(USE_AURA) 417 #endif // defined(ENABLE_AURA_WINDOW_TESTS)
412 418
413 TEST_F(NativeDesktopMediaListTest, RemoveNativeWindow) { 419 TEST_F(NativeDesktopMediaListTest, RemoveNativeWindow) {
414 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); 420 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false);
415 421
416 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), 1)) 422 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), 1))
417 .WillOnce(DoAll(CheckListSize(model_.get(), kDefaultWindowCount), 423 .WillOnce(DoAll(CheckListSize(model_.get(), kDefaultWindowCount),
418 QuitMessageLoop(message_loop()))); 424 QuitMessageLoop(message_loop())));
419 425
420 window_list_.erase(window_list_.begin()); 426 window_list_.erase(window_list_.begin());
421 window_capturer_->SetWindowList(window_list_); 427 window_capturer_->SetWindowList(window_list_);
422 428
423 message_loop()->Run(); 429 message_loop()->Run();
424 } 430 }
425 431
426 #if defined(USE_AURA) 432 #if defined(ENABLE_AURA_WINDOW_TESTS)
427 TEST_F(NativeDesktopMediaListTest, RemoveAuraWindow) { 433 TEST_F(NativeDesktopMediaListTest, RemoveAuraWindow) {
428 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); 434 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false);
429 435
430 int aura_window_start_index = kDefaultWindowCount - kDefaultAuraCount + 1; 436 int aura_window_start_index = kDefaultWindowCount - kDefaultAuraCount + 1;
431 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), aura_window_start_index)) 437 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), aura_window_start_index))
432 .WillOnce(DoAll(CheckListSize(model_.get(), kDefaultWindowCount), 438 .WillOnce(DoAll(CheckListSize(model_.get(), kDefaultWindowCount),
433 QuitMessageLoop(message_loop()))); 439 QuitMessageLoop(message_loop())));
434 440
435 RemoveAuraWindow(0); 441 RemoveAuraWindow(0);
436 window_capturer_->SetWindowList(window_list_); 442 window_capturer_->SetWindowList(window_list_);
437 443
438 message_loop()->Run(); 444 message_loop()->Run();
439 } 445 }
440 #endif // defined(USE_AURA) 446 #endif // defined(ENABLE_AURA_WINDOW_TESTS)
441 447
442 TEST_F(NativeDesktopMediaListTest, RemoveAllWindows) { 448 TEST_F(NativeDesktopMediaListTest, RemoveAllWindows) {
443 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false); 449 AddWindowsAndVerify(true, kDefaultWindowCount, kDefaultAuraCount, false);
444 450
445 testing::InSequence seq; 451 testing::InSequence seq;
446 for (int i = 0; i < kDefaultWindowCount - 1; i++) { 452 for (int i = 0; i < kDefaultWindowCount - 1; i++) {
447 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), 1)) 453 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), 1))
448 .WillOnce(CheckListSize(model_.get(), kDefaultWindowCount - i)); 454 .WillOnce(CheckListSize(model_.get(), kDefaultWindowCount - i));
449 } 455 }
450 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), 1)) 456 EXPECT_CALL(observer_, OnSourceRemoved(model_.get(), 1))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 QuitMessageLoop(message_loop()))); 498 QuitMessageLoop(message_loop())));
493 499
494 // Swap the two windows. 500 // Swap the two windows.
495 webrtc::WindowCapturer::Window temp = window_list_[0]; 501 webrtc::WindowCapturer::Window temp = window_list_[0];
496 window_list_[0] = window_list_[1]; 502 window_list_[0] = window_list_[1];
497 window_list_[1] = temp; 503 window_list_[1] = temp;
498 window_capturer_->SetWindowList(window_list_); 504 window_capturer_->SetWindowList(window_list_);
499 505
500 message_loop()->Run(); 506 message_loop()->Run();
501 } 507 }
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/unit_tests.gtest_linux.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698