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

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

Issue 364123002: [Cross-Site Isolation] Migrate entire MediaStream verticals to be per-RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: It's random enough. + REBASE Created 6 years, 5 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 | 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void ResponseCallback(int index, 92 void ResponseCallback(int index,
93 const MediaStreamDevices& devices, 93 const MediaStreamDevices& devices,
94 scoped_ptr<MediaStreamUIProxy> ui_proxy) { 94 scoped_ptr<MediaStreamUIProxy> ui_proxy) {
95 Response(index); 95 Response(index);
96 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); 96 message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure());
97 } 97 }
98 98
99 protected: 99 protected:
100 std::string MakeMediaAccessRequest(int index) { 100 std::string MakeMediaAccessRequest(int index) {
101 const int render_process_id = 1; 101 const int render_process_id = 1;
102 const int render_view_id = 1; 102 const int render_frame_id = 1;
103 const int page_request_id = 1; 103 const int page_request_id = 1;
104 const GURL security_origin; 104 const GURL security_origin;
105 MediaStreamManager::MediaRequestResponseCallback callback = 105 MediaStreamManager::MediaRequestResponseCallback callback =
106 base::Bind(&MediaStreamManagerTest::ResponseCallback, 106 base::Bind(&MediaStreamManagerTest::ResponseCallback,
107 base::Unretained(this), index); 107 base::Unretained(this), index);
108 StreamOptions options(true, true); 108 StreamOptions options(true, true);
109 return media_stream_manager_->MakeMediaAccessRequest(render_process_id, 109 return media_stream_manager_->MakeMediaAccessRequest(render_process_id,
110 render_view_id, 110 render_frame_id,
111 page_request_id, 111 page_request_id,
112 options, 112 options,
113 security_origin, 113 security_origin,
114 callback); 114 callback);
115 } 115 }
116 116
117 scoped_ptr<media::AudioManager> audio_manager_; 117 scoped_ptr<media::AudioManager> audio_manager_;
118 scoped_ptr<MediaStreamManager> media_stream_manager_; 118 scoped_ptr<MediaStreamManager> media_stream_manager_;
119 content::TestBrowserThreadBundle thread_bundle_; 119 content::TestBrowserThreadBundle thread_bundle_;
120 scoped_refptr<base::MessageLoopProxy> message_loop_; 120 scoped_refptr<base::MessageLoopProxy> message_loop_;
(...skipping 18 matching lines...) Expand all
139 run_loop_.RunUntilIdle(); 139 run_loop_.RunUntilIdle();
140 media_stream_manager_->WillDestroyCurrentMessageLoop(); 140 media_stream_manager_->WillDestroyCurrentMessageLoop();
141 } 141 }
142 142
143 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) { 143 TEST_F(MediaStreamManagerTest, MakeMultipleRequests) {
144 // First request. 144 // First request.
145 std::string label1 = MakeMediaAccessRequest(0); 145 std::string label1 = MakeMediaAccessRequest(0);
146 146
147 // Second request. 147 // Second request.
148 int render_process_id = 2; 148 int render_process_id = 2;
149 int render_view_id = 2; 149 int render_frame_id = 2;
150 int page_request_id = 2; 150 int page_request_id = 2;
151 GURL security_origin; 151 GURL security_origin;
152 StreamOptions options(true, true); 152 StreamOptions options(true, true);
153 MediaStreamManager::MediaRequestResponseCallback callback = 153 MediaStreamManager::MediaRequestResponseCallback callback =
154 base::Bind(&MediaStreamManagerTest::ResponseCallback, 154 base::Bind(&MediaStreamManagerTest::ResponseCallback,
155 base::Unretained(this), 1); 155 base::Unretained(this), 1);
156 std::string label2 = media_stream_manager_->MakeMediaAccessRequest( 156 std::string label2 = media_stream_manager_->MakeMediaAccessRequest(
157 render_process_id, 157 render_process_id,
158 render_view_id, 158 render_frame_id,
159 page_request_id, 159 page_request_id,
160 options, 160 options,
161 security_origin, 161 security_origin,
162 callback); 162 callback);
163 163
164 // Expecting the callbackS from requests will be triggered and quit the test. 164 // Expecting the callbackS from requests will be triggered and quit the test.
165 // Note, the callbacks might come in a different order depending on the 165 // Note, the callbacks might come in a different order depending on the
166 // value of labels. 166 // value of labels.
167 EXPECT_CALL(*this, Response(0)); 167 EXPECT_CALL(*this, Response(0));
168 EXPECT_CALL(*this, Response(1)); 168 EXPECT_CALL(*this, Response(1));
169 run_loop_.Run(); 169 run_loop_.Run();
170 } 170 }
171 171
172 TEST_F(MediaStreamManagerTest, MakeAndCancelMultipleRequests) { 172 TEST_F(MediaStreamManagerTest, MakeAndCancelMultipleRequests) {
173 std::string label1 = MakeMediaAccessRequest(0); 173 std::string label1 = MakeMediaAccessRequest(0);
174 std::string label2 = MakeMediaAccessRequest(1); 174 std::string label2 = MakeMediaAccessRequest(1);
175 media_stream_manager_->CancelRequest(label1); 175 media_stream_manager_->CancelRequest(label1);
176 176
177 // Expecting the callback from the second request will be triggered and 177 // Expecting the callback from the second request will be triggered and
178 // quit the test. 178 // quit the test.
179 EXPECT_CALL(*this, Response(1)); 179 EXPECT_CALL(*this, Response(1));
180 run_loop_.Run(); 180 run_loop_.Run();
181 } 181 }
182 182
183 } // namespace content 183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698