| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/strings/string_piece.h" | 5 #include "base/strings/string_piece.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "webkit/browser/database/database_util.h" | 8 #include "webkit/browser/database/database_util.h" |
| 9 #include "webkit/common/database/database_identifier.h" | 9 #include "webkit/common/database/database_identifier.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 std::string id = webkit_database::GetIdentifierFromOrigin(origin_url); | 33 std::string id = webkit_database::GetIdentifierFromOrigin(origin_url); |
| 34 return webkit_database::GetOriginFromIdentifier(id); | 34 return webkit_database::GetOriginFromIdentifier(id); |
| 35 } | 35 } |
| 36 | 36 |
| 37 static void TestValidOriginIdentifier(bool expected_result, | 37 static void TestValidOriginIdentifier(bool expected_result, |
| 38 const std::string& id) { | 38 const std::string& id) { |
| 39 EXPECT_EQ(expected_result, | 39 EXPECT_EQ(expected_result, |
| 40 DatabaseUtil::IsValidOriginIdentifier(id)); | 40 DatabaseUtil::IsValidOriginIdentifier(id)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 namespace webkit_database { | 43 namespace content { |
| 44 | 44 |
| 45 // Test DatabaseUtil::CrackVfsFilePath on various inputs. | 45 // Test DatabaseUtil::CrackVfsFilePath on various inputs. |
| 46 TEST(DatabaseUtilTest, CrackVfsFilePathTest) { | 46 TEST(DatabaseUtilTest, CrackVfsFilePathTest) { |
| 47 TestVfsFilePath(true, "origin/#", "origin", "", ""); | 47 TestVfsFilePath(true, "origin/#", "origin", "", ""); |
| 48 TestVfsFilePath(true, "origin/#suffix", "origin", "", "suffix"); | 48 TestVfsFilePath(true, "origin/#suffix", "origin", "", "suffix"); |
| 49 TestVfsFilePath(true, "origin/db_name#", "origin", "db_name", ""); | 49 TestVfsFilePath(true, "origin/db_name#", "origin", "db_name", ""); |
| 50 TestVfsFilePath(true, "origin/db_name#suffix", "origin", "db_name", "suffix"); | 50 TestVfsFilePath(true, "origin/db_name#suffix", "origin", "db_name", "suffix"); |
| 51 TestVfsFilePath(false, "origindb_name#"); | 51 TestVfsFilePath(false, "origindb_name#"); |
| 52 TestVfsFilePath(false, "origindb_name#suffix"); | 52 TestVfsFilePath(false, "origindb_name#suffix"); |
| 53 TestVfsFilePath(false, "origin/db_name"); | 53 TestVfsFilePath(false, "origin/db_name"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 | 65 |
| 66 TEST(DatabaseUtilTest, IsValidOriginIdentifier) { | 66 TEST(DatabaseUtilTest, IsValidOriginIdentifier) { |
| 67 TestValidOriginIdentifier(true, "http_bar_0"); | 67 TestValidOriginIdentifier(true, "http_bar_0"); |
| 68 TestValidOriginIdentifier(true, ""); | 68 TestValidOriginIdentifier(true, ""); |
| 69 TestValidOriginIdentifier(false, "bad..id"); | 69 TestValidOriginIdentifier(false, "bad..id"); |
| 70 TestValidOriginIdentifier(false, "bad/id"); | 70 TestValidOriginIdentifier(false, "bad/id"); |
| 71 TestValidOriginIdentifier(false, "bad\\id"); | 71 TestValidOriginIdentifier(false, "bad\\id"); |
| 72 TestValidOriginIdentifier(false, std::string("bad\0id", 6)); | 72 TestValidOriginIdentifier(false, std::string("bad\0id", 6)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace webkit_database | 75 } // namespace content |
| OLD | NEW |