OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "chrome/browser/extensions/extension_info_map.h" | 7 #include "chrome/browser/extensions/extension_info_map.h" |
8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 info_map->AddExtension(extension1, base::Time(), false); | 87 info_map->AddExtension(extension1, base::Time(), false); |
88 info_map->AddExtension(extension2, base::Time(), false); | 88 info_map->AddExtension(extension2, base::Time(), false); |
89 info_map->AddExtension(extension3, base::Time(), false); | 89 info_map->AddExtension(extension3, base::Time(), false); |
90 | 90 |
91 // Release extension1, and the info map should have the only ref. | 91 // Release extension1, and the info map should have the only ref. |
92 const Extension* weak_extension1 = extension1; | 92 const Extension* weak_extension1 = extension1; |
93 extension1 = NULL; | 93 extension1 = NULL; |
94 EXPECT_TRUE(weak_extension1->HasOneRef()); | 94 EXPECT_TRUE(weak_extension1->HasOneRef()); |
95 | 95 |
96 // Remove extension2, and the extension2 object should have the only ref. | 96 // Remove extension2, and the extension2 object should have the only ref. |
97 info_map->RemoveExtension(extension2->id(), UnloadedExtensionInfo::UNINSTALL); | 97 info_map->RemoveExtension( |
| 98 extension2->id(), extension_misc::UNLOAD_REASON_UNINSTALL); |
98 EXPECT_TRUE(extension2->HasOneRef()); | 99 EXPECT_TRUE(extension2->HasOneRef()); |
99 | 100 |
100 // Delete the info map, and the extension3 object should have the only ref. | 101 // Delete the info map, and the extension3 object should have the only ref. |
101 info_map = NULL; | 102 info_map = NULL; |
102 EXPECT_TRUE(extension3->HasOneRef()); | 103 EXPECT_TRUE(extension3->HasOneRef()); |
103 } | 104 } |
104 | 105 |
105 // Tests that we can query a few extension properties from the ExtensionInfoMap. | 106 // Tests that we can query a few extension properties from the ExtensionInfoMap. |
106 TEST_F(ExtensionInfoMapTest, Properties) { | 107 TEST_F(ExtensionInfoMapTest, Properties) { |
107 scoped_refptr<ExtensionInfoMap> info_map(new ExtensionInfoMap()); | 108 scoped_refptr<ExtensionInfoMap> info_map(new ExtensionInfoMap()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 match->HasAPIPermission(ExtensionAPIPermission::kTab)); | 152 match->HasAPIPermission(ExtensionAPIPermission::kTab)); |
152 EXPECT_FALSE(match && | 153 EXPECT_FALSE(match && |
153 match->HasAPIPermission(ExtensionAPIPermission::kNotification)); | 154 match->HasAPIPermission(ExtensionAPIPermission::kNotification)); |
154 | 155 |
155 // Random URL should not have any permissions. | 156 // Random URL should not have any permissions. |
156 match = info_map->extensions().GetByURL(GURL("http://evil.com/a.html")); | 157 match = info_map->extensions().GetByURL(GURL("http://evil.com/a.html")); |
157 EXPECT_FALSE(match); | 158 EXPECT_FALSE(match); |
158 } | 159 } |
159 | 160 |
160 } // namespace | 161 } // namespace |
OLD | NEW |