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/browser/extensions/api/permissions/permissions_api_helpers.h" | 5 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 base::ListValue* origin_list = NULL; | 51 base::ListValue* origin_list = NULL; |
52 EXPECT_TRUE(value->GetList("permissions", &api_list)); | 52 EXPECT_TRUE(value->GetList("permissions", &api_list)); |
53 EXPECT_TRUE(value->GetList("origins", &origin_list)); | 53 EXPECT_TRUE(value->GetList("origins", &origin_list)); |
54 | 54 |
55 EXPECT_EQ(3u, api_list->GetSize()); | 55 EXPECT_EQ(3u, api_list->GetSize()); |
56 EXPECT_EQ(2u, origin_list->GetSize()); | 56 EXPECT_EQ(2u, origin_list->GetSize()); |
57 | 57 |
58 std::string expected_apis[] = {"tabs", "fileBrowserHandler", | 58 std::string expected_apis[] = {"tabs", "fileBrowserHandler", |
59 "fileBrowserHandlerInternal"}; | 59 "fileBrowserHandlerInternal"}; |
60 for (size_t i = 0; i < arraysize(expected_apis); ++i) { | 60 for (size_t i = 0; i < arraysize(expected_apis); ++i) { |
61 std::unique_ptr<base::Value> value(new base::StringValue(expected_apis[i])); | 61 std::unique_ptr<base::Value> value(new base::Value(expected_apis[i])); |
62 EXPECT_NE(api_list->end(), api_list->Find(*value)); | 62 EXPECT_NE(api_list->end(), api_list->Find(*value)); |
63 } | 63 } |
64 | 64 |
65 std::string expected_origins[] = { "http://a.com/*", "http://b.com/*" }; | 65 std::string expected_origins[] = { "http://a.com/*", "http://b.com/*" }; |
66 for (size_t i = 0; i < arraysize(expected_origins); ++i) { | 66 for (size_t i = 0; i < arraysize(expected_origins); ++i) { |
67 std::unique_ptr<base::Value> value( | 67 std::unique_ptr<base::Value> value(new base::Value(expected_origins[i])); |
68 new base::StringValue(expected_origins[i])); | |
69 EXPECT_NE(origin_list->end(), origin_list->Find(*value)); | 68 EXPECT_NE(origin_list->end(), origin_list->Find(*value)); |
70 } | 69 } |
71 | 70 |
72 // Unpack the value back to a permission set and make sure its equal to the | 71 // Unpack the value back to a permission set and make sure its equal to the |
73 // original one. | 72 // original one. |
74 std::string error; | 73 std::string error; |
75 Permissions permissions_object; | 74 Permissions permissions_object; |
76 EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); | 75 EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); |
77 std::unique_ptr<const PermissionSet> from_value = | 76 std::unique_ptr<const PermissionSet> from_value = |
78 UnpackPermissionSet(permissions_object, true, &error); | 77 UnpackPermissionSet(permissions_object, true, &error); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 value->Set("permissions", invalid_apis->DeepCopy()); | 172 value->Set("permissions", invalid_apis->DeepCopy()); |
174 EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); | 173 EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); |
175 permissions = UnpackPermissionSet(permissions_object, true, &error); | 174 permissions = UnpackPermissionSet(permissions_object, true, &error); |
176 EXPECT_FALSE(permissions.get()); | 175 EXPECT_FALSE(permissions.get()); |
177 EXPECT_FALSE(error.empty()); | 176 EXPECT_FALSE(error.empty()); |
178 EXPECT_EQ(error, "'unknown_permission' is not a recognized permission."); | 177 EXPECT_EQ(error, "'unknown_permission' is not a recognized permission."); |
179 } | 178 } |
180 } | 179 } |
181 | 180 |
182 } // namespace extensions | 181 } // namespace extensions |
OLD | NEW |