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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/test/thread_test_helper.h" | 14 #include "base/test/thread_test_helper.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/browsing_data_helper_browsertest.h" | 16 #include "chrome/browser/browsing_data_helper_browsertest.h" |
17 #include "chrome/browser/browsing_data_local_storage_helper.h" | 17 #include "chrome/browser/browsing_data_local_storage_helper.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
22 #include "content/public/browser/dom_storage_context.h" | 22 #include "content/public/browser/dom_storage_context.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
| 25 using content::BrowserContext; |
25 using content::BrowserThread; | 26 using content::BrowserThread; |
26 using content::DOMStorageContext; | 27 using content::DOMStorageContext; |
27 | 28 |
28 namespace { | 29 namespace { |
29 typedef | 30 typedef |
30 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 31 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
31 TestCompletionCallback; | 32 TestCompletionCallback; |
32 | 33 |
33 const FilePath::CharType kTestFile0[] = | 34 const FilePath::CharType kTestFile0[] = |
34 FILE_PATH_LITERAL("http_www.chromium.org_0.localstorage"); | 35 FILE_PATH_LITERAL("http_www.chromium.org_0.localstorage"); |
(...skipping 16 matching lines...) Expand all Loading... |
51 const FilePath::CharType* kFilesToCreate[] = { | 52 const FilePath::CharType* kFilesToCreate[] = { |
52 kTestFile0, kTestFile1, kTestFileInvalid, kTestFileExtension | 53 kTestFile0, kTestFile1, kTestFileInvalid, kTestFileExtension |
53 }; | 54 }; |
54 for (size_t i = 0; i < arraysize(kFilesToCreate); ++i) { | 55 for (size_t i = 0; i < arraysize(kFilesToCreate); ++i) { |
55 FilePath file_path = storage_path.Append(kFilesToCreate[i]); | 56 FilePath file_path = storage_path.Append(kFilesToCreate[i]); |
56 file_util::WriteFile(file_path, NULL, 0); | 57 file_util::WriteFile(file_path, NULL, 0); |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
60 FilePath GetLocalStoragePathForTestingProfile() { | 61 FilePath GetLocalStoragePathForTestingProfile() { |
61 return DOMStorageContext::GetForBrowserContext(browser()->profile())-> | 62 return BrowserContext::GetDOMStorageContext(browser()->profile())-> |
62 GetFilePath(ASCIIToUTF16("blah")).DirName(); | 63 GetFilePath(ASCIIToUTF16("blah")).DirName(); |
63 } | 64 } |
64 }; | 65 }; |
65 | 66 |
66 // This class is notified by BrowsingDataLocalStorageHelper on the UI thread | 67 // This class is notified by BrowsingDataLocalStorageHelper on the UI thread |
67 // once it finishes fetching the local storage data. | 68 // once it finishes fetching the local storage data. |
68 class StopTestOnCallback { | 69 class StopTestOnCallback { |
69 public: | 70 public: |
70 explicit StopTestOnCallback( | 71 explicit StopTestOnCallback( |
71 BrowsingDataLocalStorageHelper* local_storage_helper) | 72 BrowsingDataLocalStorageHelper* local_storage_helper) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 base::Unretained(&callback))); | 189 base::Unretained(&callback))); |
189 | 190 |
190 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = | 191 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = |
191 callback.result(); | 192 callback.result(); |
192 | 193 |
193 ASSERT_EQ(1u, result.size()); | 194 ASSERT_EQ(1u, result.size()); |
194 EXPECT_EQ(FilePath(file).value(), | 195 EXPECT_EQ(FilePath(file).value(), |
195 result.begin()->file_path.BaseName().value()); | 196 result.begin()->file_path.BaseName().value()); |
196 } | 197 } |
197 } // namespace | 198 } // namespace |
OLD | NEW |