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

Side by Side Diff: chrome/common/extensions/manifest_handlers/automation_unittest.cc

Issue 415293002: Current host warning "Read and modify your data .." should say "Read and change your data .." to ma… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a typo in a test Created 6 years, 5 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 | chrome/common/extensions/permissions/permission_set_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/common/extensions/manifest_handlers/automation.h" 6 #include "chrome/common/extensions/manifest_handlers/automation.h"
7 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" 7 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
8 #include "extensions/common/error_utils.h" 8 #include "extensions/common/error_utils.h"
9 #include "extensions/common/manifest_constants.h" 9 #include "extensions/common/manifest_constants.h"
10 #include "extensions/common/permissions/permissions_data.h" 10 #include "extensions/common/permissions/permissions_data.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 TEST_F(AutomationManifestTest, AsBooleanTrue) { 45 TEST_F(AutomationManifestTest, AsBooleanTrue) {
46 scoped_refptr<Extension> extension = 46 scoped_refptr<Extension> extension =
47 LoadAndExpectSuccess("automation_boolean_true.json"); 47 LoadAndExpectSuccess("automation_boolean_true.json");
48 ASSERT_TRUE(extension.get()); 48 ASSERT_TRUE(extension.get());
49 49
50 std::vector<base::string16> warnings = 50 std::vector<base::string16> warnings =
51 extension->permissions_data()->GetPermissionMessageStrings(); 51 extension->permissions_data()->GetPermissionMessageStrings();
52 ASSERT_EQ(1u, warnings.size()); 52 ASSERT_EQ(1u, warnings.size());
53 EXPECT_EQ("Read and modify your data on www.google.com", 53 EXPECT_EQ("Read and change your data on www.google.com",
54 base::UTF16ToUTF8(warnings[0])); 54 base::UTF16ToUTF8(warnings[0]));
55 55
56 const AutomationInfo* info = AutomationInfo::Get(extension.get()); 56 const AutomationInfo* info = AutomationInfo::Get(extension.get());
57 ASSERT_TRUE(info); 57 ASSERT_TRUE(info);
58 58
59 EXPECT_FALSE(info->desktop); 59 EXPECT_FALSE(info->desktop);
60 EXPECT_FALSE(info->interact); 60 EXPECT_FALSE(info->interact);
61 EXPECT_TRUE(info->matches.is_empty()); 61 EXPECT_TRUE(info->matches.is_empty());
62 } 62 }
63 63
64 TEST_F(AutomationManifestTest, InteractTrue) { 64 TEST_F(AutomationManifestTest, InteractTrue) {
65 scoped_refptr<Extension> extension = 65 scoped_refptr<Extension> extension =
66 LoadAndExpectSuccess("automation_interact_true.json"); 66 LoadAndExpectSuccess("automation_interact_true.json");
67 ASSERT_TRUE(extension.get()); 67 ASSERT_TRUE(extension.get());
68 68
69 std::vector<base::string16> warnings = 69 std::vector<base::string16> warnings =
70 extension->permissions_data()->GetPermissionMessageStrings(); 70 extension->permissions_data()->GetPermissionMessageStrings();
71 ASSERT_EQ(1u, warnings.size()); 71 ASSERT_EQ(1u, warnings.size());
72 EXPECT_EQ("Read and modify your data on www.google.com", 72 EXPECT_EQ("Read and change your data on www.google.com",
73 base::UTF16ToUTF8(warnings[0])); 73 base::UTF16ToUTF8(warnings[0]));
74 74
75 const AutomationInfo* info = AutomationInfo::Get(extension.get()); 75 const AutomationInfo* info = AutomationInfo::Get(extension.get());
76 ASSERT_TRUE(info); 76 ASSERT_TRUE(info);
77 77
78 EXPECT_FALSE(info->desktop); 78 EXPECT_FALSE(info->desktop);
79 EXPECT_TRUE(info->interact); 79 EXPECT_TRUE(info->interact);
80 EXPECT_TRUE(info->matches.is_empty()); 80 EXPECT_TRUE(info->matches.is_empty());
81 } 81 }
82 82
83 TEST_F(AutomationManifestTest, Matches) { 83 TEST_F(AutomationManifestTest, Matches) {
84 scoped_refptr<Extension> extension = LoadAndExpectWarning( 84 scoped_refptr<Extension> extension = LoadAndExpectWarning(
85 "automation_matches.json", 85 "automation_matches.json",
86 ErrorUtils::FormatErrorMessage( 86 ErrorUtils::FormatErrorMessage(
87 automation_errors::kErrorInvalidMatch, 87 automation_errors::kErrorInvalidMatch,
88 "www.badpattern.com", 88 "www.badpattern.com",
89 URLPattern::GetParseResultString( 89 URLPattern::GetParseResultString(
90 URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR))); 90 URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR)));
91 ASSERT_TRUE(extension.get()); 91 ASSERT_TRUE(extension.get());
92 92
93 std::vector<base::string16> warnings = 93 std::vector<base::string16> warnings =
94 extension->permissions_data()->GetPermissionMessageStrings(); 94 extension->permissions_data()->GetPermissionMessageStrings();
95 ASSERT_EQ(1u, warnings.size()); 95 ASSERT_EQ(1u, warnings.size());
96 EXPECT_EQ("Read and modify your data on www.google.com and www.twitter.com", 96 EXPECT_EQ("Read and change your data on www.google.com and www.twitter.com",
97 base::UTF16ToUTF8(warnings[0])); 97 base::UTF16ToUTF8(warnings[0]));
98 98
99 const AutomationInfo* info = AutomationInfo::Get(extension.get()); 99 const AutomationInfo* info = AutomationInfo::Get(extension.get());
100 ASSERT_TRUE(info); 100 ASSERT_TRUE(info);
101 101
102 EXPECT_FALSE(info->desktop); 102 EXPECT_FALSE(info->desktop);
103 EXPECT_FALSE(info->interact); 103 EXPECT_FALSE(info->interact);
104 EXPECT_FALSE(info->matches.is_empty()); 104 EXPECT_FALSE(info->matches.is_empty());
105 105
106 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.google.com/"))); 106 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.google.com/")));
107 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.google.com"))); 107 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.google.com")));
108 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.twitter.com/"))); 108 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.twitter.com/")));
109 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.twitter.com"))); 109 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.twitter.com")));
110 110
111 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://www.bing.com/"))); 111 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://www.bing.com/")));
112 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://www.bing.com"))); 112 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://www.bing.com")));
113 } 113 }
114 114
115 TEST_F(AutomationManifestTest, MatchesAndPermissions) { 115 TEST_F(AutomationManifestTest, MatchesAndPermissions) {
116 scoped_refptr<Extension> extension = 116 scoped_refptr<Extension> extension =
117 LoadAndExpectSuccess("automation_matches_and_permissions.json"); 117 LoadAndExpectSuccess("automation_matches_and_permissions.json");
118 ASSERT_TRUE(extension.get()); 118 ASSERT_TRUE(extension.get());
119 119
120 std::vector<base::string16> warnings = 120 std::vector<base::string16> warnings =
121 extension->permissions_data()->GetPermissionMessageStrings(); 121 extension->permissions_data()->GetPermissionMessageStrings();
122 ASSERT_EQ(2u, warnings.size()); 122 ASSERT_EQ(2u, warnings.size());
123 EXPECT_EQ("Read and modify your data on www.google.com", 123 EXPECT_EQ("Read and change your data on www.google.com",
124 base::UTF16ToUTF8(warnings[0])); 124 base::UTF16ToUTF8(warnings[0]));
125 EXPECT_EQ("Read and modify your data on www.twitter.com", 125 EXPECT_EQ("Read and change your data on www.twitter.com",
126 base::UTF16ToUTF8(warnings[1])); 126 base::UTF16ToUTF8(warnings[1]));
127 127
128 const AutomationInfo* info = AutomationInfo::Get(extension.get()); 128 const AutomationInfo* info = AutomationInfo::Get(extension.get());
129 ASSERT_TRUE(info); 129 ASSERT_TRUE(info);
130 130
131 EXPECT_FALSE(info->desktop); 131 EXPECT_FALSE(info->desktop);
132 EXPECT_FALSE(info->interact); 132 EXPECT_FALSE(info->interact);
133 EXPECT_FALSE(info->matches.is_empty()); 133 EXPECT_FALSE(info->matches.is_empty());
134 134
135 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.twitter.com/"))); 135 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://www.twitter.com/")));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 TEST_F(AutomationManifestTest, DesktopFalse) { 185 TEST_F(AutomationManifestTest, DesktopFalse) {
186 scoped_refptr<Extension> extension = 186 scoped_refptr<Extension> extension =
187 LoadAndExpectSuccess("automation_desktop_false.json"); 187 LoadAndExpectSuccess("automation_desktop_false.json");
188 ASSERT_TRUE(extension.get()); 188 ASSERT_TRUE(extension.get());
189 189
190 std::vector<base::string16> warnings = 190 std::vector<base::string16> warnings =
191 extension->permissions_data()->GetPermissionMessageStrings(); 191 extension->permissions_data()->GetPermissionMessageStrings();
192 ASSERT_EQ(1u, warnings.size()); 192 ASSERT_EQ(1u, warnings.size());
193 EXPECT_EQ("Read and modify your data on www.google.com", 193 EXPECT_EQ("Read and change your data on www.google.com",
194 base::UTF16ToUTF8(warnings[0])); 194 base::UTF16ToUTF8(warnings[0]));
195 195
196 const AutomationInfo* info = AutomationInfo::Get(extension.get()); 196 const AutomationInfo* info = AutomationInfo::Get(extension.get());
197 ASSERT_TRUE(info); 197 ASSERT_TRUE(info);
198 198
199 EXPECT_FALSE(info->desktop); 199 EXPECT_FALSE(info->desktop);
200 EXPECT_FALSE(info->interact); 200 EXPECT_FALSE(info->interact);
201 EXPECT_TRUE(info->matches.is_empty()); 201 EXPECT_TRUE(info->matches.is_empty());
202 } 202 }
203 203
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 const AutomationInfo* info = AutomationInfo::Get(extension.get()); 273 const AutomationInfo* info = AutomationInfo::Get(extension.get());
274 ASSERT_TRUE(info); 274 ASSERT_TRUE(info);
275 275
276 EXPECT_TRUE(info->desktop); 276 EXPECT_TRUE(info->desktop);
277 EXPECT_TRUE(info->interact); 277 EXPECT_TRUE(info->interact);
278 EXPECT_TRUE(info->matches.is_empty()); 278 EXPECT_TRUE(info->matches.is_empty());
279 } 279 }
280 280
281 } // namespace extensions 281 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/permissions/permission_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698