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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 std::string InvokeGetActiveSink(int tab_id) { | 97 std::string InvokeGetActiveSink(int tab_id) { |
98 base::ListValue parameters; | 98 base::ListValue parameters; |
99 AppendTabIdToRequestInfo(¶meters, tab_id); | 99 AppendTabIdToRequestInfo(¶meters, tab_id); |
100 std::string parameter_string; | 100 std::string parameter_string; |
101 JSONWriter::Write(parameters, ¶meter_string); | 101 JSONWriter::Write(parameters, ¶meter_string); |
102 | 102 |
103 scoped_refptr<WebrtcAudioPrivateGetActiveSinkFunction> function = | 103 scoped_refptr<WebrtcAudioPrivateGetActiveSinkFunction> function = |
104 new WebrtcAudioPrivateGetActiveSinkFunction(); | 104 new WebrtcAudioPrivateGetActiveSinkFunction(); |
105 function->set_source_url(source_url_); | 105 function->set_source_url(source_url_); |
106 scoped_ptr<base::Value> result( | 106 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
107 RunFunctionAndReturnSingleResult(function.get(), | 107 function.get(), parameter_string, browser())); |
108 parameter_string, | |
109 browser())); | |
110 std::string device_id; | 108 std::string device_id; |
111 result->GetAsString(&device_id); | 109 result->GetAsString(&device_id); |
112 return device_id; | 110 return device_id; |
113 } | 111 } |
114 | 112 |
115 scoped_ptr<base::Value> InvokeGetSinks(base::ListValue** sink_list) { | 113 std::unique_ptr<base::Value> InvokeGetSinks(base::ListValue** sink_list) { |
116 scoped_refptr<WebrtcAudioPrivateGetSinksFunction> function = | 114 scoped_refptr<WebrtcAudioPrivateGetSinksFunction> function = |
117 new WebrtcAudioPrivateGetSinksFunction(); | 115 new WebrtcAudioPrivateGetSinksFunction(); |
118 function->set_source_url(source_url_); | 116 function->set_source_url(source_url_); |
119 | 117 |
120 scoped_ptr<base::Value> result( | 118 std::unique_ptr<base::Value> result( |
121 RunFunctionAndReturnSingleResult(function.get(), "[]", browser())); | 119 RunFunctionAndReturnSingleResult(function.get(), "[]", browser())); |
122 result->GetAsList(sink_list); | 120 result->GetAsList(sink_list); |
123 return result; | 121 return result; |
124 } | 122 } |
125 | 123 |
126 // Synchronously (from the calling thread's point of view) runs the | 124 // Synchronously (from the calling thread's point of view) runs the |
127 // given enumeration function on the device thread. On return, | 125 // given enumeration function on the device thread. On return, |
128 // |device_names| has been filled with the device names resulting | 126 // |device_names| has been filled with the device names resulting |
129 // from that call. | 127 // from that call. |
130 void GetAudioDeviceNames( | 128 void GetAudioDeviceNames( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 GURL source_url_; | 172 GURL source_url_; |
175 }; | 173 }; |
176 | 174 |
177 #if !defined(OS_MACOSX) | 175 #if !defined(OS_MACOSX) |
178 // http://crbug.com/334579 | 176 // http://crbug.com/334579 |
179 IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetSinks) { | 177 IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, GetSinks) { |
180 AudioDeviceNames devices; | 178 AudioDeviceNames devices; |
181 GetAudioDeviceNames(&AudioManager::GetAudioOutputDeviceNames, &devices); | 179 GetAudioDeviceNames(&AudioManager::GetAudioOutputDeviceNames, &devices); |
182 | 180 |
183 base::ListValue* sink_list = NULL; | 181 base::ListValue* sink_list = NULL; |
184 scoped_ptr<base::Value> result = InvokeGetSinks(&sink_list); | 182 std::unique_ptr<base::Value> result = InvokeGetSinks(&sink_list); |
185 | 183 |
186 std::string result_string; | 184 std::string result_string; |
187 JSONWriter::Write(*result, &result_string); | 185 JSONWriter::Write(*result, &result_string); |
188 VLOG(2) << result_string; | 186 VLOG(2) << result_string; |
189 | 187 |
190 EXPECT_EQ(devices.size(), sink_list->GetSize()); | 188 EXPECT_EQ(devices.size(), sink_list->GetSize()); |
191 | 189 |
192 // Iterate through both lists in lockstep and compare. The order | 190 // Iterate through both lists in lockstep and compare. The order |
193 // should be identical. | 191 // should be identical. |
194 size_t ix = 0; | 192 size_t ix = 0; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 229 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
232 int tab_id = ExtensionTabUtil::GetTabId(tab); | 230 int tab_id = ExtensionTabUtil::GetTabId(tab); |
233 base::ListValue parameters; | 231 base::ListValue parameters; |
234 AppendTabIdToRequestInfo(¶meters, tab_id); | 232 AppendTabIdToRequestInfo(¶meters, tab_id); |
235 std::string parameter_string; | 233 std::string parameter_string; |
236 JSONWriter::Write(parameters, ¶meter_string); | 234 JSONWriter::Write(parameters, ¶meter_string); |
237 | 235 |
238 scoped_refptr<WebrtcAudioPrivateGetActiveSinkFunction> function = | 236 scoped_refptr<WebrtcAudioPrivateGetActiveSinkFunction> function = |
239 new WebrtcAudioPrivateGetActiveSinkFunction(); | 237 new WebrtcAudioPrivateGetActiveSinkFunction(); |
240 function->set_source_url(source_url_); | 238 function->set_source_url(source_url_); |
241 scoped_ptr<base::Value> result( | 239 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
242 RunFunctionAndReturnSingleResult(function.get(), | 240 function.get(), parameter_string, browser())); |
243 parameter_string, | |
244 browser())); | |
245 | 241 |
246 std::string result_string; | 242 std::string result_string; |
247 JSONWriter::Write(*result, &result_string); | 243 JSONWriter::Write(*result, &result_string); |
248 EXPECT_EQ("\"\"", result_string); | 244 EXPECT_EQ("\"\"", result_string); |
249 } | 245 } |
250 | 246 |
251 // This exercises the case where you have a tab with no active media | 247 // This exercises the case where you have a tab with no active media |
252 // stream and try to set the audio sink. | 248 // stream and try to set the audio sink. |
253 IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, SetActiveSinkNoMediaStream) { | 249 IN_PROC_BROWSER_TEST_F(WebrtcAudioPrivateTest, SetActiveSinkNoMediaStream) { |
254 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 250 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 18 matching lines...) Expand all Loading... |
273 // Disabled on Win 7. https://crbug.com/500432. | 269 // Disabled on Win 7. https://crbug.com/500432. |
274 #if defined(OS_WIN) | 270 #if defined(OS_WIN) |
275 if (base::win::GetVersion() == base::win::VERSION_WIN7) | 271 if (base::win::GetVersion() == base::win::VERSION_WIN7) |
276 return; | 272 return; |
277 #endif | 273 #endif |
278 | 274 |
279 // First retrieve the list of all sinks, so that we can run a test | 275 // First retrieve the list of all sinks, so that we can run a test |
280 // where we set the active sink to each of the different available | 276 // where we set the active sink to each of the different available |
281 // sinks in turn. | 277 // sinks in turn. |
282 base::ListValue* sink_list = NULL; | 278 base::ListValue* sink_list = NULL; |
283 scoped_ptr<base::Value> result = InvokeGetSinks(&sink_list); | 279 std::unique_ptr<base::Value> result = InvokeGetSinks(&sink_list); |
284 | 280 |
285 ASSERT_TRUE(StartEmbeddedTestServer()); | 281 ASSERT_TRUE(StartEmbeddedTestServer()); |
286 | 282 |
287 // Open a normal page that uses an audio sink. | 283 // Open a normal page that uses an audio sink. |
288 ui_test_utils::NavigateToURL( | 284 ui_test_utils::NavigateToURL( |
289 browser(), | 285 browser(), |
290 GURL(embedded_test_server()->GetURL("/extensions/loop_audio.html"))); | 286 GURL(embedded_test_server()->GetURL("/extensions/loop_audio.html"))); |
291 | 287 |
292 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 288 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
293 int tab_id = ExtensionTabUtil::GetTabId(tab); | 289 int tab_id = ExtensionTabUtil::GetTabId(tab); |
(...skipping 13 matching lines...) Expand all Loading... |
307 | 303 |
308 base::ListValue parameters; | 304 base::ListValue parameters; |
309 AppendTabIdToRequestInfo(¶meters, tab_id); | 305 AppendTabIdToRequestInfo(¶meters, tab_id); |
310 parameters.AppendString(target_device); | 306 parameters.AppendString(target_device); |
311 std::string parameter_string; | 307 std::string parameter_string; |
312 JSONWriter::Write(parameters, ¶meter_string); | 308 JSONWriter::Write(parameters, ¶meter_string); |
313 | 309 |
314 scoped_refptr<WebrtcAudioPrivateSetActiveSinkFunction> function = | 310 scoped_refptr<WebrtcAudioPrivateSetActiveSinkFunction> function = |
315 new WebrtcAudioPrivateSetActiveSinkFunction(); | 311 new WebrtcAudioPrivateSetActiveSinkFunction(); |
316 function->set_source_url(source_url_); | 312 function->set_source_url(source_url_); |
317 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult( | 313 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
318 function.get(), parameter_string, browser())); | 314 function.get(), parameter_string, browser())); |
319 // The function was successful if the above invocation doesn't | 315 // The function was successful if the above invocation doesn't |
320 // fail. Just for kicks, also check that it returns no result. | 316 // fail. Just for kicks, also check that it returns no result. |
321 EXPECT_EQ(NULL, result.get()); | 317 EXPECT_EQ(NULL, result.get()); |
322 | 318 |
323 current_device = InvokeGetActiveSink(tab_id); | 319 current_device = InvokeGetActiveSink(tab_id); |
324 VLOG(2) << "After setting to " << target_device | 320 VLOG(2) << "After setting to " << target_device |
325 << ", current device is " << current_device; | 321 << ", current device is " << current_device; |
326 EXPECT_EQ(target_device, current_device); | 322 EXPECT_EQ(target_device, current_device); |
327 } | 323 } |
(...skipping 22 matching lines...) Expand all Loading... |
350 origin, | 346 origin, |
351 raw_device_id, | 347 raw_device_id, |
352 &source_id_in_origin); | 348 &source_id_in_origin); |
353 | 349 |
354 base::ListValue parameters; | 350 base::ListValue parameters; |
355 parameters.AppendString(origin.spec()); | 351 parameters.AppendString(origin.spec()); |
356 parameters.AppendString(source_id_in_origin); | 352 parameters.AppendString(source_id_in_origin); |
357 std::string parameter_string; | 353 std::string parameter_string; |
358 JSONWriter::Write(parameters, ¶meter_string); | 354 JSONWriter::Write(parameters, ¶meter_string); |
359 | 355 |
360 scoped_ptr<base::Value> result( | 356 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
361 RunFunctionAndReturnSingleResult(function.get(), | 357 function.get(), parameter_string, browser())); |
362 parameter_string, | |
363 browser())); | |
364 std::string result_string; | 358 std::string result_string; |
365 JSONWriter::Write(*result, &result_string); | 359 JSONWriter::Write(*result, &result_string); |
366 VLOG(2) << "Results: " << result_string; | 360 VLOG(2) << "Results: " << result_string; |
367 } | 361 } |
368 } | 362 } |
369 | 363 |
370 // Times out frequently on Windows, CrOS: http://crbug.com/517112 | 364 // Times out frequently on Windows, CrOS: http://crbug.com/517112 |
371 #if defined(OS_WIN) || defined(OS_CHROMEOS) | 365 #if defined(OS_WIN) || defined(OS_CHROMEOS) |
372 #define MAYBE_TriggerEvent DISABLED_TriggerEvent | 366 #define MAYBE_TriggerEvent DISABLED_TriggerEvent |
373 #else | 367 #else |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("failure")); | 428 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("failure")); |
435 base::string16 result = title_watcher.WaitAndGetTitle(); | 429 base::string16 result = title_watcher.WaitAndGetTitle(); |
436 EXPECT_EQ(base::ASCIIToUTF16("success"), result); | 430 EXPECT_EQ(base::ASCIIToUTF16("success"), result); |
437 | 431 |
438 g_browser_process->webrtc_log_uploader()->OverrideUploadWithBufferForTesting( | 432 g_browser_process->webrtc_log_uploader()->OverrideUploadWithBufferForTesting( |
439 NULL); | 433 NULL); |
440 } | 434 } |
441 #endif // defined(GOOGLE_CHROME_BUILD) || defined(ENABLE_HANGOUT_SERVICES_EXTEN
SION) | 435 #endif // defined(GOOGLE_CHROME_BUILD) || defined(ENABLE_HANGOUT_SERVICES_EXTEN
SION) |
442 | 436 |
443 } // namespace extensions | 437 } // namespace extensions |
OLD | NEW |