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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager_unittest.cc

Issue 88283002: Reland review 34393006: Refactor MediaStreamManager to not output real device id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 message_loop_(base::MessageLoopProxy::current()) { 74 message_loop_(base::MessageLoopProxy::current()) {
75 // Create our own MediaStreamManager. 75 // Create our own MediaStreamManager.
76 audio_manager_.reset(new MockAudioManager()); 76 audio_manager_.reset(new MockAudioManager());
77 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 77 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
78 78
79 // Use fake devices in order to run on the bots. 79 // Use fake devices in order to run on the bots.
80 media_stream_manager_->UseFakeDevice(); 80 media_stream_manager_->UseFakeDevice();
81 } 81 }
82 82
83 virtual ~MediaStreamManagerTest() { 83 virtual ~MediaStreamManagerTest() {
84 media_stream_manager_->WillDestroyCurrentMessageLoop();
85 } 84 }
86 85
87 MOCK_METHOD1(Response, void(int index)); 86 MOCK_METHOD1(Response, void(int index));
88 void ResponseCallback(int index, 87 void ResponseCallback(int index,
89 const MediaStreamDevices& devices, 88 const MediaStreamDevices& devices,
90 scoped_ptr<MediaStreamUIProxy> ui_proxy) { 89 scoped_ptr<MediaStreamUIProxy> ui_proxy) {
91 Response(index); 90 Response(index);
92 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); 91 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure());
93 } 92 }
94 93
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 125
127 // Expecting the callback will be triggered and quit the test. 126 // Expecting the callback will be triggered and quit the test.
128 EXPECT_CALL(*this, Response(0)); 127 EXPECT_CALL(*this, Response(0));
129 run_loop_.Run(); 128 run_loop_.Run();
130 } 129 }
131 130
132 TEST_F(MediaStreamManagerTest, MakeAndCancelMediaAccessRequest) { 131 TEST_F(MediaStreamManagerTest, MakeAndCancelMediaAccessRequest) {
133 std::string label = MakeMediaAccessRequest(0); 132 std::string label = MakeMediaAccessRequest(0);
134 // No callback is expected. 133 // No callback is expected.
135 media_stream_manager_->CancelRequest(label); 134 media_stream_manager_->CancelRequest(label);
135 run_loop_.RunUntilIdle();
136 media_stream_manager_->WillDestroyCurrentMessageLoop();
136 } 137 }
137 138
138 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) { 139 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) {
139 // First request. 140 // First request.
140 std::string label1 = MakeMediaAccessRequest(0); 141 std::string label1 = MakeMediaAccessRequest(0);
141 142
142 // Second request. 143 // Second request.
143 int render_process_id = 2; 144 int render_process_id = 2;
144 int render_view_id = 2; 145 int render_view_id = 2;
145 int page_request_id = 2; 146 int page_request_id = 2;
(...skipping 24 matching lines...) Expand all
170 std::string label2 = MakeMediaAccessRequest(1); 171 std::string label2 = MakeMediaAccessRequest(1);
171 media_stream_manager_->CancelRequest(label1); 172 media_stream_manager_->CancelRequest(label1);
172 173
173 // Expecting the callback from the second request will be triggered and 174 // Expecting the callback from the second request will be triggered and
174 // quit the test. 175 // quit the test.
175 EXPECT_CALL(*this, Response(1)); 176 EXPECT_CALL(*this, Response(1));
176 run_loop_.Run(); 177 run_loop_.Run();
177 } 178 }
178 179
179 } // namespace content 180 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698