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

Side by Side Diff: extensions/browser/info_map_unittest.cc

Issue 314113010: Remove deprecated permissions functions from Extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « extensions/browser/info_map.cc ('k') | extensions/common/extension.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/common/chrome_paths.h" 8 #include "chrome/common/chrome_paths.h"
9 #include "content/public/test/test_browser_thread.h" 9 #include "content/public/test/test_browser_thread.h"
10 #include "extensions/browser/info_map.h" 10 #include "extensions/browser/info_map.h"
11 #include "extensions/common/extension.h" 11 #include "extensions/common/extension.h"
12 #include "extensions/common/manifest_constants.h" 12 #include "extensions/common/manifest_constants.h"
13 #include "extensions/common/permissions/permissions_data.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
17 namespace keys = extensions::manifest_keys; 18 namespace keys = extensions::manifest_keys;
18 19
19 namespace extensions { 20 namespace extensions {
20 21
21 class InfoMapTest : public testing::Test { 22 class InfoMapTest : public testing::Test {
22 public: 23 public:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ASSERT_TRUE(app->is_app()); 138 ASSERT_TRUE(app->is_app());
138 ASSERT_TRUE(app->web_extent().MatchesURL(app_url)); 139 ASSERT_TRUE(app->web_extent().MatchesURL(app_url));
139 140
140 info_map->AddExtension(app.get(), base::Time(), false, false); 141 info_map->AddExtension(app.get(), base::Time(), false, false);
141 info_map->AddExtension(extension.get(), base::Time(), false, false); 142 info_map->AddExtension(extension.get(), base::Time(), false, false);
142 143
143 // The app should have the notifications permission, either from a 144 // The app should have the notifications permission, either from a
144 // chrome-extension URL or from its web extent. 145 // chrome-extension URL or from its web extent.
145 const Extension* match = info_map->extensions().GetExtensionOrAppByURL( 146 const Extension* match = info_map->extensions().GetExtensionOrAppByURL(
146 app->GetResourceURL("a.html")); 147 app->GetResourceURL("a.html"));
147 EXPECT_TRUE(match && match->HasAPIPermission(APIPermission::kNotification)); 148 EXPECT_TRUE(match &&
149 match->permissions_data()->HasAPIPermission(
150 APIPermission::kNotification));
148 match = info_map->extensions().GetExtensionOrAppByURL(app_url); 151 match = info_map->extensions().GetExtensionOrAppByURL(app_url);
149 EXPECT_TRUE(match && match->HasAPIPermission(APIPermission::kNotification)); 152 EXPECT_TRUE(match &&
150 EXPECT_FALSE(match && match->HasAPIPermission(APIPermission::kTab)); 153 match->permissions_data()->HasAPIPermission(
154 APIPermission::kNotification));
155 EXPECT_FALSE(
156 match &&
157 match->permissions_data()->HasAPIPermission(APIPermission::kTab));
151 158
152 // The extension should have the tabs permission. 159 // The extension should have the tabs permission.
153 match = info_map->extensions().GetExtensionOrAppByURL( 160 match = info_map->extensions().GetExtensionOrAppByURL(
154 extension->GetResourceURL("a.html")); 161 extension->GetResourceURL("a.html"));
155 EXPECT_TRUE(match && match->HasAPIPermission(APIPermission::kTab)); 162 EXPECT_TRUE(match &&
156 EXPECT_FALSE(match && match->HasAPIPermission(APIPermission::kNotification)); 163 match->permissions_data()->HasAPIPermission(APIPermission::kTab));
164 EXPECT_FALSE(match &&
165 match->permissions_data()->HasAPIPermission(
166 APIPermission::kNotification));
157 167
158 // Random URL should not have any permissions. 168 // Random URL should not have any permissions.
159 GURL evil_url("http://evil.com/a.html"); 169 GURL evil_url("http://evil.com/a.html");
160 match = info_map->extensions().GetExtensionOrAppByURL(evil_url); 170 match = info_map->extensions().GetExtensionOrAppByURL(evil_url);
161 EXPECT_FALSE(match); 171 EXPECT_FALSE(match);
162 } 172 }
163 173
164 TEST_F(InfoMapTest, TestNotificationsDisabled) { 174 TEST_F(InfoMapTest, TestNotificationsDisabled) {
165 scoped_refptr<InfoMap> info_map(new InfoMap()); 175 scoped_refptr<InfoMap> info_map(new InfoMap());
166 scoped_refptr<Extension> app(LoadManifest("manifest_tests", 176 scoped_refptr<Extension> app(LoadManifest("manifest_tests",
167 "valid_app.json")); 177 "valid_app.json"));
168 info_map->AddExtension(app.get(), base::Time(), false, false); 178 info_map->AddExtension(app.get(), base::Time(), false, false);
169 179
170 EXPECT_FALSE(info_map->AreNotificationsDisabled(app->id())); 180 EXPECT_FALSE(info_map->AreNotificationsDisabled(app->id()));
171 info_map->SetNotificationsDisabled(app->id(), true); 181 info_map->SetNotificationsDisabled(app->id(), true);
172 EXPECT_TRUE(info_map->AreNotificationsDisabled(app->id())); 182 EXPECT_TRUE(info_map->AreNotificationsDisabled(app->id()));
173 info_map->SetNotificationsDisabled(app->id(), false); 183 info_map->SetNotificationsDisabled(app->id(), false);
174 } 184 }
175 185
176 } // namespace extensions 186 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/info_map.cc ('k') | extensions/common/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698