Index: chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc |
diff --git a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc |
index e24d4f65a0b9df63db60e71c31b18dbaacefb226..58af5d829402802e2aad37903b97f48af75b2adf 100644 |
--- a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc |
+++ b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc |
@@ -156,6 +156,33 @@ TEST_F(ExternallyConnectableTest, AllIDs) { |
EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html"))); |
} |
+TEST_F(ExternallyConnectableTest, MatchesIdOrAllIds) { |
+ // Not in order to test that ExternallyConnectableInfo sorts it. |
+ std::string matches_ids_array[] = { "g", "h", "c", "i", "a", "z", "b" }; |
+ std::vector<std::string> matches_ids( |
+ matches_ids_array, matches_ids_array + arraysize(matches_ids_array)); |
+ |
+ std::string nomatches_ids_array[] = { "2", "3", "1" }; |
+ |
+ // matches_all_ids = false. |
+ { |
+ ExternallyConnectableInfo info(URLPatternSet(), matches_ids, false); |
+ for (size_t i = 0; i < matches_ids.size(); ++i) |
+ EXPECT_TRUE(info.MatchesIdOrAllIds(matches_ids[i])); |
+ for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i) |
+ EXPECT_FALSE(info.MatchesIdOrAllIds(nomatches_ids_array[i])); |
+ } |
+ |
+ // matches_all_ids = true. |
+ { |
+ ExternallyConnectableInfo info(URLPatternSet(), matches_ids, true); |
+ for (size_t i = 0; i < matches_ids.size(); ++i) |
+ EXPECT_TRUE(info.MatchesIdOrAllIds(matches_ids[i])); |
+ for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i) |
+ EXPECT_TRUE(info.MatchesIdOrAllIds(nomatches_ids_array[i])); |
+ } |
+} |
+ |
TEST_F(ExternallyConnectableTest, ErrorWrongFormat) { |
RunTestcase(Testcase("externally_connectable_error_wrong_format.json", |
errors::kErrorInvalid), |