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

Unified Diff: chrome/browser/permissions/permission_manager_unittest.cc

Issue 2904623002: Disable permissions dialog in VR (Closed)
Patch Set: CancelPermissionRequest is removed Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/permissions/permission_manager_unittest.cc
diff --git a/chrome/browser/permissions/permission_manager_unittest.cc b/chrome/browser/permissions/permission_manager_unittest.cc
index 3eac84bd33fecd9e4ac834b6d057606d0b67e286..0a9b258339aabd60a8ac92162df08834823be283 100644
--- a/chrome/browser/permissions/permission_manager_unittest.cc
+++ b/chrome/browser/permissions/permission_manager_unittest.cc
@@ -13,13 +13,21 @@
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/permission_type.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_renderer_host.h"
+#include "device/vr/features/features.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if BUILDFLAG(ENABLE_VR)
+#include "chrome/browser/android/vr_shell/vr_tab_helper.h"
+#endif // BUILDFLAG(ENABLE_VR)
+
using blink::mojom::PermissionStatus;
using content::PermissionType;
namespace {
+int kNoPendingOperation = -1;
+
class PermissionManagerTestingProfile final : public TestingProfile {
public:
PermissionManagerTestingProfile() {}
@@ -34,7 +42,7 @@ class PermissionManagerTestingProfile final : public TestingProfile {
} // anonymous namespace
-class PermissionManagerTest : public testing::Test {
+class PermissionManagerTest : public content::RenderViewHostTestHarness {
public:
void OnPermissionChange(PermissionStatus permission) {
callback_called_ = true;
@@ -380,3 +388,40 @@ TEST_F(PermissionManagerTest, SubscribeMIDIPermission) {
GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id);
}
+
+TEST_F(PermissionManagerTest, SuppressPermissionRequests) {
+ content::WebContents* contents = web_contents();
+ EXPECT_NE(kNoPendingOperation,
+ GetPermissionManager()->RequestPermission(
+ PermissionType::GEOLOCATION, web_contents()->GetMainFrame(),
raymes 2017/05/31 23:10:08 nit: either use |contents| everywhere or web_conte
asimjour1 2017/06/06 17:58:56 Done.
+ url(), true,
+ base::Bind(&PermissionManagerTest::OnPermissionChange,
+ base::Unretained(this))));
+ EXPECT_TRUE(callback_called());
+ EXPECT_EQ(PermissionStatus::GRANTED, callback_result());
+
+#if BUILDFLAG(ENABLE_VR)
+ vr_shell::VrTabHelper* vr_tab_helper =
+ vr_shell::VrTabHelper::FromWebContents(contents);
+
+ vr_tab_helper->SetIsInVr(true);
+ EXPECT_EQ(kNoPendingOperation,
+ GetPermissionManager()->RequestPermission(
+ PermissionType::GEOLOCATION, web_contents()->GetMainFrame(),
+ url(), true,
+ base::Bind(&PermissionManagerTest::OnPermissionChange,
+ base::Unretained(this))));
+ EXPECT_FALSE(callback_called());
+ EXPECT_NE(PermissionStatus::GRANTED, callback_result());
+
+ vr_tab_helper->SetIsInVr(false);
+ EXPECT_NE(kNoPendingOperation,
+ GetPermissionManager()->RequestPermission(
+ PermissionType::GEOLOCATION, web_contents()->GetMainFrame(),
+ url(), true,
+ base::Bind(&PermissionManagerTest::OnPermissionChange,
+ base::Unretained(this))));
+ EXPECT_TRUE(callback_called());
+ EXPECT_EQ(PermissionStatus::GRANTED, callback_result());
+#endif // BUILDFLAG(ENABLE_VR)
+}

Powered by Google App Engine
This is Rietveld 408576698