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

Side by Side Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicyTest.cpp

Issue 2819293003: Fix more g_k_* symbols after blink rename. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/feature_policy/FeaturePolicy.h" 5 #include "platform/feature_policy/FeaturePolicy.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 // Origin strings used for tests 10 // Origin strings used for tests
11 #define ORIGIN_A "https://example.com/" 11 #define ORIGIN_A "https://example.com/"
12 #define ORIGIN_B "https://example.net/" 12 #define ORIGIN_B "https://example.net/"
13 #define ORIGIN_C "https://example.org/" 13 #define ORIGIN_C "https://example.org/"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 const char* const kValidPolicies[] = { 19 const char* const kValidPolicies[] = {
20 "{\"vibrate\": []}", 20 "{\"vibrate\": []}",
21 "{\"vibrate\": [\"self\"]}", 21 "{\"vibrate\": [\"self\"]}",
22 "{\"vibrate\": [\"*\"]}", 22 "{\"vibrate\": [\"*\"]}",
23 "{\"vibrate\": [\"" ORIGIN_A "\"]}", 23 "{\"vibrate\": [\"" ORIGIN_A "\"]}",
24 "{\"vibrate\": [\"" ORIGIN_B "\"]}", 24 "{\"vibrate\": [\"" ORIGIN_B "\"]}",
25 "{\"vibrate\": [\"" ORIGIN_A "\", \"" ORIGIN_B "\"]}", 25 "{\"vibrate\": [\"" ORIGIN_A "\", \"" ORIGIN_B "\"]}",
26 "{\"fullscreen\": [\"" ORIGIN_A "\"], \"payment\": [\"self\"]}", 26 "{\"fullscreen\": [\"" ORIGIN_A "\"], \"payment\": [\"self\"]}",
27 "{\"fullscreen\": [\"" ORIGIN_A "\"]}, {\"payment\": [\"self\"]}"}; 27 "{\"fullscreen\": [\"" ORIGIN_A "\"]}, {\"payment\": [\"self\"]}"};
28 28
29 const char* g_k_invalid_policies[] = { 29 const char* const kInvalidPolicies[] = {
30 "Not A JSON literal", 30 "Not A JSON literal",
31 "\"Not a JSON object\"", 31 "\"Not a JSON object\"",
32 "[\"Also\", \"Not a JSON object\"]", 32 "[\"Also\", \"Not a JSON object\"]",
33 "1.0", 33 "1.0",
34 "{\"vibrate\": \"Not a JSON array\"}", 34 "{\"vibrate\": \"Not a JSON array\"}",
35 "{\"vibrate\": [\"*\"], \"payment\": \"Not a JSON array\"}"}; 35 "{\"vibrate\": [\"*\"], \"payment\": \"Not a JSON array\"}"};
36 36
37 } // namespace 37 } // namespace
38 38
39 class FeaturePolicyTest : public ::testing::Test { 39 class FeaturePolicyTest : public ::testing::Test {
(...skipping 12 matching lines...) Expand all
52 Vector<String> messages; 52 Vector<String> messages;
53 for (const char* policy_string : kValidPolicies) { 53 for (const char* policy_string : kValidPolicies) {
54 messages.Clear(); 54 messages.Clear();
55 ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages); 55 ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages);
56 EXPECT_EQ(0UL, messages.size()); 56 EXPECT_EQ(0UL, messages.size());
57 } 57 }
58 } 58 }
59 59
60 TEST_F(FeaturePolicyTest, ParseInvalidPolicy) { 60 TEST_F(FeaturePolicyTest, ParseInvalidPolicy) {
61 Vector<String> messages; 61 Vector<String> messages;
62 for (const char* policy_string : g_k_invalid_policies) { 62 for (const char* policy_string : kInvalidPolicies) {
63 messages.Clear(); 63 messages.Clear();
64 ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages); 64 ParseFeaturePolicy(policy_string, origin_a_.Get(), &messages);
65 EXPECT_NE(0UL, messages.size()); 65 EXPECT_NE(0UL, messages.size());
66 } 66 }
67 } 67 }
68 68
69 TEST_F(FeaturePolicyTest, PolicyParsedCorrectly) { 69 TEST_F(FeaturePolicyTest, PolicyParsedCorrectly) {
70 Vector<String> messages; 70 Vector<String> messages;
71 71
72 // Empty policy. 72 // Empty policy.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin( 137 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
138 container_policy[0].origins[0].Get())); 138 container_policy[0].origins[0].Get()));
139 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, container_policy[1].feature); 139 EXPECT_EQ(WebFeaturePolicyFeature::kPayment, container_policy[1].feature);
140 EXPECT_FALSE(container_policy[1].matches_all_origins); 140 EXPECT_FALSE(container_policy[1].matches_all_origins);
141 EXPECT_EQ(1UL, container_policy[1].origins.size()); 141 EXPECT_EQ(1UL, container_policy[1].origins.size());
142 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin( 142 EXPECT_TRUE(origin_a_->IsSameSchemeHostPortAndSuborigin(
143 container_policy[1].origins[0].Get())); 143 container_policy[1].origins[0].Get()));
144 } 144 }
145 145
146 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698