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

Side by Side Diff: webkit/browser/database/database_util_unittest.cc

Issue 16879013: Use chromium logic for database identifier<->origin conversions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove webkit/base/origin_url_conversions 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/base/origin_url_conversions.h"
9 #include "webkit/browser/database/database_util.h" 8 #include "webkit/browser/database/database_util.h"
9 #include "webkit/common/database/database_identifier.h"
10 10
11 using webkit_database::DatabaseUtil; 11 using webkit_database::DatabaseUtil;
12 12
13 static void TestVfsFilePath(bool expected_result, 13 static void TestVfsFilePath(bool expected_result,
14 const char* vfs_file_name, 14 const char* vfs_file_name,
15 const char* expected_origin_identifier = "", 15 const char* expected_origin_identifier = "",
16 const char* expected_database_name = "", 16 const char* expected_database_name = "",
17 const char* expected_sqlite_suffix = "") { 17 const char* expected_sqlite_suffix = "") {
18 std::string origin_identifier; 18 std::string origin_identifier;
19 base::string16 database_name; 19 base::string16 database_name;
20 base::string16 sqlite_suffix; 20 base::string16 sqlite_suffix;
21 EXPECT_EQ(expected_result, 21 EXPECT_EQ(expected_result,
22 DatabaseUtil::CrackVfsFileName(ASCIIToUTF16(vfs_file_name), 22 DatabaseUtil::CrackVfsFileName(ASCIIToUTF16(vfs_file_name),
23 &origin_identifier, 23 &origin_identifier,
24 &database_name, 24 &database_name,
25 &sqlite_suffix)); 25 &sqlite_suffix));
26 EXPECT_EQ(expected_origin_identifier, origin_identifier); 26 EXPECT_EQ(expected_origin_identifier, origin_identifier);
27 EXPECT_EQ(ASCIIToUTF16(expected_database_name), database_name); 27 EXPECT_EQ(ASCIIToUTF16(expected_database_name), database_name);
28 EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix); 28 EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix);
29 } 29 }
30 30
31 static GURL ToAndFromOriginIdentifier(const GURL origin_url) { 31 static GURL ToAndFromOriginIdentifier(const GURL origin_url) {
32 std::string id = webkit_base::GetOriginIdentifierFromURL(origin_url); 32 std::string id = webkit_database::GetIdentifierFromOrigin(origin_url);
33 return webkit_base::GetOriginURLFromIdentifier(id); 33 return webkit_database::GetOriginFromIdentifier(id);
34 } 34 }
35 35
36 static void TestValidOriginIdentifier(bool expected_result, 36 static void TestValidOriginIdentifier(bool expected_result,
37 const std::string& id) { 37 const std::string& id) {
38 EXPECT_EQ(expected_result, 38 EXPECT_EQ(expected_result,
39 DatabaseUtil::IsValidOriginIdentifier(id)); 39 DatabaseUtil::IsValidOriginIdentifier(id));
40 } 40 }
41 41
42 namespace webkit_database { 42 namespace webkit_database {
43 43
(...skipping 21 matching lines...) Expand all
65 TEST(DatabaseUtilTest, IsValidOriginIdentifier) { 65 TEST(DatabaseUtilTest, IsValidOriginIdentifier) {
66 TestValidOriginIdentifier(true, "http_bar_0"); 66 TestValidOriginIdentifier(true, "http_bar_0");
67 TestValidOriginIdentifier(true, ""); 67 TestValidOriginIdentifier(true, "");
68 TestValidOriginIdentifier(false, "bad..id"); 68 TestValidOriginIdentifier(false, "bad..id");
69 TestValidOriginIdentifier(false, "bad/id"); 69 TestValidOriginIdentifier(false, "bad/id");
70 TestValidOriginIdentifier(false, "bad\\id"); 70 TestValidOriginIdentifier(false, "bad\\id");
71 TestValidOriginIdentifier(false, std::string("bad\0id", 6)); 71 TestValidOriginIdentifier(false, std::string("bad\0id", 6));
72 } 72 }
73 73
74 } // namespace webkit_database 74 } // namespace webkit_database
OLDNEW
« no previous file with comments | « webkit/browser/database/database_util.cc ('k') | webkit/browser/dom_storage/dom_storage_area.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698