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

Unified Diff: chrome/browser/payments/payment_handler_permission_context_unittest.cc

Issue 2946013002: PaymentHandler: Implement requestPermission().
Patch Set: Created 3 years, 6 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/payments/payment_handler_permission_context_unittest.cc
diff --git a/chrome/browser/media/midi_sysex_permission_context_unittest.cc b/chrome/browser/payments/payment_handler_permission_context_unittest.cc
similarity index 67%
copy from chrome/browser/media/midi_sysex_permission_context_unittest.cc
copy to chrome/browser/payments/payment_handler_permission_context_unittest.cc
index 0ddf724e2aabeb0e01f350eff0a73736e793e81e..e6ea8d16fdace561d5831d9d2185fe94df5993b2 100644
--- a/chrome/browser/media/midi_sysex_permission_context_unittest.cc
+++ b/chrome/browser/payments/payment_handler_permission_context_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/media/midi_sysex_permission_context.h"
+#include "chrome/browser/payments/payment_handler_permission_context.h"
#include "base/bind.h"
#include "base/macros.h"
#include "build/build_config.h"
@@ -26,13 +26,12 @@
namespace {
-class TestPermissionContext : public MidiSysexPermissionContext {
+class TestPermissionContext : public PaymentHandlerPermissionContext {
public:
explicit TestPermissionContext(Profile* profile)
- : MidiSysexPermissionContext(profile),
+ : PaymentHandlerPermissionContext(profile),
permission_set_(false),
- permission_granted_(false),
- tab_context_updated_(false) {}
+ permission_granted_(false) {}
~TestPermissionContext() override {}
@@ -40,31 +39,22 @@ class TestPermissionContext : public MidiSysexPermissionContext {
bool permission_set() { return permission_set_; }
- bool tab_context_updated() { return tab_context_updated_; }
-
void TrackPermissionDecision(ContentSetting content_setting) {
permission_set_ = true;
permission_granted_ = content_setting == CONTENT_SETTING_ALLOW;
}
- protected:
- void UpdateTabContext(const PermissionRequestID& id,
- const GURL& requesting_origin,
- bool allowed) override {
- tab_context_updated_ = true;
- }
-
private:
bool permission_set_;
bool permission_granted_;
- bool tab_context_updated_;
};
} // anonymous namespace
-class MidiSysexPermissionContextTests : public ChromeRenderViewHostTestHarness {
+class PaymentHandlerPermissionContextTests
+ : public ChromeRenderViewHostTestHarness {
protected:
- MidiSysexPermissionContextTests() = default;
+ PaymentHandlerPermissionContextTests() = default;
private:
// ChromeRenderViewHostTestHarness:
@@ -77,11 +67,11 @@ class MidiSysexPermissionContextTests : public ChromeRenderViewHostTestHarness {
#endif
}
- DISALLOW_COPY_AND_ASSIGN(MidiSysexPermissionContextTests);
+ DISALLOW_COPY_AND_ASSIGN(PaymentHandlerPermissionContextTests);
};
-// Web MIDI sysex permission should be denied for insecure origin.
-TEST_F(MidiSysexPermissionContextTests, TestInsecureRequestingUrl) {
+// PaymentHandler permission should be denied for insecure origin.
+TEST_F(PaymentHandlerPermissionContextTests, TestInsecureRequestingUrl) {
TestPermissionContext permission_context(profile());
GURL url("http://www.example.com");
content::WebContentsTester::For(web_contents())->NavigateAndCommit(url);
@@ -96,17 +86,17 @@ TEST_F(MidiSysexPermissionContextTests, TestInsecureRequestingUrl) {
EXPECT_TRUE(permission_context.permission_set());
EXPECT_FALSE(permission_context.permission_granted());
- EXPECT_TRUE(permission_context.tab_context_updated());
ContentSetting setting =
HostContentSettingsMapFactory::GetForProfile(profile())
->GetContentSetting(url.GetOrigin(), url.GetOrigin(),
- CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string());
+ CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER,
+ std::string());
EXPECT_EQ(CONTENT_SETTING_ASK, setting);
}
-// Web MIDI sysex permission status should be denied for insecure origin.
-TEST_F(MidiSysexPermissionContextTests, TestInsecureQueryingUrl) {
+// PaymentHandler permission status should be denied for insecure origin.
+TEST_F(PaymentHandlerPermissionContextTests, TestInsecureQueryingUrl) {
TestPermissionContext permission_context(profile());
GURL insecure_url("http://www.example.com");
GURL secure_url("https://www.example.com");
@@ -116,17 +106,17 @@ TEST_F(MidiSysexPermissionContextTests, TestInsecureQueryingUrl) {
HostContentSettingsMapFactory::GetForProfile(profile())
->GetContentSetting(
insecure_url.GetOrigin(), insecure_url.GetOrigin(),
- CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string()));
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
- HostContentSettingsMapFactory::GetForProfile(profile())
- ->GetContentSetting(secure_url.GetOrigin(), insecure_url.GetOrigin(),
- CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string()));
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
- HostContentSettingsMapFactory::GetForProfile(profile())
- ->GetContentSetting(insecure_url.GetOrigin(), secure_url.GetOrigin(),
- CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string()));
+ CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER, std::string()));
+ EXPECT_EQ(CONTENT_SETTING_ASK,
+ HostContentSettingsMapFactory::GetForProfile(profile())
+ ->GetContentSetting(
+ secure_url.GetOrigin(), insecure_url.GetOrigin(),
+ CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER, std::string()));
+ EXPECT_EQ(CONTENT_SETTING_ASK,
+ HostContentSettingsMapFactory::GetForProfile(profile())
+ ->GetContentSetting(
+ insecure_url.GetOrigin(), secure_url.GetOrigin(),
+ CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER, std::string()));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
permission_context
@@ -137,6 +127,12 @@ TEST_F(MidiSysexPermissionContextTests, TestInsecureQueryingUrl) {
EXPECT_EQ(CONTENT_SETTING_BLOCK,
permission_context
.GetPermissionStatus(nullptr /* render_frame_host */,
+ secure_url, insecure_url)
+ .content_setting);
+
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ permission_context
+ .GetPermissionStatus(nullptr /* render_frame_host */,
insecure_url, secure_url)
.content_setting);
}

Powered by Google App Engine
This is Rietveld 408576698