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

Unified Diff: chrome/browser/media/chrome_media_stream_infobar_browsertest.cc

Issue 341833004: [WebsiteSettings] Enable permission bubbles by default. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
diff --git a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
index bddc113b4bb5d8f89be6b9010cc8032abbf1a4c3..6ae9540266364dcaf2e89f1e15da07848a31c42c 100644
--- a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
+++ b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.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/test/base/in_process_browser_test.h"
#include "chrome/test/base/test_switches.h"
@@ -29,12 +30,44 @@
#include "net/test/spawned_test_server/spawned_test_server.h"
-// MediaStreamInfoBarTest -----------------------------------------------------
+class MockPermissionBubbleView : public PermissionBubbleView {
+ public:
+ MockPermissionBubbleView() : shown_(false) {}
+ virtual ~MockPermissionBubbleView() {}
+
+ virtual void SetDelegate(Delegate* delegate) OVERRIDE {
+ }
+
+ virtual void Show(
+ const std::vector<PermissionBubbleRequest*>& requests,
+ const std::vector<bool>& accept_state,
+ bool customization_mode) OVERRIDE {
+LOG(INFO) << "Showing view... " << requests[0]->GetMessageText();
+ shown_ = true;
+ }
+
+ virtual bool CanAcceptRequestUpdate() OVERRIDE {
+ return true;
+ }
+
+ virtual void Hide() OVERRIDE {
+ shown_ = false;
+ }
+
+ virtual bool IsVisible() OVERRIDE {
+ return shown_;
+ }
+
+ private:
+ bool shown_;
+};
+
+// MediaStreamBrowserTest -----------------------------------------------------
-class MediaStreamInfoBarTest : public WebRtcTestBase {
+class MediaStreamBrowserTest : public WebRtcTestBase {
public:
- MediaStreamInfoBarTest() {}
- virtual ~MediaStreamInfoBarTest() {}
+ MediaStreamBrowserTest() {}
+ virtual ~MediaStreamBrowserTest() {}
// InProcessBrowserTest:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
@@ -77,6 +110,10 @@ class MediaStreamInfoBarTest : public WebRtcTestBase {
controller->Deny(true, result);
}
+ int GetBubblesQueueSize(PermissionBubbleManager* mgr) {
+ return static_cast<int>(mgr->requests_.size());
+ }
+
// Executes stopLocalStream() in the test page, which frees up an already
// acquired mediastream.
bool StopLocalStream(content::WebContents* tab_contents) {
@@ -100,32 +137,34 @@ class MediaStreamInfoBarTest : public WebRtcTestBase {
content::MediaStreamRequestResult result,
scoped_ptr<content::MediaStreamUI> ui) {}
- DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarTest);
+ MockPermissionBubbleView mock_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaStreamBrowserTest);
};
// Actual tests ---------------------------------------------------------------
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestAllowingUserMedia) {
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest, TestAllowingUserMedia) {
content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndAccept(tab_contents);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDenyingUserMedia) {
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest, TestDenyingUserMedia) {
content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndDeny(tab_contents);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissingInfobar) {
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest, TestDismissingPrompt) {
content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndDismiss(tab_contents);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDenyingUserMediaIncognito) {
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest, TestDenyingUserMediaIncognito) {
content::WebContents* tab_contents = LoadTestPageInIncognitoTab();
GetUserMediaAndDeny(tab_contents);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest,
TestAcceptThenDenyWhichShouldBeSticky) {
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
@@ -138,35 +177,42 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
GetUserMediaAndAccept(tab_contents);
GetUserMediaAndDeny(tab_contents);
- // Should fail with permission denied right away with no infobar popping up.
+ // Should fail with permission denied right away with no prompt popping up.
GetUserMedia(tab_contents, kAudioVideoCallConstraints);
EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
kFailedWithPermissionDeniedError,
tab_contents));
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(tab_contents);
- EXPECT_EQ(0u, infobar_service->infobar_count());
+
+ if (!PermissionBubbleManager::Enabled()) {
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(tab_contents);
+ EXPECT_EQ(0u, infobar_service->infobar_count());
+ } else {
+ PermissionBubbleManager* manager =
+ PermissionBubbleManager::FromWebContents(tab_contents);
+ EXPECT_EQ(0, GetBubblesQueueSize(manager));
+ }
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestAcceptIsNotSticky) {
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest, TestAcceptIsNotSticky) {
content::WebContents* tab_contents = LoadTestPageInTab();
- // If accept were sticky the second call would hang because it hangs if an
- // infobar does not pop up.
+ // If accept were sticky the second call would hang because it hangs if a
+ // prompt does not pop up.
GetUserMediaAndAccept(tab_contents);
GetUserMediaAndAccept(tab_contents);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) {
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest, TestDismissIsNotSticky) {
content::WebContents* tab_contents = LoadTestPageInTab();
- // If dismiss were sticky the second call would hang because it hangs if an
- // infobar does not pop up.
+ // If dismiss were sticky the second call would hang because it hangs if a
+ // prompt does not pop up.
GetUserMediaAndDismiss(tab_contents);
GetUserMediaAndDismiss(tab_contents);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest,
TestDenyingThenClearingStickyException) {
content::WebContents* tab_contents = LoadTestPageInTab();
@@ -179,7 +225,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
settings_map->ClearSettingsForOneType(
CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
- // If an infobar is not launched now, this will hang.
+ // If a prompt is not shown now, this will hang.
GetUserMediaAndDeny(tab_contents);
}
@@ -191,7 +237,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
#define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \
DenyingMicDoesNotCauseStickyDenyForCameras
#endif
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest,
MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) {
content::WebContents* tab_contents = LoadTestPageInTab();
@@ -202,7 +248,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
kVideoOnlyCallConstraints);
}
-IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
+IN_PROC_BROWSER_TEST_F(MediaStreamBrowserTest,
DenyingCameraDoesNotCauseStickyDenyForMics) {
content::WebContents* tab_contents = LoadTestPageInTab();

Powered by Google App Engine
This is Rietveld 408576698