| 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 "net/base/registry_controlled_domains/registry_controlled_domain.h" | 5 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "url/gurl.h" | 7 #include "url/gurl.h" |
| 8 | 8 |
| 9 namespace { | 9 #include "effective_tld_names_unittest1.cc" |
| 10 namespace test1 { | 10 static const char* const Perfect_Hash_Test1_stringpool = stringpool1; |
| 11 #include "effective_tld_names_unittest1-inc.cc" | 11 #undef TOTAL_KEYWORDS |
| 12 } | 12 #undef MIN_WORD_LENGTH |
| 13 namespace test2 { | 13 #undef MAX_WORD_LENGTH |
| 14 #include "effective_tld_names_unittest2-inc.cc" | 14 #undef MIN_HASH_VALUE |
| 15 } | 15 #undef MAX_HASH_VALUE |
| 16 namespace test3 { | 16 #include "effective_tld_names_unittest2.cc" |
| 17 #include "effective_tld_names_unittest3-inc.cc" | 17 static const char* const Perfect_Hash_Test2_stringpool = stringpool2; |
| 18 } | |
| 19 namespace test4 { | |
| 20 #include "effective_tld_names_unittest4-inc.cc" | |
| 21 } | |
| 22 namespace test5 { | |
| 23 #include "effective_tld_names_unittest5-inc.cc" | |
| 24 } | |
| 25 namespace test6 { | |
| 26 #include "effective_tld_names_unittest6-inc.cc" | |
| 27 } | |
| 28 } // namespace | |
| 29 | 18 |
| 30 namespace net { | 19 namespace net { |
| 31 namespace registry_controlled_domains { | 20 namespace registry_controlled_domains { |
| 32 namespace { | 21 namespace { |
| 33 | 22 |
| 34 std::string GetDomainFromURL(const std::string& url) { | 23 std::string GetDomainFromURL(const std::string& url) { |
| 35 return GetDomainAndRegistry(GURL(url), EXCLUDE_PRIVATE_REGISTRIES); | 24 return GetDomainAndRegistry(GURL(url), EXCLUDE_PRIVATE_REGISTRIES); |
| 36 } | 25 } |
| 37 | 26 |
| 38 std::string GetDomainFromHost(const std::string& host) { | 27 std::string GetDomainFromHost(const std::string& host) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 54 unknown_filter, | 43 unknown_filter, |
| 55 INCLUDE_PRIVATE_REGISTRIES); | 44 INCLUDE_PRIVATE_REGISTRIES); |
| 56 } | 45 } |
| 57 | 46 |
| 58 size_t GetRegistryLengthFromHost( | 47 size_t GetRegistryLengthFromHost( |
| 59 const std::string& host, | 48 const std::string& host, |
| 60 UnknownRegistryFilter unknown_filter) { | 49 UnknownRegistryFilter unknown_filter) { |
| 61 return GetRegistryLength(host, unknown_filter, EXCLUDE_PRIVATE_REGISTRIES); | 50 return GetRegistryLength(host, unknown_filter, EXCLUDE_PRIVATE_REGISTRIES); |
| 62 } | 51 } |
| 63 | 52 |
| 64 size_t GetRegistryLengthFromHostIncludingPrivate( | |
| 65 const std::string& host, | |
| 66 UnknownRegistryFilter unknown_filter) { | |
| 67 return GetRegistryLength(host, unknown_filter, INCLUDE_PRIVATE_REGISTRIES); | |
| 68 } | |
| 69 | |
| 70 bool CompareDomains(const std::string& url1, const std::string& url2) { | 53 bool CompareDomains(const std::string& url1, const std::string& url2) { |
| 71 GURL g1 = GURL(url1); | 54 GURL g1 = GURL(url1); |
| 72 GURL g2 = GURL(url2); | 55 GURL g2 = GURL(url2); |
| 73 return SameDomainOrHost(g1, g2, EXCLUDE_PRIVATE_REGISTRIES); | 56 return SameDomainOrHost(g1, g2, EXCLUDE_PRIVATE_REGISTRIES); |
| 74 } | 57 } |
| 75 | 58 |
| 76 } // namespace | 59 } // namespace |
| 77 | 60 |
| 78 class RegistryControlledDomainTest : public testing::Test { | 61 class RegistryControlledDomainTest : public testing::Test { |
| 79 protected: | 62 protected: |
| 80 template <typename Graph> | 63 void UseDomainData(FindDomainPtr function, const char* const stringpool) { |
| 81 void UseDomainData(const Graph& graph) { | 64 SetFindDomainFunctionAndStringPoolForTesting(function, stringpool); |
| 82 SetFindDomainGraph(graph, sizeof(Graph)); | |
| 83 } | 65 } |
| 84 | 66 |
| 85 virtual void TearDown() { SetFindDomainGraph(); } | 67 virtual void TearDown() { |
| 68 SetFindDomainFunctionAndStringPoolForTesting(NULL, NULL); |
| 69 } |
| 86 }; | 70 }; |
| 87 | 71 |
| 88 TEST_F(RegistryControlledDomainTest, TestGetDomainAndRegistry) { | 72 TEST_F(RegistryControlledDomainTest, TestGetDomainAndRegistry) { |
| 89 UseDomainData(test1::kDafsa); | 73 UseDomainData(Perfect_Hash_Test1::FindDomain, Perfect_Hash_Test1_stringpool); |
| 90 | 74 |
| 91 // Test GURL version of GetDomainAndRegistry(). | 75 // Test GURL version of GetDomainAndRegistry(). |
| 92 EXPECT_EQ("baz.jp", GetDomainFromURL("http://a.baz.jp/file.html")); // 1 | 76 EXPECT_EQ("baz.jp", GetDomainFromURL("http://a.baz.jp/file.html")); // 1 |
| 93 EXPECT_EQ("baz.jp.", GetDomainFromURL("http://a.baz.jp./file.html")); // 1 | 77 EXPECT_EQ("baz.jp.", GetDomainFromURL("http://a.baz.jp./file.html")); // 1 |
| 94 EXPECT_EQ("", GetDomainFromURL("http://ac.jp")); // 2 | 78 EXPECT_EQ("", GetDomainFromURL("http://ac.jp")); // 2 |
| 95 EXPECT_EQ("", GetDomainFromURL("http://a.bar.jp")); // 3 | 79 EXPECT_EQ("", GetDomainFromURL("http://a.bar.jp")); // 3 |
| 96 EXPECT_EQ("", GetDomainFromURL("http://bar.jp")); // 3 | 80 EXPECT_EQ("", GetDomainFromURL("http://bar.jp")); // 3 |
| 97 EXPECT_EQ("", GetDomainFromURL("http://baz.bar.jp")); // 3 4 | 81 EXPECT_EQ("", GetDomainFromURL("http://baz.bar.jp")); // 3 4 |
| 98 EXPECT_EQ("a.b.baz.bar.jp", GetDomainFromURL("http://a.b.baz.bar.jp")); | 82 EXPECT_EQ("a.b.baz.bar.jp", GetDomainFromURL("http://a.b.baz.bar.jp")); |
| 99 // 4 | 83 // 4 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 122 |
| 139 EXPECT_EQ("", GetDomainFromHost(std::string())); | 123 EXPECT_EQ("", GetDomainFromHost(std::string())); |
| 140 EXPECT_EQ("", GetDomainFromHost("foo.com..")); | 124 EXPECT_EQ("", GetDomainFromHost("foo.com..")); |
| 141 EXPECT_EQ("", GetDomainFromHost("...")); | 125 EXPECT_EQ("", GetDomainFromHost("...")); |
| 142 EXPECT_EQ("", GetDomainFromHost("192.168.0.1")); | 126 EXPECT_EQ("", GetDomainFromHost("192.168.0.1")); |
| 143 EXPECT_EQ("", GetDomainFromHost("localhost.")); | 127 EXPECT_EQ("", GetDomainFromHost("localhost.")); |
| 144 EXPECT_EQ("", GetDomainFromHost(".localhost.")); | 128 EXPECT_EQ("", GetDomainFromHost(".localhost.")); |
| 145 } | 129 } |
| 146 | 130 |
| 147 TEST_F(RegistryControlledDomainTest, TestGetRegistryLength) { | 131 TEST_F(RegistryControlledDomainTest, TestGetRegistryLength) { |
| 148 UseDomainData(test1::kDafsa); | 132 UseDomainData(Perfect_Hash_Test1::FindDomain, Perfect_Hash_Test1_stringpool); |
| 149 | 133 |
| 150 // Test GURL version of GetRegistryLength(). | 134 // Test GURL version of GetRegistryLength(). |
| 151 EXPECT_EQ(2U, GetRegistryLengthFromURL("http://a.baz.jp/file.html", | 135 EXPECT_EQ(2U, GetRegistryLengthFromURL("http://a.baz.jp/file.html", |
| 152 EXCLUDE_UNKNOWN_REGISTRIES)); // 1 | 136 EXCLUDE_UNKNOWN_REGISTRIES)); // 1 |
| 153 EXPECT_EQ(3U, GetRegistryLengthFromURL("http://a.baz.jp./file.html", | 137 EXPECT_EQ(3U, GetRegistryLengthFromURL("http://a.baz.jp./file.html", |
| 154 EXCLUDE_UNKNOWN_REGISTRIES)); // 1 | 138 EXCLUDE_UNKNOWN_REGISTRIES)); // 1 |
| 155 EXPECT_EQ(0U, GetRegistryLengthFromURL("http://ac.jp", | 139 EXPECT_EQ(0U, GetRegistryLengthFromURL("http://ac.jp", |
| 156 EXCLUDE_UNKNOWN_REGISTRIES)); // 2 | 140 EXCLUDE_UNKNOWN_REGISTRIES)); // 2 |
| 157 EXPECT_EQ(0U, GetRegistryLengthFromURL("http://a.bar.jp", | 141 EXPECT_EQ(0U, GetRegistryLengthFromURL("http://a.bar.jp", |
| 158 EXCLUDE_UNKNOWN_REGISTRIES)); // 3 | 142 EXCLUDE_UNKNOWN_REGISTRIES)); // 3 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 EXCLUDE_UNKNOWN_REGISTRIES)); | 241 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 258 EXPECT_EQ(0U, GetRegistryLengthFromHost("localhost", | 242 EXPECT_EQ(0U, GetRegistryLengthFromHost("localhost", |
| 259 INCLUDE_UNKNOWN_REGISTRIES)); | 243 INCLUDE_UNKNOWN_REGISTRIES)); |
| 260 EXPECT_EQ(0U, GetRegistryLengthFromHost("localhost.", | 244 EXPECT_EQ(0U, GetRegistryLengthFromHost("localhost.", |
| 261 EXCLUDE_UNKNOWN_REGISTRIES)); | 245 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 262 EXPECT_EQ(0U, GetRegistryLengthFromHost("localhost.", | 246 EXPECT_EQ(0U, GetRegistryLengthFromHost("localhost.", |
| 263 INCLUDE_UNKNOWN_REGISTRIES)); | 247 INCLUDE_UNKNOWN_REGISTRIES)); |
| 264 } | 248 } |
| 265 | 249 |
| 266 TEST_F(RegistryControlledDomainTest, TestSameDomainOrHost) { | 250 TEST_F(RegistryControlledDomainTest, TestSameDomainOrHost) { |
| 267 UseDomainData(test2::kDafsa); | 251 UseDomainData(Perfect_Hash_Test2::FindDomain, Perfect_Hash_Test2_stringpool); |
| 268 | 252 |
| 269 EXPECT_TRUE(CompareDomains("http://a.b.bar.jp/file.html", | 253 EXPECT_TRUE(CompareDomains("http://a.b.bar.jp/file.html", |
| 270 "http://a.b.bar.jp/file.html")); // b.bar.jp | 254 "http://a.b.bar.jp/file.html")); // b.bar.jp |
| 271 EXPECT_TRUE(CompareDomains("http://a.b.bar.jp/file.html", | 255 EXPECT_TRUE(CompareDomains("http://a.b.bar.jp/file.html", |
| 272 "http://b.b.bar.jp/file.html")); // b.bar.jp | 256 "http://b.b.bar.jp/file.html")); // b.bar.jp |
| 273 EXPECT_FALSE(CompareDomains("http://a.foo.jp/file.html", // foo.jp | 257 EXPECT_FALSE(CompareDomains("http://a.foo.jp/file.html", // foo.jp |
| 274 "http://a.not.jp/file.html")); // not.jp | 258 "http://a.not.jp/file.html")); // not.jp |
| 275 EXPECT_FALSE(CompareDomains("http://a.foo.jp/file.html", // foo.jp | 259 EXPECT_FALSE(CompareDomains("http://a.foo.jp/file.html", // foo.jp |
| 276 "http://a.foo.jp./file.html")); // foo.jp. | 260 "http://a.foo.jp./file.html")); // foo.jp. |
| 277 EXPECT_FALSE(CompareDomains("http://a.com/file.html", // a.com | 261 EXPECT_FALSE(CompareDomains("http://a.com/file.html", // a.com |
| (...skipping 26 matching lines...) Expand all Loading... |
| 304 EXCLUDE_UNKNOWN_REGISTRIES)); | 288 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 305 EXPECT_EQ(3U, GetRegistryLengthFromURL("http://ferretcentral.org", | 289 EXPECT_EQ(3U, GetRegistryLengthFromURL("http://ferretcentral.org", |
| 306 EXCLUDE_UNKNOWN_REGISTRIES)); | 290 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 307 EXPECT_EQ(0U, GetRegistryLengthFromURL("http://nowhere.notavaliddomain", | 291 EXPECT_EQ(0U, GetRegistryLengthFromURL("http://nowhere.notavaliddomain", |
| 308 EXCLUDE_UNKNOWN_REGISTRIES)); | 292 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 309 EXPECT_EQ(15U, GetRegistryLengthFromURL("http://nowhere.notavaliddomain", | 293 EXPECT_EQ(15U, GetRegistryLengthFromURL("http://nowhere.notavaliddomain", |
| 310 INCLUDE_UNKNOWN_REGISTRIES)); | 294 INCLUDE_UNKNOWN_REGISTRIES)); |
| 311 } | 295 } |
| 312 | 296 |
| 313 TEST_F(RegistryControlledDomainTest, TestPrivateRegistryHandling) { | 297 TEST_F(RegistryControlledDomainTest, TestPrivateRegistryHandling) { |
| 314 UseDomainData(test1::kDafsa); | 298 UseDomainData(Perfect_Hash_Test1::FindDomain, Perfect_Hash_Test1_stringpool); |
| 315 | 299 |
| 316 // Testing the same dataset for INCLUDE_PRIVATE_REGISTRIES and | 300 // Testing the same dataset for INCLUDE_PRIVATE_REGISTRIES and |
| 317 // EXCLUDE_PRIVATE_REGISTRIES arguments. | 301 // EXCLUDE_PRIVATE_REGISTRIES arguments. |
| 318 // For the domain data used for this test, the private registries are | 302 // For the domain data used for this test, the private registries are |
| 319 // 'priv.no' and 'private'. | 303 // 'priv.no' and 'private'. |
| 320 | 304 |
| 321 // Non-private registries. | 305 // Non-private registries. |
| 322 EXPECT_EQ(2U, GetRegistryLengthFromURL("http://priv.no", | 306 EXPECT_EQ(2U, GetRegistryLengthFromURL("http://priv.no", |
| 323 EXCLUDE_UNKNOWN_REGISTRIES)); | 307 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 324 EXPECT_EQ(2U, GetRegistryLengthFromURL("http://foo.priv.no", | 308 EXPECT_EQ(2U, GetRegistryLengthFromURL("http://foo.priv.no", |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 GetRegistryLengthFromURLIncludingPrivate("http://foo.private", | 340 GetRegistryLengthFromURLIncludingPrivate("http://foo.private", |
| 357 EXCLUDE_UNKNOWN_REGISTRIES)); | 341 EXCLUDE_UNKNOWN_REGISTRIES)); |
| 358 EXPECT_EQ(0U, | 342 EXPECT_EQ(0U, |
| 359 GetRegistryLengthFromURLIncludingPrivate("http://private", | 343 GetRegistryLengthFromURLIncludingPrivate("http://private", |
| 360 INCLUDE_UNKNOWN_REGISTRIES)); | 344 INCLUDE_UNKNOWN_REGISTRIES)); |
| 361 EXPECT_EQ(7U, | 345 EXPECT_EQ(7U, |
| 362 GetRegistryLengthFromURLIncludingPrivate("http://foo.private", | 346 GetRegistryLengthFromURLIncludingPrivate("http://foo.private", |
| 363 INCLUDE_UNKNOWN_REGISTRIES)); | 347 INCLUDE_UNKNOWN_REGISTRIES)); |
| 364 } | 348 } |
| 365 | 349 |
| 366 TEST_F(RegistryControlledDomainTest, TestDafsaTwoByteOffsets) { | |
| 367 UseDomainData(test3::kDafsa); | |
| 368 | 350 |
| 369 // Testing to lookup keys in a DAFSA with two byte offsets. | |
| 370 // This DAFSA is constructed so that labels begin and end with unique | |
| 371 // characters, which makes it impossible to merge labels. Each inner node | |
| 372 // is about 100 bytes and a one byte offset can at most add 64 bytes to | |
| 373 // previous offset. Thus the paths must go over two byte offsets. | |
| 374 | |
| 375 const char* key0 = | |
| 376 "a.b.6____________________________________________________" | |
| 377 "________________________________________________6"; | |
| 378 const char* key1 = | |
| 379 "a.b.7____________________________________________________" | |
| 380 "________________________________________________7"; | |
| 381 const char* key2 = | |
| 382 "a.b.a____________________________________________________" | |
| 383 "________________________________________________8"; | |
| 384 | |
| 385 EXPECT_EQ(102U, GetRegistryLengthFromHost(key0, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 386 EXPECT_EQ(0U, GetRegistryLengthFromHost(key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 387 EXPECT_EQ(102U, | |
| 388 GetRegistryLengthFromHostIncludingPrivate( | |
| 389 key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 390 EXPECT_EQ(0U, GetRegistryLengthFromHost(key2, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 391 } | |
| 392 | |
| 393 TEST_F(RegistryControlledDomainTest, TestDafsaThreeByteOffsets) { | |
| 394 UseDomainData(test4::kDafsa); | |
| 395 | |
| 396 // Testing to lookup keys in a DAFSA with three byte offsets. | |
| 397 // This DAFSA is constructed so that labels begin and end with unique | |
| 398 // characters, which makes it impossible to merge labels. The byte array | |
| 399 // has a size of ~54k. A two byte offset can add at most add 8k to the | |
| 400 // previous offset. Since we can skip only forward in memory, the nodes | |
| 401 // representing the return values must be located near the end of the byte | |
| 402 // array. The probability that we can reach from an arbitrary inner node to | |
| 403 // a return value without using a three byte offset is small (but not zero). | |
| 404 // The test is repeated with some different keys and with a reasonable | |
| 405 // probability at least one of the tested paths has go over a three byte | |
| 406 // offset. | |
| 407 | |
| 408 const char* key0 = | |
| 409 "a.b.Z6___________________________________________________" | |
| 410 "_________________________________________________Z6"; | |
| 411 const char* key1 = | |
| 412 "a.b.Z7___________________________________________________" | |
| 413 "_________________________________________________Z7"; | |
| 414 const char* key2 = | |
| 415 "a.b.Za___________________________________________________" | |
| 416 "_________________________________________________Z8"; | |
| 417 | |
| 418 EXPECT_EQ(104U, GetRegistryLengthFromHost(key0, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 419 EXPECT_EQ(0U, GetRegistryLengthFromHost(key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 420 EXPECT_EQ(104U, | |
| 421 GetRegistryLengthFromHostIncludingPrivate( | |
| 422 key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 423 EXPECT_EQ(0U, GetRegistryLengthFromHost(key2, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 424 } | |
| 425 | |
| 426 TEST_F(RegistryControlledDomainTest, TestDafsaJoinedPrefixes) { | |
| 427 UseDomainData(test5::kDafsa); | |
| 428 | |
| 429 // Testing to lookup keys in a DAFSA with compressed prefixes. | |
| 430 // This DAFSA is constructed from words with similar prefixes but distinct | |
| 431 // suffixes. The DAFSA will then form a trie with the implicit source node | |
| 432 // as root. | |
| 433 | |
| 434 const char* key0 = "a.b.ai"; | |
| 435 const char* key1 = "a.b.bj"; | |
| 436 const char* key2 = "a.b.aak"; | |
| 437 const char* key3 = "a.b.bbl"; | |
| 438 const char* key4 = "a.b.aaa"; | |
| 439 const char* key5 = "a.b.bbb"; | |
| 440 const char* key6 = "a.b.aaaam"; | |
| 441 const char* key7 = "a.b.bbbbn"; | |
| 442 | |
| 443 EXPECT_EQ(2U, GetRegistryLengthFromHost(key0, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 444 EXPECT_EQ(0U, GetRegistryLengthFromHost(key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 445 EXPECT_EQ(2U, | |
| 446 GetRegistryLengthFromHostIncludingPrivate( | |
| 447 key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 448 EXPECT_EQ(3U, GetRegistryLengthFromHost(key2, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 449 EXPECT_EQ(0U, GetRegistryLengthFromHost(key3, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 450 EXPECT_EQ(3U, | |
| 451 GetRegistryLengthFromHostIncludingPrivate( | |
| 452 key3, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 453 EXPECT_EQ(0U, | |
| 454 GetRegistryLengthFromHostIncludingPrivate( | |
| 455 key4, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 456 EXPECT_EQ(0U, | |
| 457 GetRegistryLengthFromHostIncludingPrivate( | |
| 458 key5, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 459 EXPECT_EQ(5U, GetRegistryLengthFromHost(key6, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 460 EXPECT_EQ(5U, GetRegistryLengthFromHost(key7, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 461 } | |
| 462 | |
| 463 TEST_F(RegistryControlledDomainTest, TestDafsaJoinedSuffixes) { | |
| 464 UseDomainData(test6::kDafsa); | |
| 465 | |
| 466 // Testing to lookup keys in a DAFSA with compressed suffixes. | |
| 467 // This DAFSA is constructed from words with similar suffixes but distinct | |
| 468 // prefixes. The DAFSA will then form a trie with the implicit sink node as | |
| 469 // root. | |
| 470 | |
| 471 const char* key0 = "a.b.ia"; | |
| 472 const char* key1 = "a.b.jb"; | |
| 473 const char* key2 = "a.b.kaa"; | |
| 474 const char* key3 = "a.b.lbb"; | |
| 475 const char* key4 = "a.b.aaa"; | |
| 476 const char* key5 = "a.b.bbb"; | |
| 477 const char* key6 = "a.b.maaaa"; | |
| 478 const char* key7 = "a.b.nbbbb"; | |
| 479 | |
| 480 EXPECT_EQ(2U, GetRegistryLengthFromHost(key0, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 481 EXPECT_EQ(0U, GetRegistryLengthFromHost(key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 482 EXPECT_EQ(2U, | |
| 483 GetRegistryLengthFromHostIncludingPrivate( | |
| 484 key1, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 485 EXPECT_EQ(3U, GetRegistryLengthFromHost(key2, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 486 EXPECT_EQ(0U, GetRegistryLengthFromHost(key3, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 487 EXPECT_EQ(3U, | |
| 488 GetRegistryLengthFromHostIncludingPrivate( | |
| 489 key3, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 490 EXPECT_EQ(0U, | |
| 491 GetRegistryLengthFromHostIncludingPrivate( | |
| 492 key4, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 493 EXPECT_EQ(0U, | |
| 494 GetRegistryLengthFromHostIncludingPrivate( | |
| 495 key5, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 496 EXPECT_EQ(5U, GetRegistryLengthFromHost(key6, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 497 EXPECT_EQ(5U, GetRegistryLengthFromHost(key7, EXCLUDE_UNKNOWN_REGISTRIES)); | |
| 498 } | |
| 499 } // namespace registry_controlled_domains | 351 } // namespace registry_controlled_domains |
| 500 } // namespace net | 352 } // namespace net |
| OLD | NEW |