OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 TEST(ExtensionTest, ApiPermissions) { | 520 TEST(ExtensionTest, ApiPermissions) { |
521 const struct { | 521 const struct { |
522 const char* permission_name; | 522 const char* permission_name; |
523 bool expect_success; | 523 bool expect_success; |
524 } kTests[] = { | 524 } kTests[] = { |
525 // Negative test. | 525 // Negative test. |
526 { "non_existing_permission", false }, | 526 { "non_existing_permission", false }, |
527 // Test default module/package permission. | 527 // Test default module/package permission. |
528 { "browserAction", true }, | 528 { "browserAction", true }, |
529 { "devtools", true }, | 529 { "devtools", true }, |
530 { "extension", true }, | |
531 { "i18n", true }, | 530 { "i18n", true }, |
532 { "pageAction", true }, | 531 { "pageAction", true }, |
533 { "pageActions", true }, | 532 { "pageActions", true }, |
534 { "test", true }, | 533 { "test", true }, |
535 // Some negative tests. | 534 // Some negative tests. |
536 { "bookmarks", false }, | 535 { "bookmarks", false }, |
537 { "cookies", false }, | 536 { "cookies", false }, |
538 { "history", false }, | 537 { "history", false }, |
539 { "tabs.onUpdated", false }, | |
540 // Make sure we find the module name after stripping '.' and '/'. | 538 // Make sure we find the module name after stripping '.' and '/'. |
541 { "browserAction/abcd/onClick", true }, | 539 { "browserAction/abcd/onClick", true }, |
542 { "browserAction.abcd.onClick", true }, | 540 { "browserAction.abcd.onClick", true }, |
543 // Test Tabs functions. | |
544 { "tabs.create", true}, | |
545 { "tabs.onRemoved", true}, | |
546 { "tabs.remove", true}, | |
547 { "tabs.update", true}, | |
548 { "tabs.getSelected", false}, | |
549 // Test getPermissionWarnings functions. Only one requires permissions. | 541 // Test getPermissionWarnings functions. Only one requires permissions. |
550 { "management.getPermissionWarningsById", false }, | 542 { "management.getPermissionWarningsById", false }, |
551 { "management.getPermissionWarningsByManifest", true }, | 543 { "management.getPermissionWarningsByManifest", true }, |
552 }; | 544 }; |
553 | 545 |
554 scoped_refptr<Extension> extension; | 546 scoped_refptr<Extension> extension; |
555 extension = LoadManifest("empty_manifest", "empty.json"); | 547 extension = LoadManifest("empty_manifest", "empty.json"); |
556 | 548 |
557 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { | 549 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { |
558 EXPECT_EQ(kTests[i].expect_success, | 550 EXPECT_EQ(kTests[i].expect_success, |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 } | 1112 } |
1121 | 1113 |
1122 TEST(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { | 1114 TEST(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { |
1123 scoped_refptr<Extension> extension( | 1115 scoped_refptr<Extension> extension( |
1124 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), | 1116 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), |
1125 Extension::INTERNAL, 2, FilePath())); | 1117 Extension::INTERNAL, 2, FilePath())); |
1126 if (extension) | 1118 if (extension) |
1127 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); | 1119 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); |
1128 } | 1120 } |
1129 #endif // !defined(OS_CHROMEOS) | 1121 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |