Chromium Code Reviews| Index: content/common/database_identifier_unittest.cc |
| diff --git a/content/common/database_identifier_unittest.cc b/content/common/database_identifier_unittest.cc |
| index f866b7639ef1a722ae2f15f460b4e0b9ced6903a..2e704d89773cc89c66e601fcfd0e06069e7c239e 100644 |
| --- a/content/common/database_identifier_unittest.cc |
| +++ b/content/common/database_identifier_unittest.cc |
| @@ -245,5 +245,33 @@ TEST(DatabaseIdentifierTest, ExtractOriginDataFromIdentifier) { |
| } |
| } |
| +static GURL ToAndFromOriginIdentifier(const GURL origin_url) { |
| + std::string id = storage::GetIdentifierFromOrigin(origin_url); |
| + return storage::GetOriginFromIdentifier(id); |
| +} |
| + |
| +static void TestValidOriginIdentifier(bool expected_result, |
| + const std::string& id) { |
| + EXPECT_EQ(expected_result, |
| + storage::IsValidOriginIdentifier(id)); |
| +} |
| + |
| +TEST(DatabaseIdentifierTest, OriginIdentifiers) { |
|
jsbell
2016/03/02 20:29:09
These are probably redundant with above cases. Lef
|
| + const GURL kFileOrigin(GURL("file:///").GetOrigin()); |
| + const GURL kHttpOrigin(GURL("http://bar/").GetOrigin()); |
| + EXPECT_EQ(kFileOrigin, ToAndFromOriginIdentifier(kFileOrigin)); |
| + EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin)); |
| +} |
| + |
| +TEST(DatabaseIdentifierTest, IsValidOriginIdentifier) { |
| + TestValidOriginIdentifier(true, "http_bar_0"); |
| + TestValidOriginIdentifier(false, ""); |
| + TestValidOriginIdentifier(false, "bad..id"); |
| + TestValidOriginIdentifier(false, "bad/id"); |
| + TestValidOriginIdentifier(false, "bad\\id"); |
| + TestValidOriginIdentifier(false, "http_bad:0_2"); |
| + TestValidOriginIdentifier(false, std::string("bad\0id", 6)); |
| +} |
| + |
| } // namespace |
| } // namespace content |