Commit f3b3efab authored by felt's avatar felt Committed by Commit bot

Convert the WebRtcTestBase to use infobar and bubble autoresponders

To prevent MediaStreamPermissionTest* flakiness:
(1) Instead of relying on the old infobar notification system, switch to
    the new infobar responder. (As per crbug.com/354380, observers are now
    preferred to notifications.)
(2) Instead of relying on mock permission bubbles, switch to the new
    PermissionBubbleManager responder.
(3) Remove the polling and timeouts.

To satisfy the requirements of the media test cases, I also updated the
InfoBarResponder. It now can handle infobar replacement and dismissing an
infobar without making a choice.

BUG=295723
R=tommi@chromium.org

Committed: https://crrev.com/ccc25707b9788597c55fb4eaa90109500e1f92cb
Cr-Commit-Position: refs/heads/master@{#333360}

Review URL: https://codereview.chromium.org/1161153003

Cr-Commit-Position: refs/heads/master@{#333685}
parent 04eb0d22
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
InfoBarResponder::InfoBarResponder(InfoBarService* infobar_service, InfoBarResponder::InfoBarResponder(InfoBarService* infobar_service,
bool should_accept) AutoResponseType response)
: infobar_service_(infobar_service), should_accept_(should_accept) { : infobar_service_(infobar_service), response_(response) {
infobar_service_->AddObserver(this); infobar_service_->AddObserver(this);
} }
...@@ -33,9 +33,21 @@ void InfoBarResponder::OnInfoBarAdded(infobars::InfoBar* infobar) { ...@@ -33,9 +33,21 @@ void InfoBarResponder::OnInfoBarAdded(infobars::InfoBar* infobar) {
base::Bind(&InfoBarResponder::Respond, base::Unretained(this), delegate)); base::Bind(&InfoBarResponder::Respond, base::Unretained(this), delegate));
} }
void InfoBarResponder::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
infobars::InfoBar* new_infobar) {
OnInfoBarAdded(new_infobar);
}
void InfoBarResponder::Respond(ConfirmInfoBarDelegate* delegate) { void InfoBarResponder::Respond(ConfirmInfoBarDelegate* delegate) {
if (should_accept_) switch (response_) {
delegate->Accept(); case ACCEPT:
else delegate->Accept();
delegate->Cancel(); break;
case DENY:
delegate->Cancel();
break;
case DISMISS:
delegate->InfoBarDismissed();
break;
}
} }
...@@ -22,19 +22,26 @@ class InfoBarService; ...@@ -22,19 +22,26 @@ class InfoBarService;
// The asynchronous response matches how real users will use the infobar. // The asynchronous response matches how real users will use the infobar.
class InfoBarResponder : public infobars::InfoBarManager::Observer { class InfoBarResponder : public infobars::InfoBarManager::Observer {
public: public:
// If |should_accept| is true, the responder will asynchronously Accept() the enum AutoResponseType {
// infobar; otherwise it will Cancel() it. ACCEPT,
InfoBarResponder(InfoBarService* infobar_service, bool should_accept); DENY,
DISMISS
};
// The responder will asynchronously perform the requested |response|.
InfoBarResponder(InfoBarService* infobar_service, AutoResponseType response);
~InfoBarResponder() override; ~InfoBarResponder() override;
// infobars::InfoBarManager::Observer: // infobars::InfoBarManager::Observer:
void OnInfoBarAdded(infobars::InfoBar* infobar) override; void OnInfoBarAdded(infobars::InfoBar* infobar) override;
void OnInfoBarReplaced(infobars::InfoBar* old_infobar,
infobars::InfoBar* new_infobar) override;
private: private:
void Respond(ConfirmInfoBarDelegate* delegate); void Respond(ConfirmInfoBarDelegate* delegate);
InfoBarService* infobar_service_; InfoBarService* infobar_service_;
bool should_accept_; AutoResponseType response_;
DISALLOW_COPY_AND_ASSIGN(InfoBarResponder); DISALLOW_COPY_AND_ASSIGN(InfoBarResponder);
}; };
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/media/media_stream_devices_controller.h" #include "chrome/browser/media/media_stream_devices_controller.h"
#include "chrome/browser/media/webrtc_browsertest_base.h" #include "chrome/browser/media/webrtc_browsertest_base.h"
#include "chrome/browser/media/webrtc_browsertest_common.h" #include "chrome/browser/media/webrtc_browsertest_common.h"
...@@ -21,7 +20,6 @@ ...@@ -21,7 +20,6 @@
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_types.h"
#include "components/infobars/core/infobar.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
...@@ -114,32 +112,29 @@ class MediaStreamPermissionTest : public WebRtcTestBase, ...@@ -114,32 +112,29 @@ class MediaStreamPermissionTest : public WebRtcTestBase,
// Actual tests --------------------------------------------------------------- // Actual tests ---------------------------------------------------------------
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestAllowingUserMedia) {
DISABLED_TestAllowingUserMedia) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDenyingUserMedia) {
DISABLED_TestDenyingUserMedia) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndDeny(tab_contents); GetUserMediaAndDeny(tab_contents);
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDismissingRequest) {
DISABLED_TestDismissingInfobar) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndDismiss(tab_contents); GetUserMediaAndDismiss(tab_contents);
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
DISABLED_TestDenyingUserMediaIncognito) { TestDenyingUserMediaIncognito) {
content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); content::WebContents* tab_contents = LoadTestPageInIncognitoTab();
GetUserMediaAndDeny(tab_contents); GetUserMediaAndDeny(tab_contents);
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
DISABLED_TestAcceptThenDenyWhichShouldBeSticky) { TestAcceptThenDenyWhichShouldBeSticky) {
#if defined(OS_WIN) && defined(USE_ASH) #if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796). // Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
...@@ -152,38 +147,33 @@ IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, ...@@ -152,38 +147,33 @@ IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
GetUserMediaAndDeny(tab_contents); GetUserMediaAndDeny(tab_contents);
// Should fail with permission denied right away with no infobar popping up. // Should fail with permission denied, instead of hanging.
GetUserMedia(tab_contents, kAudioVideoCallConstraints); GetUserMedia(tab_contents, kAudioVideoCallConstraints);
EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
kFailedWithPermissionDeniedError, kFailedWithPermissionDeniedError,
tab_contents)); tab_contents));
InfoBarService* infobar_service =
InfoBarService::FromWebContents(tab_contents);
EXPECT_EQ(0u, infobar_service->infobar_count());
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestAcceptIsNotSticky) {
DISABLED_TestAcceptIsNotSticky) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
// If accept were sticky the second call would hang because it hangs if an // If accept were sticky the second call would hang because it hangs if an
// infobar does not pop up. // infobar or bubble does not pop up.
EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDismissIsNotSticky) {
DISABLED_TestDismissIsNotSticky) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
// If dismiss were sticky the second call would hang because it hangs if an // If dismiss were sticky the second call would hang because it hangs if an
// infobar does not pop up. // infobar or bubble does not pop up.
GetUserMediaAndDismiss(tab_contents); GetUserMediaAndDismiss(tab_contents);
GetUserMediaAndDismiss(tab_contents); GetUserMediaAndDismiss(tab_contents);
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
DISABLED_TestDenyingThenClearingStickyException) { TestDenyingThenClearingStickyException) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndDeny(tab_contents); GetUserMediaAndDeny(tab_contents);
...@@ -195,7 +185,7 @@ IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, ...@@ -195,7 +185,7 @@ IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
settings_map->ClearSettingsForOneType( settings_map->ClearSettingsForOneType(
CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
// If an infobar is not launched now, this will hang. // If an infobar or bubble is not launched now, this will hang.
GetUserMediaAndDeny(tab_contents); GetUserMediaAndDeny(tab_contents);
} }
...@@ -219,7 +209,7 @@ IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, ...@@ -219,7 +209,7 @@ IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
} }
IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
DISABLED_DenyingCameraDoesNotCauseStickyDenyForMics) { DenyingCameraDoesNotCauseStickyDenyForMics) {
content::WebContents* tab_contents = LoadTestPageInTab(); content::WebContents* tab_contents = LoadTestPageInTab();
// If camera blocking also blocked mics, the second call here would hang. // If camera blocking also blocked mics, the second call here would hang.
......
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/infobars/infobar_responder.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/media/webrtc_browsertest_base.h" #include "chrome/browser/media/webrtc_browsertest_base.h"
#include "chrome/browser/media/webrtc_browsertest_common.h" #include "chrome/browser/media/webrtc_browsertest_common.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
...@@ -246,11 +249,25 @@ IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) { ...@@ -246,11 +249,25 @@ IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, MANUAL_WorksOnApprtc) {
GURL room_url = GURL("http://localhost:9999/r/some_room" GURL room_url = GURL("http://localhost:9999/r/some_room"
"?wshpp=localhost:8089&wstls=false"); "?wshpp=localhost:8089&wstls=false");
// Set up the left tab.
chrome::AddTabAt(browser(), GURL(), -1, true); chrome::AddTabAt(browser(), GURL(), -1, true);
content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url); content::WebContents* left_tab =
browser()->tab_strip_model()->GetActiveWebContents();
PermissionBubbleManager::FromWebContents(left_tab)
->set_auto_response_for_test(PermissionBubbleManager::ACCEPT_ALL);
InfoBarResponder left_infobar_responder(
InfoBarService::FromWebContents(left_tab), InfoBarResponder::ACCEPT);
ui_test_utils::NavigateToURL(browser(), room_url);
// Set up the right tab.
chrome::AddTabAt(browser(), GURL(), -1, true); chrome::AddTabAt(browser(), GURL(), -1, true);
content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url); content::WebContents* right_tab =
browser()->tab_strip_model()->GetActiveWebContents();
PermissionBubbleManager::FromWebContents(right_tab)
->set_auto_response_for_test(PermissionBubbleManager::ACCEPT_ALL);
InfoBarResponder right_infobar_responder(
InfoBarService::FromWebContents(right_tab), InfoBarResponder::ACCEPT);
ui_test_utils::NavigateToURL(browser(), room_url);
ASSERT_TRUE(WaitForCallToComeUp(left_tab)); ASSERT_TRUE(WaitForCallToComeUp(left_tab));
ASSERT_TRUE(WaitForCallToComeUp(right_tab)); ASSERT_TRUE(WaitForCallToComeUp(right_tab));
...@@ -284,7 +301,14 @@ IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest, ...@@ -284,7 +301,14 @@ IN_PROC_BROWSER_TEST_F(WebRtcApprtcBrowserTest,
GURL room_url = GURL("http://localhost:9999/r/some_room" GURL room_url = GURL("http://localhost:9999/r/some_room"
"?wshpp=localhost:8089&wstls=false" "?wshpp=localhost:8089&wstls=false"
"&firefox_fake_device=1"); "&firefox_fake_device=1");
content::WebContents* chrome_tab = OpenPageAndAcceptUserMedia(room_url); chrome::AddTabAt(browser(), GURL(), -1, true);
content::WebContents* chrome_tab =
browser()->tab_strip_model()->GetActiveWebContents();
PermissionBubbleManager::FromWebContents(chrome_tab)
->set_auto_response_for_test(PermissionBubbleManager::ACCEPT_ALL);
InfoBarResponder infobar_responder(
InfoBarService::FromWebContents(chrome_tab), InfoBarResponder::ACCEPT);
ui_test_utils::NavigateToURL(browser(), room_url);
ASSERT_TRUE(LaunchFirefoxWithUrl(room_url)); ASSERT_TRUE(LaunchFirefoxWithUrl(room_url));
......
...@@ -158,7 +158,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -158,7 +158,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
DisplayPersistentNotificationWithoutPermission) { DisplayPersistentNotificationWithoutPermission) {
std::string script_result; std::string script_result;
InfoBarResponder cancelling_responder(GetInfoBarService(), false); InfoBarResponder cancelling_responder(GetInfoBarService(),
InfoBarResponder::DENY);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
EXPECT_EQ("denied", script_result); EXPECT_EQ("denied", script_result);
...@@ -174,7 +175,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -174,7 +175,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
DisplayPersistentNotificationWithPermission) { DisplayPersistentNotificationWithPermission) {
std::string script_result; std::string script_result;
InfoBarResponder accepting_responder(GetInfoBarService(), true); InfoBarResponder accepting_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
EXPECT_EQ("granted", script_result); EXPECT_EQ("granted", script_result);
...@@ -199,7 +201,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -199,7 +201,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
// TODO(peter): It doesn't add much value if we use the InfoBarResponder for // TODO(peter): It doesn't add much value if we use the InfoBarResponder for
// each test. Rather, we should just toggle the content setting. // each test. Rather, we should just toggle the content setting.
InfoBarResponder accepting_responder(GetInfoBarService(), true); InfoBarResponder accepting_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
EXPECT_EQ("granted", script_result); EXPECT_EQ("granted", script_result);
...@@ -225,7 +228,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -225,7 +228,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
WebNotificationOptionsVibrationPattern) { WebNotificationOptionsVibrationPattern) {
std::string script_result; std::string script_result;
InfoBarResponder accepting_responder(GetInfoBarService(), true); InfoBarResponder accepting_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
EXPECT_EQ("granted", script_result); EXPECT_EQ("granted", script_result);
...@@ -247,7 +251,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -247,7 +251,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
CloseDisplayedPersistentNotification) { CloseDisplayedPersistentNotification) {
std::string script_result; std::string script_result;
InfoBarResponder accepting_responder(GetInfoBarService(), true); InfoBarResponder accepting_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
EXPECT_EQ("granted", script_result); EXPECT_EQ("granted", script_result);
...@@ -271,7 +276,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -271,7 +276,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
std::string script_result; std::string script_result;
// Creates a simple notification. // Creates a simple notification.
InfoBarResponder accepting_responder(GetInfoBarService(), true); InfoBarResponder accepting_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
ASSERT_EQ("granted", script_result); ASSERT_EQ("granted", script_result);
ASSERT_TRUE(RunScript("DisplayPersistentNotification()", &script_result)); ASSERT_TRUE(RunScript("DisplayPersistentNotification()", &script_result));
...@@ -293,7 +299,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -293,7 +299,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
// See crbug.com/402191. // See crbug.com/402191.
std::string script_result; std::string script_result;
InfoBarResponder accepting_responder_web(GetInfoBarService(), true); InfoBarResponder accepting_responder_web(GetInfoBarService(),
InfoBarResponder::ACCEPT);
DesktopNotificationService* notification_service = DesktopNotificationService* notification_service =
DesktopNotificationServiceFactory::GetForProfile(browser()->profile()); DesktopNotificationServiceFactory::GetForProfile(browser()->profile());
...@@ -315,7 +322,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, ...@@ -315,7 +322,8 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
message_center::NotifierId file_notifier(file_url); message_center::NotifierId file_notifier(file_url);
EXPECT_FALSE(notification_service->IsNotifierEnabled(file_notifier)); EXPECT_FALSE(notification_service->IsNotifierEnabled(file_notifier));
InfoBarResponder accepting_responder_file(GetInfoBarService(), true); InfoBarResponder accepting_responder_file(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
EXPECT_EQ("granted", script_result); EXPECT_EQ("granted", script_result);
......
...@@ -243,7 +243,8 @@ void PushMessagingBrowserTest::RequestAndAcceptPermission() { ...@@ -243,7 +243,8 @@ void PushMessagingBrowserTest::RequestAndAcceptPermission() {
PermissionBubbleManager::ACCEPT_ALL); PermissionBubbleManager::ACCEPT_ALL);
EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result));
} else { } else {
InfoBarResponder infobar_accept_responder(GetInfoBarService(), true); InfoBarResponder infobar_accept_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result));
} }
EXPECT_EQ("permission status - granted", script_result); EXPECT_EQ("permission status - granted", script_result);
...@@ -257,7 +258,8 @@ void PushMessagingBrowserTest::RequestAndDenyPermission() { ...@@ -257,7 +258,8 @@ void PushMessagingBrowserTest::RequestAndDenyPermission() {
PermissionBubbleManager::DENY_ALL); PermissionBubbleManager::DENY_ALL);
EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result));
} else { } else {
InfoBarResponder infobar_deny_responder(GetInfoBarService(), false); InfoBarResponder infobar_deny_responder(GetInfoBarService(),
InfoBarResponder::DENY);
EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result));
} }
EXPECT_EQ("permission status - denied", script_result); EXPECT_EQ("permission status - denied", script_result);
...@@ -319,7 +321,8 @@ IN_PROC_BROWSER_TEST_P(PushMessagingBrowserTest, ...@@ -319,7 +321,8 @@ IN_PROC_BROWSER_TEST_P(PushMessagingBrowserTest,
PermissionBubbleManager::ACCEPT_ALL); PermissionBubbleManager::ACCEPT_ALL);
ASSERT_TRUE(RunScript("subscribePush()", &script_result)); ASSERT_TRUE(RunScript("subscribePush()", &script_result));
} else { } else {
InfoBarResponder infobar_accept_responder(GetInfoBarService(), true); InfoBarResponder infobar_accept_responder(GetInfoBarService(),
InfoBarResponder::ACCEPT);
ASSERT_TRUE(RunScript("subscribePush()", &script_result)); ASSERT_TRUE(RunScript("subscribePush()", &script_result));
} }
EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result);
......
...@@ -39,11 +39,11 @@ $ = function(id) { ...@@ -39,11 +39,11 @@ $ = function(id) {
}; };
/** /**
* This function asks permission to use the webcam and mic from the browser. It * This function asks permission to use the webcam and mic from the browser.
* will return ok-requested to the test. This does not mean the request was * Its callbacks will return either request-callback-granted or
* approved though. The test will then have to click past the dialog that * request-callback-denied depending on the outcome. If the caller does not
* appears in Chrome, which will run either the OK or failed callback as a * successfully resolve the request by granting or denying, the test will hang.
* a result. To see which callback was called, use obtainGetUserMediaResult(). * To verify which callback was called, use obtainGetUserMediaResult().
* *
* @param {!object} constraints Defines what to be requested, with mandatory * @param {!object} constraints Defines what to be requested, with mandatory
* and optional constraints defined. The contents of this parameter depends * and optional constraints defined. The contents of this parameter depends
...@@ -62,7 +62,6 @@ function doGetUserMedia(constraints) { ...@@ -62,7 +62,6 @@ function doGetUserMedia(constraints) {
getUserMediaOkCallback_(stream); getUserMediaOkCallback_(stream);
}, },
getUserMediaFailedCallback_); getUserMediaFailedCallback_);
returnToTest('ok-requested');
} }
/** /**
...@@ -156,6 +155,8 @@ function getUserMediaOkCallback_(stream) { ...@@ -156,6 +155,8 @@ function getUserMediaOkCallback_(stream) {
gRequestWebcamAndMicrophoneResult = 'ok-got-stream'; gRequestWebcamAndMicrophoneResult = 'ok-got-stream';
attachMediaStream($('local-view'), stream); attachMediaStream($('local-view'), stream);
returnToTest('request-callback-granted');
} }
/** /**
...@@ -169,4 +170,6 @@ function getUserMediaFailedCallback_(error) { ...@@ -169,4 +170,6 @@ function getUserMediaFailedCallback_(error) {
debug('GetUserMedia FAILED: Maybe the camera is in use by another process?'); debug('GetUserMedia FAILED: Maybe the camera is in use by another process?');
gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + errorName; gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + errorName;
debug(gRequestWebcamAndMicrophoneResult); debug(gRequestWebcamAndMicrophoneResult);
returnToTest('request-callback-denied');
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment