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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "extensions/common/api/sockets/sockets_manifest_permission.h" | 10 #include "extensions/common/api/sockets/sockets_manifest_permission.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return testing::AssertionFailure() << "Invalid permission " << json; | 90 return testing::AssertionFailure() << "Invalid permission " << json; |
91 | 91 |
92 if (permissions.size() != permission->entries().size()) { | 92 if (permissions.size() != permission->entries().size()) { |
93 return testing::AssertionFailure() | 93 return testing::AssertionFailure() |
94 << "Incorrect # of entries in json: " << json; | 94 << "Incorrect # of entries in json: " << json; |
95 } | 95 } |
96 | 96 |
97 // Note: We use multiset because SocketsManifestPermission does not have to | 97 // Note: We use multiset because SocketsManifestPermission does not have to |
98 // store entries in the order found in the json message. | 98 // store entries in the order found in the json message. |
99 std::multiset<CheckFormatEntry> parsed_permissions; | 99 std::multiset<CheckFormatEntry> parsed_permissions; |
100 for (SocketsManifestPermission::SocketPermissionEntrySet::const_iterator it = | 100 for (SocketPermissionEntrySet::const_iterator it = |
101 permission->entries().begin(); | 101 permission->entries().begin(); |
102 it != permission->entries().end(); | 102 it != permission->entries().end(); ++it) { |
103 ++it) { | |
104 parsed_permissions.insert( | 103 parsed_permissions.insert( |
105 CheckFormatEntry(it->pattern().type, it->GetHostPatternAsString())); | 104 CheckFormatEntry(it->pattern().type, it->GetHostPatternAsString())); |
106 } | 105 } |
107 | 106 |
108 if (!std::equal( | 107 if (!std::equal( |
109 permissions.begin(), permissions.end(), parsed_permissions.begin())) { | 108 permissions.begin(), permissions.end(), parsed_permissions.begin())) { |
110 return testing::AssertionFailure() << "Incorrect socket operations."; | 109 return testing::AssertionFailure() << "Incorrect socket operations."; |
111 } | 110 } |
112 return testing::AssertionSuccess(); | 111 return testing::AssertionSuccess(); |
113 } | 112 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 new SocketsManifestPermission()); | 398 new SocketsManifestPermission()); |
400 | 399 |
401 IPC::Message m; | 400 IPC::Message m; |
402 ipc_perm->Write(&m); | 401 ipc_perm->Write(&m); |
403 PickleIterator iter(m); | 402 PickleIterator iter(m); |
404 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); | 403 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); |
405 EXPECT_TRUE(permission->Equal(ipc_perm2.get())); | 404 EXPECT_TRUE(permission->Equal(ipc_perm2.get())); |
406 } | 405 } |
407 | 406 |
408 } // namespace extensions | 407 } // namespace extensions |
OLD | NEW |