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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
10 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/storage_partition.h" |
15 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
16 | 17 |
17 using content::BrowserContext; | 18 using content::BrowserContext; |
18 using content::BrowserThread; | 19 using content::BrowserThread; |
19 | 20 |
20 namespace { | 21 namespace { |
21 typedef BrowsingDataHelperCallback<BrowsingDataDatabaseHelper::DatabaseInfo> | 22 typedef BrowsingDataHelperCallback<BrowsingDataDatabaseHelper::DatabaseInfo> |
22 TestCompletionCallback; | 23 TestCompletionCallback; |
23 | 24 |
24 const char kTestIdentifier1[] = "http_www.google.com_0"; | 25 const char kTestIdentifier1[] = "http_www.google.com_0"; |
25 | 26 |
26 const char kTestIdentifierExtension[] = | 27 const char kTestIdentifierExtension[] = |
27 "chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0"; | 28 "chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0"; |
28 | 29 |
29 class BrowsingDataDatabaseHelperTest : public InProcessBrowserTest { | 30 class BrowsingDataDatabaseHelperTest : public InProcessBrowserTest { |
30 public: | 31 public: |
31 virtual void CreateDatabases() { | 32 virtual void CreateDatabases() { |
32 webkit_database::DatabaseTracker* db_tracker = | 33 webkit_database::DatabaseTracker* db_tracker = |
33 BrowserContext::GetDatabaseTracker(browser()->profile()); | 34 BrowserContext::GetDefaultStoragePartition(browser()->profile())-> |
| 35 GetDatabaseTracker(); |
34 string16 db_name = ASCIIToUTF16("db"); | 36 string16 db_name = ASCIIToUTF16("db"); |
35 string16 description = ASCIIToUTF16("db_description"); | 37 string16 description = ASCIIToUTF16("db_description"); |
36 int64 size; | 38 int64 size; |
37 string16 identifier1(UTF8ToUTF16(kTestIdentifier1)); | 39 string16 identifier1(UTF8ToUTF16(kTestIdentifier1)); |
38 db_tracker->DatabaseOpened(identifier1, db_name, description, 1, &size); | 40 db_tracker->DatabaseOpened(identifier1, db_name, description, 1, &size); |
39 db_tracker->DatabaseClosed(identifier1, db_name); | 41 db_tracker->DatabaseClosed(identifier1, db_name); |
40 FilePath db_path1 = db_tracker->GetFullDBFilePath(identifier1, db_name); | 42 FilePath db_path1 = db_tracker->GetFullDBFilePath(identifier1, db_name); |
41 file_util::CreateDirectory(db_path1.DirName()); | 43 file_util::CreateDirectory(db_path1.DirName()); |
42 ASSERT_EQ(0, file_util::WriteFile(db_path1, NULL, 0)); | 44 ASSERT_EQ(0, file_util::WriteFile(db_path1, NULL, 0)); |
43 string16 identifierExtension(UTF8ToUTF16(kTestIdentifierExtension)); | 45 string16 identifierExtension(UTF8ToUTF16(kTestIdentifierExtension)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 base::Unretained(&callback))); | 144 base::Unretained(&callback))); |
143 | 145 |
144 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = | 146 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = |
145 callback.result(); | 147 callback.result(); |
146 | 148 |
147 ASSERT_EQ(1u, result.size()); | 149 ASSERT_EQ(1u, result.size()); |
148 EXPECT_STREQ(origin_str, result.begin()->origin_identifier.c_str()); | 150 EXPECT_STREQ(origin_str, result.begin()->origin_identifier.c_str()); |
149 EXPECT_STREQ(db, result.begin()->database_name.c_str()); | 151 EXPECT_STREQ(db, result.begin()->database_name.c_str()); |
150 } | 152 } |
151 } // namespace | 153 } // namespace |
OLD | NEW |