OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/test/scoped_feature_list.h" | 12 #include "base/test/scoped_feature_list.h" |
13 #include "base/test/trace_event_analyzer.h" | 13 #include "base/test/trace_event_analyzer.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "base/trace_event/trace_event_impl.h" | 15 #include "base/trace_event/trace_event_impl.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/browser/browser_main_loop.h" | 18 #include "content/browser/browser_main_loop.h" |
19 #include "content/browser/renderer_host/media/media_stream_manager.h" | 19 #include "content/browser/renderer_host/media/media_stream_manager.h" |
20 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
21 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" | 21 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" |
22 #include "content/browser/webrtc/webrtc_internals.h" | 22 #include "content/browser/webrtc/webrtc_internals.h" |
23 #include "content/public/common/content_features.h" | 23 #include "content/public/common/content_features.h" |
24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
25 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
26 #include "content/public/test/content_browser_test_utils.h" | 26 #include "content/public/test/content_browser_test_utils.h" |
27 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
28 #include "content/shell/browser/shell.h" | 28 #include "content/shell/browser/shell.h" |
29 #include "media/audio/audio_manager.h" | 29 #include "media/audio/audio_manager.h" |
| 30 #include "media/audio/fake_audio_input_stream.h" |
30 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
31 #include "testing/perf/perf_test.h" | 32 #include "testing/perf/perf_test.h" |
32 | 33 |
33 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
34 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
35 #endif | 36 #endif |
36 | 37 |
37 using trace_analyzer::TraceAnalyzer; | 38 using trace_analyzer::TraceAnalyzer; |
38 using trace_analyzer::Query; | 39 using trace_analyzer::Query; |
39 using trace_analyzer::TraceEventVector; | 40 using trace_analyzer::TraceEventVector; |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
43 static const char kGetUserMediaAndStop[] = "getUserMediaAndStop"; | 44 static const char kGetUserMediaAndStop[] = "getUserMediaAndStop"; |
44 static const char kGetUserMediaAndGetStreamUp[] = "getUserMediaAndGetStreamUp"; | 45 static const char kGetUserMediaAndGetStreamUp[] = "getUserMediaAndGetStreamUp"; |
45 static const char kGetUserMediaAndAnalyseAndStop[] = | 46 static const char kGetUserMediaAndAnalyseAndStop[] = |
46 "getUserMediaAndAnalyseAndStop"; | 47 "getUserMediaAndAnalyseAndStop"; |
47 static const char kGetUserMediaAndExpectFailure[] = | 48 static const char kGetUserMediaAndExpectFailure[] = |
48 "getUserMediaAndExpectFailure"; | 49 "getUserMediaAndExpectFailure"; |
| 50 static const char kGetUserMediaForAudioMutingTest[] = |
| 51 "getUserMediaForAudioMutingTest"; |
49 static const char kRenderSameTrackMediastreamAndStop[] = | 52 static const char kRenderSameTrackMediastreamAndStop[] = |
50 "renderSameTrackMediastreamAndStop"; | 53 "renderSameTrackMediastreamAndStop"; |
51 static const char kRenderClonedMediastreamAndStop[] = | 54 static const char kRenderClonedMediastreamAndStop[] = |
52 "renderClonedMediastreamAndStop"; | 55 "renderClonedMediastreamAndStop"; |
53 static const char kRenderClonedTrackMediastreamAndStop[] = | 56 static const char kRenderClonedTrackMediastreamAndStop[] = |
54 "renderClonedTrackMediastreamAndStop"; | 57 "renderClonedTrackMediastreamAndStop"; |
55 static const char kRenderDuplicatedMediastreamAndStop[] = | 58 static const char kRenderDuplicatedMediastreamAndStop[] = |
56 "renderDuplicatedMediastreamAndStop"; | 59 "renderDuplicatedMediastreamAndStop"; |
57 | 60 |
58 // Results returned by JS. | 61 // Results returned by JS. |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 manager->SetGenerateStreamCallbackForTesting( | 1447 manager->SetGenerateStreamCallbackForTesting( |
1445 base::Bind(&VerifyDisableLocalEcho, true)); | 1448 base::Bind(&VerifyDisableLocalEcho, true)); |
1446 call = GenerateGetUserMediaWithDisableLocalEcho( | 1449 call = GenerateGetUserMediaWithDisableLocalEcho( |
1447 "getUserMediaAndExpectSuccess", "true"); | 1450 "getUserMediaAndExpectSuccess", "true"); |
1448 ExecuteJavascriptAndWaitForOk(call); | 1451 ExecuteJavascriptAndWaitForOk(call); |
1449 | 1452 |
1450 manager->SetGenerateStreamCallbackForTesting( | 1453 manager->SetGenerateStreamCallbackForTesting( |
1451 MediaStreamManager::GenerateStreamTestCallback()); | 1454 MediaStreamManager::GenerateStreamTestCallback()); |
1452 } | 1455 } |
1453 | 1456 |
| 1457 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, |
| 1458 GetAudioStreamAndCheckMutingInitiallyUnmuted) { |
| 1459 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1460 |
| 1461 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 1462 NavigateToURL(shell(), url); |
| 1463 |
| 1464 // Expect stream to initially not be muted |
| 1465 media::FakeAudioInputStream::SetMutedState(false); |
| 1466 ExecuteJavascriptAndWaitForOk( |
| 1467 base::StringPrintf("%s(false);", kGetUserMediaForAudioMutingTest)); |
| 1468 |
| 1469 // Mute |
| 1470 media::FakeAudioInputStream::SetMutedState(true); |
| 1471 EXPECT_EQ("onmute: muted=true, readyState=live", |
| 1472 ExecuteJavascriptAndReturnResult( |
| 1473 "failTestAfterTimeout('Got no mute event', 1500);")); |
| 1474 // Unmute |
| 1475 media::FakeAudioInputStream::SetMutedState(false); |
| 1476 EXPECT_EQ("onunmute: muted=false, readyState=live", |
| 1477 ExecuteJavascriptAndReturnResult( |
| 1478 "failTestAfterTimeout('Got no unmute event', 1500);")); |
| 1479 } |
| 1480 |
| 1481 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, |
| 1482 GetAudioStreamAndCheckMutingInitiallyMuted) { |
| 1483 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1484 |
| 1485 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 1486 NavigateToURL(shell(), url); |
| 1487 |
| 1488 // Expect stream to initially be muted |
| 1489 media::FakeAudioInputStream::SetMutedState(true); |
| 1490 ExecuteJavascriptAndWaitForOk( |
| 1491 base::StringPrintf("%s(true);", kGetUserMediaForAudioMutingTest)); |
| 1492 |
| 1493 // Unmute |
| 1494 media::FakeAudioInputStream::SetMutedState(false); |
| 1495 EXPECT_EQ("onunmute: muted=false, readyState=live", |
| 1496 ExecuteJavascriptAndReturnResult( |
| 1497 "failTestAfterTimeout('Got no unmute event', 1500);")); |
| 1498 |
| 1499 // Mute |
| 1500 media::FakeAudioInputStream::SetMutedState(true); |
| 1501 EXPECT_EQ("onmute: muted=true, readyState=live", |
| 1502 ExecuteJavascriptAndReturnResult( |
| 1503 "failTestAfterTimeout('Got no mute event', 1500);")); |
| 1504 } |
| 1505 |
1454 } // namespace content | 1506 } // namespace content |
OLD | NEW |