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

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

Issue 7053007: We need this work-around for file:/// URIs as (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
« no previous file with comments | « webkit/database/database_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "webkit/database/database_util.h" 7 #include "webkit/database/database_util.h"
8 8
9 using webkit_database::DatabaseUtil; 9 using webkit_database::DatabaseUtil;
10 10
11 static void TestVfsFilePath(bool expected_result, 11 static void TestVfsFilePath(bool expected_result,
12 const char* vfs_file_name, 12 const char* vfs_file_name,
13 const char* expected_origin_identifier = "", 13 const char* expected_origin_identifier = "",
14 const char* expected_database_name = "", 14 const char* expected_database_name = "",
15 const char* expected_sqlite_suffix = "") { 15 const char* expected_sqlite_suffix = "") {
16 string16 origin_identifier; 16 string16 origin_identifier;
17 string16 database_name; 17 string16 database_name;
18 string16 sqlite_suffix; 18 string16 sqlite_suffix;
19 EXPECT_EQ(expected_result, 19 EXPECT_EQ(expected_result,
20 DatabaseUtil::CrackVfsFileName(ASCIIToUTF16(vfs_file_name), 20 DatabaseUtil::CrackVfsFileName(ASCIIToUTF16(vfs_file_name),
21 &origin_identifier, 21 &origin_identifier,
22 &database_name, 22 &database_name,
23 &sqlite_suffix)); 23 &sqlite_suffix));
24 EXPECT_EQ(ASCIIToUTF16(expected_origin_identifier), origin_identifier); 24 EXPECT_EQ(ASCIIToUTF16(expected_origin_identifier), origin_identifier);
25 EXPECT_EQ(ASCIIToUTF16(expected_database_name), database_name); 25 EXPECT_EQ(ASCIIToUTF16(expected_database_name), database_name);
26 EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix); 26 EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix);
27 } 27 }
28 28
29 static GURL ToAndFromOriginIdentifier(const GURL origin_url) {
30 string16 id = DatabaseUtil::GetOriginIdentifier(origin_url);
31 return DatabaseUtil::GetOriginFromIdentifier(id);
32 }
33
29 namespace webkit_database { 34 namespace webkit_database {
30 35
31 // Test DatabaseUtil::CrackVfsFilePath on various inputs. 36 // Test DatabaseUtil::CrackVfsFilePath on various inputs.
32 TEST(DatabaseUtilTest, CrackVfsFilePathTest) { 37 TEST(DatabaseUtilTest, CrackVfsFilePathTest) {
33 TestVfsFilePath(true, "origin/#", "origin", "", ""); 38 TestVfsFilePath(true, "origin/#", "origin", "", "");
34 TestVfsFilePath(true, "origin/#suffix", "origin", "", "suffix"); 39 TestVfsFilePath(true, "origin/#suffix", "origin", "", "suffix");
35 TestVfsFilePath(true, "origin/db_name#", "origin", "db_name", ""); 40 TestVfsFilePath(true, "origin/db_name#", "origin", "db_name", "");
36 TestVfsFilePath(true, "origin/db_name#suffix", "origin", "db_name", "suffix"); 41 TestVfsFilePath(true, "origin/db_name#suffix", "origin", "db_name", "suffix");
37 TestVfsFilePath(false, "origindb_name#"); 42 TestVfsFilePath(false, "origindb_name#");
38 TestVfsFilePath(false, "origindb_name#suffix"); 43 TestVfsFilePath(false, "origindb_name#suffix");
39 TestVfsFilePath(false, "origin/db_name"); 44 TestVfsFilePath(false, "origin/db_name");
40 TestVfsFilePath(false, "origin#db_name/suffix"); 45 TestVfsFilePath(false, "origin#db_name/suffix");
41 TestVfsFilePath(false, "/db_name#"); 46 TestVfsFilePath(false, "/db_name#");
42 TestVfsFilePath(false, "/db_name#suffix"); 47 TestVfsFilePath(false, "/db_name#suffix");
43 } 48 }
44 49
50 TEST(DatabaseUtilTest, OriginIdentifiers) {
51 const GURL kFileOrigin(GURL("file:///").GetOrigin());
52 const GURL kHttpOrigin(GURL("http://bar/").GetOrigin());
53 EXPECT_EQ(kFileOrigin, ToAndFromOriginIdentifier(kFileOrigin));
54 EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin));
55 }
56
45 } // namespace webkit_database 57 } // namespace webkit_database
OLDNEW
« no previous file with comments | « webkit/database/database_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698