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

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

Issue 2814153002: Move feature policy vibrate tests to correct directory (Closed)
Patch Set: Rebase update 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
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 c57bc389788965b8658ee43700d5635195f64b45..4c84774e2e97c984a1cd54daa741a93877db31c1 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 dummy_feature_name_map = {
iclelland 2017/04/19 17:23:28 Maybe rename this to something like test_feature_n
+ {"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,
+ dummy_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,
+ dummy_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, dummy_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, dummy_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, dummy_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, dummy_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);

Powered by Google App Engine
This is Rietveld 408576698