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/webrtc/desktop_media_list_ash.h" | 5 #include "chrome/browser/media/webrtc/desktop_media_list_ash.h" |
6 | 6 |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "chrome/browser/media/webrtc/desktop_media_list_observer.h" | 15 #include "chrome/browser/media/webrtc/desktop_media_list_observer.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
18 | 19 |
19 int kThumbnailSize = 100; | 20 int kThumbnailSize = 100; |
20 | 21 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 58 } |
58 | 59 |
59 TEST_F(DesktopMediaListAshTest, Screen) { | 60 TEST_F(DesktopMediaListAshTest, Screen) { |
60 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); | 61 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); |
61 | 62 |
62 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); | 63 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); |
63 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) | 64 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) |
64 .WillOnce(QuitMessageLoop()) | 65 .WillOnce(QuitMessageLoop()) |
65 .WillRepeatedly(DoDefault()); | 66 .WillRepeatedly(DoDefault()); |
66 list_->StartUpdating(&observer_); | 67 list_->StartUpdating(&observer_); |
67 base::MessageLoop::current()->Run(); | 68 base::RunLoop().Run(); |
68 } | 69 } |
69 | 70 |
70 TEST_F(DesktopMediaListAshTest, OneWindow) { | 71 TEST_F(DesktopMediaListAshTest, OneWindow) { |
71 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); | 72 CreateList(DesktopMediaListAsh::SCREENS | DesktopMediaListAsh::WINDOWS); |
72 | 73 |
73 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 74 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
74 | 75 |
75 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); | 76 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); |
76 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 1)); | 77 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 1)); |
77 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) | 78 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) |
78 .Times(AtLeast(1)); | 79 .Times(AtLeast(1)); |
79 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 1)) | 80 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 1)) |
80 .WillOnce(QuitMessageLoop()) | 81 .WillOnce(QuitMessageLoop()) |
81 .WillRepeatedly(DoDefault()); | 82 .WillRepeatedly(DoDefault()); |
82 EXPECT_CALL(observer_, OnSourceRemoved(list_.get(), 1)) | 83 EXPECT_CALL(observer_, OnSourceRemoved(list_.get(), 1)) |
83 .WillOnce(QuitMessageLoop()); | 84 .WillOnce(QuitMessageLoop()); |
84 | 85 |
85 list_->StartUpdating(&observer_); | 86 list_->StartUpdating(&observer_); |
86 base::MessageLoop::current()->Run(); | 87 base::RunLoop().Run(); |
87 window.reset(); | 88 window.reset(); |
88 base::MessageLoop::current()->Run(); | 89 base::RunLoop().Run(); |
89 } | 90 } |
90 | 91 |
91 TEST_F(DesktopMediaListAshTest, ScreenOnly) { | 92 TEST_F(DesktopMediaListAshTest, ScreenOnly) { |
92 CreateList(DesktopMediaListAsh::SCREENS); | 93 CreateList(DesktopMediaListAsh::SCREENS); |
93 | 94 |
94 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 95 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
95 | 96 |
96 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); | 97 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); |
97 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) | 98 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) |
98 .WillOnce(QuitMessageLoop()) | 99 .WillOnce(QuitMessageLoop()) |
99 .WillRepeatedly(DoDefault()); | 100 .WillRepeatedly(DoDefault()); |
100 | 101 |
101 list_->StartUpdating(&observer_); | 102 list_->StartUpdating(&observer_); |
102 base::MessageLoop::current()->Run(); | 103 base::RunLoop().Run(); |
103 } | 104 } |
104 | 105 |
105 // Times out on Win DrMemory bot. http://crbug.com/493187 | 106 // Times out on Win DrMemory bot. http://crbug.com/493187 |
106 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
107 #define MAYBE_WindowOnly DISABLED_WindowOnly | 108 #define MAYBE_WindowOnly DISABLED_WindowOnly |
108 #else | 109 #else |
109 #define MAYBE_WindowOnly WindowOnly | 110 #define MAYBE_WindowOnly WindowOnly |
110 #endif | 111 #endif |
111 | 112 |
112 TEST_F(DesktopMediaListAshTest, MAYBE_WindowOnly) { | 113 TEST_F(DesktopMediaListAshTest, MAYBE_WindowOnly) { |
113 CreateList(DesktopMediaListAsh::WINDOWS); | 114 CreateList(DesktopMediaListAsh::WINDOWS); |
114 | 115 |
115 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 116 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
116 | 117 |
117 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); | 118 EXPECT_CALL(observer_, OnSourceAdded(list_.get(), 0)); |
118 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) | 119 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) |
119 .WillOnce(QuitMessageLoop()) | 120 .WillOnce(QuitMessageLoop()) |
120 .WillRepeatedly(DoDefault()); | 121 .WillRepeatedly(DoDefault()); |
121 EXPECT_CALL(observer_, OnSourceRemoved(list_.get(), 0)) | 122 EXPECT_CALL(observer_, OnSourceRemoved(list_.get(), 0)) |
122 .WillOnce(QuitMessageLoop()); | 123 .WillOnce(QuitMessageLoop()); |
123 | 124 |
124 list_->StartUpdating(&observer_); | 125 list_->StartUpdating(&observer_); |
125 base::MessageLoop::current()->Run(); | 126 base::RunLoop().Run(); |
126 window.reset(); | 127 window.reset(); |
127 base::MessageLoop::current()->Run(); | 128 base::RunLoop().Run(); |
128 } | 129 } |
OLD | NEW |