| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 message_loop_(base::MessageLoopProxy::current()) { | 70 message_loop_(base::MessageLoopProxy::current()) { |
| 71 // Create our own MediaStreamManager. | 71 // Create our own MediaStreamManager. |
| 72 audio_manager_.reset(new MockAudioManager()); | 72 audio_manager_.reset(new MockAudioManager()); |
| 73 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 73 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
| 74 | 74 |
| 75 // Use fake devices in order to run on the bots. | 75 // Use fake devices in order to run on the bots. |
| 76 media_stream_manager_->UseFakeDevice(); | 76 media_stream_manager_->UseFakeDevice(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual ~MediaStreamManagerTest() { | 79 virtual ~MediaStreamManagerTest() { |
| 80 media_stream_manager_->WillDestroyCurrentMessageLoop(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 MOCK_METHOD1(Response, void(int index)); | 83 MOCK_METHOD1(Response, void(int index)); |
| 83 void ResponseCallback(int index, | 84 void ResponseCallback(int index, |
| 84 const MediaStreamDevices& devices, | 85 const MediaStreamDevices& devices, |
| 85 scoped_ptr<MediaStreamUIProxy> ui_proxy) { | 86 scoped_ptr<MediaStreamUIProxy> ui_proxy) { |
| 86 Response(index); | 87 Response(index); |
| 87 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); | 88 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); |
| 88 } | 89 } |
| 89 | 90 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 122 |
| 122 // Expecting the callback will be triggered and quit the test. | 123 // Expecting the callback will be triggered and quit the test. |
| 123 EXPECT_CALL(*this, Response(0)); | 124 EXPECT_CALL(*this, Response(0)); |
| 124 run_loop_.Run(); | 125 run_loop_.Run(); |
| 125 } | 126 } |
| 126 | 127 |
| 127 TEST_F(MediaStreamManagerTest, MakeAndCancelMediaAccessRequest) { | 128 TEST_F(MediaStreamManagerTest, MakeAndCancelMediaAccessRequest) { |
| 128 std::string label = MakeMediaAccessRequest(0); | 129 std::string label = MakeMediaAccessRequest(0); |
| 129 // No callback is expected. | 130 // No callback is expected. |
| 130 media_stream_manager_->CancelRequest(label); | 131 media_stream_manager_->CancelRequest(label); |
| 131 run_loop_.RunUntilIdle(); | |
| 132 media_stream_manager_->WillDestroyCurrentMessageLoop(); | |
| 133 } | 132 } |
| 134 | 133 |
| 135 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) { | 134 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) { |
| 136 // First request. | 135 // First request. |
| 137 std::string label1 = MakeMediaAccessRequest(0); | 136 std::string label1 = MakeMediaAccessRequest(0); |
| 138 | 137 |
| 139 // Second request. | 138 // Second request. |
| 140 int render_process_id = 2; | 139 int render_process_id = 2; |
| 141 int render_view_id = 2; | 140 int render_view_id = 2; |
| 142 int page_request_id = 2; | 141 int page_request_id = 2; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 167 std::string label2 = MakeMediaAccessRequest(1); | 166 std::string label2 = MakeMediaAccessRequest(1); |
| 168 media_stream_manager_->CancelRequest(label1); | 167 media_stream_manager_->CancelRequest(label1); |
| 169 | 168 |
| 170 // Expecting the callback from the second request will be triggered and | 169 // Expecting the callback from the second request will be triggered and |
| 171 // quit the test. | 170 // quit the test. |
| 172 EXPECT_CALL(*this, Response(1)); | 171 EXPECT_CALL(*this, Response(1)); |
| 173 run_loop_.Run(); | 172 run_loop_.Run(); |
| 174 } | 173 } |
| 175 | 174 |
| 176 } // namespace content | 175 } // namespace content |
| OLD | NEW |