Chromium Code Reviews| 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(); | |
| 81 } | 80 } |
| 82 | 81 |
| 83 MOCK_METHOD1(Response, void(int index)); | 82 MOCK_METHOD1(Response, void(int index)); |
| 84 void ResponseCallback(int index, | 83 void ResponseCallback(int index, |
| 85 const MediaStreamDevices& devices, | 84 const MediaStreamDevices& devices, |
| 86 scoped_ptr<MediaStreamUIProxy> ui_proxy) { | 85 scoped_ptr<MediaStreamUIProxy> ui_proxy) { |
| 87 Response(index); | 86 Response(index); |
| 88 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); | 87 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); |
| 89 } | 88 } |
| 90 | 89 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 121 |
| 123 // Expecting the callback will be triggered and quit the test. | 122 // Expecting the callback will be triggered and quit the test. |
| 124 EXPECT_CALL(*this, Response(0)); | 123 EXPECT_CALL(*this, Response(0)); |
| 125 run_loop_.Run(); | 124 run_loop_.Run(); |
| 126 } | 125 } |
| 127 | 126 |
| 128 TEST_F(MediaStreamManagerTest, MakeAndCancelMediaAccessRequest) { | 127 TEST_F(MediaStreamManagerTest, MakeAndCancelMediaAccessRequest) { |
| 129 std::string label = MakeMediaAccessRequest(0); | 128 std::string label = MakeMediaAccessRequest(0); |
| 130 // No callback is expected. | 129 // No callback is expected. |
| 131 media_stream_manager_->CancelRequest(label); | 130 media_stream_manager_->CancelRequest(label); |
| 131 run_loop_.RunUntilIdle(); | |
| 132 media_stream_manager_->WillDestroyCurrentMessageLoop(); | |
|
tommi (sloooow) - chröme
2013/11/26 14:44:21
is this necessary?
| |
| 132 } | 133 } |
| 133 | 134 |
| 134 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) { | 135 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) { |
| 135 // First request. | 136 // First request. |
| 136 std::string label1 = MakeMediaAccessRequest(0); | 137 std::string label1 = MakeMediaAccessRequest(0); |
| 137 | 138 |
| 138 // Second request. | 139 // Second request. |
| 139 int render_process_id = 2; | 140 int render_process_id = 2; |
| 140 int render_view_id = 2; | 141 int render_view_id = 2; |
| 141 int page_request_id = 2; | 142 int page_request_id = 2; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 166 std::string label2 = MakeMediaAccessRequest(1); | 167 std::string label2 = MakeMediaAccessRequest(1); |
| 167 media_stream_manager_->CancelRequest(label1); | 168 media_stream_manager_->CancelRequest(label1); |
| 168 | 169 |
| 169 // Expecting the callback from the second request will be triggered and | 170 // Expecting the callback from the second request will be triggered and |
| 170 // quit the test. | 171 // quit the test. |
| 171 EXPECT_CALL(*this, Response(1)); | 172 EXPECT_CALL(*this, Response(1)); |
| 172 run_loop_.Run(); | 173 run_loop_.Run(); |
| 173 } | 174 } |
| 174 | 175 |
| 175 } // namespace content | 176 } // namespace content |
| OLD | NEW |