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

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

Issue 2904623002: Disable permissions dialog in VR (Closed)
Patch Set: Unittest 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
« no previous file with comments | « chrome/browser/permissions/permission_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9a185ff4aa2a12f2aafd80c7e7e5708f159c23f4 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;
@@ -102,6 +110,9 @@ class PermissionManagerTest : public testing::Test {
PermissionStatus callback_result_;
content::TestBrowserThreadBundle thread_bundle_;
PermissionManagerTestingProfile profile_;
+ void SetUp() override { RenderViewHostTestHarness::SetUp(); }
+
+ void TearDown() override { RenderViewHostTestHarness::TearDown(); }
raymes 2017/05/30 00:32:32 nit: methods always go above member variables
asimjour1 2017/05/30 18:27:45 Done.
};
TEST_F(PermissionManagerTest, GetPermissionStatusDefault) {
@@ -380,3 +391,34 @@ 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(),
+ url(), true,
+ base::Bind(&PermissionManagerTest::OnPermissionChange,
+ base::Unretained(this))));
+
+#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))));
+
+ vr_tab_helper->SetIsInVr(false);
+ EXPECT_NE(kNoPendingOperation,
+ GetPermissionManager()->RequestPermission(
+ PermissionType::GEOLOCATION, web_contents()->GetMainFrame(),
+ url(), true,
+ base::Bind(&PermissionManagerTest::OnPermissionChange,
+ base::Unretained(this))));
raymes 2017/05/30 00:32:32 Please check callback_called() and callback_result
asimjour1 2017/05/30 18:27:45 Done.
+#endif // BUILDFLAG(ENABLE_VR)
+}
« no previous file with comments | « chrome/browser/permissions/permission_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698