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

Unified Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp

Issue 2814153002: Move feature policy vibrate tests to correct directory (Closed)
Patch Set: Update test expect Created 3 years, 8 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 | « third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
diff --git a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
index ff425738d5848763491adbbf42d0b4729dbfd05e..f3dfdb035398e808810f1ab2726435ed3d683922 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp
@@ -46,13 +46,19 @@ class FeaturePolicyTest : public ::testing::Test {
RefPtr<SecurityOrigin> origin_a_ = SecurityOrigin::CreateFromString(ORIGIN_A);
RefPtr<SecurityOrigin> origin_b_ = SecurityOrigin::CreateFromString(ORIGIN_B);
RefPtr<SecurityOrigin> origin_c_ = SecurityOrigin::CreateFromString(ORIGIN_C);
+
+ const FeatureNameMap test_feature_name_map = {
+ {"fullscreen", blink::WebFeaturePolicyFeature::kFullscreen},
+ {"payment", blink::WebFeaturePolicyFeature::kPayment},
+ {"vibrate", blink::WebFeaturePolicyFeature::kVibrate}};
};
TEST_F(FeaturePolicyTest, ParseValidPolicy) {
Vector<String> messages;
for (const char* policy_string : kValidPolicies) {
messages.clear();
- ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages);
+ ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages,
+ test_feature_name_map);
EXPECT_EQ(0UL, messages.size());
}
}
@@ -61,7 +67,8 @@ TEST_F(FeaturePolicyTest, ParseInvalidPolicy) {
Vector<String> messages;
for (const char* policy_string : kInvalidPolicies) {
messages.clear();
- ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages);
+ ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages,
+ test_feature_name_map);
EXPECT_NE(0UL, messages.size());
}
}
@@ -70,23 +77,24 @@ TEST_F(FeaturePolicyTest, PolicyParsedCorrectly) {
Vector<String> messages;
// Empty policy.
- WebParsedFeaturePolicy parsed_policy =
- ParseFeaturePolicy("{}", origin_a_.Get(), &messages);
+ WebParsedFeaturePolicy parsed_policy = ParseFeaturePolicy(
+ "{}", origin_a_.Get(), &messages, test_feature_name_map);
EXPECT_EQ(0UL, parsed_policy.size());
// Simple policy with "self".
- parsed_policy = ParseFeaturePolicy("{\"vibrate\": [\"self\"]}",
- origin_a_.Get(), &messages);
+ parsed_policy =
+ ParseFeaturePolicy("{\"vibrate\": [\"self\"]}", origin_a_.Get(),
+ &messages, test_feature_name_map);
EXPECT_EQ(1UL, parsed_policy.size());
+
EXPECT_EQ(WebFeaturePolicyFeature::kVibrate, parsed_policy[0].feature);
EXPECT_FALSE(parsed_policy[0].matches_all_origins);
EXPECT_EQ(1UL, parsed_policy[0].origins.size());
EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
parsed_policy[0].origins[0].Get()));
-
// Simple policy with *.
- parsed_policy =
- ParseFeaturePolicy("{\"vibrate\": [\"*\"]}", origin_a_.Get(), &messages);
+ parsed_policy = ParseFeaturePolicy("{\"vibrate\": [\"*\"]}", origin_a_.Get(),
+ &messages, test_feature_name_map);
EXPECT_EQ(1UL, parsed_policy.size());
EXPECT_EQ(WebFeaturePolicyFeature::kVibrate, parsed_policy[0].feature);
EXPECT_TRUE(parsed_policy[0].matches_all_origins);
@@ -97,7 +105,7 @@ TEST_F(FeaturePolicyTest, PolicyParsedCorrectly) {
"{\"vibrate\": [\"*\"], "
"\"fullscreen\": [\"https://example.net\", \"https://example.org\"], "
"\"payment\": [\"self\"]}",
- origin_a_.Get(), &messages);
+ origin_a_.Get(), &messages, test_feature_name_map);
EXPECT_EQ(3UL, parsed_policy.size());
EXPECT_EQ(WebFeaturePolicyFeature::kVibrate, parsed_policy[0].feature);
EXPECT_TRUE(parsed_policy[0].matches_all_origins);
« no previous file with comments | « third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698