| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "chrome/common/extensions/extension_manifest_constants.h" | 7 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 8 #include "chrome/common/extensions/features/feature.h" | 8 #include "chrome/common/extensions/features/feature.h" |
| 9 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" | 9 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" |
| 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 public: | 22 public: |
| 23 ExternallyConnectableTest() : channel_(chrome::VersionInfo::CHANNEL_DEV) {} | 23 ExternallyConnectableTest() : channel_(chrome::VersionInfo::CHANNEL_DEV) {} |
| 24 | 24 |
| 25 private: | 25 private: |
| 26 Feature::ScopedCurrentChannel channel_; | 26 Feature::ScopedCurrentChannel channel_; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 TEST_F(ExternallyConnectableTest, IDsAndMatches) { | 29 TEST_F(ExternallyConnectableTest, IDsAndMatches) { |
| 30 scoped_refptr<Extension> extension = | 30 scoped_refptr<Extension> extension = |
| 31 LoadAndExpectSuccess("externally_connectable_ids_and_matches.json"); | 31 LoadAndExpectSuccess("externally_connectable_ids_and_matches.json"); |
| 32 ASSERT_TRUE(extension); | 32 ASSERT_TRUE(extension.get()); |
| 33 | 33 |
| 34 ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); | 34 ExternallyConnectableInfo* info = |
| 35 ExternallyConnectableInfo::Get(extension.get()); |
| 35 ASSERT_TRUE(info); | 36 ASSERT_TRUE(info); |
| 36 | 37 |
| 37 EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", | 38 EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", |
| 38 "ponmlkjihgfedcbaponmlkjihgfedcba")); | 39 "ponmlkjihgfedcbaponmlkjihgfedcba")); |
| 39 | 40 |
| 40 EXPECT_FALSE(info->matches_all_ids); | 41 EXPECT_FALSE(info->matches_all_ids); |
| 41 | 42 |
| 42 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com"))); | 43 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com"))); |
| 43 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com/"))); | 44 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com/"))); |
| 44 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://example.com/index.html"))); | 45 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://example.com/index.html"))); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // ignore the trailing slash. This is kind of a corner case, so let's test it. | 80 // ignore the trailing slash. This is kind of a corner case, so let's test it. |
| 80 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://no.wildcard.path"))); | 81 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://no.wildcard.path"))); |
| 81 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://no.wildcard.path/"))); | 82 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://no.wildcard.path/"))); |
| 82 EXPECT_FALSE(info->matches.MatchesURL( | 83 EXPECT_FALSE(info->matches.MatchesURL( |
| 83 GURL("http://no.wildcard.path/index.html"))); | 84 GURL("http://no.wildcard.path/index.html"))); |
| 84 } | 85 } |
| 85 | 86 |
| 86 TEST_F(ExternallyConnectableTest, IDs) { | 87 TEST_F(ExternallyConnectableTest, IDs) { |
| 87 scoped_refptr<Extension> extension = | 88 scoped_refptr<Extension> extension = |
| 88 LoadAndExpectSuccess("externally_connectable_ids.json"); | 89 LoadAndExpectSuccess("externally_connectable_ids.json"); |
| 89 ASSERT_TRUE(extension); | 90 ASSERT_TRUE(extension.get()); |
| 90 | 91 |
| 91 ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); | 92 ExternallyConnectableInfo* info = |
| 93 ExternallyConnectableInfo::Get(extension.get()); |
| 92 ASSERT_TRUE(info); | 94 ASSERT_TRUE(info); |
| 93 | 95 |
| 94 EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", | 96 EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", |
| 95 "ponmlkjihgfedcbaponmlkjihgfedcba")); | 97 "ponmlkjihgfedcbaponmlkjihgfedcba")); |
| 96 | 98 |
| 97 EXPECT_FALSE(info->matches_all_ids); | 99 EXPECT_FALSE(info->matches_all_ids); |
| 98 | 100 |
| 99 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html"))); | 101 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html"))); |
| 100 } | 102 } |
| 101 | 103 |
| 102 TEST_F(ExternallyConnectableTest, Matches) { | 104 TEST_F(ExternallyConnectableTest, Matches) { |
| 103 scoped_refptr<Extension> extension = | 105 scoped_refptr<Extension> extension = |
| 104 LoadAndExpectSuccess("externally_connectable_matches.json"); | 106 LoadAndExpectSuccess("externally_connectable_matches.json"); |
| 105 ASSERT_TRUE(extension); | 107 ASSERT_TRUE(extension.get()); |
| 106 | 108 |
| 107 ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); | 109 ExternallyConnectableInfo* info = |
| 110 ExternallyConnectableInfo::Get(extension.get()); |
| 108 ASSERT_TRUE(info); | 111 ASSERT_TRUE(info); |
| 109 | 112 |
| 110 EXPECT_THAT(info->ids, ElementsAre()); | 113 EXPECT_THAT(info->ids, ElementsAre()); |
| 111 | 114 |
| 112 EXPECT_FALSE(info->matches_all_ids); | 115 EXPECT_FALSE(info->matches_all_ids); |
| 113 | 116 |
| 114 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com"))); | 117 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com"))); |
| 115 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com/"))); | 118 EXPECT_TRUE(info->matches.MatchesURL(GURL("http://example.com/"))); |
| 116 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://example.com/index.html"))); | 119 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://example.com/index.html"))); |
| 117 | 120 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 132 EXPECT_FALSE( | 135 EXPECT_FALSE( |
| 133 info->matches.MatchesURL(GURL("http://foo.chromium.org/index.html"))); | 136 info->matches.MatchesURL(GURL("http://foo.chromium.org/index.html"))); |
| 134 | 137 |
| 135 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://yahoo.com"))); | 138 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://yahoo.com"))); |
| 136 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://yahoo.com/"))); | 139 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://yahoo.com/"))); |
| 137 } | 140 } |
| 138 | 141 |
| 139 TEST_F(ExternallyConnectableTest, AllIDs) { | 142 TEST_F(ExternallyConnectableTest, AllIDs) { |
| 140 scoped_refptr<Extension> extension = | 143 scoped_refptr<Extension> extension = |
| 141 LoadAndExpectSuccess("externally_connectable_all_ids.json"); | 144 LoadAndExpectSuccess("externally_connectable_all_ids.json"); |
| 142 ASSERT_TRUE(extension); | 145 ASSERT_TRUE(extension.get()); |
| 143 | 146 |
| 144 ExternallyConnectableInfo* info = ExternallyConnectableInfo::Get(extension); | 147 ExternallyConnectableInfo* info = |
| 148 ExternallyConnectableInfo::Get(extension.get()); |
| 145 ASSERT_TRUE(info); | 149 ASSERT_TRUE(info); |
| 146 | 150 |
| 147 EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", | 151 EXPECT_THAT(info->ids, ElementsAre("abcdefghijklmnopabcdefghijklmnop", |
| 148 "ponmlkjihgfedcbaponmlkjihgfedcba")); | 152 "ponmlkjihgfedcbaponmlkjihgfedcba")); |
| 149 | 153 |
| 150 EXPECT_TRUE(info->matches_all_ids); | 154 EXPECT_TRUE(info->matches_all_ids); |
| 151 | 155 |
| 152 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html"))); | 156 EXPECT_FALSE(info->matches.MatchesURL(GURL("http://google.com/index.html"))); |
| 153 } | 157 } |
| 154 | 158 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 Testcase( | 222 Testcase( |
| 219 "externally_connectable_error_unknown_tld.json", | 223 "externally_connectable_error_unknown_tld.json", |
| 220 ErrorUtils::FormatErrorMessage( | 224 ErrorUtils::FormatErrorMessage( |
| 221 errors::kErrorTopLevelDomainsNotAllowed, | 225 errors::kErrorTopLevelDomainsNotAllowed, |
| 222 "notatld", | 226 "notatld", |
| 223 "http://*.notatld/*")), | 227 "http://*.notatld/*")), |
| 224 EXPECT_TYPE_ERROR); | 228 EXPECT_TYPE_ERROR); |
| 225 } | 229 } |
| 226 | 230 |
| 227 } // namespace extensions | 231 } // namespace extensions |
| OLD | NEW |