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

Side by Side Diff: content/browser/media/webrtc_browsertest.cc

Issue 15505003: GTTF: Convert most tests in content to use EmbeddedTestServer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang Created 7 years, 7 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/common/content_switches.h" 8 #include "content/public/common/content_switches.h"
9 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
10 #include "content/shell/shell.h" 10 #include "content/shell/shell.h"
11 #include "content/test/content_browser_test.h" 11 #include "content/test/content_browser_test.h"
12 #include "content/test/content_browser_test_utils.h" 12 #include "content/test/content_browser_test_utils.h"
13 #include "net/test/spawned_test_server/spawned_test_server.h" 13 #include "net/test/embedded_test_server/embedded_test_server.h"
14 14
15 #if defined(OS_WIN) 15 #if defined(OS_WIN)
16 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
17 #endif 17 #endif
18 18
19 namespace content { 19 namespace content {
20 20
21 class WebrtcBrowserTest: public ContentBrowserTest { 21 class WebrtcBrowserTest: public ContentBrowserTest {
22 public: 22 public:
23 WebrtcBrowserTest() {} 23 WebrtcBrowserTest() {}
24 virtual ~WebrtcBrowserTest() {} 24 virtual ~WebrtcBrowserTest() {}
25 25
26 virtual void SetUpOnMainThread() OVERRIDE { 26 virtual void SetUpOnMainThread() OVERRIDE {
27 // We need fake devices in this test since we want to run on naked VMs. We 27 // We need fake devices in this test since we want to run on naked VMs. We
28 // assume this switch is set by default in content_browsertests. 28 // assume this switch is set by default in content_browsertests.
29 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( 29 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kUseFakeDeviceForMediaStream)); 30 switches::kUseFakeDeviceForMediaStream));
31 31
32 ASSERT_TRUE(test_server()->Start()); 32 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
33 } 33 }
34
34 protected: 35 protected:
35 bool ExecuteJavascript(const std::string& javascript) { 36 bool ExecuteJavascript(const std::string& javascript) {
36 return ExecuteScript(shell()->web_contents(), javascript); 37 return ExecuteScript(shell()->web_contents(), javascript);
37 } 38 }
38 39
39 void ExpectTitle(const std::string& expected_title) const { 40 void ExpectTitle(const std::string& expected_title) const {
40 string16 expected_title16(ASCIIToUTF16(expected_title)); 41 string16 expected_title16(ASCIIToUTF16(expected_title));
41 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); 42 TitleWatcher title_watcher(shell()->web_contents(), expected_title16);
42 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); 43 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
43 } 44 }
44 }; 45 };
45 46
46 // These tests will all make a getUserMedia call with different constraints and 47 // These tests will all make a getUserMedia call with different constraints and
47 // see that the success callback is called. If the error callback is called or 48 // see that the success callback is called. If the error callback is called or
48 // none of the callbacks are called the tests will simply time out and fail. 49 // none of the callbacks are called the tests will simply time out and fail.
49 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) { 50 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) {
50 GURL url(test_server()->GetURL("files/media/getusermedia.html")); 51 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
51 NavigateToURL(shell(), url); 52 NavigateToURL(shell(), url);
52 53
53 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true});")); 54 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true});"));
54 55
55 ExpectTitle("OK"); 56 ExpectTitle("OK");
56 } 57 }
57 58
58 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) { 59 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) {
59 GURL url(test_server()->GetURL("files/media/getusermedia.html")); 60 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
60 NavigateToURL(shell(), url); 61 NavigateToURL(shell(), url);
61 62
62 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true, audio: true});")); 63 EXPECT_TRUE(ExecuteJavascript("getUserMedia({video: true, audio: true});"));
63 64
64 ExpectTitle("OK"); 65 ExpectTitle("OK");
65 } 66 }
66 67
67 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndClone) { 68 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndClone) {
68 GURL url(test_server()->GetURL("files/media/getusermedia.html")); 69 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
69 NavigateToURL(shell(), url); 70 NavigateToURL(shell(), url);
70 71
71 EXPECT_TRUE(ExecuteJavascript("getUserMediaAndClone();")); 72 EXPECT_TRUE(ExecuteJavascript("getUserMediaAndClone();"));
72 73
73 ExpectTitle("OK"); 74 ExpectTitle("OK");
74 } 75 }
75 76
76 77
77 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 78 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
78 // Timing out on ARM linux bot: http://crbug.com/238490 79 // Timing out on ARM linux bot: http://crbug.com/238490
79 #define MAYBE_CanSetupVideoCall DISABLED_CanSetupVideoCall 80 #define MAYBE_CanSetupVideoCall DISABLED_CanSetupVideoCall
80 #else 81 #else
81 #define MAYBE_CanSetupVideoCall CanSetupVideoCall 82 #define MAYBE_CanSetupVideoCall CanSetupVideoCall
82 #endif 83 #endif
83 84
84 // These tests will make a complete PeerConnection-based call and verify that 85 // These tests will make a complete PeerConnection-based call and verify that
85 // video is playing for the call. 86 // video is playing for the call.
86 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupVideoCall) { 87 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupVideoCall) {
87 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 88 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
88 NavigateToURL(shell(), url); 89 NavigateToURL(shell(), url);
89 90
90 EXPECT_TRUE(ExecuteJavascript("call({video: true});")); 91 EXPECT_TRUE(ExecuteJavascript("call({video: true});"));
91 ExpectTitle("OK"); 92 ExpectTitle("OK");
92 } 93 }
93 94
94 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 95 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
95 // Timing out on ARM linux, see http://crbug.com/240376 96 // Timing out on ARM linux, see http://crbug.com/240376
96 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall 97 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall
97 #else 98 #else
98 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall 99 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall
99 #endif 100 #endif
100 101
101 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) { 102 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) {
102 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 103 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
103 NavigateToURL(shell(), url); 104 NavigateToURL(shell(), url);
104 105
105 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});")); 106 EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});"));
106 ExpectTitle("OK"); 107 ExpectTitle("OK");
107 } 108 }
108 109
109 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) { 110 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) {
110 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 111 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
111 NavigateToURL(shell(), url); 112 NavigateToURL(shell(), url);
112 113
113 EXPECT_TRUE( 114 EXPECT_TRUE(
114 ExecuteJavascript("callAndSendDtmf('123,abc');")); 115 ExecuteJavascript("callAndSendDtmf('123,abc');"));
115 } 116 }
116 117
117 // TODO(miu): Test is flaky. http://crbug.com/236102 118 // TODO(miu): Test is flaky. http://crbug.com/236102
118 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, 119 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
119 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) { 120 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) {
120 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 121 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
121 NavigateToURL(shell(), url); 122 NavigateToURL(shell(), url);
122 123
123 const char* kJavascript = 124 const char* kJavascript =
124 "makeEmptyCallThenAddOneStreamAndRenegotiate(" 125 "makeEmptyCallThenAddOneStreamAndRenegotiate("
125 "{video: true, audio: true});"; 126 "{video: true, audio: true});";
126 EXPECT_TRUE(ExecuteJavascript(kJavascript)); 127 EXPECT_TRUE(ExecuteJavascript(kJavascript));
127 ExpectTitle("OK"); 128 ExpectTitle("OK");
128 } 129 }
129 130
130 // This test will make a complete PeerConnection-based call but remove the 131 // This test will make a complete PeerConnection-based call but remove the
131 // MSID and bundle attribute from the initial offer to verify that 132 // MSID and bundle attribute from the initial offer to verify that
132 // video is playing for the call even if the initiating client don't support 133 // video is playing for the call even if the initiating client don't support
133 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02 134 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02
134 #if defined(OS_WIN) && defined(USE_AURA) 135 #if defined(OS_WIN) && defined(USE_AURA)
135 // Disabled for win7_aura, see http://crbug.com/235089. 136 // Disabled for win7_aura, see http://crbug.com/235089.
136 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ 137 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
137 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle 138 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
138 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 139 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
139 // Timing out on ARM linux, see http://crbug.com/240373 140 // Timing out on ARM linux, see http://crbug.com/240373
140 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ 141 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
141 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle 142 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
142 #else 143 #else
143 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ 144 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
144 CanSetupAudioAndVideoCallWithoutMsidAndBundle 145 CanSetupAudioAndVideoCallWithoutMsidAndBundle
145 #endif 146 #endif
146 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, 147 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
147 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) { 148 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) {
148 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 149 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
149 NavigateToURL(shell(), url); 150 NavigateToURL(shell(), url);
150 151
151 EXPECT_TRUE(ExecuteJavascript("callWithoutMsidAndBundle();")); 152 EXPECT_TRUE(ExecuteJavascript("callWithoutMsidAndBundle();"));
152 ExpectTitle("OK"); 153 ExpectTitle("OK");
153 } 154 }
154 155
155 // This test will make a PeerConnection-based call and test an unreliable text 156 // This test will make a PeerConnection-based call and test an unreliable text
156 // dataChannel. 157 // dataChannel.
157 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) { 158 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) {
158 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 159 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
159 NavigateToURL(shell(), url); 160 NavigateToURL(shell(), url);
160 161
161 EXPECT_TRUE(ExecuteJavascript("callWithDataOnly();")); 162 EXPECT_TRUE(ExecuteJavascript("callWithDataOnly();"));
162 ExpectTitle("OK"); 163 ExpectTitle("OK");
163 } 164 }
164 165
165 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 166 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
166 // Timing out on ARM linux bot: http://crbug.com/238490 167 // Timing out on ARM linux bot: http://crbug.com/238490
167 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia 168 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia
168 #else 169 #else
169 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia 170 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia
170 #endif 171 #endif
171 172
172 // This test will make a PeerConnection-based call and test an unreliable text 173 // This test will make a PeerConnection-based call and test an unreliable text
173 // dataChannel and audio and video tracks. 174 // dataChannel and audio and video tracks.
174 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) { 175 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) {
175 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 176 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
176 NavigateToURL(shell(), url); 177 NavigateToURL(shell(), url);
177 178
178 EXPECT_TRUE(ExecuteJavascript("callWithDataAndMedia();")); 179 EXPECT_TRUE(ExecuteJavascript("callWithDataAndMedia();"));
179 ExpectTitle("OK"); 180 ExpectTitle("OK");
180 } 181 }
181 182
182 // This test will make a PeerConnection-based call and test an unreliable text 183 // This test will make a PeerConnection-based call and test an unreliable text
183 // dataChannel and later add an audio and video track. 184 // dataChannel and later add an audio and video track.
184 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataAndLaterAddMedia) { 185 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataAndLaterAddMedia) {
185 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 186 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
186 NavigateToURL(shell(), url); 187 NavigateToURL(shell(), url);
187 188
188 EXPECT_TRUE(ExecuteJavascript("callWithDataAndLaterAddMedia();")); 189 EXPECT_TRUE(ExecuteJavascript("callWithDataAndLaterAddMedia();"));
189 ExpectTitle("OK"); 190 ExpectTitle("OK");
190 } 191 }
191 192
192 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 193 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
193 // Timing out on ARM linux bot: http://crbug.com/238490 194 // Timing out on ARM linux bot: http://crbug.com/238490
194 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream 195 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream
195 #else 196 #else
196 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream 197 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream
197 #endif 198 #endif
198 199
199 // This test will make a PeerConnection-based call and send a new Video 200 // This test will make a PeerConnection-based call and send a new Video
200 // MediaStream that has been created based on a MediaStream created with 201 // MediaStream that has been created based on a MediaStream created with
201 // getUserMedia. 202 // getUserMedia.
202 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) { 203 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) {
203 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 204 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
204 NavigateToURL(shell(), url); 205 NavigateToURL(shell(), url);
205 206
206 EXPECT_TRUE(ExecuteJavascript("callWithNewVideoMediaStream();")); 207 EXPECT_TRUE(ExecuteJavascript("callWithNewVideoMediaStream();"));
207 ExpectTitle("OK"); 208 ExpectTitle("OK");
208 } 209 }
209 210
210 // This test will make a PeerConnection-based call and send a new Video 211 // This test will make a PeerConnection-based call and send a new Video
211 // MediaStream that has been created based on a MediaStream created with 212 // MediaStream that has been created based on a MediaStream created with
212 // getUserMedia. When video is flowing, the VideoTrack is removed and an 213 // getUserMedia. When video is flowing, the VideoTrack is removed and an
213 // AudioTrack is added instead. 214 // AudioTrack is added instead.
214 // TODO(phoglund): This test is manual since not all buildbots has an audio 215 // TODO(phoglund): This test is manual since not all buildbots has an audio
215 // input. 216 // input.
216 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CallAndModifyStream) { 217 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CallAndModifyStream) {
217 GURL url(test_server()->GetURL("files/media/peerconnection-call.html")); 218 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
218 NavigateToURL(shell(), url); 219 NavigateToURL(shell(), url);
219 220
220 EXPECT_TRUE( 221 EXPECT_TRUE(
221 ExecuteJavascript("callWithNewVideoMediaStreamLaterSwitchToAudio();")); 222 ExecuteJavascript("callWithNewVideoMediaStreamLaterSwitchToAudio();"));
222 ExpectTitle("OK"); 223 ExpectTitle("OK");
223 } 224 }
224 225
225 } // namespace content 226 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_browsertest.cc ('k') | content/browser/media/webrtc_internals_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698