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

Side by Side Diff: chrome/browser/media/webrtc_browsertest_base.h

Issue 2307083002: Cleanup: move WebRTC related files from chrome/browser/media to chrome/browser/media/webrtc/ (Closed)
Patch Set: Removed file wrongly resuscitated during rebase Created 4 years, 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_BASE_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_BASE_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12
13 namespace infobars {
14 class InfoBar;
15 }
16
17 namespace content {
18 class WebContents;
19 }
20
21 // Base class for WebRTC browser tests with useful primitives for interacting
22 // getUserMedia. We use inheritance here because it makes the test code look
23 // as clean as it can be.
24 class WebRtcTestBase : public InProcessBrowserTest {
25 public:
26 // Typical constraints.
27 static const char kAudioVideoCallConstraints[];
28 static const char kAudioOnlyCallConstraints[];
29 static const char kVideoOnlyCallConstraints[];
30 static const char kVideoCallConstraintsQVGA[];
31 static const char kVideoCallConstraints360p[];
32 static const char kVideoCallConstraintsVGA[];
33 static const char kVideoCallConstraints720p[];
34 static const char kVideoCallConstraints1080p[];
35 static const char kAudioVideoCallConstraints360p[];
36 static const char kAudioVideoCallConstraints720p[];
37
38 static const char kOkGotStream[];
39 static const char kFailedWithPermissionDeniedError[];
40 static const char kFailedWithPermissionDismissedError[];
41
42 static const char kUseDefaultCertKeygen[];
43 static const char kUseDefaultVideoCodec[];
44
45 protected:
46 WebRtcTestBase();
47 ~WebRtcTestBase() override;
48
49 // These all require that the loaded page fulfills the public interface in
50 // chrome/test/data/webrtc/getusermedia.js.
51 // If an error is reported back from the getUserMedia call, these functions
52 // will return false.
53 // The ...AndAccept()/...AndDeny()/...AndDismiss() functions expect that a
54 // prompt will be shown (i.e. the current origin in the tab_contents doesn't
55 // have a saved permission).
56 bool GetUserMediaAndAccept(content::WebContents* tab_contents) const;
57 bool GetUserMediaWithSpecificConstraintsAndAccept(
58 content::WebContents* tab_contents,
59 const std::string& constraints) const;
60 bool GetUserMediaWithSpecificConstraintsAndAcceptIfPrompted(
61 content::WebContents* tab_contents,
62 const std::string& constraints) const;
63 void GetUserMediaAndDeny(content::WebContents* tab_contents);
64 void GetUserMediaWithSpecificConstraintsAndDeny(
65 content::WebContents* tab_contents,
66 const std::string& constraints) const;
67 void GetUserMediaAndDismiss(content::WebContents* tab_contents) const;
68 void GetUserMediaAndExpectAutoAcceptWithoutPrompt(
69 content::WebContents* tab_contents) const;
70 void GetUserMediaAndExpectAutoDenyWithoutPrompt(
71 content::WebContents* tab_contents) const;
72 void GetUserMedia(content::WebContents* tab_contents,
73 const std::string& constraints) const;
74
75 // Convenience method which opens the page at url, calls GetUserMediaAndAccept
76 // and returns the new tab.
77 content::WebContents* OpenPageAndGetUserMediaInNewTab(const GURL& url) const;
78
79 // Convenience method which opens the page at url, calls
80 // GetUserMediaAndAcceptWithSpecificConstraints and returns the new tab.
81 content::WebContents* OpenPageAndGetUserMediaInNewTabWithConstraints(
82 const GURL& url, const std::string& constraints) const;
83
84 // Convenience method which gets the URL for |test_page| and calls
85 // OpenPageAndGetUserMediaInNewTab().
86 content::WebContents* OpenTestPageAndGetUserMediaInNewTab(
87 const std::string& test_page) const;
88
89 // Opens the page at |url| where getUserMedia has been invoked through other
90 // means and accepts the user media request.
91 content::WebContents* OpenPageAndAcceptUserMedia(const GURL& url) const;
92
93 // Closes the last local stream acquired by the GetUserMedia* methods.
94 void CloseLastLocalStream(content::WebContents* tab_contents) const;
95
96 std::string ExecuteJavascript(const std::string& javascript,
97 content::WebContents* tab_contents) const;
98
99 // Sets up a peer connection in the tab and adds the current local stream
100 // (which you can prepare by calling one of the GetUserMedia* methods above).
101 // Optionally, |certificate_keygen_algorithm| is JavaScript for an
102 // |AlgorithmIdentifier| to be used as parameter to
103 // |RTCPeerConnection.generateCertificate|. The resulting certificate will be
104 // used by the peer connection. Or use |kUseDefaultCertKeygen| to use a
105 // certificate.
106 void SetupPeerconnectionWithLocalStream(
107 content::WebContents* tab,
108 const std::string& certificate_keygen_algorithm =
109 kUseDefaultCertKeygen) const;
110 // Same as above but does not add the local stream.
111 void SetupPeerconnectionWithoutLocalStream(
112 content::WebContents* tab,
113 const std::string& certificate_keygen_algorithm =
114 kUseDefaultCertKeygen) const;
115 // Same as |SetupPeerconnectionWithLocalStream| except a certificate is
116 // specified, which is a reference to an |RTCCertificate| object.
117 void SetupPeerconnectionWithCertificateAndLocalStream(
118 content::WebContents* tab,
119 const std::string& certificate) const;
120 // Same as above but does not add the local stream.
121 void SetupPeerconnectionWithCertificateWithoutLocalStream(
122 content::WebContents* tab,
123 const std::string& certificate) const;
124
125 // Exchanges offers and answers between the peer connections in the
126 // respective tabs. Before calling this, you must have prepared peer
127 // connections in both tabs and configured them as you like (for instance by
128 // calling SetupPeerconnectionWithLocalStream).
129 // If |video_codec| is not |kUseDefaultVideoCodec|, the SDP offer is modified
130 // (and SDP answer verified) so that the specified video codec (case-sensitive
131 // name) is used during the call instead of the default one.
132 void NegotiateCall(content::WebContents* from_tab,
133 content::WebContents* to_tab) const;
134
135 // Hangs up a negotiated call.
136 void HangUp(content::WebContents* from_tab) const;
137
138 // Call this to enable monitoring of javascript errors for this test method.
139 // This will only work if the tests are run sequentially by the test runner
140 // (i.e. with --test-launcher-developer-mode or --test-launcher-jobs=1).
141 void DetectErrorsInJavaScript();
142
143 // Methods for detecting if video is playing (the loaded page must have
144 // chrome/test/data/webrtc/video_detector.js and its dependencies loaded to
145 // make that work). Looks at a 320x240 area of the target video tag.
146 void StartDetectingVideo(content::WebContents* tab_contents,
147 const std::string& video_element) const;
148 bool WaitForVideoToPlay(content::WebContents* tab_contents) const;
149
150 // Returns the stream size as a string on the format <width>x<height>.
151 std::string GetStreamSize(content::WebContents* tab_contents,
152 const std::string& video_element) const;
153
154 // Methods to check what devices we have on the system.
155 bool HasWebcamAvailableOnSystem(content::WebContents* tab_contents) const;
156
157 // Returns true if we're on win 8.
158 bool OnWin8() const;
159
160 void OpenDatabase(content::WebContents* tab) const;
161 void CloseDatabase(content::WebContents* tab) const;
162 void DeleteDatabase(content::WebContents* tab) const;
163
164 void GenerateAndCloneCertificate(content::WebContents* tab,
165 const std::string& keygen_algorithm) const;
166
167 void VerifyStatsGenerated(content::WebContents* tab) const;
168
169 // Change the default video codec in the offer SDP.
170 void SetDefaultVideoCodec(content::WebContents* tab,
171 const std::string& video_codec) const;
172
173 // Add 'usedtx=1' to the offer SDP.
174 void EnableOpusDtx(content::WebContents* tab) const;
175
176 private:
177 void CloseInfoBarInTab(content::WebContents* tab_contents,
178 infobars::InfoBar* infobar) const;
179
180 std::string CreateLocalOffer(content::WebContents* from_tab) const;
181 std::string CreateAnswer(std::string local_offer,
182 content::WebContents* to_tab) const;
183 void ReceiveAnswer(const std::string& answer,
184 content::WebContents* from_tab) const;
185 void GatherAndSendIceCandidates(content::WebContents* from_tab,
186 content::WebContents* to_tab) const;
187
188 infobars::InfoBar* GetUserMediaAndWaitForInfoBar(
189 content::WebContents* tab_contents,
190 const std::string& constraints) const;
191
192 bool detect_errors_in_javascript_;
193
194 DISALLOW_COPY_AND_ASSIGN(WebRtcTestBase);
195 };
196
197 #endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_audio.cc ('k') | chrome/browser/media/webrtc_browsertest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698