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

Unified Diff: chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc

Issue 16174005: Implement externally_connectable! Web pages can now communicate directly with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: absolute path... Created 7 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 side-by-side diff with in-line comments
Download patch
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 379c6774f11dcd7319ff0c9babab720e0b147c0a..c2da186b59b5bdb8da8b2830b38bb58aa4720225 100644
--- a/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc
+++ b/chrome/common/extensions/manifest_handlers/externally_connectable_unittest.cc
@@ -40,7 +40,7 @@ TEST_F(ExternallyConnectableTest, IDsAndMatches) {
EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop",
"ponmlkjihgfedcbaponmlkjihgfedcba"));
- EXPECT_FALSE(info->matches_all_ids);
+ EXPECT_FALSE(info->all_ids);
EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com")));
EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com/")));
@@ -100,7 +100,7 @@ TEST_F(ExternallyConnectableTest, IDs) {
EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop",
"ponmlkjihgfedcbaponmlkjihgfedcba"));
- EXPECT_FALSE(info->matches_all_ids);
+ EXPECT_FALSE(info->all_ids);
EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html")));
}
@@ -118,7 +118,7 @@ TEST_F(ExternallyConnectableTest, Matches) {
EXPECT_THAT(info->ids, ElementsAre());
- EXPECT_FALSE(info->matches_all_ids);
+ EXPECT_FALSE(info->all_ids);
EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com")));
EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com/")));
@@ -159,11 +159,38 @@ TEST_F(ExternallyConnectableTest, AllIDs) {
EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop",
"ponmlkjihgfedcbaponmlkjihgfedcba"));
- EXPECT_TRUE(info->matches_all_ids);
+ EXPECT_TRUE(info->all_ids);
EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html")));
}
+TEST_F(ExternallyConnectableTest, IdCanConnect) {
+ // 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" };
+
+ // all_ids = false.
+ {
+ ExternallyConnectableInfo info(URLPatternSet(), matches_ids, false);
+ for (size_t i = 0; i < matches_ids.size(); ++i)
+ EXPECT_TRUE(info.IdCanConnect(matches_ids[i]));
+ for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i)
+ EXPECT_FALSE(info.IdCanConnect(nomatches_ids_array[i]));
+ }
+
+ // all_ids = true.
+ {
+ ExternallyConnectableInfo info(URLPatternSet(), matches_ids, true);
+ for (size_t i = 0; i < matches_ids.size(); ++i)
+ EXPECT_TRUE(info.IdCanConnect(matches_ids[i]));
+ for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i)
+ EXPECT_TRUE(info.IdCanConnect(nomatches_ids_array[i]));
+ }
+}
+
TEST_F(ExternallyConnectableTest, ErrorWrongFormat) {
RunTestcase(Testcase("externally_connectable_error_wrong_format.json",
errors::kErrorInvalid),
« no previous file with comments | « chrome/common/extensions/manifest_handlers/externally_connectable.cc ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698