OLD | NEW |
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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" |
9 #include "base/test/values_test_util.h" | 10 #include "base/test/values_test_util.h" |
10 #include "chrome/browser/extensions/test_extension_environment.h" | 11 #include "chrome/browser/extensions/test_extension_environment.h" |
11 #include "chrome/common/extensions/permissions/chrome_permission_message_provide
r.h" | 12 #include "chrome/common/extensions/permissions/chrome_permission_message_provide
r.h" |
12 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
13 #include "extensions/common/features/simple_feature.h" | 14 #include "extensions/common/features/simple_feature.h" |
14 #include "extensions/common/permissions/permission_message_test_util.h" | 15 #include "extensions/common/permissions/permission_message_test_util.h" |
15 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
16 #include "extensions/common/switches.h" | 17 #include "extensions/common/switches.h" |
17 #include "testing/gmock/include/gmock/gmock-matchers.h" | 18 #include "testing/gmock/include/gmock/gmock-matchers.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 " 'scripts': ['background.js']" | 1156 " 'scripts': ['background.js']" |
1156 " }" | 1157 " }" |
1157 " }," | 1158 " }," |
1158 " 'plugins': [" | 1159 " 'plugins': [" |
1159 " { 'path': 'extension_plugin.dll' }" | 1160 " { 'path': 'extension_plugin.dll' }" |
1160 " ]" | 1161 " ]" |
1161 "}"); | 1162 "}"); |
1162 ASSERT_TRUE(CheckManifestProducesPermissions()); | 1163 ASSERT_TRUE(CheckManifestProducesPermissions()); |
1163 } | 1164 } |
1164 | 1165 |
| 1166 TEST_F(PermissionMessageCombinationsUnittest, ClipboardPermissionMessages) { |
| 1167 const char kManifest[] = |
| 1168 "{" |
| 1169 " 'app': {" |
| 1170 " 'background': {" |
| 1171 " 'scripts': ['background.js']" |
| 1172 " }" |
| 1173 " }," |
| 1174 " 'permissions': [%s]" |
| 1175 "}"; |
| 1176 |
| 1177 CreateAndInstall(base::StringPrintf(kManifest, "'clipboardRead'")); |
| 1178 ASSERT_TRUE(CheckManifestProducesPermissions("Read data you copy and paste")); |
| 1179 |
| 1180 CreateAndInstall( |
| 1181 base::StringPrintf(kManifest, "'clipboardRead', 'clipboardWrite'")); |
| 1182 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1183 "Read and modify data you copy and paste")); |
| 1184 |
| 1185 CreateAndInstall(base::StringPrintf(kManifest, "'clipboardWrite'")); |
| 1186 ASSERT_TRUE( |
| 1187 CheckManifestProducesPermissions("Modify data you copy and paste")); |
| 1188 } |
| 1189 |
1165 // TODO(sashab): Add a test that checks that messages are generated correctly | 1190 // TODO(sashab): Add a test that checks that messages are generated correctly |
1166 // for withheld permissions, when an app is granted the 'all sites' permission. | 1191 // for withheld permissions, when an app is granted the 'all sites' permission. |
1167 | 1192 |
1168 // TODO(sashab): Add a test that ensures that all permissions that can generate | 1193 // TODO(sashab): Add a test that ensures that all permissions that can generate |
1169 // a coalesced message can also generate a message on their own (i.e. ensure | 1194 // a coalesced message can also generate a message on their own (i.e. ensure |
1170 // that no permissions only modify other permissions). | 1195 // that no permissions only modify other permissions). |
1171 | 1196 |
1172 // TODO(sashab): Add a test for every permission message combination that can | 1197 // TODO(sashab): Add a test for every permission message combination that can |
1173 // generate a message. | 1198 // generate a message. |
1174 | 1199 |
1175 // TODO(aboxhall): Add tests for the automation API permission messages. | 1200 // TODO(aboxhall): Add tests for the automation API permission messages. |
1176 | 1201 |
1177 } // namespace extensions | 1202 } // namespace extensions |
OLD | NEW |