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.
5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_BASE_H_
6 #define CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_BASE_H_
10 #include "chrome/test/base/in_process_browser_test.h"
18 // Base class for WebRTC browser tests with useful primitives for interacting
19 // getUserMedia. We use inheritance here because it makes the test code look
20 // as clean as it can be.
21 class WebRtcTestBase
: public InProcessBrowserTest
{
23 // Typical constraints.
24 static const char kAudioVideoCallConstraints
[];
25 static const char kAudioOnlyCallConstraints
[];
26 static const char kVideoOnlyCallConstraints
[];
28 static const char kFailedWithPermissionDeniedError
[];
31 virtual ~WebRtcTestBase();
33 // These all require that the loaded page fulfills the public interface in
34 // chrome/test/data/webrtc/message_handling.js.
35 void GetUserMediaAndAccept(content::WebContents
* tab_contents
) const;
36 void GetUserMediaWithSpecificConstraintsAndAccept(
37 content::WebContents
* tab_contents
,
38 const std::string
& constraints
) const;
39 void GetUserMediaAndDeny(content::WebContents
* tab_contents
);
40 void GetUserMediaWithSpecificConstraintsAndDeny(
41 content::WebContents
* tab_contents
,
42 const std::string
& constraints
) const;
43 void GetUserMediaAndDismiss(content::WebContents
* tab_contents
) const;
44 void GetUserMedia(content::WebContents
* tab_contents
,
45 const std::string
& constraints
) const;
47 // Convenience method which opens the page at url, calls GetUserMediaAndAccept
48 // and returns the new tab.
49 content::WebContents
* OpenPageAndGetUserMediaInNewTab(const GURL
& url
) const;
51 // Opens the page at |url| where getUserMedia has been invoked through other
52 // means and accepts the user media request.
53 content::WebContents
* OpenPageAndAcceptUserMedia(const GURL
& url
) const;
55 void ConnectToPeerConnectionServer(const std::string
& peer_name
,
56 content::WebContents
* tab_contents
) const;
57 std::string
ExecuteJavascript(const std::string
& javascript
,
58 content::WebContents
* tab_contents
) const;
60 // Call this to enable monitoring of javascript errors for this test method.
61 // This will only work if the tests are run sequentially by the test runner
62 // (i.e. with --test-launcher-developer-mode or --test-launcher-jobs=1).
63 void DetectErrorsInJavaScript();
66 void CloseInfoBarInTab(content::WebContents
* tab_contents
,
67 InfoBar
* infobar
) const;
68 InfoBar
* GetUserMediaAndWaitForInfoBar(content::WebContents
* tab_contents
,
69 const std::string
& constraints
) const;
71 bool detect_errors_in_javascript_
;
73 DISALLOW_COPY_AND_ASSIGN(WebRtcTestBase
);
76 #endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_BASE_H_